http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-assembly/src/test/java/org/apache/geode/BundledJarsJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-assembly/src/test/java/org/apache/geode/BundledJarsJUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/BundledJarsJUnitTest.java index 415866b..8c228f2 100644 --- a/geode-assembly/src/test/java/org/apache/geode/BundledJarsJUnitTest.java +++ b/geode-assembly/src/test/java/org/apache/geode/BundledJarsJUnitTest.java @@ -1,18 +1,16 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode; @@ -45,31 +43,34 @@ public class BundledJarsJUnitTest { private static final String VERSION_PATTERN = "[0-9-_.v]{3,}.*\\.jar$"; protected static final String GEMFIRE_HOME = System.getenv("GEMFIRE"); private Set<String> expectedJars; - + @Before public void loadExpectedJars() throws IOException { - String expectedJarFile = TestUtil.getResourcePath(BundledJarsJUnitTest.class, "/expected_jars.txt"); - - expectedJars = Files.lines(Paths.get(expectedJarFile)) - .collect(Collectors.toSet()); + String expectedJarFile = + TestUtil.getResourcePath(BundledJarsJUnitTest.class, "/expected_jars.txt"); + + expectedJars = Files.lines(Paths.get(expectedJarFile)).collect(Collectors.toSet()); } - + @Test public void verifyBundledJarsHaveNotChanged() throws IOException { TreeMap<String, String> sortedJars = getBundledJars(); - Stream<String> lines = sortedJars.entrySet().stream().map(entry -> removeVersion(entry.getKey())); + Stream<String> lines = + sortedJars.entrySet().stream().map(entry -> removeVersion(entry.getKey())); Set<String> bundledJarNames = new TreeSet<String>(lines.collect(Collectors.toSet())); - + Files.write(Paths.get("bundled_jars.txt"), bundledJarNames); TreeSet<String> newJars = new TreeSet<String>(bundledJarNames); newJars.removeAll(expectedJars); TreeSet<String> missingJars = new TreeSet<String>(expectedJars); missingJars.removeAll(bundledJarNames); - + StringBuilder message = new StringBuilder(); - message.append("The bundled jars have changed. Please make sure you update the licence and notice"); - message.append("\nas described in https://cwiki.apache.org/confluence/display/GEODE/License+Guide+for+Contributors"); + message.append( + "The bundled jars have changed. Please make sure you update the licence and notice"); + message.append( + "\nas described in https://cwiki.apache.org/confluence/display/GEODE/License+Guide+for+Contributors"); message.append("\nWhen fixed, copy geode-assembly/build/test/bundled_jars.txt"); message.append("\nto src/test/resources/expected_jars.txt"); message.append("\nRemoved Jars\n--------------\n"); @@ -77,34 +78,33 @@ public class BundledJarsJUnitTest { message.append("\n\nAdded Jars\n--------------\n"); message.append(String.join("\n", newJars)); message.append("\n\n"); - + assertTrue(message.toString(), expectedJars.equals(bundledJarNames)); - + } /** - * Find all of the jars bundled with the project. - * Key is the name of the jar, value is the path. + * Find all of the jars bundled with the project. Key is the name of the jar, value is the path. */ protected TreeMap<String, String> getBundledJars() { - File gemfireHomeDirectory= new File(GEMFIRE_HOME); + File gemfireHomeDirectory = new File(GEMFIRE_HOME); assertTrue("Please set the GEMFIRE environment variable to the product installation directory.", gemfireHomeDirectory.isDirectory()); - + List<File> jars = FileUtil.findAll(gemfireHomeDirectory, ".*\\.jar"); TreeMap<String, String> sortedJars = new TreeMap<String, String>(); jars.stream().forEach(jar -> sortedJars.put(jar.getName(), jar.getPath())); - + List<File> wars = FileUtil.findAll(gemfireHomeDirectory, ".*\\.war"); TreeSet<File> sortedWars = new TreeSet<File>(wars); sortedWars.stream().flatMap(BundledJarsJUnitTest::extractJarNames) - .forEach(jar -> sortedJars.put(jar.getName(), jar.getPath())); - + .forEach(jar -> sortedJars.put(jar.getName(), jar.getPath())); + sortedJars.keySet().removeIf(s -> s.startsWith("geode")); return sortedJars; } - + private String removeVersion(String name) { return name.replaceAll(VERSION_PATTERN, ""); } @@ -115,11 +115,11 @@ public class BundledJarsJUnitTest { private static Stream<File> extractJarNames(File war) { try (JarFile warContents = new JarFile(war)) { return warContents.stream() - //Look for jars in the war + // Look for jars in the war .filter(entry -> entry.getName().endsWith(".jar")) - //Create a File with a path that includes the war name + // Create a File with a path that includes the war name .map(entry -> new File(war.getName(), entry.getName())) - //Materialize the list of files while the war is still open + // Materialize the list of files while the war is still open .collect(Collectors.toList()).stream(); } catch (IOException e) { throw new RuntimeException(e);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-assembly/src/test/java/org/apache/geode/distributed/LocatorLauncherAssemblyIntegrationTest.java ---------------------------------------------------------------------- diff --git a/geode-assembly/src/test/java/org/apache/geode/distributed/LocatorLauncherAssemblyIntegrationTest.java b/geode-assembly/src/test/java/org/apache/geode/distributed/LocatorLauncherAssemblyIntegrationTest.java index ee72b30..4e8d389 100644 --- a/geode-assembly/src/test/java/org/apache/geode/distributed/LocatorLauncherAssemblyIntegrationTest.java +++ b/geode-assembly/src/test/java/org/apache/geode/distributed/LocatorLauncherAssemblyIntegrationTest.java @@ -1,18 +1,16 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode.distributed; @@ -46,7 +44,8 @@ import static org.apache.geode.distributed.ConfigurationProperties.*; @Category(IntegrationTest.class) @RunWith(Parameterized.class) @Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class) -public class LocatorLauncherAssemblyIntegrationTest extends AbstractLocatorLauncherIntegrationTestCase { +public class LocatorLauncherAssemblyIntegrationTest + extends AbstractLocatorLauncherIntegrationTestCase { @Before public final void setUpLocatorLauncherLocalTest() throws Exception { @@ -66,16 +65,10 @@ public class LocatorLauncherAssemblyIntegrationTest extends AbstractLocatorLaunc public void testLocatorStopsWhenJmxPortIsZero() throws Throwable { String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath(); - final Builder builder = new Builder() - .setMemberName(getUniqueName()) - .setPort(this.locatorPort) - .setRedirectOutput(false) - .setWorkingDirectory(rootFolder) - .set(LOG_LEVEL, "config") - .set(ENABLE_CLUSTER_CONFIGURATION, "false") - .set(JMX_MANAGER, "true") - .set(JMX_MANAGER_START, "true") - .set(JMX_MANAGER_PORT, "0"); + final Builder builder = new Builder().setMemberName(getUniqueName()).setPort(this.locatorPort) + .setRedirectOutput(false).setWorkingDirectory(rootFolder).set(LOG_LEVEL, "config") + .set(ENABLE_CLUSTER_CONFIGURATION, "false").set(JMX_MANAGER, "true") + .set(JMX_MANAGER_START, "true").set(JMX_MANAGER_PORT, "0"); performTest(builder); } @@ -88,15 +81,10 @@ public class LocatorLauncherAssemblyIntegrationTest extends AbstractLocatorLaunc String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath(); final int jmxPort = AvailablePortHelper.getRandomAvailableTCPPorts(1)[0]; - final Builder builder = new Builder().setMemberName(getUniqueName()) - .setPort(this.locatorPort) - .setRedirectOutput(false) - .setWorkingDirectory(rootFolder) - .set(LOG_LEVEL, "config") - .set(ENABLE_CLUSTER_CONFIGURATION, "false") - .set(JMX_MANAGER, "true") - .set(JMX_MANAGER_START, "true") - .set(JMX_MANAGER_PORT, Integer.toString(jmxPort)); + final Builder builder = new Builder().setMemberName(getUniqueName()).setPort(this.locatorPort) + .setRedirectOutput(false).setWorkingDirectory(rootFolder).set(LOG_LEVEL, "config") + .set(ENABLE_CLUSTER_CONFIGURATION, "false").set(JMX_MANAGER, "true") + .set(JMX_MANAGER_START, "true").set(JMX_MANAGER_PORT, Integer.toString(jmxPort)); performTest(builder); } @@ -115,7 +103,8 @@ public class LocatorLauncherAssemblyIntegrationTest extends AbstractLocatorLaunc // validate the pid file and its contents this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName()); - assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists()); + assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", + this.pidFile.exists()); final int pid = readPid(this.pidFile); assertTrue(pid > 0); assertEquals(ProcessUtils.identifyPid(), pid); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-assembly/src/test/java/org/apache/geode/management/internal/AgentUtilJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/AgentUtilJUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/AgentUtilJUnitTest.java index 78cf167..1a20655 100644 --- a/geode-assembly/src/test/java/org/apache/geode/management/internal/AgentUtilJUnitTest.java +++ b/geode-assembly/src/test/java/org/apache/geode/management/internal/AgentUtilJUnitTest.java @@ -1,18 +1,16 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode.management.internal; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java index 933d152..4f42cb0 100644 --- a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java +++ b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java @@ -1,18 +1,16 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode.management.internal.cli.commands; @@ -83,8 +81,9 @@ import org.apache.geode.test.dunit.WaitCriterion; import org.apache.geode.test.junit.categories.DistributedTest; /** - * The LauncherLifecycleCommandsDUnitTest class is a test suite of integration tests testing the contract and - * functionality of the GemFire launcher lifecycle commands inside Gfsh. + * The LauncherLifecycleCommandsDUnitTest class is a test suite of integration tests testing the + * contract and functionality of the GemFire launcher lifecycle commands inside Gfsh. + * * @see javax.management.MBeanServerConnection * @see javax.management.remote.JMXConnector * @see org.apache.geode.distributed.AbstractLauncher @@ -105,15 +104,18 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { private final Queue<Integer> processIds = new ConcurrentLinkedDeque<>(); - protected static String getMemberId(final int jmxManagerPort, final String memberName) throws Exception { + protected static String getMemberId(final int jmxManagerPort, final String memberName) + throws Exception { return getMemberId(InetAddress.getLocalHost().getHostName(), jmxManagerPort, memberName); } - protected static String getMemberId(final String jmxManagerHost, final int jmxManagerPort, final String memberName) throws Exception { + protected static String getMemberId(final String jmxManagerHost, final int jmxManagerPort, + final String memberName) throws Exception { JMXConnector connector = null; try { - connector = JMXConnectorFactory.connect(new JMXServiceURL(String.format("service:jmx:rmi://%1$s/jndi/rmi://%1$s:%2$d/jmxrmi", jmxManagerHost, jmxManagerPort))); + connector = JMXConnectorFactory.connect(new JMXServiceURL(String.format( + "service:jmx:rmi://%1$s/jndi/rmi://%1$s:%2$d/jmxrmi", jmxManagerHost, jmxManagerPort))); MBeanServerConnection connection = connector.getMBeanServerConnection(); @@ -127,10 +129,12 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { assertFalse(objectNames.isEmpty()); assertEquals(1, objectNames.size()); - //final ObjectName objectName = ObjectName.getInstance("GemFire:type=Member,Name=" + memberName); + // final ObjectName objectName = ObjectName.getInstance("GemFire:type=Member,Name=" + + // memberName); ObjectName objectName = objectNames.iterator().next(); - //System.err.printf("ObjectName for Member with Name (%1$s) is %2$s%n", memberName, objectName); + // System.err.printf("ObjectName for Member with Name (%1$s) is %2$s%n", memberName, + // objectName); return ObjectUtils.toString(connection.getAttribute(objectName, "Id")); } finally { @@ -146,7 +150,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { while ((pid = processIds.poll()) != null) { if (launcherLifecycleCommands.isVmWithProcessIdRunning(pid)) { try { - String killCommand = String.format("%1$s %2$d", SystemUtils.isWindows() ? "taskkill /F /PID" : "kill -9", pid); + String killCommand = String.format("%1$s %2$d", + SystemUtils.isWindows() ? "taskkill /F /PID" : "kill -9", pid); Runtime.getRuntime().exec(killCommand); } catch (Throwable ignore) { } @@ -169,9 +174,11 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { } protected Integer readPid(final File workingDirectory) throws IOException { - assertTrue(String.format("The working directory (%1$s) must exist!", workingDirectory), workingDirectory != null && workingDirectory.isDirectory()); + assertTrue(String.format("The working directory (%1$s) must exist!", workingDirectory), + workingDirectory != null && workingDirectory.isDirectory()); - File[] files = workingDirectory.listFiles(pathname -> (pathname != null && pathname.isFile() && pathname.getAbsolutePath().endsWith(".pid"))); + File[] files = workingDirectory.listFiles(pathname -> (pathname != null && pathname.isFile() + && pathname.getAbsolutePath().endsWith(".pid"))); assertNotNull(files); assertTrue(files.length > 0); @@ -196,11 +203,13 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { protected String serviceStateStatusStringNormalized(final String serviceStateStatus) { assertNotNull(serviceStateStatus); - assertTrue("serviceStateStatus is missing 'Uptime': " + serviceStateStatus, serviceStateStatus.contains("Uptime")); - assertTrue("serviceStateStatus is missing 'JVM Arguments': " + serviceStateStatus, serviceStateStatus.contains("JVM Arguments")); + assertTrue("serviceStateStatus is missing 'Uptime': " + serviceStateStatus, + serviceStateStatus.contains("Uptime")); + assertTrue("serviceStateStatus is missing 'JVM Arguments': " + serviceStateStatus, + serviceStateStatus.contains("JVM Arguments")); return serviceStateStatus.substring(0, serviceStateStatus.indexOf("Uptime")) - .concat(serviceStateStatus.substring(serviceStateStatus.indexOf("JVM Arguments"))); + .concat(serviceStateStatus.substring(serviceStateStatus.indexOf("JVM Arguments"))); } protected Status stopLocator(final File workingDirectory) { @@ -208,14 +217,16 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { } protected Status stopLocator(final String workingDirectory) { - return waitForGemFireProcessToStop(new Builder().setCommand(Command.STOP).setWorkingDirectory(workingDirectory).build().stop(), workingDirectory); + return waitForGemFireProcessToStop( + new Builder().setCommand(Command.STOP).setWorkingDirectory(workingDirectory).build().stop(), + workingDirectory); } protected Status stopServer(final String workingDirectory) { - return waitForGemFireProcessToStop(new ServerLauncher.Builder().setCommand(ServerLauncher.Command.STOP) - .setWorkingDirectory(workingDirectory) - .build() - .stop(), workingDirectory); + return waitForGemFireProcessToStop( + new ServerLauncher.Builder().setCommand(ServerLauncher.Command.STOP) + .setWorkingDirectory(workingDirectory).build().stop(), + workingDirectory); } protected String toString(final Result result) { @@ -231,14 +242,16 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { return buffer.toString(); } - protected Status waitForGemFireProcessToStop(final ServiceState serviceState, final String workingDirectory) { + protected Status waitForGemFireProcessToStop(final ServiceState serviceState, + final String workingDirectory) { if (!Status.STOPPED.equals(serviceState.getStatus())) { try { final Integer pid = readPid(new File(workingDirectory)); if (pid != null) { WaitCriterion waitCriteria = new WaitCriterion() { - private LauncherLifecycleCommands launcherLifecycleCommands = new LauncherLifecycleCommands(); + private LauncherLifecycleCommands launcherLifecycleCommands = + new LauncherLifecycleCommands(); @Override public boolean done() { @@ -251,7 +264,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { } }; - waitForCriterion(waitCriteria, TimeUnit.SECONDS.toMillis(15), TimeUnit.SECONDS.toMillis(5), false); + waitForCriterion(waitCriteria, TimeUnit.SECONDS.toMillis(15), + TimeUnit.SECONDS.toMillis(5), false); if (!waitCriteria.done()) { processIds.offer(pid); @@ -302,9 +316,12 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname); command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath()); command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort)); - command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString()); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort()); + command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, + Boolean.FALSE.toString()); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); + command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort()); CommandResult result = executeCommand(command.toString()); @@ -313,15 +330,19 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { String resultString = toString(result); - assertTrue(resultString, resultString.contains("Exception in thread \"main\" java.lang.RuntimeException: A PID file already exists and a Locator may be running in " + IOUtils - .tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory))); - assertTrue(resultString, resultString.contains("Caused by: org.apache.geode.internal.process.FileAlreadyExistsException: Pid file already exists: " + IOUtils - .tryGetCanonicalFileElseGetAbsoluteFile(pidFile))); + assertTrue(resultString, + resultString.contains( + "Exception in thread \"main\" java.lang.RuntimeException: A PID file already exists and a Locator may be running in " + + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory))); + assertTrue(resultString, + resultString.contains( + "Caused by: org.apache.geode.internal.process.FileAlreadyExistsException: Pid file already exists: " + + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(pidFile))); } /* - * This method makes an effort to get the PID of the running process. If it is unable to determine accurately, it - * simply returns 1. + * This method makes an effort to get the PID of the running process. If it is unable to determine + * accurately, it simply returns 1. */ private int getPidOrOne() { int pid = 1; @@ -349,10 +370,14 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath()); command.addOption(CliStrings.START_LOCATOR__PORT, "0"); command.addOption(CliStrings.START_LOCATOR__PROPERTIES, gemfirePropertiesPathname); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager=false"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=0"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-start=false"); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager=false"); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=0"); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-start=false"); CommandResult result = executeCommand(command.toString()); @@ -361,11 +386,15 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { String resultString = toString(result); - assertTrue(resultString, resultString.contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY_STRING, gemfirePropertiesPathname))); + assertTrue(resultString, + resultString + .contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, + StringUtils.EMPTY_STRING, gemfirePropertiesPathname))); } @Test - public void test002StartLocatorFailsFastOnMissingGemFireSecurityPropertiesFile() throws IOException { + public void test002StartLocatorFailsFastOnMissingGemFireSecurityPropertiesFile() + throws IOException { String gemfireSecurityPropertiesPathname = "/path/to/missing/gemfire-security.properties"; String pathName = getClass().getSimpleName().concat("_").concat(getTestMethodName()); final File workingDirectory = temporaryFolder.newFolder(pathName); @@ -375,11 +404,16 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathName); command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath()); command.addOption(CliStrings.START_LOCATOR__PORT, "0"); - command.addOption(CliStrings.START_LOCATOR__SECURITY_PROPERTIES, gemfireSecurityPropertiesPathname); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager=false"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=0"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-start=false"); + command.addOption(CliStrings.START_LOCATOR__SECURITY_PROPERTIES, + gemfireSecurityPropertiesPathname); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager=false"); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=0"); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-start=false"); CommandResult result = executeCommand(command.toString()); @@ -388,7 +422,10 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { String resultString = toString(result); - assertTrue(resultString, resultString.contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ", gemfireSecurityPropertiesPathname))); + assertTrue(resultString, + resultString + .contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, + "Security ", gemfireSecurityPropertiesPathname))); } @Test @@ -410,7 +447,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { String resultString = toString(result); - assertTrue(resultString, resultString.contains(MessageFormat.format(CliStrings.CACHE_XML_NOT_FOUND_MESSAGE, cacheXmlPathname))); + assertTrue(resultString, resultString + .contains(MessageFormat.format(CliStrings.CACHE_XML_NOT_FOUND_MESSAGE, cacheXmlPathname))); } @Test @@ -433,7 +471,10 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { String resultString = toString(result); - assertTrue(resultString, resultString.contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY_STRING, gemfirePropertiesFile))); + assertTrue(resultString, + resultString + .contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, + StringUtils.EMPTY_STRING, gemfirePropertiesFile))); } @Test @@ -459,7 +500,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { } @Test - public void test005StartServerFailsFastOnMissingGemFireSecurityPropertiesFile() throws IOException { + public void test005StartServerFailsFastOnMissingGemFireSecurityPropertiesFile() + throws IOException { String gemfireSecuritiesPropertiesFile = "/path/to/missing/gemfire-securities.properties"; CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_SERVER); @@ -469,7 +511,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { command.addOption(CliStrings.START_SERVER__NAME, pathName); command.addOption(CliStrings.START_SERVER__DIR, workingDirectory.getCanonicalPath()); - command.addOption(CliStrings.START_SERVER__SECURITY_PROPERTIES, gemfireSecuritiesPropertiesFile); + command.addOption(CliStrings.START_SERVER__SECURITY_PROPERTIES, + gemfireSecuritiesPropertiesFile); CommandResult result = executeCommand(command.toString()); @@ -478,7 +521,10 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { String resultString = toString(result); - assertTrue(resultString, resultString.contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ", gemfireSecuritiesPropertiesFile))); + assertTrue(resultString, + resultString + .contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, + "Security ", gemfireSecuritiesPropertiesFile))); } @Test @@ -497,9 +543,12 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString()); command.addOption(CliStrings.START_LOCATOR__DIR, pathname); command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort)); - command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString()); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort()); + command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, + Boolean.FALSE.toString()); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); + command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort()); CommandResult result = executeCommand(command.toString()); @@ -509,7 +558,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { String locatorOutput = toString(result); assertNotNull(locatorOutput); - assertTrue("Locator output was: " + locatorOutput, locatorOutput.contains("Locator in " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory))); + assertTrue("Locator output was: " + locatorOutput, locatorOutput.contains( + "Locator in " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory))); } finally { stopLocator(workingDirectory); } @@ -517,11 +567,14 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { @Test public void test007StatusLocatorUsingMemberNameIDWhenGfshIsNotConnected() { - CommandResult result = executeCommand(CliStrings.STATUS_LOCATOR + " --name=" + getTestMethodName()); + CommandResult result = + executeCommand(CliStrings.STATUS_LOCATOR + " --name=" + getTestMethodName()); assertNotNull(result); assertEquals(Result.Status.ERROR, result.getStatus()); - assertEquals(CliStrings.format(CliStrings.STATUS_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Locator"), StringUtils.trim(toString(result))); + assertEquals( + CliStrings.format(CliStrings.STATUS_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Locator"), + StringUtils.trim(toString(result))); } @Test @@ -543,45 +596,54 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString()); command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath()); command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort)); - command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString()); + command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, + Boolean.FALSE.toString()); command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString()); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort); CommandResult result = executeCommand(command.toString()); assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.STATUS) - .setBindAddress(null) - .setPort(locatorPort) - .setWorkingDirectory(workingDirectory.getPath()) - .build(); + LocatorLauncher locatorLauncher = new LocatorLauncher.Builder() + .setCommand(LocatorLauncher.Command.STATUS).setBindAddress(null).setPort(locatorPort) + .setWorkingDirectory(workingDirectory.getPath()).build(); assertNotNull(locatorLauncher); - LocatorState expectedLocatorState = locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS); + LocatorState expectedLocatorState = + locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS); assertNotNull(expectedLocatorState); assertEquals(Status.ONLINE, expectedLocatorState.getStatus()); - result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort)); + result = executeCommand( + String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort)); assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - result = executeCommand(String.format("%1$s --name=invalidLocatorMemberName", CliStrings.STATUS_LOCATOR)); + result = executeCommand( + String.format("%1$s --name=invalidLocatorMemberName", CliStrings.STATUS_LOCATOR)); assertNotNull(result); assertEquals(Result.Status.ERROR, result.getStatus()); - assertEquals(CliStrings.format(CliStrings.STATUS_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, "invalidLocatorMemberName"), StringUtils.trim(toString(result))); + assertEquals( + CliStrings.format(CliStrings.STATUS_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, + "invalidLocatorMemberName"), + StringUtils.trim(toString(result))); - result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STATUS_LOCATOR, pathname)); + result = + executeCommand(String.format("%1$s --name=%2$s", CliStrings.STATUS_LOCATOR, pathname)); assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - assertTrue(serviceStateStatusStringNormalized(toString(result)).contains(serviceStateStatusStringNormalized(expectedLocatorState))); + assertTrue(serviceStateStatusStringNormalized(toString(result)) + .contains(serviceStateStatusStringNormalized(expectedLocatorState))); } finally { stopLocator(workingDirectory); } @@ -606,39 +668,44 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString()); command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath()); command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort)); - command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString()); + command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, + Boolean.FALSE.toString()); command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString()); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort); CommandResult result = executeCommand(command.toString()); assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.STATUS) - .setBindAddress(null) - .setPort(locatorPort) - .setWorkingDirectory(workingDirectory.getPath()) - .build(); + LocatorLauncher locatorLauncher = new LocatorLauncher.Builder() + .setCommand(LocatorLauncher.Command.STATUS).setBindAddress(null).setPort(locatorPort) + .setWorkingDirectory(workingDirectory.getPath()).build(); assertNotNull(locatorLauncher); - LocatorState expectedLocatorState = locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS); + LocatorState expectedLocatorState = + locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS); assertNotNull(expectedLocatorState); assertEquals(Status.ONLINE, expectedLocatorState.getStatus()); - result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort)); + result = executeCommand( + String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort)); assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STATUS_LOCATOR, getMemberId(jmxManagerPort, pathname))); + result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STATUS_LOCATOR, + getMemberId(jmxManagerPort, pathname))); assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - assertTrue(serviceStateStatusStringNormalized(toString(result)).contains(serviceStateStatusStringNormalized(expectedLocatorState))); + assertTrue(serviceStateStatusStringNormalized(toString(result)) + .contains(serviceStateStatusStringNormalized(expectedLocatorState))); } finally { stopLocator(workingDirectory); } @@ -646,11 +713,14 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { @Test public void test010StopLocatorUsingMemberNameIDWhenGfshIsNotConnected() { - CommandResult result = executeCommand(CliStrings.STOP_LOCATOR + " --name=" + getTestMethodName()); + CommandResult result = + executeCommand(CliStrings.STOP_LOCATOR + " --name=" + getTestMethodName()); assertNotNull(result); assertEquals(Result.Status.ERROR, result.getStatus()); - assertEquals(CliStrings.format(CliStrings.STOP_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Locator"), StringUtils.trim(toString(result))); + assertEquals( + CliStrings.format(CliStrings.STOP_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Locator"), + StringUtils.trim(toString(result))); } @Test @@ -672,21 +742,22 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString()); command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath()); command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort)); - command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString()); + command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, + Boolean.FALSE.toString()); command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString()); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort); CommandResult result = executeCommand(command.toString()); assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - final LocatorLauncher locatorLauncher = new Builder().setCommand(Command.STOP) - .setBindAddress(null) - .setPort(locatorPort) - .setWorkingDirectory(workingDirectory.getPath()) - .build(); + final LocatorLauncher locatorLauncher = + new Builder().setCommand(Command.STOP).setBindAddress(null).setPort(locatorPort) + .setWorkingDirectory(workingDirectory.getPath()).build(); assertNotNull(locatorLauncher); @@ -695,16 +766,21 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { assertNotNull(locatorStatus); assertEquals(Status.ONLINE, locatorStatus.getStatus()); - result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort)); + result = executeCommand( + String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort)); assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - result = executeCommand(String.format("%1$s --name=invalidLocatorMemberName", CliStrings.STOP_LOCATOR)); + result = executeCommand( + String.format("%1$s --name=invalidLocatorMemberName", CliStrings.STOP_LOCATOR)); assertNotNull(result); assertEquals(Result.Status.ERROR, result.getStatus()); - assertEquals(CliStrings.format(CliStrings.STOP_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, "invalidLocatorMemberName"), StringUtils.trim(toString(result))); + assertEquals( + CliStrings.format(CliStrings.STOP_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, + "invalidLocatorMemberName"), + StringUtils.trim(toString(result))); locatorStatus = locatorLauncher.status(); @@ -716,10 +792,12 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - // TODO figure out what output to assert and validate on now that 'stop locator' uses Gfsh's logger + // TODO figure out what output to assert and validate on now that 'stop locator' uses Gfsh's + // logger // and standard err/out... - //assertIndexDetailsEquals(CliStrings.format(CliStrings.STOP_LOCATOR__SHUTDOWN_MEMBER_MESSAGE, pathname), - // StringUtils.trim(toString(result))); + // assertIndexDetailsEquals(CliStrings.format(CliStrings.STOP_LOCATOR__SHUTDOWN_MEMBER_MESSAGE, + // pathname), + // StringUtils.trim(toString(result))); WaitCriterion waitCriteria = new WaitCriterion() { @Override @@ -765,21 +843,22 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString()); command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath()); command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort)); - command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString()); + command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, + Boolean.FALSE.toString()); command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString()); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); - command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0"); + command.addOption(CliStrings.START_LOCATOR__J, + "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort); CommandResult result = executeCommand(command.toString()); assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - final LocatorLauncher locatorLauncher = new Builder().setCommand(Command.STOP) - .setBindAddress(null) - .setPort(locatorPort) - .setWorkingDirectory(workingDirectory.getPath()) - .build(); + final LocatorLauncher locatorLauncher = + new Builder().setCommand(Command.STOP).setBindAddress(null).setPort(locatorPort) + .setWorkingDirectory(workingDirectory.getPath()).build(); assertNotNull(locatorLauncher); @@ -788,7 +867,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { assertNotNull(locatorState); assertEquals(Status.ONLINE, locatorState.getStatus()); - result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort)); + result = executeCommand( + String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort)); assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); @@ -800,10 +880,12 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - // TODO figure out what output to assert and validate on now that 'stop locator' uses Gfsh's logger + // TODO figure out what output to assert and validate on now that 'stop locator' uses Gfsh's + // logger // and standard err/out... - //assertIndexDetailsEquals(CliStrings.format(CliStrings.STOP_LOCATOR__SHUTDOWN_MEMBER_MESSAGE, memberId), - // StringUtils.trim(toString(result))); + // assertIndexDetailsEquals(CliStrings.format(CliStrings.STOP_LOCATOR__SHUTDOWN_MEMBER_MESSAGE, + // memberId), + // StringUtils.trim(toString(result))); WaitCriterion waitCriteria = new WaitCriterion() { @Override @@ -841,15 +923,18 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_SERVER); - command.addOption(CliStrings.START_SERVER__NAME, pathname + TIMESTAMP.format(Calendar.getInstance().getTime())); + command.addOption(CliStrings.START_SERVER__NAME, + pathname + TIMESTAMP.format(Calendar.getInstance().getTime())); command.addOption(CliStrings.START_SERVER__SERVER_PORT, String.valueOf(serverPort)); command.addOption(CliStrings.START_SERVER__USE_CLUSTER_CONFIGURATION, Boolean.FALSE.toString()); command.addOption(CliStrings.START_SERVER__MAXHEAP, "10M"); command.addOption(CliStrings.START_SERVER__LOG_LEVEL, "config"); command.addOption(CliStrings.START_SERVER__DIR, workingDirectory.getCanonicalPath()); - command.addOption(CliStrings.START_SERVER__CACHE_XML_FILE, IOUtils.tryGetCanonicalPathElseGetAbsolutePath(writeAndGetCacheXmlFile(workingDirectory))); + command.addOption(CliStrings.START_SERVER__CACHE_XML_FILE, + IOUtils.tryGetCanonicalPathElseGetAbsolutePath(writeAndGetCacheXmlFile(workingDirectory))); command.addOption(CliStrings.START_SERVER__INCLUDE_SYSTEM_CLASSPATH); - command.addOption(CliStrings.START_SERVER__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "" + START_LOCATOR + "=localhost[" + locatorPort + "]"); + command.addOption(CliStrings.START_SERVER__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "" + + START_LOCATOR + "=localhost[" + locatorPort + "]"); CommandResult result = executeCommand(command.toString()); @@ -858,9 +943,10 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { assertNotNull(result); assertEquals(Result.Status.OK, result.getStatus()); - ServerLauncher serverLauncher = new ServerLauncher.Builder().setCommand(ServerLauncher.Command.STATUS) - .setWorkingDirectory(IOUtils.tryGetCanonicalPathElseGetAbsolutePath(workingDirectory)) - .build(); + ServerLauncher serverLauncher = + new ServerLauncher.Builder().setCommand(ServerLauncher.Command.STATUS) + .setWorkingDirectory(IOUtils.tryGetCanonicalPathElseGetAbsolutePath(workingDirectory)) + .build(); assertNotNull(serverLauncher); @@ -890,7 +976,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { final int serverPid = serverState.getPid(); WaitCriterion waitCriteria = new WaitCriterion() { - private LauncherLifecycleCommands launcherLifecycleCommands = new LauncherLifecycleCommands(); + private LauncherLifecycleCommands launcherLifecycleCommands = + new LauncherLifecycleCommands(); @Override public boolean done() { @@ -903,7 +990,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { } }; - waitForCriterion(waitCriteria, TimeUnit.SECONDS.toMillis(30), TimeUnit.SECONDS.toMillis(10), true); + waitForCriterion(waitCriteria, TimeUnit.SECONDS.toMillis(30), TimeUnit.SECONDS.toMillis(10), + true); // Verify our GemFire Server JVM process is was terminated! assertFalse(new LauncherLifecycleCommands().isVmWithProcessIdRunning(serverState.getPid())); @@ -920,7 +1008,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { StringBuilder buffer = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); buffer.append(StringUtils.LINE_SEPARATOR); - buffer.append("<!DOCTYPE cache PUBLIC \"-//GemStone Systems, Inc.//GemFire Declarative Caching 7.0//EN\""); + buffer.append( + "<!DOCTYPE cache PUBLIC \"-//GemStone Systems, Inc.//GemFire Declarative Caching 7.0//EN\""); buffer.append(StringUtils.LINE_SEPARATOR); buffer.append(" \"http://www.gemstone.com/dtd/cache7_0.dtd\">"); buffer.append(StringUtils.LINE_SEPARATOR); @@ -933,7 +1022,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { BufferedWriter fileWriter = null; try { - fileWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cacheXml, false), Charset.forName("UTF-8").newEncoder())); + fileWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cacheXml, false), + Charset.forName("UTF-8").newEncoder())); fileWriter.write(buffer.toString()); fileWriter.flush(); } finally { @@ -944,7 +1034,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { } private ClientCache setupClientCache(final String durableClientId, final int serverPort) { - ClientCache clientCache = new ClientCacheFactory().set(DURABLE_CLIENT_ID, durableClientId).create(); + ClientCache clientCache = + new ClientCacheFactory().set(DURABLE_CLIENT_ID, durableClientId).create(); PoolFactory poolFactory = PoolManager.createFactory(); @@ -957,7 +1048,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { assertNotNull("The 'serverConnectionPool' was not properly configured and initialized!", pool); - ClientRegionFactory<Long, String> regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY); + ClientRegionFactory<Long, String> regionFactory = + clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY); regionFactory.setPoolName(pool.getName()); regionFactory.setKeyConstraint(Long.class); @@ -965,7 +1057,8 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase { Region<Long, String> exampleProxy = regionFactory.create("Example"); - assertNotNull("The 'Example' Client Region was not properly configured and initialized", exampleProxy); + assertNotNull("The 'Example' Client Region was not properly configured and initialized", + exampleProxy); return clientCache; } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsIntegrationTest.java ---------------------------------------------------------------------- diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsIntegrationTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsIntegrationTest.java index be77c7e..1872a84 100644 --- a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsIntegrationTest.java +++ b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsIntegrationTest.java @@ -1,18 +1,16 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode.management.internal.cli.commands; @@ -42,8 +40,8 @@ import org.apache.geode.internal.util.IOUtils; import org.apache.geode.test.junit.categories.IntegrationTest; /** - * The LauncherLifecycleCommandsJUnitTest class is a test suite of test cases testing the contract and functionality of - * the lifecycle launcher GemFire shell (Gfsh) commands. + * The LauncherLifecycleCommandsJUnitTest class is a test suite of test cases testing the contract + * and functionality of the lifecycle launcher GemFire shell (Gfsh) commands. * * @see org.apache.geode.management.internal.cli.commands.LauncherLifecycleCommands * @see org.junit.Assert @@ -78,12 +76,13 @@ public class LauncherLifecycleCommandsIntegrationTest { assertNotNull(coreDependenciesJar); assertTrue(coreDependenciesJar + " is not a file", coreDependenciesJar.isFile()); - Collection<String> expectedJarDependencies = Arrays.asList("antlr", "commons-io", "commons-lang", "commons-logging", - "geode", "jackson-annotations", "jackson-core", "jackson-databind", "jansi", "jline", "snappy", - "spring-core", "spring-shell", "jetty-server", "jetty-servlet", "jetty-webapp", "jetty-util", "jetty-http", - "servlet-api", "jetty-io", "jetty-security", "jetty-xml" + Collection<String> expectedJarDependencies = + Arrays.asList("antlr", "commons-io", "commons-lang", "commons-logging", "geode", + "jackson-annotations", "jackson-core", "jackson-databind", "jansi", "jline", "snappy", + "spring-core", "spring-shell", "jetty-server", "jetty-servlet", "jetty-webapp", + "jetty-util", "jetty-http", "servlet-api", "jetty-io", "jetty-security", "jetty-xml" - ); + ); assertJarFileManifestClassPath(coreDependenciesJar, expectedJarDependencies); } @@ -93,7 +92,8 @@ public class LauncherLifecycleCommandsIntegrationTest { final int expectedPid = 12345; File folder = temporaryFolder.newFolder(); - File pidFile = new File(folder, getClass().getSimpleName() + "_" + testName.getMethodName() + ".pid"); + File pidFile = + new File(folder, getClass().getSimpleName() + "_" + testName.getMethodName() + ".pid"); assertTrue(pidFile.createNewFile()); @@ -118,7 +118,7 @@ public class LauncherLifecycleCommandsIntegrationTest { } private void assertJarFileManifestClassPath(final File dependenciesJar, - final Collection<String> expectedJarDependencies) throws IOException { + final Collection<String> expectedJarDependencies) throws IOException { JarFile dependenciesJarFile = new JarFile(dependenciesJar); Manifest manifest = dependenciesJarFile.getManifest(); @@ -132,19 +132,23 @@ public class LauncherLifecycleCommandsIntegrationTest { String[] actualJarDependencies = attributes.getValue(Name.CLASS_PATH).split(" "); assertNotNull(actualJarDependencies); - assertTrue(String.format("Expected the actual number of JAR dependencies to be (%1$d); but was (%2$d)!", + assertTrue( + String.format( + "Expected the actual number of JAR dependencies to be (%1$d); but was (%2$d)!", expectedJarDependencies.size(), actualJarDependencies.length), - actualJarDependencies.length >= expectedJarDependencies.size()); - //assertTrue(Arrays.asList(actualJarDependencies).containsAll(expectedJarDependencies)); + actualJarDependencies.length >= expectedJarDependencies.size()); + // assertTrue(Arrays.asList(actualJarDependencies).containsAll(expectedJarDependencies)); List<String> actualJarDependenciesList = new ArrayList<>(Arrays.asList(actualJarDependencies)); - List<String> missingExpectedJarDependenciesList = new ArrayList<>(expectedJarDependencies.size()); + List<String> missingExpectedJarDependenciesList = + new ArrayList<>(expectedJarDependencies.size()); for (String expectedJarDependency : expectedJarDependencies) { boolean containsExpectedJar = false; for (int index = 0, size = actualJarDependenciesList.size(); index < size; index++) { - if (actualJarDependenciesList.get(index).toLowerCase().contains(expectedJarDependency.toLowerCase())) { + if (actualJarDependenciesList.get(index).toLowerCase() + .contains(expectedJarDependency.toLowerCase())) { actualJarDependenciesList.remove(index); containsExpectedJar = true; break; @@ -156,10 +160,12 @@ public class LauncherLifecycleCommandsIntegrationTest { } } - assertTrue(String.format( + assertTrue( + String.format( "GemFire dependencies JAR file (%1$s) does not contain the expected dependencies (%2$s) in the Manifest Class-Path attribute (%3$s)!", - dependenciesJar, missingExpectedJarDependenciesList, attributes.getValue(Name.CLASS_PATH)), - missingExpectedJarDependenciesList.isEmpty()); + dependenciesJar, missingExpectedJarDependenciesList, + attributes.getValue(Name.CLASS_PATH)), + missingExpectedJarDependenciesList.isEmpty()); } }