abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1452052 - in /abdera/java/trunk: adapters/jcr/ adapters/jcr/src/test/java/org/apache/abdera/jcr/ client/ client/src/test/java/org/apache/abdera/test/client/ extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/i...
Date Sun, 03 Mar 2013 15:13:18 GMT
Author: veithen
Date: Sun Mar  3 15:13:17 2013
New Revision: 1452052

URL: http://svn.apache.org/r1452052
Log:
Avoid using fixed TCP port numbers in unit tests.

Modified:
    abdera/java/trunk/adapters/jcr/pom.xml
    abdera/java/trunk/adapters/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionAdapterTest.java
    abdera/java/trunk/client/pom.xml
    abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/JettyUtil.java
    abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/impl/AbstractOpenSearchUrlAdapterTest.java
    abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/processors/OpenSearchDescriptionRequestProcessorTest.java
    abdera/java/trunk/server/pom.xml
    abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/basic/BasicTest.java
    abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/custom/CustomProviderTest.java
    abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java
    abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/multipart/MultipartRelatedTest.java

Modified: abdera/java/trunk/adapters/jcr/pom.xml
URL: http://svn.apache.org/viewvc/abdera/java/trunk/adapters/jcr/pom.xml?rev=1452052&r1=1452051&r2=1452052&view=diff
==============================================================================
--- abdera/java/trunk/adapters/jcr/pom.xml (original)
+++ abdera/java/trunk/adapters/jcr/pom.xml Sun Mar  3 15:13:17 2013
@@ -79,6 +79,11 @@
       <version>1.0</version>  
     </dependency>
 
+    <dependency>
+      <groupId>org.apache.ws.commons.axiom</groupId>
+      <artifactId>axiom-testutils</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   
   <build>

Modified: abdera/java/trunk/adapters/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionAdapterTest.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/adapters/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionAdapterTest.java?rev=1452052&r1=1452051&r2=1452052&view=diff
==============================================================================
--- abdera/java/trunk/adapters/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionAdapterTest.java
(original)
+++ abdera/java/trunk/adapters/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionAdapterTest.java
Sun Mar  3 15:13:17 2013
@@ -46,6 +46,7 @@ import org.apache.abdera.protocol.server
 import org.apache.abdera.protocol.server.impl.SimpleWorkspaceInfo;
 import org.apache.abdera.protocol.server.servlet.AbderaServlet;
 import org.apache.abdera.writer.Writer;
+import org.apache.axiom.testutils.PortAllocator;
 import org.apache.jackrabbit.core.TransientRepository;
 import org.junit.After;
 import org.junit.Before;
