cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1333832 - in /cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs: BookStore.java JAXRSClientServerBookTest.java
Date Fri, 04 May 2012 09:49:59 GMT
Author: sergeyb
Date: Fri May  4 09:49:58 2012
New Revision: 1333832

URL: http://svn.apache.org/viewvc?rev=1333832&view=rev
Log:
Updating some of JAXRSClientServerBookTest tests not to depend on the state updates

Modified:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1333832&r1=1333831&r2=1333832&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Fri
May  4 09:49:58 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/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1333832&r1=1333831&r2=1333832&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Fri May  4 09:49:58 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



Mime
View raw message