You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/09/27 21:01:51 UTC
[1/2] incubator-geode git commit: GEODE-1940: increase line length to
prevent line-wrapping
Repository: incubator-geode
Updated Branches:
refs/heads/develop 8a6a46abd -> ddf4f3dbc
GEODE-1940: increase line length to prevent line-wrapping
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/9f422dd3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/9f422dd3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/9f422dd3
Branch: refs/heads/develop
Commit: 9f422dd39ac5311db26431fb96e5adfc32546119
Parents: 8a6a46a
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Sep 27 12:48:24 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Sep 27 13:54:39 2016 -0700
----------------------------------------------------------------------
etc/eclipseFormatterProfile.xml | 2 +-
etc/intellijIdeaCodeStyle.xml | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9f422dd3/etc/eclipseFormatterProfile.xml
----------------------------------------------------------------------
diff --git a/etc/eclipseFormatterProfile.xml b/etc/eclipseFormatterProfile.xml
index ead2f39..b9f8410 100755
--- a/etc/eclipseFormatterProfile.xml
+++ b/etc/eclipseFormatterProfile.xml
@@ -288,7 +288,7 @@
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="160"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="999"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
</profile>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9f422dd3/etc/intellijIdeaCodeStyle.xml
----------------------------------------------------------------------
diff --git a/etc/intellijIdeaCodeStyle.xml b/etc/intellijIdeaCodeStyle.xml
index 5b01917..0b5c31b 100755
--- a/etc/intellijIdeaCodeStyle.xml
+++ b/etc/intellijIdeaCodeStyle.xml
@@ -60,6 +60,7 @@
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JAVA">
+ <option name="RIGHT_MARGIN" value="999" />
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
@@ -82,6 +83,7 @@
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
<option name="VARIABLE_ANNOTATION_WRAP" value="2" />
+ <option name="WRAP_ON_TYPING" value="0" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
[2/2] incubator-geode git commit: GEODE-1939: change test category to
IntegrationTest
Posted by kl...@apache.org.
GEODE-1939: change test category to IntegrationTest
* remove class hierarchy because it repeats running of tests
* reformat, privatize vars and methods
* remove catching of unexpected exceptions
* remove system out statements
* move all setup to setup method
* fix minor concurrency bug in JSSESocketJUnitTest
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/ddf4f3db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/ddf4f3db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/ddf4f3db
Branch: refs/heads/develop
Commit: ddf4f3dbc6cbd1ca68ba812128c25163aa5c23ac
Parents: 9f422dd
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Sep 27 13:50:21 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Sep 27 13:54:40 2016 -0700
----------------------------------------------------------------------
.../geode/internal/net/JSSESocketJUnitTest.java | 111 ++++++-------------
.../net/SocketCreatorFactoryJUnitTest.java | 77 +++++++------
2 files changed, 76 insertions(+), 112 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ddf4f3db/geode-core/src/test/java/org/apache/geode/internal/net/JSSESocketJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/net/JSSESocketJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/net/JSSESocketJUnitTest.java
index 4a62ec7..e63a46f 100755
--- a/geode-core/src/test/java/org/apache/geode/internal/net/JSSESocketJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/net/JSSESocketJUnitTest.java
@@ -30,6 +30,8 @@ import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
@@ -43,9 +45,12 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.contrib.java.lang.system.SystemErrRule;
+import org.junit.contrib.java.lang.system.SystemOutRule;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
+import org.apache.geode.distributed.ClientSocketFactory;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.distributed.internal.DistributionConfigImpl;
import org.apache.geode.internal.AvailablePort;
@@ -62,48 +67,39 @@ import org.apache.geode.util.test.TestUtil;
@Category(IntegrationTest.class)
public class JSSESocketJUnitTest {
- public
- @Rule
- TestName name = new TestName();
-
- private static final org.apache.logging.log4j.Logger logger = LogService.getLogger();
+ private static volatile boolean factoryInvoked;
- ServerSocket acceptor;
- Socket server;
+ private ServerSocket acceptor;
+ private Socket server;
+ private int randport;
- static ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ @Rule
+ public TestName name = new TestName();
- private int randport = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule();
@Before
public void setUp() throws Exception {
- System.out.println("\n\n########## setup " + name.getMethodName() + " ############\n\n");
- server = null;
- acceptor = null;
- baos.reset();
+ randport = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
}
@After
public void tearDown() throws Exception {
- System.out.println("\n\n########## teardown " + name.getMethodName() + " ############\n\n");
-
if (server != null) {
server.close();
}
if (acceptor != null) {
acceptor.close();
}
- System.out.println(baos.toString());
SocketCreatorFactory.close();
}
- //----- test methods ------
-
@Test
public void testSSLSocket() throws Exception {
- final Object[] receiver = new Object[1];
+ systemOutRule.mute().enableLog();
- TestAppender.create();
+ final Object[] receiver = new Object[1];
// Get original base log level
Level originalBaseLevel = LogService.getBaseLogLevel();
@@ -136,7 +132,7 @@ public class JSSESocketJUnitTest {
Socket client = SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).connectForServer(InetAddress.getByName("localhost"), randport);
ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream());
- String expected = new String("testing " + name.getMethodName());
+ String expected = "testing " + name.getMethodName();
oos.writeObject(expected);
oos.flush();
@@ -144,27 +140,19 @@ public class JSSESocketJUnitTest {
client.close();
serverSocket.close();
- if (expected.equals(receiver[0])) {
- System.out.println("received " + receiver[0] + " as expected.");
- } else {
- throw new Exception("Expected \"" + expected + "\" but received \"" + receiver[0] + "\"");
- }
+ assertEquals("Expected \"" + expected + "\" but received \"" + receiver[0] + "\"", expected, receiver[0]);
- String logOutput = baos.toString();
- StringReader sreader = new StringReader(logOutput);
- LineNumberReader reader = new LineNumberReader(sreader);
- int peerLogCount = 0;
- String line = null;
- while ((line = reader.readLine()) != null) {
+ String stdOut = systemOutRule.getLog();
+ int foundExpectedString = 0;
- if (line.matches(".*peer CN=.*")) {
- System.out.println("Found peer log statement.");
- peerLogCount++;
- }
- }
- if (peerLogCount != 2) {
- throw new Exception("Expected to find to peer identities logged.");
+ Pattern pattern = Pattern.compile(".*peer CN=.*");
+ Matcher matcher = pattern.matcher(stdOut);
+ while (matcher.find()) {
+ foundExpectedString++;
}
+
+ assertEquals(2, foundExpectedString);
+
} finally {
// Reset original base log level
LogService.setBaseLogLevel(originalBaseLevel);
@@ -198,22 +186,7 @@ public class JSSESocketJUnitTest {
}
}
- static boolean factoryInvoked;
-
- public static class TSocketFactory implements org.apache.geode.distributed.ClientSocketFactory {
-
- public TSocketFactory() {
- }
-
- public Socket createSocket(InetAddress address, int port) throws IOException {
- JSSESocketJUnitTest.factoryInvoked = true;
- throw new IOException("splort!");
- }
- }
-
- //------------- utilities -----
-
- protected File findTestJKS() {
+ private File findTestJKS() {
return new File(TestUtil.getResourcePath(getClass(), "/ssl/trusted.keystore"));
}
@@ -237,32 +210,14 @@ public class JSSESocketJUnitTest {
return t;
}
- public static final class TestAppender extends AbstractAppender {
-
- private static final String APPENDER_NAME = TestAppender.class.getName();
- private final static String SOCKET_CREATOR_CLASSNAME = SocketCreator.class.getName();
+ private static class TSocketFactory implements ClientSocketFactory {
- private TestAppender() {
- super(APPENDER_NAME, null, PatternLayout.createDefaultLayout());
- start();
- }
-
- public static Appender create() {
- Appender appender = new TestAppender();
- Logger socketCreatorLogger = (Logger) LogManager.getLogger(SOCKET_CREATOR_CLASSNAME);
- LoggerConfig config = socketCreatorLogger.getContext().getConfiguration().getLoggerConfig(SOCKET_CREATOR_CLASSNAME);
- config.addAppender(appender, Level.DEBUG, null);
- return appender;
+ public TSocketFactory() {
}
- @SuppressWarnings("synthetic-access")
- @Override
- public void append(final LogEvent event) {
- try {
- baos.write(new String(event.getMessage().getFormattedMessage() + "\n").getBytes());
- } catch (IOException ioex) {
- logger.warn(ioex);
- }
+ public Socket createSocket(InetAddress address, int port) throws IOException {
+ JSSESocketJUnitTest.factoryInvoked = true;
+ throw new IOException("splort!");
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ddf4f3db/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java
index 16e2837..b9faff0 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java
@@ -22,20 +22,27 @@ import java.io.File;
import java.io.IOException;
import java.util.Properties;
+import org.junit.After;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.geode.distributed.internal.DistributionConfigImpl;
import org.apache.geode.internal.security.SecurableCommunicationChannel;
import org.apache.geode.test.dunit.Assert;
-import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.geode.test.junit.categories.IntegrationTest;
import org.apache.geode.util.test.TestUtil;
-@Category(UnitTest.class)
-public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
+@Category(IntegrationTest.class)
+public class SocketCreatorFactoryJUnitTest {
+
+ @After
+ public void tearDown() throws Exception {
+ SocketCreatorFactory.close();
+ }
@Test
- public void testNewSSLConfigSSLComponentLocator() {
+ public void testNewSSLConfigSSLComponentLocator() throws Exception {
Properties properties = configureSSLProperties(SecurableCommunicationChannel.LOCATOR.getConstant());
DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
@@ -50,7 +57,7 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
}
@Test
- public void testNewSSLConfigSSLComponentALL() {
+ public void testNewSSLConfigSSLComponentALL() throws Exception {
Properties properties = configureSSLProperties(SecurableCommunicationChannel.ALL.getConstant());
DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
@@ -65,7 +72,7 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
}
@Test
- public void testNewSSLConfigSSLComponentCLUSTER() {
+ public void testNewSSLConfigSSLComponentCLUSTER() throws Exception {
Properties properties = configureSSLProperties(SecurableCommunicationChannel.CLUSTER.getConstant());
DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
@@ -80,7 +87,7 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
}
@Test
- public void testNewSSLConfigSSLComponentGATEWAY() {
+ public void testNewSSLConfigSSLComponentGATEWAY() throws Exception {
Properties properties = configureSSLProperties(SecurableCommunicationChannel.GATEWAY.getConstant());
DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
@@ -95,7 +102,7 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
}
@Test
- public void testNewSSLConfigSSLComponentHTTP_SERVICE() {
+ public void testNewSSLConfigSSLComponentHTTP_SERVICE() throws Exception {
Properties properties = configureSSLProperties(SecurableCommunicationChannel.WEB.getConstant());
DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
@@ -110,7 +117,7 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
}
@Test
- public void testNewSSLConfigSSLComponentJMX() {
+ public void testNewSSLConfigSSLComponentJMX() throws Exception {
Properties properties = configureSSLProperties(SecurableCommunicationChannel.JMX.getConstant());
DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
@@ -125,7 +132,7 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
}
@Test
- public void testNewSSLConfigSSLComponentSERVER() {
+ public void testNewSSLConfigSSLComponentSERVER() throws Exception {
Properties properties = configureSSLProperties(SecurableCommunicationChannel.SERVER.getConstant());
DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
@@ -141,7 +148,7 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
}
@Test
- public void testNewSSLConfigSSLComponentCombinations1() {
+ public void testNewSSLConfigSSLComponentCombinations1() throws Exception {
Properties properties = configureSSLProperties(commaDelimitedString(SecurableCommunicationChannel.CLUSTER.getConstant(), SecurableCommunicationChannel.SERVER.getConstant()));
DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
@@ -156,9 +163,8 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
}
@Test
- public void testNewSSLConfigSSLComponentCombinations2() {
- Properties properties = configureSSLProperties(commaDelimitedString(SecurableCommunicationChannel.CLUSTER.getConstant(), SecurableCommunicationChannel.SERVER.getConstant(), SecurableCommunicationChannel.WEB
- .getConstant(), SecurableCommunicationChannel.JMX.getConstant()));
+ public void testNewSSLConfigSSLComponentCombinations2() throws Exception {
+ Properties properties = configureSSLProperties(commaDelimitedString(SecurableCommunicationChannel.CLUSTER.getConstant(), SecurableCommunicationChannel.SERVER.getConstant(), SecurableCommunicationChannel.WEB.getConstant(), SecurableCommunicationChannel.JMX.getConstant()));
DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
SocketCreatorFactory.setDistributionConfig(distributionConfig);
@@ -172,7 +178,7 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
}
@Test
- public void testNewSSLConfigSSLComponentAliasWithMultiKeyStore() {
+ public void testNewSSLConfigSSLComponentAliasWithMultiKeyStore() throws Exception {
Properties properties = configureSSLProperties(SecurableCommunicationChannel.ALL.getConstant());
properties.setProperty(SSL_KEYSTORE, TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKey.jks"));
@@ -193,7 +199,7 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
}
@Test
- public void testNewSSLConfigSSLComponentWithoutAliasWithMultiKeyStore() {
+ public void testNewSSLConfigSSLComponentWithoutAliasWithMultiKeyStore() throws Exception {
Properties properties = configureSSLProperties(SecurableCommunicationChannel.ALL.getConstant());
properties.setProperty(SSL_KEYSTORE, TestUtil.getResourcePath(getClass(), "/org/apache/geode/internal/net/multiKey.jks"));
@@ -210,28 +216,24 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
Assert.assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL());
}
- private Properties configureSSLProperties(String sslComponents) {
+ private Properties configureSSLProperties(String sslComponents) throws IOException {
+ File jks = findTestJKS();
+
Properties properties = new Properties();
- try {
- File jks = findTestJKS();
-
- properties.setProperty(MCAST_PORT, "0");
- properties.setProperty(SSL_REQUIRE_AUTHENTICATION, "true");
- properties.setProperty(SSL_CIPHERS, "TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384,TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,TLS_DHE_DSS_WITH_AES_256_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA");
- properties.setProperty(SSL_PROTOCOLS, "TLSv1,TLSv1.1,TLSv1.2");
- properties.setProperty(SSL_KEYSTORE, jks.getCanonicalPath());
- properties.setProperty(SSL_KEYSTORE_PASSWORD, "password");
- properties.setProperty(SSL_KEYSTORE_TYPE, "JKS");
- properties.setProperty(SSL_TRUSTSTORE, jks.getCanonicalPath());
- properties.setProperty(SSL_TRUSTSTORE_PASSWORD, "password");
- properties.setProperty(SSL_ENABLED_COMPONENTS, sslComponents);
- } catch (IOException e) {
- Assert.fail("Failed to configure the cluster");
- }
+ properties.setProperty(MCAST_PORT, "0");
+ properties.setProperty(SSL_REQUIRE_AUTHENTICATION, "true");
+ properties.setProperty(SSL_CIPHERS, "TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384,TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,TLS_DHE_DSS_WITH_AES_256_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA");
+ properties.setProperty(SSL_PROTOCOLS, "TLSv1,TLSv1.1,TLSv1.2");
+ properties.setProperty(SSL_KEYSTORE, jks.getCanonicalPath());
+ properties.setProperty(SSL_KEYSTORE_PASSWORD, "password");
+ properties.setProperty(SSL_KEYSTORE_TYPE, "JKS");
+ properties.setProperty(SSL_TRUSTSTORE, jks.getCanonicalPath());
+ properties.setProperty(SSL_TRUSTSTORE_PASSWORD, "password");
+ properties.setProperty(SSL_ENABLED_COMPONENTS, sslComponents);
+
return properties;
}
-
private String commaDelimitedString(final String... sslComponents) {
StringBuilder stringBuilder = new StringBuilder();
for (String sslComponent : sslComponents) {
@@ -241,20 +243,27 @@ public class SocketCreatorFactoryJUnitTest extends JSSESocketJUnitTest {
return stringBuilder.substring(0, stringBuilder.length() - 1);
}
+ @Ignore("Test is not implemented")
@Test
public void testLegacyServerSSLConfig() {
}
+ @Ignore("Test is not implemented")
@Test
public void testLegacyJMXSSLConfig() {
}
+ @Ignore("Test is not implemented")
@Test
public void testLegacyGatewaySSLConfig() {
}
+ @Ignore("Test is not implemented")
@Test
public void testLegacyHttpServiceSSLConfig() {
}
+ private File findTestJKS() {
+ return new File(TestUtil.getResourcePath(getClass(), "/ssl/trusted.keystore"));
+ }
}