You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2012/05/04 11:55:28 UTC
svn commit: r1333834 - in /cxf/branches/2.5.x-fixes: ./
systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Author: sergeyb
Date: Fri May 4 09:55:27 2012
New Revision: 1333834
URL: http://svn.apache.org/viewvc?rev=1333834&view=rev
Log:
Merged revisions 1333832 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1333832 | sergeyb | 2012-05-04 10:49:58 +0100 (Fri, 04 May 2012) | 1 line
Updating some of JAXRSClientServerBookTest tests not to depend on the state updates
........
Modified:
cxf/branches/2.5.x-fixes/ (props changed)
cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Merged /cxf/trunk:r1333832
Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1333834&r1=1333833&r2=1333834&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Fri May 4 09:55:27 2012
@@ -777,8 +777,6 @@ public class BookStore {
}
book.setId(bookId + 1);
- books.put(book.getId(), book);
-
return Response.ok(book).build();
}
@@ -826,8 +824,7 @@ public class BookStore {
Response r;
if (b != null) {
- books.put(book.getId(), book);
- r = Response.ok().build();
+ r = Response.ok(book).build();
} else {
r = Response.notModified().build();
}
@@ -844,8 +841,7 @@ public class BookStore {
if (b == null) {
Book newBook = new Book();
newBook.setId(id);
- books.put(newBook.getId(), newBook);
- r = Response.ok().build();
+ r = Response.ok(newBook).build();
} else {
r = Response.notModified().build();
}
@@ -868,8 +864,7 @@ public class BookStore {
Response r;
if (b != null) {
- books.put(book.getId(), book);
- r = Response.ok().build();
+ r = Response.ok(book).build();
} else {
r = Response.notModified().build();
}
@@ -1012,8 +1007,6 @@ public class BookStore {
return new BookSubresourceImpl();
}
- @GET
- @Path("/reset")
public final String init() {
books.clear();
cds.clear();
Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1333834&r1=1333833&r2=1333834&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Fri May 4 09:55:27 2012
@@ -23,7 +23,6 @@ import java.io.File;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
-import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
@@ -60,7 +59,6 @@ import org.apache.cxf.systest.jaxrs.Book
import org.apache.cxf.systest.jaxrs.BookStore.BookInfoInterface;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
-import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@@ -74,10 +72,6 @@ public class JAXRSClientServerBookTest e
assertTrue("server did not launch correctly",
launchServer(BookServer.class, true));
}
- @After
- public void resetBookServer() throws Exception {
- new URL("http://localhost:" + PORT + "/bookstore/reset").openStream().close();
- }
@Test
public void testWithComplexPath() {
@@ -1406,39 +1400,14 @@ public class JAXRSClientServerBookTest e
try {
int result = httpclient.executeMethod(put);
assertEquals(200, result);
+ InputStream expected = getClass().getResourceAsStream("resources/expected_update_book.txt");
+ assertEquals(getStringFromInputStream(expected),
+ getStringFromInputStream(put.getResponseBodyAsStream()));
} finally {
// Release current connection to the connection pool once you are
// done
put.releaseConnection();
}
-
- // Verify result
- endpointAddress = "http://localhost:" + PORT + "/bookstore/books/123";
- URL url = new URL(endpointAddress);
- URLConnection connect = url.openConnection();
- connect.addRequestProperty("Accept", "application/xml");
- InputStream in = connect.getInputStream();
- assertNotNull(in);
-
- InputStream expected = getClass().getResourceAsStream("resources/expected_update_book.txt");
-
- assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in));
-
- // Roll back changes:
- File input1 = new File(getClass().getResource("resources/expected_get_book123.txt").toURI());
- PutMethod put1 = new PutMethod(endpointAddress);
- RequestEntity entity1 = new FileRequestEntity(input1, "text/xml; charset=ISO-8859-1");
- put1.setRequestEntity(entity1);
- HttpClient httpclient1 = new HttpClient();
-
- try {
- int result = httpclient1.executeMethod(put);
- assertEquals(200, result);
- } finally {
- // Release current connection to the connection pool once you are
- // done
- put1.releaseConnection();
- }
}
@Test
@@ -1479,39 +1448,14 @@ public class JAXRSClientServerBookTest e
try {
int result = httpclient.executeMethod(put);
assertEquals(200, result);
+ InputStream expected = getClass().getResourceAsStream("resources/expected_update_book.txt");
+ assertEquals(getStringFromInputStream(expected),
+ getStringFromInputStream(put.getResponseBodyAsStream()));
} finally {
// Release current connection to the connection pool once you are
// done
put.releaseConnection();
}
-
- // Verify result
- endpointAddress = "http://localhost:" + PORT + "/bookstore/books/123";
- URL url = new URL(endpointAddress);
- URLConnection connection = url.openConnection();
- connection.addRequestProperty("Accept", "application/xml");
- InputStream in = connection.getInputStream();
- assertNotNull(in);
-
- InputStream expected = getClass().getResourceAsStream("resources/expected_update_book.txt");
-
- assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in));
-
- // Roll back changes:
- File input1 = new File(getClass().getResource("resources/expected_get_book123.txt").toURI());
- PutMethod put1 = new PutMethod(endpointAddress);
- RequestEntity entity1 = new FileRequestEntity(input1, "text/xml; charset=ISO-8859-1");
- put1.setRequestEntity(entity1);
- HttpClient httpclient1 = new HttpClient();
-
- try {
- int result = httpclient1.executeMethod(put);
- assertEquals(200, result);
- } finally {
- // Release current connection to the connection pool once you are
- // done
- put1.releaseConnection();
- }
}
@Test