[jboss-cvs] JBossAS SVN: r88129 - in projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as: server and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun May 3 20:54:08 EDT 2009


Author: ALRubinger
Date: 2009-05-03 20:54:08 -0400 (Sun, 03 May 2009)
New Revision: 88129

Modified:
   projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationPropertyOverrideTestCase.java
   projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java
Log:
[JBBOOT-31] Handle configuration of "jboss.partition.udpGroup" and "jboss.jgroups.udp.mcast_port", overrides, and tests

Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationPropertyOverrideTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationPropertyOverrideTestCase.java	2009-05-03 23:28:44 UTC (rev 88128)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationPropertyOverrideTestCase.java	2009-05-04 00:54:08 UTC (rev 88129)
@@ -69,6 +69,11 @@
    private static final String STRING_EXPLICIT_SETTING = "explicit";
 
    /**
+    * An Integer used to model an explicit setting while testing the config
+    */
+   private static final Integer INTEGER_EXPLICIT_SETTING = 102;
+
+   /**
     * A String used to model an explicit setting while testing the config
     */
    private static final URL URL_EXPLICIT_SETTING;
@@ -88,6 +93,11 @@
     */
    private static final String STRING_OVERRIDE;
 
+   /**
+    * An Integer used to model an override setting while testing the config
+    */
+   private static final Integer INTEGER_OVERRIDE = 513;
+
    static
    {
       try
@@ -528,4 +538,59 @@
       log.info("Got expected: " + STRING_OVERRIDE);
    }
 
+   /**
+    * Ensures that the Partition UDP Group may be overridden from
+    * the corresponding property
+    */
+   @Test
+   public void testUdpGroupPropOverride() throws Throwable
+   {
+      // Log
+      log.info("testUdpGroupPropOverride");
+
+      // Get the config
+      final JBossASServerConfig config = this.config;
+
+      // Explicitly set
+      config.udpGroup(STRING_EXPLICIT_SETTING);
+
+      // Set override property
+      config.property(JBossASServerConfig.PROP_KEY_JBOSSAS_PARTITION_UDP_GROUP, STRING_OVERRIDE);
+
+      // Initialize
+      initializer.initialize(config);
+
+      // Test
+      TestCase.assertEquals(FAIL_MESSAGE, STRING_OVERRIDE, config.getUdpGroup());
+      log.info("Got expected: " + STRING_OVERRIDE);
+   }
+
+   /**
+    * Ensures that the Partition UDP Port may be overridden from
+    * the corresponding property
+    */
+   @Test
+   public void testUdpPortPropOverride() throws Throwable
+   {
+      // Log
+      log.info("testUdpPortPropOverride");
+
+      // Get the config
+      final JBossASServerConfig config = this.config;
+
+      // Explicitly set
+      config.udpPort(INTEGER_EXPLICIT_SETTING);
+
+      // Set override property
+      final String override = INTEGER_OVERRIDE.toString();
+      config.property(JBossASServerConfig.PROP_KEY_JBOSSAS_PARTITION_UDP_PORT, override);
+
+      // Initialize
+      initializer.initialize(config);
+
+      // Test
+      TestCase.assertEquals(FAIL_MESSAGE, override, config.getUdpPort().toString());
+      log.info("Got expected: " + override);
+   }
+
 }

Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java	2009-05-03 23:28:44 UTC (rev 88128)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java	2009-05-04 00:54:08 UTC (rev 88129)
@@ -71,14 +71,22 @@
       // Create a server that skips real start/stop
       this.server = new NoOpJBossASServer(true);
 
+      // Get the configuration
+      final JBossASServerConfig configuration = this.server.getConfiguration();
+
       // Set some JBOSS_HOME explicitly so the tests are reproducible
       // (environment properties cannot be mutated via the test env, and we need
       // to be sure no $JBOSS_HOME default is picked up)
-      this.server.getConfiguration().jbossHome(TestUtils.getJBossHome());
+      configuration.jbossHome(TestUtils.getJBossHome());
 
-      // Initialize via start (Though this is a no-op, so we won't *really* start anything)
-      server.start();
+      // Manually set a UDP group and port, as there's no default and we want to test
+      final String udpGroupValue = "udpGroup";
+      final Integer udpPortValue = 342;
+      configuration.udpGroup(udpGroupValue).udpPort(udpPortValue);
 
