Skip to content

Commit

Permalink
[GEODE-20] - Closing PRs apache#2 and apache#9
Browse files Browse the repository at this point in the history
Changing build.gradle on gemfire-assembly for running junits
  • Loading branch information
William Markito committed Jun 23, 2015
1 parent 2cae5b7 commit 05e4eb9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
12 changes: 10 additions & 2 deletions gemfire-assembly/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,25 @@ dependencies {
archives project(':gemfire-core')
archives project(':gemfire-web')
archives project(':gemfire-web-api')

testCompile project(path: ':gemfire-junit', configuration: 'testOutput')
testCompile project(path: ':gemfire-core', configuration: 'testOutput')
}

sourceSets {
// need to remove this since we use the dependencies jar out of the install dir
test.runtimeClasspath -= configurations.provided
//test.runtimeClasspath -= configurations.provided
}

test {
// test from the actual classpath not the gradle classpath
dependsOn installDist
classpath += files "$buildDir/install/${distributions.main.baseName}/lib/gemfire-core-dependencies.jar"
// @TODO: this doesn't seem to be working need to get basename first.
classpath += files "$buildDir/install/apache-geode/lib/gemfire-core-dependencies.jar"
}

tasks.withType(Test){
environment 'GEMFIRE', "$buildDir/install/${distributions.main.baseName}/lib"
}

task defaultDistributionConfig(type: JavaExec, dependsOn: classes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,32 @@
* limitations under the License.
*/

package com.gemstone.gemfire.management.internal;
import com.gemstone.gemfire.management.internal.AgentUtil;
import com.gemstone.junit.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 junit.framework.TestCase;

import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.util.Assert;

import com.gemstone.junit.UnitTest;
import static org.junit.Assert.*;

@Category(UnitTest.class)
public class AgentUtilJUnitTest extends TestCase {
@Category(IntegrationTest.class)
public class AgentUtilJUnitTest {

private AgentUtil agentUtil;
private String version;

@Before
public void setUp() {
version = getGemfireVersion();
agentUtil = new AgentUtil(version);
Expand All @@ -46,7 +49,7 @@ public void setUp() {
@Test
public void testRESTApiExists() {
String gemFireWarLocation = agentUtil.getGemFireWebApiWarLocation();
Assert.notNull(gemFireWarLocation, "GemFire REST API WAR File was not found");
assertNotNull(gemFireWarLocation, "GemFire REST API WAR File was not found");
}

/*
Expand All @@ -55,7 +58,7 @@ public void testRESTApiExists() {
// @Test
// public void testPulseWarExists() {
// String gemFireWarLocation = agentUtil.getPulseWarLocation();
// Assert.notNull(gemFireWarLocation, "Pulse WAR File was not found");
// assertNotNull(gemFireWarLocation, "Pulse WAR File was not found");
// }

private String getGemfireVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ public class AgentUtil {
private static final String LIB_API_WAR = "/lib/gemfire-api-";
private static final String TOOLS_PULSE_WAR = "/tools/Pulse/pulse.war";
private static final String LIB_PULSE_WAR = "/lib/pulse.war";
public static final String ERROR_VARIABLE_NOT_SET = "The GEMFIRE environment variable must be set!";

private String gemfireVersion = null;

public AgentUtil(String gemfireVersion) {
this.gemfireVersion = gemfireVersion;
}

String getGemFireWebApiWarLocation() {
public String getGemFireWebApiWarLocation() {
String gemfireHome = getGemFireHome();
assert !StringUtils.isBlank(gemfireHome) : "The GEMFIRE environment variable must be set!";
assert !StringUtils.isBlank(gemfireHome) : ERROR_VARIABLE_NOT_SET;
logger.warn(gemfireHome + TOOLS_WEB_API_WAR + gemfireVersion + ".war");

if (new File(gemfireHome + TOOLS_WEB_API_WAR + gemfireVersion + ".war").isFile()) {
Expand All @@ -69,9 +70,9 @@ String getGemFireWebApiWarLocation() {
* $GEMFIRE/lib directory Finally, if we cannot find Management WAR file then
* return null...
*/
String getGemFireWebWarLocation() {
public String getGemFireWebWarLocation() {
String gemfireHome = getGemFireHome();
assert !StringUtils.isBlank(gemfireHome) : "The GEMFIRE environment variable must be set!";
assert !StringUtils.isBlank(gemfireHome) : ERROR_VARIABLE_NOT_SET;

if (new File(gemfireHome + TOOLS_WEB_WAR + gemfireVersion + ".war").isFile()) {
return gemfireHome + TOOLS_WEB_WAR + gemfireVersion + ".war";
Expand All @@ -82,9 +83,9 @@ String getGemFireWebWarLocation() {
}
}

String getGemfireApiWarLocation() {
public String getGemfireApiWarLocation() {
String gemfireHome = getGemFireHome();
assert !StringUtils.isBlank(gemfireHome) : "The GEMFIRE environment variable must be set!";
assert !StringUtils.isBlank(gemfireHome) :ERROR_VARIABLE_NOT_SET;

if (new File(gemfireHome + TOOLS_API_WAR + gemfireVersion + ".war").isFile()) {
return gemfireHome + TOOLS_API_WAR + gemfireVersion + ".war";
Expand All @@ -99,9 +100,9 @@ String getGemfireApiWarLocation() {
// First, look in the $GEMFIRE/tools/Pulse directory
// Second, look in the $GEMFIRE/lib directory
// Finally, if we cannot find the Management WAR file then return null...
String getPulseWarLocation() {
public String getPulseWarLocation() {
String gemfireHome = getGemFireHome();
assert !StringUtils.isBlank(gemfireHome) : "The GEMFIRE environment variable must be set!";
assert !StringUtils.isBlank(gemfireHome) : ERROR_VARIABLE_NOT_SET;

if (new File(gemfireHome + TOOLS_PULSE_WAR).isFile()) {
return gemfireHome + TOOLS_PULSE_WAR;
Expand All @@ -112,11 +113,11 @@ String getPulseWarLocation() {
}
}

boolean isWebApplicationAvailable(final String warFileLocation) {
public boolean isWebApplicationAvailable(final String warFileLocation) {
return !StringUtils.isBlank(warFileLocation);
}

boolean isWebApplicationAvailable(final String... warFileLocations) {
public boolean isWebApplicationAvailable(final String... warFileLocations) {
for (String warFileLocation : warFileLocations) {
if (isWebApplicationAvailable(warFileLocation)) {
return true;
Expand All @@ -126,10 +127,11 @@ boolean isWebApplicationAvailable(final String... warFileLocations) {
return false;
}

String getGemFireHome() {
public String getGemFireHome() {

String gemFireHome = System.getenv("GEMFIRE");

logger.info("GEMFIRE HOME:" + gemFireHome);
// Check for empty variable. if empty, then log message and exit HTTP server
// startup
if (StringUtils.isBlank(gemFireHome)) {
Expand All @@ -143,7 +145,7 @@ String getGemFireHome() {
return gemFireHome;
}

boolean isGemfireHomeDefined() {
public boolean isGemfireHomeDefined() {
String gemfireHome = getGemFireHome();
return !StringUtils.isBlank(gemfireHome);
}
Expand Down

0 comments on commit 05e4eb9

Please sign in to comment.