geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [11/26] incubator-geode git commit: GEODE-420: Added tests to cover the ssl-enabled-components. cleaned up code using AbstractDistributionConfig.checkAttributes to not require the method to return a value. Added a validation step at the end of the initia
Date Fri, 22 Jul 2016 00:19:58 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/851e02bf/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
index c1384c3..515e5df 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
@@ -61,7 +61,7 @@ public final class RuntimeDistributionConfigImpl
   ////////////////////  Configuration Methods  ////////////////////
   @Override
   public void setLogLevel(int value) {
-    this.logLevel = (Integer)checkAttribute(LOG_LEVEL, value);
+    this.logLevel = value;
     getAttSourceMap().put(LOG_LEVEL, ConfigSource.runtime());
     this.ds.getInternalLogWriter().setLogWriterLevel(value);
     LogWriterAppenders.configChanged(LogWriterAppenders.Identifier.MAIN);
@@ -69,13 +69,12 @@ public final class RuntimeDistributionConfigImpl
   
   @Override
   public void setStatisticSamplingEnabled(boolean value) {
-    this.statisticSamplingEnabled = (Boolean)checkAttribute(STATISTIC_SAMPLING_ENABLED, value);
+    this.statisticSamplingEnabled = value;
     getAttSourceMap().put(STATISTIC_SAMPLING_ENABLED, ConfigSource.runtime());
   }
 
   @Override
   public void setStatisticSampleRate(int value) {
-    value = (Integer)checkAttribute(STATISTIC_SAMPLE_RATE, value);
     if (value < DEFAULT_STATISTIC_SAMPLE_RATE) {
       // fix 48228
       this.ds.getLogWriter().info("Setting statistic-sample-rate to " + DEFAULT_STATISTIC_SAMPLE_RATE
+ " instead of the requested " + value + " because VSD does not work with sub-second sampling.");
@@ -86,7 +85,6 @@ public final class RuntimeDistributionConfigImpl
 
   @Override
   public void setStatisticArchiveFile(File value) {
-    value = (File)checkAttribute(STATISTIC_ARCHIVE_FILE, value);
     if (value == null) {
       value = new File("");
     }
@@ -102,26 +100,26 @@ public final class RuntimeDistributionConfigImpl
 
   @Override
   public void setArchiveDiskSpaceLimit(int value) {
-    this.archiveDiskSpaceLimit = (Integer)checkAttribute(ARCHIVE_DISK_SPACE_LIMIT, value);
+    this.archiveDiskSpaceLimit = value;
     getAttSourceMap().put(ARCHIVE_DISK_SPACE_LIMIT, ConfigSource.runtime());
   }
 
   @Override
   public void setArchiveFileSizeLimit(int value) {
-    this.archiveFileSizeLimit = (Integer)checkAttribute(ARCHIVE_FILE_SIZE_LIMIT, value);
+    this.archiveFileSizeLimit = value;
     getAttSourceMap().put(ARCHIVE_FILE_SIZE_LIMIT, ConfigSource.runtime());
   }
 
   @Override
   public void setLogDiskSpaceLimit(int value) {
-    this.logDiskSpaceLimit = (Integer)checkAttribute(LOG_DISK_SPACE_LIMIT, value);
+    this.logDiskSpaceLimit = value;
     getAttSourceMap().put(LOG_DISK_SPACE_LIMIT, ConfigSource.runtime());
     LogWriterAppenders.configChanged(LogWriterAppenders.Identifier.MAIN);
   }
 
   @Override
   public void setLogFileSizeLimit(int value) {
-    this.logFileSizeLimit = (Integer)checkAttribute(LOG_FILE_SIZE_LIMIT, value);
+    this.logFileSizeLimit = value;
     getAttSourceMap().put(LOG_FILE_SIZE_LIMIT, ConfigSource.runtime());
     LogWriterAppenders.configChanged(LogWriterAppenders.Identifier.MAIN);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/851e02bf/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
index 7c6e933..fa0a6c5 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
@@ -3551,7 +3551,7 @@ public class LocalizedStrings {
   public static final StringId Region_REGION_0_HAS_1_ASYNC_EVENT_QUEUE_IDS_ANOTHER_CACHE_HAS_THE_SAME_REGION_WITH_2_ASYNC_EVENT_QUEUE_IDS_FOR_REGION_ACROSS_ALL_MEMBERS_IN_DS_ASYNC_EVENT_QUEUE_IDS_SHOULD_BE_SAME
= new StringId(
       5304,
       "Region {0} has {1} AsyncEvent queue IDs. Another cache has same region with {2} AsyncEvent
queue IDs. For region across all members, AsyncEvent queue IDs should be same.");
-  public static final StringId GatewayEventFilter_EXCEPTION_OCCURED_WHILE_HANDLING_CALL_TO_0_AFTER_ACKNOWLEDGEMENT_FOR_EVENT_1
= new StringId(5305, "Exception occured while handling call to {0}.afterAcknowledgement for
event {1}:"); 
+  public static final StringId GatewayEventFilter_EXCEPTION_OCCURED_WHILE_HANDLING_CALL_TO_0_AFTER_ACKNOWLEDGEMENT_FOR_EVENT_1
= new StringId(5305, "Exception occured while handling call to {0}.afterAcknowledgement for
event {1}:");
   public static final StringId GatewayReceiverImpl_USING_LOCAL_HOST = new StringId(5399,
"No bind-address or hostname-for-sender is specified, Using local host ");
   public static final StringId GatewayReceiverImpl_COULD_NOT_GET_HOST_NAME = new StringId(5400,
"Could not get host name");
   public static final StringId CqService_ERROR_SENDING_CQ_CONNECTION_STATUS = new StringId(5401,
"Error while sending connection status to cq listeners");
@@ -3616,7 +3616,7 @@ public class LocalizedStrings {
   public static final StringId PERCENTAGE_MOVE_DIRECTORY_SOURCE_NOT_DATA_STORE = new StringId(5450,
"Source member does not exist or is not a data store for the partitioned region {0}: {1}");
   public static final StringId PERCENTAGE_MOVE_DIRECTORY_TARGET_NOT_DATA_STORE = new StringId(5451,
"Target member does not exist or is not a data store for the partitioned region {0}: {1}");
   public static final StringId PERCENTAGE_MOVE_TARGET_SAME_AS_SOURCE = new StringId(5452,
"Target member is the same as source member for the partitioned region {0}: {1}");
-  
+
   public static final StringId GatewaySender_SEQUENCENUMBER_GENERATED_FOR_EVENT_IS_INVALID
= new StringId(5453, "ERROR! The sequence number {0} generated for the bucket {1} is incorrect.");
 
   public static final StringId CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_GATEWAY_SENDER_OR_ASYNC_EVENT_QUEUE
= new StringId(5456, "A  {0}  must be defined in the context of gateway-sender or async-event-queue.");
@@ -3627,7 +3627,7 @@ public class LocalizedStrings {
   public static final StringId DistributedPutAllOperation_MISSING_VERSION = new StringId(5459,"memberID
cannot be null for persistent regions: {0}");
 
   public static final StringId Server_Ping_Failure = new StringId(5460, "Could not ping one
of the following servers: {0}");
-  
+
   public static final StringId DistributionManager_PR_META_DATA_CLEANUP_MESSAGE_PROCESSOR
= new StringId(5500, "PrMetaData cleanup Message Processor ");
   public static final StringId RegionCreation_REGION_DESTROYED_DURING_INITIALIZATION = new
StringId(5501, "Region was globally destroyed during cache initialization: {0}");
   public static final StringId SnappyCompressor_UNABLE_TO_LOAD_NATIVE_SNAPPY_LIBRARY = new
StringId(5502, "Unable to load native Snappy library.");
@@ -3654,7 +3654,7 @@ public class LocalizedStrings {
   public static final StringId DiskStoreMonitor_DISK_WARNING = new StringId(5616, "The disk
volume {0} for disk store {1} has exceeded the warning usage threshold and is {2} full");
   public static final StringId DiskStoreMonitor_DISK_CRITICAL = new StringId(5617, "The disk
volume {0} for disk store {1} has exceeded the critical usage threshold and is {2} full");
   public static final StringId DiskStoreMonitor_DISK_NORMAL = new StringId(5618, "The disk
volume {0} for disk store {1} has returned to normal usage levels and is {2} full");
-  
+
   public static final StringId DiskStoreMonitor_ERR = new StringId(5619, "The DiskStore Monitor
has encountered an error");
   public static final StringId DiskStoreMonitor_ThreadGroup = new StringId(5620, "DiskStoreMonitorss");
 
@@ -3665,7 +3665,7 @@ public class LocalizedStrings {
   public static final StringId Oplog_Close_Failed = new StringId(5640, "Failed to close file
{0}");
   public static final StringId Oplog_PreAllocate_Failure = new StringId(5641, "Could not
pre-allocate file {0} with size={1}");
   public static final StringId Oplog_PreAllocate_Failure_Init = new StringId(5642, "Could
not create and pre grow file in dir {0} with size={1}");
-  
+
   public static final StringId InternalInstantiator_REGISTERED = new StringId(5650, "Instantiator
registered with id {0} class {1}");
   public static final StringId InternalInstantiator_REGISTERED_HOLDER = new StringId(5651,
"Instantiator registered with holder id {0} class {1}");
   public static final StringId RegisterInstantiators_BAD_CLIENT = new StringId(5652, "Client
{0} failed to register instantiators: {1}");
@@ -3717,7 +3717,7 @@ public class LocalizedStrings {
 
   public static final StringId AbstractDistributionConfig_LOCATOR_WAIT_TIME_NAME_0 = new
StringId(6599, "The amount of time, in seconds, to wait for a locator to be available before
throwing an exception during startup.  The default is {0}.");
   public static final StringId CliLegacyMessage_ERROR = new StringId(6600, "Error processing
request {0}.");
-  
+
   public static final StringId AbstractDistributionConfig_MEMCACHED_BIND_ADDRESS_0_INVALID_MUST_BE_IN_1
= new StringId(6601, "The memcached-bind-address \"{0}\" is not a valid address for this machine.
 These are the valid addresses for this machine: {1}");
   public static final StringId GemFireCacheImpl_STARTING_GEMFIRE_MEMCACHED_SERVER_ON_BIND_ADDRESS_0_PORT_1_FOR_2_PROTOCOL
= new StringId(6602, "Starting GemFireMemcachedServer on bind address {0} on port {1} for
{2} protocol");
 
@@ -3729,7 +3729,7 @@ public class LocalizedStrings {
   public static final StringId LOCATOR_UNABLE_TO_RECOVER_VIEW = new StringId(6606, "Unable
to recover previous membership view from {0}");
 
   public static final StringId Network_partition_detected = new StringId(6607, "Exiting due
to possible network partition event due to loss of {0} cache processes: {1}");
-  
+
   // GMSAuthenticator
   public static final StringId AUTH_PEER_AUTHENTICATION_FAILED_WITH_EXCEPTION = new StringId(6608,
"Authentication failed for [{0}]. {1}");
   public static final StringId AUTH_PEER_AUTHENTICATION_FAILED = new StringId(6609, "Authentication
failed. See coordinator [{0}] logs for details.");
@@ -3766,19 +3766,19 @@ public class LocalizedStrings {
   public static final StringId AbstractDistributionConfig_HTTP_SERVICE_SSL_ALIAS_0 = new
StringId(6636,"SSL http service communication uses the this alias when determining the key
to use from the keystore for SSL. Defaults to \"{0}\".");
   public static final StringId AbstractDistributionConfig_JMX_MANAGER_SSL_ALIAS_0 = new StringId(6637,"SSL
jmx communication uses the this alias when determining the key to use from the keystore for
SSL. Defaults to \"{0}\".");
 
-  public static final StringId AbstractDistributionConfig_SSL_ENABLED_COMPONENTS_0_INVALID_TRY_1
= new StringId(6638,"\"{0}\" is not in the valid set of {1}");
+  public static final StringId AbstractDistributionConfig_SSL_ENABLED_COMPONENTS_0_INVALID_TRY_1
= new StringId(6638,"\"{0}\" is not in the valid set of options \"{1}\"");
 
   public static final StringId AbstractDistributionConfig_SSL_ENABLED_COMPONENTS_SET_INVALID_DEPRECATED_SSL_SET
= new StringId(6639,"When using ssl-enabled-components one cannot use any other SSL properties
other than cluster-ssl-* or the corresponding aliases");
 
   /** Testing strings, messageId 90000-99999 **/
-  
+
   /** These are simple messages for testing, translated with Babelfish. **/
   public static final StringId TESTING_THIS_IS_A_TEST_MESSAGE = new StringId(90000, "This
is a test message.");
   public static final StringId TESTING_THIS_MESSAGE_HAS_0_MEMBERS = new StringId(90001, "Please
ignore: This message has {0} members.");
   public static final StringId OBJECT_PREFIX = new StringId(90002, "Object_");
   public static final StringId REGION_PREFIX = new StringId(90003, "Region_");
   public static final StringId LISTENER_PREFIX = new StringId(90004, "Listener_");
-  
+
   public static final StringId DistributedRegion_INITIALIZING_REGION_COMPLETED_0 = new StringId(90005,
"Initialization of region {0} completed");
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/851e02bf/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
index 24d9673..9e43279 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
@@ -110,11 +110,12 @@ public class DistributionConfigJUnitTest {
     System.out.println();
     System.out.println("otherList: " + otherList);
 
-    assertEquals(boolList.size(), 30);
-    assertEquals(intList.size(), 33);
-    assertEquals(stringList.size(), 72);
-    assertEquals(fileList.size(), 5);
-    assertEquals(otherList.size(), 3);
+    //TODO - This makes no sense. One has no idea what the correct expected number of attributes
are.
+    assertEquals(27, boolList.size());
+    assertEquals(33, intList.size());
+    assertEquals(74, stringList.size());
+    assertEquals(5, fileList.size());
+    assertEquals(3, otherList.size());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/851e02bf/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystemJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystemJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystemJUnitTest.java
index cde334a..067ac59 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystemJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystemJUnitTest.java
@@ -16,12 +16,36 @@
  */
 package com.gemstone.gemfire.distributed.internal;
 
+import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.logging.Level;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.ExpectedException;
+
 import com.gemstone.gemfire.distributed.DistributedSystem;
 import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException;
 import com.gemstone.gemfire.distributed.Locator;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.Config;
 import com.gemstone.gemfire.internal.ConfigSource;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 import org.junit.After;
@@ -44,16 +68,16 @@ import static org.junit.Assert.*;
 /**
  * Tests the functionality of the {@link InternalDistributedSystem}
  * class.  Mostly checks configuration error checking.
- *
- *
  * @since GemFire 2.1
  */
 @Category(IntegrationTest.class)
-public class InternalDistributedSystemJUnitTest 
+public class InternalDistributedSystemJUnitTest
   //implements DistributionConfig
 {
 
-  /** A connection to a distributed system created by this test */
+  /**
+   * A connection to a distributed system created by this test
+   */
   private InternalDistributedSystem system;
 
   /**
@@ -62,14 +86,12 @@ public class InternalDistributedSystemJUnitTest
    */
   protected InternalDistributedSystem createSystem(Properties props) {
     assertFalse(com.gemstone.gemfire.distributed.internal.DistributionManager.isDedicatedAdminVM);
-    this.system =
-      (InternalDistributedSystem) DistributedSystem.connect(props);
+    this.system = (InternalDistributedSystem) DistributedSystem.connect(props);
     return this.system;
   }
 
   /**
    * Disconnects any distributed system that was created by this test
-   *
    * @see DistributedSystem#disconnect
    */
   @After
@@ -78,9 +100,9 @@ public class InternalDistributedSystemJUnitTest
       this.system.disconnect();
     }
   }
-  
+
   ////////  Test methods
-  
+
   @Test
   public void testUnknownArgument() {
     Properties props = new Properties();
@@ -109,7 +131,7 @@ public class InternalDistributedSystemJUnitTest
     assertEquals(DistributionConfig.DEFAULT_NAME, config.getName());
 
     assertEquals(0, config.getMcastPort());
-    
+
     assertEquals(DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[0], config.getMembershipPortRange()[0]);
     assertEquals(DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1], config.getMembershipPortRange()[1]);
 
@@ -123,30 +145,27 @@ public class InternalDistributedSystemJUnitTest
     assertEquals(DistributionConfig.DEFAULT_LOG_FILE, config.getLogFile());
 
     //default log level gets overrided by the gemfire.properties created for unit tests.
-//    assertIndexDetailsEquals(DistributionConfig.DEFAULT_LOG_LEVEL, config.getLogLevel());
+    //    assertIndexDetailsEquals(DistributionConfig.DEFAULT_LOG_LEVEL, config.getLogLevel());
 
-    assertEquals(DistributionConfig.DEFAULT_STATISTIC_SAMPLING_ENABLED,
-                 config.getStatisticSamplingEnabled());
+    assertEquals(DistributionConfig.DEFAULT_STATISTIC_SAMPLING_ENABLED, config.getStatisticSamplingEnabled());
 
-    assertEquals(DistributionConfig.DEFAULT_STATISTIC_SAMPLE_RATE,
-                 config.getStatisticSampleRate());
+    assertEquals(DistributionConfig.DEFAULT_STATISTIC_SAMPLE_RATE, config.getStatisticSampleRate());
 
-    assertEquals(DistributionConfig.DEFAULT_STATISTIC_ARCHIVE_FILE,
-                 config.getStatisticArchiveFile());
+    assertEquals(DistributionConfig.DEFAULT_STATISTIC_ARCHIVE_FILE, config.getStatisticArchiveFile());
 
     // ack-wait-threadshold is overridden on VM's command line using a
     // system property.  This is not a valid test.  Hrm.
-//     assertIndexDetailsEquals(DistributionConfig.DEFAULT_ACK_WAIT_THRESHOLD, config.getAckWaitThreshold());
+    //     assertIndexDetailsEquals(DistributionConfig.DEFAULT_ACK_WAIT_THRESHOLD, config.getAckWaitThreshold());
 
     assertEquals(DistributionConfig.DEFAULT_ACK_SEVERE_ALERT_THRESHOLD, config.getAckSevereAlertThreshold());
-    
+
     assertEquals(DistributionConfig.DEFAULT_CACHE_XML_FILE, config.getCacheXmlFile());
 
     assertEquals(DistributionConfig.DEFAULT_ARCHIVE_DISK_SPACE_LIMIT, config.getArchiveDiskSpaceLimit());
     assertEquals(DistributionConfig.DEFAULT_ARCHIVE_FILE_SIZE_LIMIT, config.getArchiveFileSizeLimit());
     assertEquals(DistributionConfig.DEFAULT_LOG_DISK_SPACE_LIMIT, config.getLogDiskSpaceLimit());
     assertEquals(DistributionConfig.DEFAULT_LOG_FILE_SIZE_LIMIT, config.getLogFileSizeLimit());
-    
+
     assertEquals(DistributionConfig.DEFAULT_ENABLE_NETWORK_PARTITION_DETECTION, config.getEnableNetworkPartitionDetection());
   }
 
@@ -163,7 +182,7 @@ public class InternalDistributedSystemJUnitTest
     DistributionConfig config = createSystem(props).getOriginalConfig();
     assertEquals(name, config.getName());
   }
-  
+
   @Test
   public void testMemberTimeout() {
     Properties props = new Properties();
@@ -233,10 +252,7 @@ public class InternalDistributedSystemJUnitTest
   /**
    * Creates a new <code>DistributionConfigImpl</code> with the given
    * locators string.
-   *
-   * @throws IllegalArgumentException
-   *         If <code>locators</code> is malformed
-   *
+   * @throws IllegalArgumentException If <code>locators</code> is malformed
    * @since GemFire 4.0
    */
   private void checkLocator(String locator) {
@@ -248,18 +264,15 @@ public class InternalDistributedSystemJUnitTest
   /**
    * Tests that both the traditional syntax ("host[port]") and post
    * bug-32306 syntax ("host:port") can be used with locators.
-   *
    * @since GemFire 4.0
    */
   @Test
   public void testLocatorSyntax() throws Exception {
-    String localhost =
-      java.net.InetAddress.getLocalHost().getCanonicalHostName();
+    String localhost = java.net.InetAddress.getLocalHost().getCanonicalHostName();
     checkLocator(localhost + "[12345]");
     checkLocator(localhost + ":12345");
 
-    String bindAddress = 
-      getHostAddress(java.net.InetAddress.getLocalHost());
+    String bindAddress = getHostAddress(java.net.InetAddress.getLocalHost());
     if (bindAddress.indexOf(':') < 0) {
       checkLocator(localhost + ":" + bindAddress + "[12345]");
     }
@@ -275,7 +288,6 @@ public class InternalDistributedSystemJUnitTest
   /**
    * Test a configuration with an <code>mcastPort</code> of zero and
    * an empty <code>locators</code>.
-   *
    * @deprecated This test creates a "loner" distributed system
    */
   @Ignore
@@ -613,6 +625,7 @@ public class InternalDistributedSystemJUnitTest
       }
     }
   }
+
   /**
    * Create a <Code>DistributedSystem</code> with a non-default name.
    */
@@ -640,7 +653,7 @@ public class InternalDistributedSystemJUnitTest
     assertEquals(level.intValue(), system.getConfig().getLogLevel());
     assertEquals(level.intValue(), ((InternalLogWriter) system.getLogWriter()).getLogWriterLevel());
   }
-  
+
   @Test
   public void testStartLocator() {
     Properties props = new Properties();
@@ -653,19 +666,19 @@ public class InternalDistributedSystemJUnitTest
     Assert.assertEquals(1, locators.size());
     Locator locator = (Locator) locators.iterator().next();
     Assert.assertTrue(locator.isPeerLocator());
-//    Assert.assertFalse(locator.isServerLocator()); server location is forced on while licensing
is disabled in GemFire
-//    Assert.assertIndexDetailsEquals("127.0.0.1", locator.getBindAddress().getHostAddress());
 removed this check for ipv6 testing
+    //    Assert.assertFalse(locator.isServerLocator()); server location is forced on while
licensing is disabled in GemFire
+    //    Assert.assertIndexDetailsEquals("127.0.0.1", locator.getBindAddress().getHostAddress());
 removed this check for ipv6 testing
     Assert.assertEquals(unusedPort, locator.getPort().intValue());
     deleteStateFile(unusedPort);
   }
 
   private void deleteStateFile(int port) {
-    File stateFile = new File("locator"+port+"state.dat");
+    File stateFile = new File("locator" + port + "state.dat");
     if (stateFile.exists()) {
       stateFile.delete();
     }
   }
-  
+
   @Test
   public void testValidateProps() {
     Properties props = new Properties();
@@ -676,19 +689,20 @@ public class InternalDistributedSystemJUnitTest
     try {
 
       props.put(MCAST_PORT, "1");
-    Config config2 = new DistributionConfigImpl(props, false);
+      Config config2 = new DistributionConfigImpl(props, false);
+
+      try {
+        sys.validateSameProperties(config2.toProperties(), true);
+        fail("should have detected different mcast-ports");
+      } catch (IllegalStateException iex) {
+        // This passes the test
+      }
 
-    try {
-      sys.validateSameProperties(config2.toProperties(), true);
-      fail("should have detected different mcast-ports");
-    } catch (IllegalStateException iex) {
-      // This passes the test
-    }
-    
     } finally {
       sys.disconnect();
     }
   }
+
   @Test
   public void testDeprecatedSSLProps() {
     Properties props = new Properties();
@@ -711,11 +725,84 @@ public class InternalDistributedSystemJUnitTest
     Config config3 = new DistributionConfigImpl(props3, false);
     assertEquals(false, config1.sameAs(config3));
   }
+
+  @Test
+  public void testSSLEnabledComponents() {
+    Properties props = new Properties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(LOCATORS, "");
+    props.setProperty(CLUSTER_SSL_ENABLED, "true");
+    props.setProperty(SSL_ENABLED_COMPONENTS, "cluster,server");
+    Config config1 = new DistributionConfigImpl(props, false);
+    assertEquals("cluster,server", config1.getAttribute(SSL_ENABLED_COMPONENTS));
+  }
+
+  @Rule
+  public ExpectedException illegalArgumentException = ExpectedException.none();
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSSLEnabledComponentsWrongComponentName() {
+    Properties props = new Properties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(LOCATORS, "");
+    props.setProperty(CLUSTER_SSL_ENABLED, "true");
+    props.setProperty(SSL_ENABLED_COMPONENTS, "testing");
+    new DistributionConfigImpl(props, false);
+    illegalArgumentException.expect(IllegalArgumentException.class);
+    illegalArgumentException.expectMessage("\"testing\" is not in the valid set of options
\"all,cluster,server,gateway,jmx,http\"");
+  }
+
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSSLEnabledComponentsWithLegacyJMXSSLSettings() {
+    Properties props = new Properties();
+    props.setProperty(CLUSTER_SSL_ENABLED, "true");
+    props.setProperty(JMX_MANAGER_SSL_ENABLED, "true");
+    props.setProperty(SSL_ENABLED_COMPONENTS, "all");
+    new DistributionConfigImpl(props, false);
+    illegalArgumentException.expect(IllegalArgumentException.class);
+    illegalArgumentException.expectMessage(LocalizedStrings.AbstractDistributionConfig_SSL_ENABLED_COMPONENTS_SET_INVALID_DEPRECATED_SSL_SET.getRawText());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSSLEnabledComponentsWithLegacyGatewaySSLSettings() {
+    Properties props = new Properties();
+    props.setProperty(CLUSTER_SSL_ENABLED, "true");
+    props.setProperty(GATEWAY_SSL_ENABLED, "true");
+    props.setProperty(SSL_ENABLED_COMPONENTS, "all");
+    new DistributionConfigImpl(props, false);
+
+    illegalArgumentException.expect(IllegalArgumentException.class);
+    illegalArgumentException.expectMessage(LocalizedStrings.AbstractDistributionConfig_SSL_ENABLED_COMPONENTS_SET_INVALID_DEPRECATED_SSL_SET.getRawText());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSSLEnabledComponentsWithLegacyServerSSLSettings() {
+    Properties props = new Properties();
+    props.setProperty(CLUSTER_SSL_ENABLED, "true");
+    props.setProperty(SERVER_SSL_ENABLED, "true");
+    props.setProperty(SSL_ENABLED_COMPONENTS, "all");
+    new DistributionConfigImpl(props, false);
+
+    illegalArgumentException.expect(IllegalArgumentException.class);
+    illegalArgumentException.expectMessage(LocalizedStrings.AbstractDistributionConfig_SSL_ENABLED_COMPONENTS_SET_INVALID_DEPRECATED_SSL_SET.getRawText());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSSLEnabledComponentsWithLegacyHTTPServiceSSLSettings() {
+    Properties props = new Properties();
+    props.setProperty(CLUSTER_SSL_ENABLED, "true");
+    props.setProperty(HTTP_SERVICE_SSL_ENABLED, "true");
+    props.setProperty(SSL_ENABLED_COMPONENTS, "all");
+    new DistributionConfigImpl(props, false);
+
+    illegalArgumentException.expect(IllegalArgumentException.class);
+    illegalArgumentException.expectMessage(LocalizedStrings.AbstractDistributionConfig_SSL_ENABLED_COMPONENTS_SET_INVALID_DEPRECATED_SSL_SET.getRawText());
+  }
+
   public static String getHostAddress(InetAddress addr) {
     String address = addr.getHostAddress();
-    if (addr instanceof Inet4Address
-        || (!addr.isLinkLocalAddress() && !addr.isLoopbackAddress()))
-    {
+    if (addr instanceof Inet4Address || (!addr.isLinkLocalAddress() && !addr.isLoopbackAddress()))
{
       int idx = address.indexOf('%');
       if (idx >= 0) {
         address = address.substring(0, idx);
@@ -725,10 +812,9 @@ public class InternalDistributedSystemJUnitTest
   }
 
   public static InetAddress getIPAddress() {
-    return Boolean.getBoolean("java.net.preferIPv6Addresses") ? getIPv6Address()
-                                                      : getIPv4Address();
+    return Boolean.getBoolean("java.net.preferIPv6Addresses") ? getIPv6Address() : getIPv4Address();
   }
-  
+
   protected static InetAddress getIPv4Address() {
     InetAddress host = null;
     try {
@@ -736,29 +822,26 @@ public class InternalDistributedSystemJUnitTest
       if (host instanceof Inet4Address) {
         return host;
       }
-    }
-    catch (UnknownHostException e) {
+    } catch (UnknownHostException e) {
       String s = "Local host not found";
       throw new RuntimeException(s, e);
     }
     try {
       Enumeration i = NetworkInterface.getNetworkInterfaces();
       while (i.hasMoreElements()) {
-        NetworkInterface ni = (NetworkInterface)i.nextElement();
+        NetworkInterface ni = (NetworkInterface) i.nextElement();
         Enumeration j = ni.getInetAddresses();
         while (j.hasMoreElements()) {
-          InetAddress addr = (InetAddress)j.nextElement();
+          InetAddress addr = (InetAddress) j.nextElement();
           // gemfire won't form connections using link-local addresses
-          if (!addr.isLinkLocalAddress() && !addr.isLoopbackAddress()
-                                         && (addr instanceof Inet4Address)) {
+          if (!addr.isLinkLocalAddress() && !addr.isLoopbackAddress() &&
(addr instanceof Inet4Address)) {
             return addr;
           }
         }
       }
       String s = "IPv4 address not found";
       throw new RuntimeException(s);
-    }
-    catch (SocketException e) {
+    } catch (SocketException e) {
       String s = "Problem reading IPv4 address";
       throw new RuntimeException(s, e);
     }
@@ -768,22 +851,19 @@ public class InternalDistributedSystemJUnitTest
     try {
       Enumeration i = NetworkInterface.getNetworkInterfaces();
       while (i.hasMoreElements()) {
-        NetworkInterface ni = (NetworkInterface)i.nextElement();
+        NetworkInterface ni = (NetworkInterface) i.nextElement();
         Enumeration j = ni.getInetAddresses();
         while (j.hasMoreElements()) {
-          InetAddress addr = (InetAddress)j.nextElement();
+          InetAddress addr = (InetAddress) j.nextElement();
           // gemfire won't form connections using link-local addresses
-          if (!addr.isLinkLocalAddress() && !addr.isLoopbackAddress()
-               && (addr instanceof Inet6Address)
-               && !isIPv6LinkLocalAddress((Inet6Address) addr)) {
+          if (!addr.isLinkLocalAddress() && !addr.isLoopbackAddress() &&
(addr instanceof Inet6Address) && !isIPv6LinkLocalAddress((Inet6Address) addr)) {
             return addr;
           }
         }
       }
       String s = "IPv6 address not found";
       throw new RuntimeException(s);
-    }
-    catch (SocketException e) {
+    } catch (SocketException e) {
       String s = "Problem reading IPv6 address";
       throw new RuntimeException(s, e);
     }


Mime
View raw message