abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1452034 - in /abdera/java/trunk/security: pom.xml src/test/java/org/apache/abdera/test/security/filter/SecurityFilterTest.java
Date Sun, 03 Mar 2013 12:54:07 GMT
Author: veithen
Date: Sun Mar  3 12:54:07 2013
New Revision: 1452034

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

Modified:
    abdera/java/trunk/security/pom.xml
    abdera/java/trunk/security/src/test/java/org/apache/abdera/test/security/filter/SecurityFilterTest.java

Modified: abdera/java/trunk/security/pom.xml
URL: http://svn.apache.org/viewvc/abdera/java/trunk/security/pom.xml?rev=1452034&r1=1452033&r2=1452034&view=diff
==============================================================================
--- abdera/java/trunk/security/pom.xml (original)
+++ abdera/java/trunk/security/pom.xml Sun Mar  3 12:54:07 2013
@@ -74,5 +74,10 @@
       <artifactId>axiom-api</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.ws.commons.axiom</groupId>
+      <artifactId>axiom-testutils</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

Modified: abdera/java/trunk/security/src/test/java/org/apache/abdera/test/security/filter/SecurityFilterTest.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/security/src/test/java/org/apache/abdera/test/security/filter/SecurityFilterTest.java?rev=1452034&r1=1452033&r2=1452034&view=diff
==============================================================================
--- abdera/java/trunk/security/src/test/java/org/apache/abdera/test/security/filter/SecurityFilterTest.java
(original)
+++ abdera/java/trunk/security/src/test/java/org/apache/abdera/test/security/filter/SecurityFilterTest.java
Sun Mar  3 12:54:07 2013
@@ -38,19 +38,22 @@ import org.apache.abdera.security.Abdera
 import org.apache.abdera.security.Signature;
 import org.apache.abdera.security.SignatureOptions;
 import org.apache.abdera.test.security.DigitalSignatureTest;
+import org.apache.axiom.testutils.PortAllocator;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class SecurityFilterTest {
 
+    private static int port;
     private static JettyServer server;
     private static Abdera abdera = Abdera.getInstance();
     private static AbderaClient client = new AbderaClient();
 
     @BeforeClass
     public static void setUp() throws Exception {
-        server = new JettyServer();
+        port = PortAllocator.allocatePort();
+        server = new JettyServer(port);
         server.start(CustomProvider.class);
     }
 
@@ -61,7 +64,7 @@ public class SecurityFilterTest {
 
     @Test
     public void testSignedResponseFilter() throws Exception {
-        ClientResponse resp = client.get("http://localhost:9002/");
+        ClientResponse resp = client.get("http://localhost:" + port + "/");
         Document<Element> doc = resp.getDocument();
         Element root = doc.getRoot();
         AbderaSecurity security = new AbderaSecurity(abdera);
@@ -80,13 +83,13 @@ public class SecurityFilterTest {
     @Test
     public void testSignedRequestFilter() throws Exception {
         Entry entry = abdera.newEntry();
-        entry.setId("http://localhost:9002/feed/entries/1");
+        entry.setId("http://localhost:" + port + "/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("http://localhost:9002/feed", entry);
+        ClientResponse resp = client.post("http://localhost:" + port + "/feed", entry);
         assertNotNull(resp);
         assertEquals(ResponseType.CLIENT_ERROR, resp.getType());
 
@@ -112,7 +115,7 @@ public class SecurityFilterTest {
         // Sign the entry
         entry = sig.sign(entry, options);
 
-        resp = client.post("http://localhost:9002/feed", entry);
+        resp = client.post("http://localhost:" + port + "/feed", entry);
         assertNotNull(resp);
         assertEquals(ResponseType.SUCCESS, resp.getType());
     }



Mime
View raw message