Author: ningjiang
Date: Fri Aug 31 01:35:51 2007
New Revision: 571400
URL: http://svn.apache.org/viewvc?rev=571400&view=rev
Log:
Added the json rest test to the HttpBindingServletTest
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/HttpBindingServletTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/restful_service.xml
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/HttpBindingServletTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/HttpBindingServletTest.java?rev=571400&r1=571399&r2=571400&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/HttpBindingServletTest.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/HttpBindingServletTest.java
Fri Aug 31 01:35:51 2007
@@ -36,6 +36,9 @@
public class HttpBindingServletTest extends AbstractServletTest {
+ static final String JSON_CUSTOMER = "{\"jra.customer\":"
+ + "{\"jra.id\":\"123\",\"jra.name\":\"Dan Diephouse\"}}";
+
@Override
protected String getConfiguration() {
@@ -56,6 +59,21 @@
@Test
public void testEndpointRestService() throws Exception {
testInvokingRestService("/services/endpoint/restful");
+ }
+
+ @Test
+ public void testJsonService() throws Exception {
+ ServletUnitClient client = newClient();
+ client.setExceptionsThrownOnErrorStatus(false);
+
+ WebRequest req =
+ new GetMethodQueryWebRequest(CONTEXT_URL +
"/services/serverFactory/json/customers");
+ WebResponse response = client.getResponse(req);
+ assertTrue("Can't get the right Json customers ",
response.getText().indexOf(JSON_CUSTOMER) > 0);
+
+ req = new GetMethodQueryWebRequest(CONTEXT_URL +
"/services/serverFactory/json/customers/123");
+ response = client.getResponse(req);
+ assertEquals("Can't get the right Json customer ", response.getText(),
JSON_CUSTOMER);
}
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/restful_service.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/restful_service.xml?rev=571400&r1=571399&r2=571400&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/restful_service.xml
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/restful_service.xml
Fri Aug 31 01:35:51 2007
@@ -33,6 +33,22 @@
<property name="wrapped" value="false"/>
</bean>
+ <bean id="MappedXMLInputFactory"
class="org.codehaus.jettison.mapped.MappedXMLInputFactory">
+ <constructor-arg>
+ <map>
+ <entry key="http://cxf.apache.org/jra" value="jra"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+ <bean id="MappedXMLOutputFactory"
class="org.codehaus.jettison.mapped.MappedXMLOutputFactory">
+ <constructor-arg>
+ <map>
+ <entry key="http://cxf.apache.org/jra" value="jra"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
<bean id="greeterServerFactory"
class="org.apache.cxf.jaxws.JaxWsServerFactoryBean" init-method="create">
<property name="serviceClass"
value="org.apache.cxf.customer.bare.CustomerService" />
@@ -44,7 +60,71 @@
<property name="bindingId" value="http://apache.org/cxf/binding/http"/>
<property name="transportId"
value="http://schemas.xmlsoap.org/wsdl/soap/http"/>
<property name="serviceFactory" ref="JaxWsServiceFactoryBean"/>
- </bean>
+ </bean>
+
+ <!--jaxws:server id="greeterJsonServer"
address="/services/serverFactory/json"
+ bus="cxf" bindingId="http://apache.org/cxf/binding/http"
+ transportId="http://schemas.xmlsoap.org/wsdl/soap/http" >
+ <jaxws:serviceBean>
+ <bean class="org.apache.cxf.customer.bare.CustomerService"/>
+ </jaxws:serviceBean>
+ <jaxws:serviceFactory>
+ <bean class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
+ <property name="wrapped" value="false"/>
+ </bean>
+ </jaxws:serviceFactory>
+ <jaxws:properties>
+ <map>
+ <entry key="Content-Type" value="text/plain"/>
+ <entry>
+ <key>
+ <value>javax.xml.stream.XMLInputFactory</value>
+ </key>
+ <ref bean="MappedXMLInputFactory"/>
+ </entry>
+ <entry>
+ <key>
+ <value>javax.xml.stream.XMLOutputFactory</value>
+ </key>
+ <ref bean="MappedXMLOutputFactory"/>
+ </entry>
+ </map>
+ </jaxws:properties>
+ </jaxws:server-->
+
+ <bean id="greeterJsonServerFactory"
+ class="org.apache.cxf.jaxws.JaxWsServerFactoryBean" init-method="create">
+ <property name="serviceClass"
value="org.apache.cxf.customer.bare.CustomerService" />
+ <property name="serviceBean">
+ <bean class="org.apache.cxf.customer.bare.CustomerService"/>
+ </property>
+ <property name="address" value="/services/serverFactory/json"/>
+ <property name="bus" ref="cxf"/>
+ <property name="bindingId" value="http://apache.org/cxf/binding/http"/>
+ <property name="transportId"
value="http://schemas.xmlsoap.org/wsdl/soap/http"/>
+ <property name="serviceFactory">
+ <bean class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
+ <property name="wrapped" value="false"/>
+ </bean>
+ </property>
+ <property name="properties">
+ <map>
+ <entry key="Content-Type" value="text/plain"/>
+ <entry>
+ <key>
+ <value>javax.xml.stream.XMLInputFactory</value>
+ </key>
+ <ref bean="MappedXMLInputFactory"/>
+ </entry>
+ <entry>
+ <key>
+ <value>javax.xml.stream.XMLOutputFactory</value>
+ </key>
+ <ref bean="MappedXMLOutputFactory"/>
+ </entry>
+ </map>
+ </property>
+ </bean>
<jaxws:endpoint id="restfulServer"
implementor="org.apache.cxf.customer.bare.CustomerService"