[jboss-cvs] JBossAS SVN: r61074 - in branches/Branch_4_2/testsuite/src/main/org/jboss/test: naming/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Mar 4 16:46:16 EST 2007
Author: bstansberry at jboss.com
Date: 2007-03-04 16:46:16 -0500 (Sun, 04 Mar 2007)
New Revision: 61074
Modified:
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/testbeancluster/test/RetryInterceptorUnitTestCase.java
Log:
Limit autodiscovery packet TTL
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java 2007-03-04 13:02:30 UTC (rev 61073)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java 2007-03-04 21:46:16 UTC (rev 61074)
@@ -338,6 +338,9 @@
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
+ // Don't let the discovery packet off the test server so we don't
+ // get spurious responses from other servers on the network
+ env.put("jnp.discoveryTTL", "1");
if (autoDisabled)
{
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java 2007-03-04 13:02:30 UTC (rev 61073)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java 2007-03-04 21:46:16 UTC (rev 61074)
@@ -238,6 +238,9 @@
env.setProperty(Context.PROVIDER_URL, "jnp://" + serverHost + ":65535/");
env.setProperty("jnp.localAddress", serverHost);
env.setProperty("jnp.partitionName", "DefaultPartition");
+ // Don't let the discovery packet off the test server so we don't
+ // get spurious responses from other servers on the network
+ env.setProperty("jnp.discoveryTTL", "1");
if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)
{
// Server is not listening for discovery on std multicast address
@@ -286,6 +289,9 @@
env.setProperty(Context.PROVIDER_URL, "jnp://" + serverHost + ":65535/");
env.setProperty("jnp.localAddress", serverHost);
env.setProperty("jnp.discoveryPort", "1102");
+ // Don't let the discovery packet off the test server so we don't
+ // get spurious responses from other servers on the network
+ env.setProperty("jnp.discoveryTTL", "1");
if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)
{
// Server is not listening for discovery on std multicast address
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/testbeancluster/test/RetryInterceptorUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/testbeancluster/test/RetryInterceptorUnitTestCase.java 2007-03-04 13:02:30 UTC (rev 61073)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/testbeancluster/test/RetryInterceptorUnitTestCase.java 2007-03-04 21:46:16 UTC (rev 61074)
@@ -23,13 +23,11 @@
import java.io.File;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.URL;
-import java.util.Enumeration;
+import java.net.URLClassLoader;
import java.util.Properties;
import java.util.Random;
-import java.util.Vector;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -61,6 +59,7 @@
{
private static final String DISCOVERY_GROUP = System.getProperty("jbosstest.udpGroup");
+ private static File customJndiDir = null;
private static File customJndiProperties = null;
// NOTE: these variables must be static as apparently a separate instance
@@ -90,7 +89,8 @@
// getResources("jndi.properties") request.
// We use this to allow running the server with
// HA-JNDI autodiscovery set to a custom address
- ClassLoader cl = new CustomJndiPropertiesClassLoader(tccl);
+ URL[] urls = new URL[]{ customJndiProperties.toURL() };
+ ClassLoader cl = new URLClassLoader(urls, tccl);
Thread.currentThread().setContextClassLoader(cl);
}
@@ -489,25 +489,30 @@
{
getLog().debug("+++ Enter testRetryWithJnpAndAutoDiscovery()");
+ // Create a jndi.properties in the temp dir with special configs
+ // to prevent autodiscovery spuriously discovering random servers
+ // on the network. When the RetryCaller runs, it will create a
+ // special classloader that will pick up this file
+ if (customJndiDir == null)
+ customJndiDir = new File(System.getProperty("java.io.tempdir"),
+ "retry-int-test");
+ if (!customJndiDir.exists())
+ customJndiDir.mkdir();
+ customJndiProperties = new File(customJndiDir, "jndi.properties");
+ FileOutputStream fos = new FileOutputStream(customJndiProperties);
+ OutputStreamWriter writer = new OutputStreamWriter(fos);
+ writer.write("jnp.discoveryTTL=1\n");
if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)
{
// The server isn't listening on the std multicast address
- // for auto discovery, so we have to pretend there is a jndi.properties
- // telling the NamingContext what address to use
- customJndiProperties = File.createTempFile("jnp-discoveryGroup", ".properties");
- FileOutputStream fos = new FileOutputStream(customJndiProperties);
- OutputStreamWriter writer = new OutputStreamWriter(fos);
writer.write("jnp.discoveryGroup=" + DISCOVERY_GROUP);
- writer.close();
- getLog().debug("Created custom jndi.properties at " + customJndiProperties +
- " -- DISCOVERY_GROUP is " + DISCOVERY_GROUP);
}
- else
- {
- getLog().debug("Not creating custom jndi.properties -- " +
- "DISCOVERY_GROUP is " + DISCOVERY_GROUP);
- }
+ writer.close();
+ getLog().debug("Created custom jndi.properties at " + customJndiProperties +
+ " -- DISCOVERY_GROUP is " + DISCOVERY_GROUP);
+
+
Properties env = getNamingProperties("org.jnp.interfaces.NamingContextFactory", true);
InitialContext ctx = new InitialContext(env);
@@ -633,6 +638,22 @@
customJndiProperties = null;
}
+ if (customJndiDir != null)
+ {
+ try
+ {
+ customJndiDir.delete();
+ if (customJndiDir.exists())
+ customJndiDir.deleteOnExit();
+ }
+ catch (Exception e)
+ {
+ log.error("problem cleaning customJndiDir", e);
+ }
+
+ customJndiProperties = null;
+ }
+
if (System.getProperty("JBossCluster-DoFail") != null)
System.setProperty("JBossCluster-DoFail", "false");
@@ -669,46 +690,5 @@
protected void setDeployed1(boolean deployed)
{
deployed1 = deployed;
- }
-
- static class CustomJndiPropertiesClassLoader extends ClassLoader
- {
- private static final Logger log = Logger.getLogger(CustomJndiPropertiesClassLoader.class);
-
- CustomJndiPropertiesClassLoader(ClassLoader parent)
- {
- super(parent);
- log.info("Constructed; using customJndiProperties " + customJndiProperties);
- }
-
- /**
- * If customJndiProperties exists, include its URL in any request
- * for "jndi.properties"
- */
- @Override
- public Enumeration<URL> getResources(String name) throws IOException
- {
- Enumeration<URL> result = super.getResources(name);
-
- if (customJndiProperties != null
- && "jndi.properties".equals(name))
- {
- log.info("Adding custom jndi.properties");
-
- Vector<URL> v = new Vector<URL>();
- v.add(customJndiProperties.toURL());
- if (result != null)
- {
- while (result.hasMoreElements())
- v.add(result.nextElement());
- }
- result = v.elements();
- }
-
- return result;
- }
-
-
}
-
}
More information about the jboss-cvs-commits
mailing list