GEODE-309: Move AgentUtilJUnitTest to the proper package Move AgentUtilJUnitTest into com.gemstone.gemfire.management.internal package. Cleanup test including:
- Remove unused imports - Uncomment a commented test and use @Ignore with description Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/f7706217 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/f7706217 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/f7706217 Branch: refs/heads/feature/GEODE-12 Commit: f77062171309895b05d34f02d9176ce5af88f6b0 Parents: ba74e9e Author: Kirk Lund <[email protected]> Authored: Fri Sep 4 12:29:24 2015 -0700 Committer: Kirk Lund <[email protected]> Committed: Fri Sep 4 15:17:32 2015 -0700 ---------------------------------------------------------------------- .../src/test/java/AgentUtilJUnitTest.java | 109 ------------------- .../management/internal/AgentUtilJUnitTest.java | 106 ++++++++++++++++++ 2 files changed, 106 insertions(+), 109 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f7706217/gemfire-assembly/src/test/java/AgentUtilJUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-assembly/src/test/java/AgentUtilJUnitTest.java b/gemfire-assembly/src/test/java/AgentUtilJUnitTest.java deleted file mode 100644 index 0f7563b..0000000 --- a/gemfire-assembly/src/test/java/AgentUtilJUnitTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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 - * - * 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. - */ - -import com.gemstone.gemfire.management.internal.AgentUtil; -import com.gemstone.gemfire.test.junit.categories.IntegrationTest; - -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.Iterator; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import static org.junit.Assert.*; - -@Category(IntegrationTest.class) -public class AgentUtilJUnitTest { - - private AgentUtil agentUtil; - private String version; - - @Before - public void setUp() { - version = getGemfireVersion(); - agentUtil = new AgentUtil(version); - } - - @Test - public void testRESTApiExists() { - String gemFireWarLocation = agentUtil.getGemFireWebApiWarLocation(); - assertNotNull(gemFireWarLocation, "GemFire REST API WAR File was not found"); - } - - /* - * This test should be activated when pulse gets added to Geode - */ - // @Test - // public void testPulseWarExists() { - // String gemFireWarLocation = agentUtil.getPulseWarLocation(); - // assertNotNull(gemFireWarLocation, "Pulse WAR File was not found"); - // } - - private String getGemfireVersion() { - String version = null; - - Properties prop = new Properties(); - InputStream inputStream = null; - String pathPrefix = null; - try { - pathPrefix = calculatePathPrefixToProjectRoot("gemfire-assembly/"); - inputStream = new FileInputStream(pathPrefix + "gradle.properties"); - } catch (FileNotFoundException e1) { - try { - pathPrefix = calculatePathPrefixToProjectRoot("gemfire-core/"); - inputStream = new FileInputStream(pathPrefix + "gradle.properties"); - } catch (FileNotFoundException e) { - } - } - - if (inputStream != null) { - try { - prop.load(inputStream); - version = prop.getProperty("version"); - } catch (FileNotFoundException e) { - } catch (IOException e) { - } - } - return version; - } - - private String calculatePathPrefixToProjectRoot(String subDirectory) { - String pathPrefix = ""; - - String currentDirectoryPath = new File(".").getAbsolutePath(); - int gemfireCoreLocationIx = currentDirectoryPath.indexOf(subDirectory); - if (gemfireCoreLocationIx < 0) { - return pathPrefix; - } - - String pathFromRoot = currentDirectoryPath.substring(gemfireCoreLocationIx); - int segmentsCount = pathFromRoot.split("/").length - 1; - - for (int i = 0; i < segmentsCount; i++) { - pathPrefix = pathPrefix + "../"; - } - return pathPrefix; - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f7706217/gemfire-assembly/src/test/java/com/gemstone/gemfire/management/internal/AgentUtilJUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-assembly/src/test/java/com/gemstone/gemfire/management/internal/AgentUtilJUnitTest.java b/gemfire-assembly/src/test/java/com/gemstone/gemfire/management/internal/AgentUtilJUnitTest.java new file mode 100644 index 0000000..cd2c429 --- /dev/null +++ b/gemfire-assembly/src/test/java/com/gemstone/gemfire/management/internal/AgentUtilJUnitTest.java @@ -0,0 +1,106 @@ +/* + * 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 + * + * 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 com.gemstone.gemfire.management.internal; + +import com.gemstone.gemfire.management.internal.AgentUtil; +import com.gemstone.gemfire.test.junit.categories.IntegrationTest; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import static org.junit.Assert.*; + +@Category(IntegrationTest.class) +public class AgentUtilJUnitTest { + + private AgentUtil agentUtil; + private String version; + + @Before + public void setUp() { + version = getGemfireVersion(); + agentUtil = new AgentUtil(version); + } + + @Test + public void testRESTApiExists() { + String gemFireWarLocation = agentUtil.getGemFireWebApiWarLocation(); + assertNotNull(gemFireWarLocation, "GemFire REST API WAR File was not found"); + } + + @Ignore("This test should be activated when pulse gets added to Geode") + @Test + public void testPulseWarExists() { + String gemFireWarLocation = agentUtil.getPulseWarLocation(); + assertNotNull(gemFireWarLocation, "Pulse WAR File was not found"); + } + + private String getGemfireVersion() { + String version = null; + + Properties prop = new Properties(); + InputStream inputStream = null; + String pathPrefix = null; + try { + pathPrefix = calculatePathPrefixToProjectRoot("gemfire-assembly/"); + inputStream = new FileInputStream(pathPrefix + "gradle.properties"); + } catch (FileNotFoundException e1) { + try { + pathPrefix = calculatePathPrefixToProjectRoot("gemfire-core/"); + inputStream = new FileInputStream(pathPrefix + "gradle.properties"); + } catch (FileNotFoundException e) { + } + } + + if (inputStream != null) { + try { + prop.load(inputStream); + version = prop.getProperty("version"); + } catch (FileNotFoundException e) { + } catch (IOException e) { + } + } + return version; + } + + private String calculatePathPrefixToProjectRoot(String subDirectory) { + String pathPrefix = ""; + + String currentDirectoryPath = new File(".").getAbsolutePath(); + int gemfireCoreLocationIx = currentDirectoryPath.indexOf(subDirectory); + if (gemfireCoreLocationIx < 0) { + return pathPrefix; + } + + String pathFromRoot = currentDirectoryPath.substring(gemfireCoreLocationIx); + int segmentsCount = pathFromRoot.split("/").length - 1; + + for (int i = 0; i < segmentsCount; i++) { + pathPrefix = pathPrefix + "../"; + } + return pathPrefix; + } +}
