[jboss-svn-commits] JBL Code SVN: r33503 - labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jun 14 20:44:28 EDT 2010


Author: eaa
Date: 2010-06-14 20:44:27 -0400 (Mon, 14 Jun 2010)
New Revision: 33503

Modified:
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentBinaryDiffTests.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentCustomClassLoaderTest.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentIncrementalChangeSetTest.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentTest.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/UrlResourceTest.java
Log:
JBRULES-2532: KnowledgeAgentTest fails when port 9000 is in use
	- Tests now always use a free port 

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentBinaryDiffTests.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentBinaryDiffTests.java	2010-06-15 00:17:12 UTC (rev 33502)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentBinaryDiffTests.java	2010-06-15 00:44:27 UTC (rev 33503)
@@ -35,7 +35,7 @@
         ResourceFactory.getResourceChangeNotifierService().start();
         ResourceFactory.getResourceChangeScannerService().start();
 
-        this.server = new Server(9000);
+        this.server = new Server(0);
         ResourceHandler resourceHandler = new ResourceHandler();
         resourceHandler.setResourceBase(fileManager.getRootDirectory().getPath());
         System.out.println("root : " + fileManager.getRootDirectory().getPath());
@@ -43,8 +43,14 @@
         server.setHandler(resourceHandler);
 
         server.start();
+
+        System.out.println("Server running on port "+this.getPort());
     }
 
+    private int getPort(){
+        return this.server.getConnectors()[0].getLocalPort();
+    }
+
     @Override
     protected void tearDown() throws Exception {
         fileManager.tearDown();
@@ -306,7 +312,7 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -383,7 +389,7 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -466,7 +472,7 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentCustomClassLoaderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentCustomClassLoaderTest.java	2010-06-15 00:17:12 UTC (rev 33502)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentCustomClassLoaderTest.java	2010-06-15 00:44:27 UTC (rev 33503)
@@ -40,7 +40,7 @@
         ResourceFactory.getResourceChangeNotifierService().start();
         ResourceFactory.getResourceChangeScannerService().start();
 
-        this.server = new Server(9000);
+        this.server = new Server(0);
         ResourceHandler resourceHandler = new ResourceHandler();
         resourceHandler.setResourceBase(fileManager.getRootDirectory().getPath());
 
@@ -49,6 +49,10 @@
         server.start();
     }
 
+    private int getPort(){
+        return this.server.getConnectors()[0].getLocalPort();
+    }
+
     @Override
     protected void tearDown() throws Exception {
         fileManager.tearDown();
@@ -101,7 +105,7 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -201,7 +205,7 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentIncrementalChangeSetTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentIncrementalChangeSetTest.java	2010-06-15 00:17:12 UTC (rev 33502)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentIncrementalChangeSetTest.java	2010-06-15 00:44:27 UTC (rev 33503)
@@ -8,7 +8,6 @@
 import java.io.IOException;
 import java.io.Writer;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
@@ -48,7 +47,7 @@
         ResourceFactory.getResourceChangeNotifierService().start();
         ResourceFactory.getResourceChangeScannerService().start();
 
-        this.server = new Server(9000);
+        this.server = new Server(0);
         ResourceHandler resourceHandler = new ResourceHandler();
         resourceHandler.setResourceBase(fileManager.getRootDirectory().getPath());
         System.out.println("root : " + fileManager.getRootDirectory().getPath());
@@ -58,6 +57,10 @@
         server.start();
     }
 
+    private int getPort(){
+        return this.server.getConnectors()[0].getLocalPort();
+    }
+
     @Override
     protected void tearDown() throws Exception {
         fileManager.tearDown();
@@ -96,8 +99,8 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
-        xml += "        <resource source='http://localhost:9000/rule2.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule2.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -175,8 +178,8 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
-        xml += "        <resource source='http://localhost:9000/rule2.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule2.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -269,8 +272,8 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
-        xml += "        <resource source='http://localhost:9000/rule2.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule2.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -363,7 +366,7 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rules.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rules.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -475,8 +478,8 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rules1.drl' type='DRL' />";
-        xml += "        <resource source='http://localhost:9000/rules2.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rules1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rules2.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -595,7 +598,7 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/pkg1.pkg' type='PKG' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/pkg1.pkg' type='PKG' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -679,7 +682,7 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/pkg1.pkg' type='PKG' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/pkg1.pkg' type='PKG' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -781,8 +784,8 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/pkg1.pkg' type='PKG' />";
-        xml += "        <resource source='http://localhost:9000/pkg2.pkg' type='PKG' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/pkg1.pkg' type='PKG' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/pkg2.pkg' type='PKG' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -876,8 +879,8 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
-        xml += "        <resource source='http://localhost:9000/rule2.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule2.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -909,7 +912,7 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule3.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule3.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
 
@@ -1075,7 +1078,7 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");
@@ -1167,7 +1170,7 @@
         xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
         xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
         xml += "    <add> ";
-        xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
+        xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
         xml += "    </add> ";
         xml += "</change-set>";
         File fxml = fileManager.newFile("changeset.xml");

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentTest.java	2010-06-15 00:17:12 UTC (rev 33502)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentTest.java	2010-06-15 00:44:27 UTC (rev 33503)
@@ -51,7 +51,8 @@
 		ResourceFactory.getResourceChangeNotifierService().start();
 		ResourceFactory.getResourceChangeScannerService().start();
 
-		this.server = new Server(9000);
+		this.server = new Server(0);
+                
 		ResourceHandler resourceHandler = new ResourceHandler();
 		resourceHandler.setResourceBase(fileManager.getRootDirectory()
 				.getPath());
@@ -61,8 +62,13 @@
 		server.setHandler(resourceHandler);
 
 		server.start();
+                System.out.println("Server running on port "+this.getPort());
 	}
 
+        private int getPort(){
+            return this.server.getConnectors()[0].getLocalPort();
+        }
+
 	protected void tearDown() throws Exception {
 		fileManager.tearDown();
 		ResourceFactory.getResourceChangeNotifierService().stop();
@@ -107,8 +113,8 @@
 		xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
 		xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
 		xml += "    <add> ";
-		xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
-		xml += "        <resource source='http://localhost:9000/rule2.drl' type='DRL' />";
+		xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
+		xml += "        <resource source='http://localhost:"+this.getPort()+"/rule2.drl' type='DRL' />";
 		xml += "    </add> ";
 		xml += "</change-set>";
 		File fxml = fileManager.newFile("changeset.xml");
@@ -219,8 +225,8 @@
 		xml1 += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
 		xml1 += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
 		xml1 += "    <add> ";
-		xml1 += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
-		xml1 += "        <resource source='http://localhost:9000/rule2.drl' type='DRL' />";
+		xml1 += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
+		xml1 += "        <resource source='http://localhost:"+this.getPort()+"/rule2.drl' type='DRL' />";
 		xml1 += "    </add> ";
 		xml1 += "</change-set>";
 		File fxml1 = fileManager.newFile("changeset2.xml");
@@ -233,7 +239,7 @@
 		xml2 += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
 		xml2 += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
 		xml2 += "    <add> ";
-		xml2 += "        <resource source='http://localhost:9000/changeset2.xml' type='CHANGE_SET' />";
+		xml2 += "        <resource source='http://localhost:"+this.getPort()+"/changeset2.xml' type='CHANGE_SET' />";
 		xml2 += "    </add> ";
 		xml2 += "</change-set>";
 		File fxml2 = fileManager.newFile("changeset.xml");
@@ -337,8 +343,8 @@
 		xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
 		xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
 		xml += "    <add> ";
-		xml += "        <resource source='http://localhost:9000/rule1.drl' type='DRL' />";
-		xml += "        <resource source='http://localhost:9000/rule2.drl' type='DRL' />";
+		xml += "        <resource source='http://localhost:"+this.getPort()+"/rule1.drl' type='DRL' />";
+		xml += "        <resource source='http://localhost:"+this.getPort()+"/rule2.drl' type='DRL' />";
 		xml += "    </add> ";
 		xml += "</change-set>";
 		File fxml = fileManager.newFile("changeset.xml");
@@ -441,7 +447,7 @@
 		xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
 		xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
 		xml += "    <add> ";
-		xml += "        <resource source='http://localhost:9000/pkg1.pkg' type='PKG' />";
+		xml += "        <resource source='http://localhost:"+this.getPort()+"/pkg1.pkg' type='PKG' />";
 		xml += "    </add> ";
 		xml += "</change-set>";
 		File fxml = fileManager.newFile("changeset.xml");
@@ -568,8 +574,8 @@
 		xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
 		xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
 		xml += "    <add> ";
-		xml += "        <resource source='http://localhost:9000/pkg1.pkg' type='PKG' />";
-		xml += "        <resource source='http://localhost:9000/pkg2.pkg' type='PKG' />";
+		xml += "        <resource source='http://localhost:"+this.getPort()+"/pkg1.pkg' type='PKG' />";
+		xml += "        <resource source='http://localhost:"+this.getPort()+"/pkg2.pkg' type='PKG' />";
 		xml += "    </add> ";
 		xml += "</change-set>";
 
@@ -614,7 +620,7 @@
 		xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
 		xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
 		xml += "    <remove> ";
-		xml += "        <resource source='http://localhost:9000/pkg2.pkg' type='PKG' />";
+		xml += "        <resource source='http://localhost:"+this.getPort()+"/pkg2.pkg' type='PKG' />";
 		xml += "    </remove> ";
 		xml += "</change-set>";
 
@@ -676,7 +682,7 @@
 		xml += "    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
 		xml += "    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >";
 		xml += "    <add> ";
-		xml += "        <resource source='http://localhost:9000/pkgold.pkg' type='PKG' />";
+		xml += "        <resource source='http://localhost:"+this.getPort()+"/pkgold.pkg' type='PKG' />";
 		xml += "    </add> ";
 		xml += "</change-set>";
 		File fxml = fileManager.newFile("changeset.xml");

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/UrlResourceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/UrlResourceTest.java	2010-06-15 00:17:12 UTC (rev 33502)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/UrlResourceTest.java	2010-06-15 00:44:27 UTC (rev 33503)
@@ -28,6 +28,7 @@
     private FileManager fileManager;
     private Server server;
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         fileManager = new FileManager();
@@ -36,7 +37,7 @@
         ResourceFactory.getResourceChangeNotifierService().start();
         ResourceFactory.getResourceChangeScannerService().start();
 
-        this.server = new Server( 9000 );
+        this.server = new Server(0);
         ResourceHandler resourceHandler = new ResourceHandler();
         resourceHandler.setResourceBase( fileManager.getRootDirectory().getPath() );
         System.out.println("root : " + fileManager.getRootDirectory().getPath() );
@@ -46,6 +47,11 @@
         server.start();
     }
 
+    private int getPort(){
+        return this.server.getConnectors()[0].getLocalPort();
+    }
+
+    @Override
     protected void tearDown() throws Exception {
         fileManager.tearDown();
         ResourceFactory.getResourceChangeNotifierService().stop();
@@ -58,7 +64,7 @@
 
 
     public void testWithCache() throws Exception {
-        URL url = new URL("http://localhost:9000/rule1.drl");
+        URL url = new URL("http://localhost:"+this.getPort()+"/rule1.drl");
         UrlResource ur = new UrlResource(url);
         UrlResource.CACHE_DIR = new File(".");
 
@@ -91,6 +97,10 @@
         output.close();
 
         server.start();
+
+        url = new URL("http://localhost:"+this.getPort()+"/rule1.drl");
+        ur = new UrlResource(url);
+
         assertNotNull(ur.getInputStream());
         assertFalse(ur.getInputStream() instanceof FileInputStream);
         long lm_ = ur.getLastModified();
@@ -121,7 +131,10 @@
         Thread.sleep(1000);
         server.start();
 
+        url = new URL("http://localhost:"+this.getPort()+"/rule1.drl");
         ur = new UrlResource(url);
+
+        ur = new UrlResource(url);
         //server is started, so should have latest...
         in_= ur.getInputStream();
         rdr = new BufferedReader(new InputStreamReader(in_));
@@ -134,7 +147,7 @@
     }
 
     public void testWithoutCache() throws Exception {
-        UrlResource ur = new UrlResource(new URL("http://localhost:9000/rule1.drl"));
+        UrlResource ur = new UrlResource(new URL("http://localhost:"+this.getPort()+"/rule1.drl"));
         UrlResource.CACHE_DIR = null;
 
         File f1 = fileManager.newFile( "rule1.drl" );



More information about the jboss-svn-commits mailing list