@@ -56,6 +57,7 @@ import org.mortbay.jetty.servlet.Servlet
 
 public class JcrCollectionAdapterTest {
 
+    private int port;
     private Server server;
     private DefaultProvider jcrProvider;
     private Repository repository;
@@ -91,7 +93,7 @@ public class JcrCollectionAdapterTest {
 
         AbderaClient client = new AbderaClient(abdera);
 
-        String base = "http://localhost:9002/";
+        String base = "http://localhost:" + port + "/";
 
         // Testing of entry creation
         IRI colUri = new IRI(base).resolve("feed");
@@ -174,8 +176,8 @@ public class JcrCollectionAdapterTest {
     }
 
     private void initializeJetty() throws Exception {
-
-        server = new Server(9002);
+        port = PortAllocator.allocatePort();
+        server = new Server(port);
         Context root = new Context(server, "/", Context.NO_SESSIONS);
         root.addServlet(new ServletHolder(new AbderaServlet() {
 

Modified: abdera/java/trunk/client/pom.xml
URL: http://svn.apache.org/viewvc/abdera/java/trunk/client/pom.xml?rev=1452052&r1=1452051&r2=1452052&view=diff
==============================================================================
--- abdera/java/trunk/client/pom.xml (original)
+++ abdera/java/trunk/client/pom.xml Sun Mar  3 15:13:17 2013
@@ -68,5 +68,10 @@
       <version>${jetty.version}</version>  
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.ws.commons.axiom</groupId>
+      <artifactId>axiom-testutils</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

Modified: abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/JettyUtil.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/JettyUtil.java?rev=1452052&r1=1452051&r2=1452052&view=diff
==============================================================================
--- abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/JettyUtil.java (original)
+++ abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/JettyUtil.java Sun
Mar  3 15:13:17 2013
@@ -17,6 +17,7 @@
  */
 package org.apache.abdera.test.client;
 
+import org.apache.axiom.testutils.PortAllocator;
 import org.mortbay.jetty.Connector;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.bio.SocketConnector;
@@ -26,7 +27,7 @@ public class JettyUtil {
 
     private static final String PORT_PROP = "abdera.test.client.port";
 
-    private static int PORT = 9002;
+    private static int PORT = PortAllocator.allocatePort();
     private static Server server = null;
     private static ServletHandler handler = null;
 

Modified: abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/impl/AbstractOpenSearchUrlAdapterTest.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/impl/AbstractOpenSearchUrlAdapterTest.java?rev=1452052&r1=1452051&r2=1452052&view=diff
==============================================================================
--- abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/impl/AbstractOpenSearchUrlAdapterTest.java
(original)
+++ abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/impl/AbstractOpenSearchUrlAdapterTest.java
Sun Mar  3 15:13:17 2013
@@ -44,18 +44,23 @@ import org.apache.abdera.protocol.server
 import org.apache.abdera.protocol.server.impl.RouteManager;
 import org.apache.abdera.test.ext.opensearch.server.AbstractOpenSearchServerTest;
 import org.apache.abdera.test.ext.opensearch.server.JettyServer;
+import org.apache.axiom.testutils.PortAllocator;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
 public class AbstractOpenSearchUrlAdapterTest extends AbstractOpenSearchServerTest {
 
-    private JettyServer server = new JettyServer();
+    private int port;
+    private JettyServer server;
     private OpenSearchInfo osInfo;
     private OpenSearchUrlRequestProcessor osUrlProcessor;
 
     @Before
     public void setUp() throws Exception {
+        port = PortAllocator.allocatePort();
+        server = new JettyServer(port);
+        
         this.osInfo = this.createOpenSearchInfo();
         ((SimpleOpenSearchUrlInfo)osInfo.getUrls()[0]).setOpenSearchUrlAdapter(new TestingOpenSearchUrlAdapter());
 
@@ -93,7 +98,7 @@ public class AbstractOpenSearchUrlAdapte
     @Test
     public void testOpenSearchFeedResponse() throws Exception {
         AbderaClient client = new AbderaClient();
-        ClientResponse response = client.get("http://localhost:9002/search1?q=test1&c=1");
+        ClientResponse response = client.get("http://localhost:" + port + "/search1?q=test1&c=1");
         assertEquals(200, response.getStatus());
 
         Document<Feed> feedDoc = response.getDocument();

Modified: abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/processors/OpenSearchDescriptionRequestProcessorTest.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/processors/OpenSearchDescriptionRequestProcessorTest.java?rev=1452052&r1=1452051&r2=1452052&view=diff
==============================================================================
--- abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/processors/OpenSearchDescriptionRequestProcessorTest.java
(original)
+++ abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/processors/OpenSearchDescriptionRequestProcessorTest.java
Sun Mar  3 15:13:17 2013
@@ -39,18 +39,23 @@ import org.apache.abdera.protocol.server
 import org.apache.abdera.test.ext.opensearch.server.AbstractOpenSearchServerTest;
 import org.apache.abdera.test.ext.opensearch.server.JettyServer;
 import org.apache.abdera.util.MimeTypeHelper;
+import org.apache.axiom.testutils.PortAllocator;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
 public class OpenSearchDescriptionRequestProcessorTest extends AbstractOpenSearchServerTest
{
 
-    private JettyServer server = new JettyServer();
+    private int port;
+    private JettyServer server;
     private OpenSearchInfo osInfo;
     private OpenSearchDescriptionRequestProcessor osRequestProcessor;
 
     @Before
     public void setUp() throws Exception {
+        port = PortAllocator.allocatePort();
+        server = new JettyServer(port);
+        
         this.osInfo = this.createOpenSearchInfo();
         this.osRequestProcessor = new OpenSearchDescriptionRequestProcessor();
         this.osRequestProcessor.setOpenSearchInfo(osInfo);
@@ -86,7 +91,7 @@ public class OpenSearchDescriptionReques
     @Test
     public void testOpenSearchDescriptionRequestProcessorOutput() throws Exception {
         AbderaClient client = new AbderaClient();
-        ClientResponse resp = client.get("http://localhost:9002/search");
+        ClientResponse resp = client.get("http://localhost:" + port + "/search");
 
         assertNotNull(resp);
         assertEquals(ResponseType.SUCCESS, resp.getType());
@@ -108,11 +113,11 @@ public class OpenSearchDescriptionReques
                                result);
         assertXpathEvaluatesTo(QUERY_TERMS, "/os:OpenSearchDescription/os:Query/@searchTerms",
result);
         assertXpathEvaluatesTo("application/atom+xml", "/os:OpenSearchDescription/os:Url[1]/@type",
result);
-        assertXpathEvaluatesTo("http://localhost:9002/search1?q={searchTerms}&c={count?}",
+        assertXpathEvaluatesTo("http://localhost:" + port + "/search1?q={searchTerms}&c={count?}",
                                "/os:OpenSearchDescription/os:Url[1]/@template",
                                result);
         assertXpathEvaluatesTo("application/atom+xml", "/os:OpenSearchDescription/os:Url[2]/@type",
result);
-        assertXpathEvaluatesTo("http://localhost:9002/search2?q={searchTerms}&c={count?}",
+        assertXpathEvaluatesTo("http://localhost:" + port + "/search2?q={searchTerms}&c={count?}",
                                "/os:OpenSearchDescription/os:Url[2]/@template",
                                result);
     }

Modified: abdera/java/trunk/server/pom.xml
URL: http://svn.apache.org/viewvc/abdera/java/trunk/server/pom.xml?rev=1452052&r1=1452051&r2=1452052&view=diff
==============================================================================
--- abdera/java/trunk/server/pom.xml (original)
+++ abdera/java/trunk/server/pom.xml Sun Mar  3 15:13:17 2013
@@ -99,5 +99,10 @@
         <scope>test</scope>
     </dependency>
    
+    <dependency>
+      <groupId>org.apache.ws.commons.axiom</groupId>
+      <artifactId>axiom-testutils</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

Modified: abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/basic/BasicTest.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/basic/BasicTest.java?rev=1452052&r1=1452051&r2=1452052&view=diff
==============================================================================
--- abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/basic/BasicTest.java
(original)
+++ abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/basic/BasicTest.java
Sun Mar  3 15:13:17 2013
@@ -43,12 +43,14 @@ import org.apache.abdera.util.Constants;
 import org.apache.abdera.util.MimeTypeHelper;
 import org.apache.abdera.writer.Writer;
 import org.apache.abdera.writer.WriterFactory;
+import org.apache.axiom.testutils.PortAllocator;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class BasicTest {
 
+    private static int port;
     private static JettyServer server;
     private static Abdera abdera = Abdera.getInstance();
     private static AbderaClient client = new AbderaClient();
@@ -56,7 +58,8 @@ public class BasicTest {
     @BeforeClass
     public static void setUp() throws Exception {
         if (server == null) {
-            server = new JettyServer();
+            port = PortAllocator.allocatePort();
+            server = new JettyServer(port);
             server.start(BasicProvider.class);
         }
     }
@@ -75,7 +78,7 @@ public class BasicTest {
 
     @Test
     public void testGetService() {
-        ClientResponse resp = client.get("http://localhost:9002/");
+        ClientResponse resp = client.get("http://localhost:" + port + "/");
         assertNotNull(resp);
         assertEquals(ResponseType.SUCCESS, resp.getType());
         assertTrue(MimeTypeHelper.isMatch(resp.getContentType().toString(), Constants.APP_MEDIA_TYPE));
@@ -87,19 +90,19 @@ public class BasicTest {
         Collection collection = workspace.getCollection("title for any sample feed");
         assertNotNull(collection);
         assertTrue(collection.acceptsEntry());
-        assertEquals("http://localhost:9002/sample", collection.getResolvedHref().toString());
+        assertEquals("http://localhost:" + port + "/sample", collection.getResolvedHref().toString());
         resp.release();
     }
 
     @Test
     public void testGetFeed() {
-        ClientResponse resp = client.get("http://localhost:9002/sample");
+        ClientResponse resp = client.get("http://localhost:" + port + "/sample");
         assertNotNull(resp);
         assertEquals(ResponseType.SUCCESS, resp.getType());
         assertTrue(MimeTypeHelper.isMatch(resp.getContentType().toString(), Constants.FEED_MEDIA_TYPE));
         Document<Feed> doc = resp.getDocument();
         Feed feed = doc.getRoot();
-        assertEquals("http://localhost:9002/sample", feed.getId().toString());
+        assertEquals("http://localhost:" + port + "/sample", feed.getId().toString());
         assertEquals("title for any sample feed", feed.getTitle());
         assertEquals("rayc", feed.getAuthor().getName());
         assertEquals(0, feed.getEntries().size());
@@ -109,19 +112,19 @@ public class BasicTest {
     @Test
     public void testPostEntry() {
         Entry entry = abdera.newEntry();
-        entry.setId("http://localhost:9002/sample/foo");
+        entry.setId("http://localhost:" + port + "/sample/foo");
         entry.setTitle("test entry");
         entry.setContent("Test Content");
         entry.addLink("http://example.org");
         entry.setUpdated(new Date());
         entry.addAuthor("James");
-        ClientResponse resp = client.post("http://localhost:9002/sample", entry);
+        ClientResponse resp = client.post("http://localhost:" + port + "/sample", entry);
         assertNotNull(resp);
         assertEquals(ResponseType.SUCCESS, resp.getType());
         assertEquals(201, resp.getStatus());
-        assertEquals("http://localhost:9002/sample/foo", resp.getLocation().toString());
+        assertEquals("http://localhost:" + port + "/sample/foo", resp.getLocation().toString());
         resp.release();
-        resp = client.get("http://localhost:9002/sample");
+        resp = client.get("http://localhost:" + port + "/sample");
         Document<Feed> feed_doc = resp.getDocument();
         Feed feed = feed_doc.getRoot();
         assertEquals(1, feed.getEntries().size());
@@ -133,7 +136,7 @@ public class BasicTest {
         ByteArrayInputStream in = new ByteArrayInputStream(new byte[] {0x01, 0x02, 0x03,
0x04});
         RequestOptions options = client.getDefaultRequestOptions();
         options.setContentType("application/octet-stream");
-        ClientResponse resp = client.post("http://localhost:9002/sample", in, options);
+        ClientResponse resp = client.post("http://localhost:" + port + "/sample", in, options);
         assertEquals(ResponseType.CLIENT_ERROR, resp.getType());
         assertEquals(405, resp.getStatus());
         resp.release();
@@ -141,22 +144,22 @@ public class BasicTest {
 
     @Test
     public void testPutEntry() {
-        ClientResponse resp = client.get("http://localhost:9002/sample/foo");
+        ClientResponse resp = client.get("http://localhost:" + port + "/sample/foo");
         assertTrue(MimeTypeHelper.isMatch(resp.getContentType().toString(), Constants.ENTRY_MEDIA_TYPE));
         Document<Entry> doc = resp.getDocument();
         Entry entry = doc.getRoot();
         entry.setTitle("This is the modified title");
         resp.release();
-        resp = client.put("http://localhost:9002/sample/foo", entry);
+        resp = client.put("http://localhost:" + port + "/sample/foo", entry);
         assertEquals(ResponseType.SUCCESS, resp.getType());
         assertEquals(200, resp.getStatus());
         resp.release();
-        resp = client.get("http://localhost:9002/sample/foo");
+        resp = client.get("http://localhost:" + port + "/sample/foo");
         doc = resp.getDocument();
         entry = doc.getRoot();
         assertEquals("This is the modified title", entry.getTitle());
         resp.release();
-        resp = client.get("http://localhost:9002/sample");
+        resp = client.get("http://localhost:" + port + "/sample");
         Document<Feed> feed_doc = resp.getDocument();
         Feed feed = feed_doc.getRoot();
         assertEquals(1, feed.getEntries().size());
@@ -165,10 +168,10 @@ public class BasicTest {
 
     @Test
     public void testDeleteEntry() {
-        ClientResponse resp = client.delete("http://localhost:9002/sample/foo");
+        ClientResponse resp = client.delete("http://localhost:" + port + "/sample/foo");
         assertEquals(ResponseType.SUCCESS, resp.getType());
         resp.release();
-        resp = client.get("http://localhost:9002/sample");
+        resp = client.get("http://localhost:" + port + "/sample");
         Document<Feed> feed_doc = resp.getDocument();
         Feed feed = feed_doc.getRoot();
         assertEquals(0, feed.getEntries().size());

Modified: abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/custom/CustomProviderTest.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/custom/CustomProviderTest.java?rev=1452052&r1=1452051&r2=1452052&view=diff
==============================================================================
--- abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/custom/CustomProviderTest.java
(original)
+++ abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/custom/CustomProviderTest.java
Sun Mar  3 15:13:17 2013
@@ -42,6 +42,7 @@ import org.apache.abdera.protocol.client
 import org.apache.abdera.protocol.server.test.JettyServer;
 import org.apache.abdera.util.Constants;
 import org.apache.abdera.util.MimeTypeHelper;
+import org.apache.axiom.testutils.PortAllocator;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -52,12 +53,14 @@ public class CustomProviderTest {
     private static Abdera abdera = Abdera.getInstance();
     private static AbderaClient client = new AbderaClient();
 
-    private static String BASE = "http://localhost:9002/atom";
+    private static String base;
 
     @BeforeClass
     public static void setUp() throws Exception {
-        server = new JettyServer();
+        int port = PortAllocator.allocatePort();
+        server = new JettyServer(port);
         server.start(CustomProvider.class);
+        base = "http://localhost:" + port + "/atom";
     }
 
     @AfterClass
@@ -67,7 +70,7 @@ public class CustomProviderTest {
 
     @Test
     public void testGetService() throws IOException {
-        ClientResponse resp = client.get(BASE);
+        ClientResponse resp = client.get(base);
         assertNotNull(resp);
         assertEquals(ResponseType.SUCCESS, resp.getType());
         assertTrue(MimeTypeHelper.isMatch(resp.getContentType().toString(), Constants.APP_MEDIA_TYPE));
@@ -82,14 +85,14 @@ public class CustomProviderTest {
         Workspace workspace = service.getWorkspaces().get(0);
         assertEquals(1, workspace.getCollections().size());
         Collection collection = workspace.getCollections().get(0);
-        assertEquals(BASE + "/feed", collection.getResolvedHref().toString());
+        assertEquals(base + "/feed", collection.getResolvedHref().toString());
         assertEquals("A simple feed", collection.getTitle().toString());
         resp.release();
     }
 
     @Test
     public void testGetCategories() {
-        ClientResponse resp = client.get(BASE + "/feed;categories");
+        ClientResponse resp = client.get(base + "/feed;categories");
         assertNotNull(resp);
         assertEquals(ResponseType.SUCCESS, resp.getType());
         assertTrue(MimeTypeHelper.isMatch(resp.getContentType().toString(), Constants.CAT_MEDIA_TYPE));
@@ -104,7 +107,7 @@ public class CustomProviderTest {
 
     @Test
     public void testGetFeed() throws Exception {
-        ClientResponse resp = client.get(BASE + "/feed");
+        ClientResponse resp = client.get(base + "/feed");
         assertNotNull(resp);
         assertEquals(ResponseType.SUCCESS, resp.getType());
         assertTrue(MimeTypeHelper.isMatch(resp.getContentType().toString(), Constants.ATOM_MEDIA_TYPE));
@@ -127,19 +130,19 @@ public class CustomProviderTest {
     @Test
     public void testPostEntry() {
         Entry entry = abdera.newEntry();
-        entry.setId(BASE + "/feed/entries/1");
+        entry.setId(base + "/feed/entries/1");
         entry.setTitle("test entry");
         entry.setContent("Test Content");
         entry.addLink("http://example.org");
         entry.setUpdated(new Date());
         entry.addAuthor("James");
-        ClientResponse resp = client.post(BASE + "/feed", entry);
+        ClientResponse resp = client.post(base + "/feed", entry);
         assertNotNull(resp);
         assertEquals(ResponseType.SUCCESS, resp.getType());
         assertEquals(201, resp.getStatus());
         assertNotNull(resp.getLocation());
         resp.release();
-        resp = client.get(BASE + "/feed");
+        resp = client.get(base + "/feed");
         Document<Feed> feed_doc = resp.getDocument();
         Feed feed = feed_doc.getRoot();
         assertEquals(1, feed.getEntries().size());
@@ -150,7 +153,7 @@ public class CustomProviderTest {
         ByteArrayInputStream in = new ByteArrayInputStream(new byte[] {0x01, 0x02, 0x03,
0x04});
         RequestOptions options = client.getDefaultRequestOptions();
         options.setContentType("application/octet-stream");
-        ClientResponse resp = client.post(BASE + "/feed", in, options);
+        ClientResponse resp = client.post(base + "/feed", in, options);
         assertEquals(ResponseType.CLIENT_ERROR, resp.getType());
         assertEquals(405, resp.getStatus());
         resp.release();
@@ -158,7 +161,7 @@ public class CustomProviderTest {
 
     @Test
     public void testPutEntry() throws IOException {
-        ClientResponse resp = client.get(BASE + "/feed");
+        ClientResponse resp = client.get(base + "/feed");
         Document<Feed> feed_doc = resp.getDocument();
         Feed feed = feed_doc.getRoot();
         prettyPrint(feed);
@@ -181,7 +184,7 @@ public class CustomProviderTest {
         entry = doc.getRoot();
         assertEquals("This is the modified title", entry.getTitle());
         resp.release();
-        resp = client.get(BASE + "/feed");
+        resp = client.get(base + "/feed");
         feed_doc = resp.getDocument();
         feed = feed_doc.getRoot();
         assertEquals(1, feed.getEntries().size());
@@ -190,7 +193,7 @@ public class CustomProviderTest {
 
     @Test
     public void testDeleteEntry() {
-        ClientResponse resp = client.get(BASE + "/feed");
+        ClientResponse resp = client.get(base + "/feed");
         Document<Feed> feed_doc = resp.getDocument();
         Feed feed = feed_doc.getRoot();
         Entry entry = feed.getEntries().get(0);
@@ -199,7 +202,7 @@ public class CustomProviderTest {
         resp = client.delete(edit);
         assertEquals(ResponseType.SUCCESS, resp.getType());
         resp.release();
-        resp = client.get(BASE + "/feed");
+        resp = client.get(base + "/feed");
         feed_doc = resp.getDocument();
         feed = feed_doc.getRoot();
         assertEquals(0, feed.getEntries().size());

Modified: abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java?rev=1452052&r1=1452051&r2=1452052&view=diff
==============================================================================
--- abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java
(original)
+++ abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java
Sun Mar  3 15:13:17 2013
@@ -48,6 +48,7 @@ import org.apache.abdera.util.Constants;
 import org.apache.abdera.util.MimeTypeHelper;
 import org.apache.abdera.writer.Writer;
 import org.apache.abdera.writer.WriterFactory;
+import org.apache.axiom.testutils.PortAllocator;
 import org.junit.After;
 import org.junit.Test;
 import org.mortbay.jetty.Server;
@@ -56,6 +57,7 @@ import org.mortbay.jetty.servlet.Servlet
 
 public class CustomerAdapterTest {
 
+    private int port;
     private Server server;
     private DefaultProvider customerProvider;
 
@@ -94,7 +96,7 @@ public class CustomerAdapterTest {
 
         AbderaClient client = new AbderaClient(abdera);
 
-        String uri = "http://localhost:9002" + base;
+        String uri = "http://localhost:" + port + base;
 
         // Service document test.
 
@@ -195,8 +197,8 @@ public class CustomerAdapterTest {
 
     @SuppressWarnings("serial")
     private void initializeJetty(String contextPath) throws Exception {
-
-        server = new Server(9002);
+        port = PortAllocator.allocatePort();
+        server = new Server(port);
         Context root = new Context(server, contextPath, Context.NO_SESSIONS);
         root.addServlet(new ServletHolder(new AbderaServlet() {
 

Modified: abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/multipart/MultipartRelatedTest.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/multipart/MultipartRelatedTest.java?rev=1452052&r1=1452051&r2=1452052&view=diff
==============================================================================
--- abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/multipart/MultipartRelatedTest.java
(original)
+++ abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/multipart/MultipartRelatedTest.java
Sun Mar  3 15:13:17 2013
@@ -19,6 +19,7 @@ import org.apache.abdera.protocol.server
 import org.apache.abdera.protocol.server.impl.SimpleWorkspaceInfo;
 import org.apache.abdera.protocol.server.processors.MultipartRelatedServiceRequestProcessor;
 import org.apache.abdera.protocol.server.servlet.AbderaServlet;
+import org.apache.axiom.testutils.PortAllocator;
 import org.junit.After;
 import org.junit.Test;
 import org.mortbay.jetty.Server;
@@ -28,10 +29,12 @@ import org.mortbay.jetty.servlet.Servlet
 @SuppressWarnings("serial")
 public class MultipartRelatedTest {
 
+    private int port;
     private Server server;
 
     private void initializeJetty(String contextPath) throws Exception {
-        server = new Server(9002);
+        port = PortAllocator.allocatePort();
+        server = new Server(port);
         Context root = new Context(server, contextPath, Context.NO_SESSIONS);
         root.addServlet(new ServletHolder(new AbderaServlet() {
             @Override
@@ -70,7 +73,7 @@ public class MultipartRelatedTest {
         initializeJetty("/");
         AbderaClient client = new AbderaClient(new Abdera());
 
-        ClientResponse res = client.get("http://localhost:9002/");
+        ClientResponse res = client.get("http://localhost:" + port + "/");
         assertEquals(200, res.getStatus());
         StringWriter sw = new StringWriter();
         res.getDocument().writeTo(sw);
@@ -108,7 +111,7 @@ public class MultipartRelatedTest {
         entry.setContent(new IRI("cid:234234@example.com"), contentType);
 
         ClientResponse res =
-            client.post("http://localhost:9002/media", entry, this.getClass().getResourceAsStream("info.png"));
+            client.post("http://localhost:" + port + "/media", entry, this.getClass().getResourceAsStream("info.png"));
         assertEquals(status, res.getStatus());
     }
 }



Mime
View raw message