+      // Initialize
+      server.initialize();
+
       // Log
       log.info("Created: " + this.server);
    }
@@ -134,6 +142,8 @@
       final String serverDataDirPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_DATA_DIR;
       final String serverTempDirPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_TEMP_DIR;
       final String partitionNamePropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_PARTITION_NAME;
+      final String udpGroupPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_PARTITION_UDP_GROUP;
+      final String udpPortPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_PARTITION_UDP_PORT;
 
       // Get Properties from Configuration
       final Map<String, String> properties = configuration.getProperties();
@@ -155,6 +165,8 @@
       final String serverDataDirFromConfProp = properties.get(serverDataDirPropKey);
       final String serverTempDirFromConfProp = properties.get(serverTempDirPropKey);
       final String partitionNameFromConfProp = properties.get(partitionNamePropKey);
+      final String udpGroupFromConfProp = properties.get(udpGroupPropKey);
+      final String udpPortFromConfProp = properties.get(udpPortPropKey);
 
       // Get Properties from System
       final String jbossHomeFromSystem = System.getProperty(jbossHomePropKey);
@@ -175,6 +187,8 @@
       final String serverDataDirFromSystem = System.getProperty(serverDataDirPropKey);
       final String serverTempDirFromSystem = System.getProperty(serverTempDirPropKey);
       final String partitionNameFromSystem = System.getProperty(partitionNamePropKey);
+      final String udpGroupFromSystem = System.getProperty(udpGroupPropKey);
+      final String udpPortFromSystem = properties.get(udpPortPropKey);
 
       // Get Expected Values
       final URL jbossHomeFromConf = configuration.getJBossHome();
@@ -206,6 +220,8 @@
       final File serverTempFile = new File(serverTempFromConf.toURI());
       final String serverTempDirFromConf = serverTempFile.getAbsolutePath();
       final String partitionNameFromConf = configuration.getPartitionName();
+      final String udpGroupFromConf = configuration.getUdpGroup();
+      final String udpPortFromConf = configuration.getUdpPort().toString();
 
       // Ensure all equal
       TestCase.assertEquals("JBoss Home in configuration must match the config property", jbossHomeDirFromConf,
@@ -280,8 +296,17 @@
             partitionNameFromConfProp);
       TestCase.assertEquals("Partition Name in configuration must match the system property", partitionNameFromConf,
             partitionNameFromSystem);
+      TestCase.assertEquals("UDP Group in configuration must match the config property", udpGroupFromConf,
+            udpGroupFromConfProp);
+      TestCase.assertEquals("UDP Group in configuration must match the system property", udpGroupFromConf,
+            udpGroupFromSystem);
+      TestCase.assertEquals("UDP Port in configuration must match the config property", udpPortFromConf,
+            udpPortFromConfProp);
+      TestCase.assertEquals("UDP Port in configuration must match the system property", udpPortFromConf,
+            udpPortFromSystem);
 
-      // Cleanup
+      // Push through lifecycle start/stop
+      server.start();
       server.shutdown();
 
       // Get Properties from System
@@ -303,6 +328,8 @@
       final String serverDataDirFromSystemAfterCleanup = System.getProperty(serverDataDirPropKey);
       final String serverTempDirFromSystemAfterCleanup = System.getProperty(serverTempDirPropKey);
       final String partitionNameFromSystemAfterCleanup = System.getProperty(partitionNamePropKey);
+      final String udpGroupFromSystemAfterCleanup = System.getProperty(udpGroupPropKey);
+      final String udpPortFromSystemAfterCleanup = System.getProperty(udpPortPropKey);
 
       // Ensure all null
       final String failMessage = "System property should be null after cleanup";
@@ -324,5 +351,7 @@
       TestCase.assertNull(failMessage, serverDataDirFromSystemAfterCleanup);
       TestCase.assertNull(failMessage, serverTempDirFromSystemAfterCleanup);
       TestCase.assertNull(failMessage, partitionNameFromSystemAfterCleanup);
+      TestCase.assertNull(failMessage, udpGroupFromSystemAfterCleanup);
+      TestCase.assertNull(failMessage, udpPortFromSystemAfterCleanup);
    }
 }




More information about the jboss-cvs-commits mailing list