Author: jliu
Date: Mon Feb 4 02:12:06 2008
New Revision: 618222
URL: http://svn.apache.org/viewvc?rev=618222&view=rev
Log:
Added a JAX-RS system test that returns a CDs object in JSON format. The CDs
object contains a list of CD object.
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cds124.txt
(with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson123.txt
(with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson124.txt
(with props)
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=618222&r1=618221&r2=618222&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Mon Feb 4 02:12:06 2008
@@ -287,14 +287,18 @@
String endpointAddress =
"http://localhost:9080/bookstore/cds";
URL url = new URL(endpointAddress);
- InputStream in = url.openStream();
+ URLConnection connect = url.openConnection();
+ connect.addRequestProperty("Accept", "application/xml");
+ InputStream in = connect.getInputStream();
assertNotNull(in);
-/* InputStream expected = getClass()
- .getResourceAsStream("resources/expected_get_cds.txt");
-
- System.out.println("---" + getStringFromInputStream(in));
- assertEquals(getStringFromInputStream(expected),
getStringFromInputStream(in)); */
+ InputStream expected123 =
getClass().getResourceAsStream("resources/expected_get_cd.txt");
+ InputStream expected124 =
getClass().getResourceAsStream("resources/expected_get_cds124.txt");
+ String result = getStringFromInputStream(in);
+ //System.out.println("---" + getStringFromInputStream(in));
+
+ assertTrue(result.indexOf(getStringFromInputStream(expected123)) >= 0);
+ assertTrue(result.indexOf(getStringFromInputStream(expected124)) >= 0);
}
@Test
@@ -319,6 +323,32 @@
get.releaseConnection();
}
}
+
+ @Test
+ public void testGetCDsJSON() throws Exception {
+ String endpointAddress =
+ "http://localhost:9080/bookstore/cds";
+
+ GetMethod get = new GetMethod(endpointAddress);
+ get.addRequestHeader("Accept" , "application/json");
+
+ HttpClient httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(get);
+ assertEquals(200, result);
+
+ InputStream expected123 =
getClass().getResourceAsStream("resources/expected_get_cdsjson123.txt");
+ InputStream expected124 =
getClass().getResourceAsStream("resources/expected_get_cdsjson124.txt");
+
+
assertTrue(get.getResponseBodyAsString().indexOf(getStringFromInputStream(expected123))
>= 0);
+
assertTrue(get.getResponseBodyAsString().indexOf(getStringFromInputStream(expected124))
>= 0);
+
+ } finally {
+ // Release current connection to the connection pool once you are
done
+ get.releaseConnection();
+ }
+ }
@Test
public void testGetCDXML() throws Exception {
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cds124.txt
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cds124.txt?rev=618222&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cds124.txt
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cds124.txt
Mon Feb 4 02:12:06 2008
@@ -0,0 +1 @@
+<CD><id>124</id><name>BICYCLE RACE</name></CD>
\ No newline at end of file
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cds124.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cds124.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson123.txt
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson123.txt?rev=618222&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson123.txt
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson123.txt
Mon Feb 4 02:12:06 2008
@@ -0,0 +1 @@
+{"id":"124","name":"BICYCLE RACE"}
\ No newline at end of file
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson123.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson123.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson124.txt
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson124.txt?rev=618222&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson124.txt
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson124.txt
Mon Feb 4 02:12:06 2008
@@ -0,0 +1 @@
+{"id":"123","name":"BOHEMIAN RHAPSODY"}
\ No newline at end of file
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson124.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cdsjson124.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain