You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by lg...@apache.org on 2015/09/30 01:12:18 UTC
[1/3] incubator-geode git commit: Reunite open and closed source
hydra classes and various other test classes.
Repository: incubator-geode
Updated Branches:
refs/heads/feature/GEODE-308 ba74e9ea8 -> 769c2ee8e
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/greplogs/ExpectedStrings.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/greplogs/ExpectedStrings.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/greplogs/ExpectedStrings.java
new file mode 100644
index 0000000..6262cfe
--- /dev/null
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/greplogs/ExpectedStrings.java
@@ -0,0 +1,180 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+/**
+ *
+ */
+package com.gemstone.gemfire.test.junit.greplogs;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.regex.Pattern;
+
+/**
+ * @author kbanks
+ *
+ */
+public class ExpectedStrings {
+
+ private ExpectedStrings() {}
+
+ public static boolean skipLogMsgs(String type) {
+ if ( type.equals("junit")
+ || type.equals("java")
+ || type.equals("query")
+ || type.equals("dunit")) {
+ return true;
+ }else {
+ return false;
+ }
+ }
+ public static List create(String type) {
+ List expected = new ArrayList();
+
+ expected.add(Pattern.compile("@todo"));
+ expected.add(Pattern.compile("Random seed"));
+ expected.add(Pattern.compile("Caused by"));
+ expected.add(Pattern.compile("continuing test"));
+ expected.add(Pattern.compile("continuing with test"));
+ expected.add(Pattern.compile("Test failed with errors"));
+ expected.add(Pattern.compile("Test reported failure"));
+ expected.add(Pattern.compile("TASK REPORT"));
+ expected.add(Pattern.compile("Test reported hang"));
+ expected.add(Pattern.compile("Proceeding past hung test"));
+ expected.add(Pattern.compile("waited too long for result"));
+ expected.add(Pattern.compile("gskill"));
+ expected.add(Pattern.compile("HANG --"));
+ expected.add(Pattern.compile("Leaving the vms running"));
+ expected.add(Pattern.compile("Non-sanctioned build detected"));
+ expected.add(Pattern.compile("may result in severe civil"));
+ expected.add(Pattern.compile("This concludes your test run"));
+ expected.add(Pattern.compile("TEST:"));
+ expected.add(Pattern.compile("\\(will reattempt\\)"));
+ expected.add(Pattern.compile("Removing disk files"));
+ expected.add(Pattern.compile("cannot find a successor due to shutdown:"));
+ expected.add(Pattern.compile("aborted due to shutdown:"));
+ expected.add(Pattern.compile("due to cache closure:"));
+ expected.add(Pattern.compile("Got expected "));
+ expected.add(Pattern.compile("Caught expected "));
+ expected.add(Pattern.compile("caught expected "));
+ expected.add(Pattern.compile("Found expected warning"));
+ expected.add(Pattern.compile("CacheClosedException: The cache is closed."));
+ expected.add(Pattern.compile("Invoked MembershipNotifierHook"));
+ expected.add(Pattern.compile("java.io.IOException: Connection reset by peer"));
+ expected.add(Pattern.compile("client connections exceeds the licensed limit"));
+ //Exclude this since the only tests with securty enabled, expect to see
+ //these and if they don't then the test fails
+ expected.add(Pattern.compile("NotAuthorizedException"));
+ expected.add(Pattern.compile("above critical heap threshold"));
+ expected.add(Pattern.compile("below critical heap threshold"));
+ expected.add(Pattern.compile("checkForForcedDisconnect processed Exception"));
+ expected.add(Pattern.compile("operation generated expected \\S+Exception"));
+
+ expected.add(Pattern.compile("ExpectedString"));
+ expected.add(Pattern.compile("ExpectedStrings"));
+
+ expected.add(Pattern.compile("PassWithExpectedSevereJUnitTest"));
+ expected.add(Pattern.compile("FailWithErrorInOutputJUnitTest"));
+ expected.add(Pattern.compile("PassWithExpectedErrorJUnitTest"));
+ expected.add(Pattern.compile("FailWithSevereInOutputJUnitTest"));
+ expected.add(Pattern.compile("SystemAlertManager: A simple Alert."));
+
+ expected.add(Pattern.compile("com.gemstone.gemfire.management.DependenciesNotFoundException"));
+
+ //expected.add(Pattern.compile("Java version older than"));
+ //expected.add(Pattern.compile("Minimum system requirements not met. Unexpected behavior may result in additional errors."));
+
+ if ( type.equals("junit") || type.equals("java") || type.equals("query")) {
+ expected.add(Pattern.compile("TEST EXCEPTION"));
+ expected.add(Pattern.compile("testLogLevels"));
+ expected.add(Pattern.compile("On iteration"));
+ expected.add(Pattern.compile("signal count"));
+ //Remove when davidw fixes
+ expected.add(Pattern.compile("Expected"));
+ //below here for gfx unit tests
+ expected.add(Pattern.compile("Valid documents must have a"));
+ expected.add(Pattern.compile("Loaded java.lang.ClassCastException"));
+ expected.add(Pattern.compile("Loaded java.io.InvalidClassException"));
+ expected.add(Pattern.compile("Loaded java.lang.NullPointerException"));
+ expected.add(Pattern.compile("Loaded java.lang.ArrayIndexOutOfBoundsException"));
+ expected.add(Pattern.compile("Loaded java.lang.IndexOutOfBoundsException"));
+ expected.add(Pattern.compile("SucessfulTest:"));
+ expected.add(Pattern.compile("SQLException: Database 'newDB' not found"));
+ expected.add(Pattern.compile("SQLException: Database 'newDB1' not found"));
+ expected.add(Pattern.compile("IGNORE_EXCEPTION_test"));
+ expected.add(Pattern.compile("Unsupported at this time"));
+ expected.add(Pattern.compile("DiskAccessException occured as expected"));
+ expected.add(Pattern.compile("Oplog::createOplog:Exception in preblowing the file"));
+ } else if ( type.equals("dunit")) {
+ expected.add(Pattern.compile("INCOMPATIBLE_ROOT"));
+ expected.add(Pattern.compile("connecting to locator"));
+ expected.add(Pattern.compile("ItsOkayForMyClassNotToBeFound"));
+ expected.add(Pattern.compile("Test Exception"));
+ expected.add(Pattern.compile("make sure exceptions from close callbacks"));
+ expected.add(Pattern.compile("Please ignore"));
+ expected.add(Pattern.compile("I have been thrown from TestFunction"));
+ expected.add(Pattern.compile("No admin on"));
+ expected.add(Pattern.compile("nonExistentMethod"));
+ expected.add(Pattern.compile("Expected exception"));
+ expected.add(Pattern.compile("BridgeLoaderTestNonSerializable"));
+ expected.add(Pattern.compile("BridgeLoaderTestSerializableImpl"));
+ expected.add(Pattern.compile("One or more DUnit tests failed"));
+ expected.add(Pattern.compile("ReplyException"));
+ expected.add(Pattern.compile("fine 2"));
+ expected.add(Pattern.compile("TESTING A VERY UNIQUE"));
+ expected.add(Pattern.compile("-01-01"));
+ expected.add(Pattern.compile("testNBRegionDestructionDuringGetInitialImage"));
+ expected.add(Pattern.compile("SQLException: Database 'newDB' not found"));
+ expected.add(Pattern.compile("SQLException: Failed to start database 'newDB'"));
+ expected.add(Pattern.compile("SQLException: Database 'newDB1' not found"));
+ expected.add(Pattern.compile("INCORRECT_localhost"));
+ expected.add(Pattern.compile("WARNING: Failed to check connection: java.net.ConnectException: Connection refused"));
+ expected.add(Pattern.compile("WARNING: Failed to call the method close..:java.rmi.ConnectException:"));
+ expected.add(Pattern.compile("WARNING: Failed to restart: java.rmi.NoSuchObjectException: no such object in table"));
+ expected.add(Pattern.compile("WARNING: Failed to restart: java.rmi.ConnectException: Connection refused to host: .* nested exception is:"));
+ expected.add(Pattern.compile("UnitTests terminating abnormally after a client had a fatal task error"));
+ expected.add(Pattern.compile("Doing stack dump on all"));
+ expected.add(Pattern.compile("Unit test result: FAILED ==> Unsuccessfully ran JUnit tests"));
+ expected.add(Pattern.compile("IGNORE_EXCEPTION_test"));
+ expected.add(Pattern.compile("SIGQUIT received, dumping threads"));
+ expected.add(Pattern.compile("Sleeping \\d+ seconds between stack dumps"));
+ expected.add(Pattern.compile("Redundancy has dropped below"));
+ expected.add(Pattern.compile("Could not find any server to create redundant client"));
+ expected.add(Pattern.compile("Could not find any server to create primary client"));
+ expected.add(Pattern.compile("Pool unexpected closed socket on server"));
+ expected.add(Pattern.compile("Could not initialize a primary queue on startup"));
+ expected.add(Pattern.compile("java.lang.IllegalArgumentException: Sample timestamp must be greater than previous timestamp"));
+ //The following 2 strings are ignored due to bug 52042
+ expected.add(Pattern.compile("failed accepting client connection"));
+ expected.add(Pattern.compile("Acceptor received unknown communication"));
+ } else if ( type.equals("smoke")) {
+ expected.add(Pattern.compile("Doing stack dump on all"));
+ expected.add(Pattern.compile("SIGQUIT received, dumping threads"));
+ expected.add(Pattern.compile("Sleeping \\d+ seconds between stack dumps"));
+ expected.add(Pattern.compile("Could not find Spring Shell library"));
+ } else if ( type.equals("perf")) {
+ expected.add(Pattern.compile("Doing stack dump on all"));
+ expected.add(Pattern.compile("SIGQUIT received, dumping threads"));
+ expected.add(Pattern.compile("Sleeping \\d+ seconds between stack dumps"));
+ } else if ( type.equals("moresmoke")) {
+ expected.add(Pattern.compile(" expected error"));
+ expected.add(Pattern.compile("Doing stack dump on all"));
+ expected.add(Pattern.compile("SIGQUIT received, dumping threads"));
+ expected.add(Pattern.compile("Sleeping \\d+ seconds between stack dumps"));
+ } else {
+ expected.add(Pattern.compile("runbattery\\(\\) returned false"));
+ expected.add(Pattern.compile(" expected error"));
+ expected.add(Pattern.compile("Doing stack dump on all"));
+ expected.add(Pattern.compile("SIGQUIT received, dumping threads"));
+ expected.add(Pattern.compile("Sleeping \\d+ seconds between stack dumps"));
+ expected.add(Pattern.compile("HydraTask_initializeExpectException"));
+ expected.add(Pattern.compile("java.net.ConnectException: Connection refused"));
+ }
+ return expected;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/greplogs/LogConsumer.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/greplogs/LogConsumer.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/greplogs/LogConsumer.java
new file mode 100644
index 0000000..7ffd1cd
--- /dev/null
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/greplogs/LogConsumer.java
@@ -0,0 +1,289 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.test.junit.greplogs;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class LogConsumer {
+ private final List expectedExceptions = new ArrayList();
+ private boolean skipLogMsgs = false;
+ private boolean infoMsgFlag = false;
+ private int eatLines = 0;
+ private boolean tmpErrFlag = false;
+ private int tmpErrLines = 0;
+ private boolean saveFlag = false;
+ private int savelinenum = 0;
+ private final List testExpectStrs;
+ StringBuilder all = null;
+ private int lineNumber;
+ private String fileName;
+ HashMap individalErrorCount = new HashMap();
+ private final int repeatLimit;
+
+ private static final Pattern ExpectedExceptionPattern = Pattern.compile("<ExpectedException action=(add|remove)>(.*)</ExpectedException>");
+ private static final Pattern logPattern = Pattern.compile("^\\[(?:fatal|error|warn|info|debug|trace|severe|warning|fine|finer|finest)");
+ private static final Pattern blankPattern = Pattern.compile("^\\s*$");
+ private static final Pattern infoOrBelowPattern = Pattern.compile("^\\[(?:info|debug|trace|fine|finer|finest)");
+ private static final Pattern fatalOrErrorPattern = Pattern.compile("^\\[(?:fatal|error|severe)");
+ private static final Pattern causedByPattern = Pattern.compile("Caused by");
+ private static final Pattern shortErrPattern = Pattern.compile("^\\[[^\\]]+\\](.*)$", Pattern.MULTILINE | Pattern.DOTALL);
+ private static final Pattern wroteExceptionPattern = Pattern.compile("\\[debug.*Wrote exception:");
+ private static final Pattern rmiWarnPattern = Pattern.compile("^WARNING: Failed to .*java.rmi.ConnectException: Connection refused to host: .*; nested exception is:");
+ private static final Pattern javaLangErrorPattern = Pattern.compile("^java\\.lang\\.\\S+Error$");
+ private static final Pattern exceptionPattern = Pattern.compile("Exception:");
+ private static final Pattern exceptionPattern2 = Pattern.compile("( [\\w\\.]+Exception: (([\\S]+ ){0,6}))");
+ private static final Pattern exceptionPattern3 = Pattern.compile("( [\\w\\.]+Exception)$");
+ private static final Pattern exceptionPattern4 = Pattern.compile("^([^:]+: (([\\w\"]+ ){0,6}))");
+ private static final Pattern misformatedI18nMessagePattern = Pattern.compile("[^\\d]\\{\\d+\\}");
+ private static final Pattern rvvBitSetMessagePattern = Pattern.compile("RegionVersionVector.+bsv\\d+.+bs=\\{\\d+\\}");
+ /** Limit long errors to this many lines */
+ private static int ERROR_BUFFER_LIMIT = 50;
+
+
+
+
+ public LogConsumer(boolean skipLogMsgs,
+ List testExpectStrs, String fileName, int repeatLimit) {
+ super();
+ this.skipLogMsgs = skipLogMsgs;
+ this.testExpectStrs = testExpectStrs;
+ this.fileName = fileName;
+ this.repeatLimit = repeatLimit;
+ }
+
+ public StringBuilder consume(CharSequence line) {
+ {
+ lineNumber++;
+ Matcher m = ExpectedExceptionPattern.matcher(line);
+ if (m.find()) {
+ if ( m.group(1).equals("add")) {
+ expectedExceptions.add(Pattern.compile(m.group(2)));
+ } else {
+ //assume add and remove are the only choices
+ expectedExceptions.remove(Pattern.compile(m.group(2)));
+ }
+ return null;
+ }
+ }
+ if(skipLogMsgs) {
+ if(infoMsgFlag) {
+ if(logPattern.matcher(line).find()) {
+ infoMsgFlag = false;
+ } else if (blankPattern.matcher(line).matches()) {
+ infoMsgFlag = false;
+ return null;
+ } else {
+ return null;
+ }
+ }
+ if (infoOrBelowPattern.matcher(line).find()){
+ infoMsgFlag = true;
+ return null;
+ }
+ }
+
+ if ( eatLines != 0 ) {
+ eatLines--;
+ return null;
+ } else {
+ if(saveFlag || fatalOrErrorPattern.matcher(line).find()) {
+ if(! saveFlag) {
+ saveFlag = true;
+ tmpErrFlag = true;
+ if(checkExpectedStrs(line, expectedExceptions)) {
+ saveFlag = false;
+ tmpErrFlag = false;
+ tmpErrLines = 0;
+ }
+ if(tmpErrFlag) {
+ tmpErrLines=1;
+ all = new StringBuilder(line);
+ all.append("\n");
+ savelinenum = lineNumber;
+ }
+ } else {
+ if (causedByPattern.matcher(line).find()) {
+ tmpErrFlag = false;
+ tmpErrLines = 0;
+ saveFlag = false;
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("-----------------------------------------------------------------------\n");
+ buffer.append("Found suspect string in ")
+ .append(fileName)
+ .append(" at line ")
+ .append(savelinenum).append("\n\n")
+ .append(all.toString());
+ return buffer;
+ } else if (checkExpectedStrs(line, expectedExceptions)) {
+ // reset the counters and throw it all away if it matches
+ // one of the registered ignorable strings
+ tmpErrFlag = false;
+ tmpErrLines = 0;
+ saveFlag = false;
+ }
+
+ // We save all the lines up to the next blank line so we're
+ //looking for a blank line here
+ if (blankPattern.matcher(line).matches()) {
+ // we found a blank line so print the suspect string
+ // and reset the savetag flag
+ saveFlag = false;
+ Matcher m = shortErrPattern.matcher(all.toString());
+ if (m.matches()) {
+ String shortName = m.group(1);
+ Integer i = (Integer) individalErrorCount.get(shortName);
+ Integer occurances =
+ new Integer((i == null) ? 1 : i.intValue() + 1);
+ individalErrorCount.put(shortName, occurances);
+ return enforceErrorLimit(occurances.intValue(),
+ all.toString(),
+ //reader.getLineNumber(),
+ savelinenum,
+ fileName);
+
+ } else {
+ //error in determining shortName, wing it
+ return enforceErrorLimit(1,
+ all.toString(),
+ lineNumber,
+ fileName);
+ }
+ }
+
+ // we're still saving lines to append them on to all which contains
+ // all the lines we're trying to save
+ if ( tmpErrFlag ) {
+ if ( tmpErrLines < ERROR_BUFFER_LIMIT ) {
+ tmpErrLines++;
+ all.append(line).append("\n");
+ }
+ if ( tmpErrLines == ERROR_BUFFER_LIMIT ) {
+ tmpErrLines++; //increment to prevent this line from repeating
+ all.append("GrepLogs: ERROR_BUFFER_LIMIT limit reached,")
+ .append(" the error was too long to display completely.\n");
+ }
+
+ }
+ }
+ // unique condition for when bridge server see log exception and
+ // logging level is set to fine. Message looks like this:
+ //[fine 2005/10/25 17:53:13.586 PDT gemfire2 Server connection from hobbes.gemstone.com:34466-0xf4 nid=0x23e40f1] Server connection from hobbes.gemstone.com:34466: Wrote exception:
+ //com.gemstone.gemfire.cache.EntryNotFoundException: remote-destroy-key
+ // also now handles a JMX WARNING
+ } else if(wroteExceptionPattern.matcher(line).find()
+ || rmiWarnPattern.matcher(line).find()) {
+ //Eat only the single EntryNotFound Exception
+ eatLines=1;
+ // if we are here then the line didn't have severe or error in it and
+ // didn't meet any special cases that require eating lines
+ // Check for other kinds of exceptions. This is by no means inclusive
+ //of all types of exceptions that could occur and some ARE missed.
+ } else if (exceptionPattern.matcher(line).find()
+ || javaLangErrorPattern.matcher(line).find()
+ || (misformatedI18nMessagePattern.matcher(line).find()
+ && !(infoOrBelowPattern.matcher(line).find()
+ && rvvBitSetMessagePattern.matcher(line).find())) ) {
+ if(! checkExpectedStrs(line, expectedExceptions)) {
+ // it's the Exception colon that we want to find
+ // along with the next six words and define to shortline
+ // shortline is only used for the unique sting to count the
+ // number of times an exception match occurs. This is so
+ // we can suppress further printing if we hit the limit
+ Matcher m2 = exceptionPattern2.matcher(line);
+ Matcher m3 = exceptionPattern3.matcher(line);
+ Matcher m4 = exceptionPattern4.matcher(line);
+ String shortName = "";
+
+ if(m2.find()) {
+ shortName = m2.group(1);
+ } else if (m3.find()) {
+ shortName = m3.group(1);
+ } else if (m4.find()) {
+ shortName = m4.group(1);
+ }
+ Integer i = (Integer) individalErrorCount.get(shortName);
+ Integer occurances =
+ new Integer((i == null) ? 1 : i.intValue() + 1);
+ individalErrorCount.put(shortName, occurances);
+ return enforceErrorLimit(occurances.intValue(),
+ line + "\n",
+ lineNumber,
+ fileName);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public StringBuilder close() {
+ if(saveFlag) {
+ // Bug fix for severe that occurs at the end of a log file. Since we
+ // collect lines up to a blank line that never happens this prints the
+ // collection of in process suspect strings if we close the file and
+ // we're still trying to save lines
+
+ saveFlag = false;
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("\n-----------------------------------------------------------------------\n")
+ .append("Found suspect string in ")
+ .append(fileName)
+ .append(" at line ")
+ .append(savelinenum)
+ .append("\n\n")
+ .append(all);
+ return buffer;
+ }
+ return null;
+ }
+
+ private boolean checkExpectedStrs(CharSequence line, List expectedExceptions) {
+ for(int i = 0; i < expectedExceptions.size(); i++) {
+ Pattern p = (Pattern) expectedExceptions.get(i);
+ if(p.matcher(line).find()) return true;
+ }
+ for(int i = 0; i < testExpectStrs.size(); i++) {
+ Pattern p = (Pattern) testExpectStrs.get(i);
+ if(p.matcher(line).find()) return true;
+ }
+ return false;
+ }
+
+ private StringBuilder enforceErrorLimit(int hits,
+ String line,
+ int linenum,
+ String filename) {
+ if ( hits <= repeatLimit ) {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("-----------------------------------------------------------------------\n")
+ .append("Found suspect string in ")
+ .append(filename)
+ .append(" at line ")
+ .append(linenum)
+ .append("\n\n")
+ .append(line)
+ .append("\n");
+ return buffer;
+ }
+ if ( hits == repeatLimit ) {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("\n\nHit occurrence limit of ")
+ .append(hits)
+ .append(" for this string.\n")
+ .append("Further reporting of this type of error will be suppressed.\n");
+ return buffer;
+ }
+ return null;
+ }
+
+}
+
[2/3] incubator-geode git commit: Reunite open and closed source
hydra classes and various other test classes.
Posted by lg...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/hydra/GsRandom.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/hydra/GsRandom.java b/gemfire-core/src/test/java/hydra/GsRandom.java
deleted file mode 100644
index 272958a..0000000
--- a/gemfire-core/src/test/java/hydra/GsRandom.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.pivotal.io/patents.
- *========================================================================
- */
-
-package hydra;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * This is a simple extension of java.util.Random that allows for the
- * generation of random numbers within ranges. It also allows for the
- * generation of random strings (within ranges as well).
- * @see java.lang.Math#random()
- * @see java.util.Random
- * @since JDK1.0
- */
-
-public class GsRandom extends java.util.Random implements Serializable {
-
- /**
- *
- * ourString is a privately held instance of a String with
- * with some junk characters
- *
- */
-
- static protected String ourString = "854ku45Q985a.lsdk;,.ifpq4z58Ao45u.sdflkjsdgkjqwJKL:EIUR[p4pnm,.zxc239*h1@0*Fn/~5.+3&gwNa(.3K-c/2bd(kb1.(=wvz!/56NIwk-4/(#mDhn%kd#9jas9_n!KC0-c>3*(fbn3Fl)Fhaw.2?nz~l;1q3=Fbak1>ah1Bci23fripB319v*bnFl2Ba-cH$lfb?A)_2bgFo2_+Vv$al+b124kasbFV[2G}b@9ASFbCk2.KIhb4K";
-
- /**
- * Creates a new random number generator. Its seed is initialized to
- * a value based on the current time.
- *
- * @see java.lang.System#currentTimeMillis()
- * @see java.util.Random#Random()
- */
-
- public GsRandom() {
- super();
- }
-
- /**
- * Creates a new random number generator using a single
- * <code>long</code> seed.
- *
- * @param seed the initial seed.
- * @see java.util.Random#Random(long)
- */
-
- public GsRandom(long seed) {
- super(seed);
- }
-
- /**
- * Returns the next pseudorandom, uniformly distributed <code>boolean</code>
- * value from this random number generator's sequence
- *
- * @return the next pseudorandom, uniformly distributed <code>boolean</code>
- * value from this random number generator's sequence.
- */
-
- public boolean nextBoolean() {
-
- return (this.next(1) == 0);
- }
-
- /**
- * Returns the next pseudorandom, uniformly distributed <code>char</code>
- * value from this random number generator's sequence
- * There is a hack here to prevent '}' so as to eliminate the possiblity
- * of generating a sequence which would falsely get marked as a suspect
- * string while we are matching the pattern <code>{[0-9]+}</code>.
- * {@link https://svn.gemstone.com/trac/gemfire/ticket/40415}
- * @return the next pseudorandom, uniformly distributed <code>char</code>
- * value from this random number generator's sequence.
- */
-
- public char nextChar() {
-
- char c = (char) this.next(16);
- if( c == '}' ) c = nextChar(); //prevent right bracket, try again
- return c;
- }
-
- /**
- * Returns the next pseudorandom, uniformly distributed <code>byte</code>
- * value from this random number generator's sequence
- *
- * @return the next pseudorandom, uniformly distributed <code>byte</code>
- * value from this random number generator's sequence.
- */
-
- public byte nextByte() {
-
- return (byte) this.next(8);
- }
-
- /**
- * Returns the next pseudorandom, uniformly distributed <code>double</code>
- * value from this random number generator's sequence within a range
- * from 0 to max.
- *
- * @param max the maximum range (inclusive) for the pseudorandom.
- * @return the next pseudorandom, uniformly distributed <code>double</code>
- * value from this random number generator's sequence.
- */
- public double nextDouble(double max) {
-
- return nextDouble(0.0, max);
-
- }
-
- /**
- * Returns the next pseudorandom, uniformly distributed <code>double</code>
- * value from this random number generator's sequence within a range
- * from min to max.
- *
- * @param min the minimum range (inclusive) for the pseudorandom.
- * @param max the maximum range (inclusive) for the pseudorandom.
- * @return the next pseudorandom, uniformly distributed <code>double</code>
- * value from this random number generator's sequence.
- */
-
- public double nextDouble(double min, double max) {
-
- return nextDouble() * (max - min) + min;
-
- // return nextDouble(max-min) + min;
- }
-
- public short nextShort() {
- return (short) this.nextChar();
- }
-
- /**
- * Returns the next pseudorandom, uniformly distributed <code>long</code>
- * value from this random number generator's sequence within a range
- * from 0 to max.
- *
- * @param max the maximum range (inclusive) for the pseudorandom.
- * @return the next pseudorandom, uniformly distributed <code>long</code>
- * value from this random number generator's sequence.
- */
-
- public long nextLong(long max) {
-
- if (max == Long.MAX_VALUE) {
- max--;
- }
-
- return Math.abs(this.nextLong()) % (max+1);
- }
-
- /**
- * Returns the next pseudorandom, uniformly distributed <code>long</code>
- * value from this random number generator's sequence within a range
- * from min to max.
- *
- * @param min the minimum range (inclusive) for the pseudorandom.
- * @param max the maximum range (inclusive) for the pseudorandom.
- * @return the next pseudorandom, uniformly distributed <code>long</code>
- * value from this random number generator's sequence.
- */
-
- public long nextLong(long min, long max) {
-
-
- return nextLong(max-min) + min;
- }
-
- /**
- * Returns the next pseudorandom, uniformly distributed <code>int</code>
- * value from this random number generator's sequence within a range
- * from 0 to max (inclusive -- which is different from {@link
- * Random#nextInt}).
- *
- * @param max the maximum range (inclusive) for the pseudorandom.
- * @return the next pseudorandom, uniformly distributed <code>int</code>
- * value from this random number generator's sequence.
- */
-
- public int nextInt(int max) {
-
- if (max == Integer.MAX_VALUE) {
- max--;
- }
-
- int theNext = this.nextInt();
- // Math.abs behaves badly when given min int, so avoid
- if (theNext == Integer.MIN_VALUE) {
- theNext = Integer.MIN_VALUE + 1;
- }
- return Math.abs(theNext) % (max+1);
- }
-
- /**
- * Returns the next pseudorandom, uniformly distributed <code>int</code>
- * value from this random number generator's sequence within a range
- * from min to max.
- * If max < min, returns 0 .
- *
- * @param min the minimum range (inclusive) for the pseudorandom.
- * @param max the maximum range (inclusive) for the pseudorandom.
- * @return the next pseudorandom, uniformly distributed <code>int</code>
- * value from this random number generator's sequence.
- */
-
- public int nextInt(int min, int max) {
- if (max < min)
- return 0; // handle max == 0 and avoid divide-by-zero exceptions
-
- return nextInt(max-min) + min;
- }
-
- /**
- * Returns a large, pregenerated string.
- *
- * @return a large, pregenerated string.
- */
-
- private String string() {
- return ourString;
- }
-
- /**
- *
- * Returns a random Date.
- *
- * @return A random Date.
- */
-
- public Date nextDate() {
- return new Date(nextLong());
- }
-
- /**
- *
- * Returns a randomly-selected element of Vector vec.
- *
- */
- public Object randomElement(Vector vec) {
- Object result;
- synchronized (vec) { // fix 26810
- int index = nextInt(0, vec.size() - 1);
- result = vec.elementAt(index);
- }
- return result;
- }
-
- /**
- * Returns a random subset of a pregenerated string. Both the
- * length and offset of the string are pseudorandom values.
- *
- * @return a random subset of a pregenerated string.
- */
-
- public String randomString() {
-
- return this.randomString(this.string().length());
- }
-
- /**
- * Returns a bounded random subset of a pregenerated large
- * string. The length can be no longer than max. max must be no
- * longer than the length of the pregenerated string.
- *
- * @param max the maximum length of the random string to generate.
- * @return a bounded random string with a length between 0 and
- * max length inclusive.
- */
-
- public String randomString(int max) {
-
- int length = this.nextInt(0, max);
- byte[] bytes = new byte[length];
- this.nextBytes(bytes);
- return new String(bytes);
- }
-
- /**
- *
- * Like randomString(), but returns only readable characters.
- *
- */
- public String randomReadableString(int max) {
-
- int stringlen = this.string().length();
- if ( max > stringlen )
- throw new HydraRuntimeException
- (
- "GsRandom.randomReadableString is limited to " + stringlen +
- " characters, cannot create string of length " + max
- );
-
- int length = this.nextInt(0, max);
- int offset = this.nextInt(0, stringlen - length);
- return this.string().substring(offset, offset+length);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/hydra/HydraRuntimeException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/hydra/HydraRuntimeException.java b/gemfire-core/src/test/java/hydra/HydraRuntimeException.java
deleted file mode 100644
index 3114aeb..0000000
--- a/gemfire-core/src/test/java/hydra/HydraRuntimeException.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.pivotal.io/patents.
- *========================================================================
- */
-
-package hydra;
-
-import com.gemstone.gemfire.*;
-
-public class HydraRuntimeException extends GemFireException {
-
- public HydraRuntimeException(String s) {
- super(s);
- }
- public HydraRuntimeException(String s,Exception e) {
- super(s,e);
- }
- public HydraRuntimeException(String s,Throwable t) {
- super(s,t);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/hydra/Log.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/hydra/Log.java b/gemfire-core/src/test/java/hydra/Log.java
deleted file mode 100644
index 63f1620..0000000
--- a/gemfire-core/src/test/java/hydra/Log.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.pivotal.io/patents.
- *========================================================================
- */
-
-package hydra;
-
-import com.gemstone.gemfire.LogWriter;
-
-import hydra.log.AnyLogWriter;
-
-import java.util.Hashtable;
-
-/**
-*
-* Manages a singleton instance of {@link com.gemstone.gemfire.LogWriter}
-* to do all the logging for a VM. The instance is created using
-* <code>createLogWriter</code> and accessed using <code>getLogWriter</code>.
-*
-*/
-public class Log {
-
- // the singleton instance
- private static AnyLogWriter logWriter;
-
- // the name of the singleton instance
- private static String logName;
-
- // cache for log writers
- private static Hashtable cache;
-
- /**
- * Creates a singleton log writer that logs to stdout.
- * @param name the name of the singleton log writer.
- * @param levelName only messages at this level or higher will be logged.
- * @return the singleton log writer.
- * @throws HydraRuntimeException if log writer has already been created.
- * @throws IllegalArgumentException if level is illegal.
- */
- public synchronized static LogWriter createLogWriter( String name, String levelName ) {
- if ( logWriter == null ) {
- logWriter = new AnyLogWriter( levelName );
- } else {
- throw new HydraRuntimeException( "Log writer has already been created" );
- }
- logName = name;
- return logWriter;
- }
- /**
- * Creates a singleton log writer that logs to a file.
- * @param name the name of the singleton log writer.
- * @param filePrefix the prefix for the name of the log file.
- * @param levelName only messages at this level or higher will be logged.
- * @param append whether to append to an existing log file.
- * @return the singleton log writer.
- * @throws HydraRuntimeException if log writer has already been created.
- * @throws IllegalArgumentException if level is illegal.
- */
- public synchronized static LogWriter createLogWriter( String name, String filePrefix, String levelName, boolean append ) {
- if ( logWriter == null ) {
- logWriter = new AnyLogWriter( filePrefix, levelName, append );
- } else {
- throw new HydraRuntimeException( "Log writer has already been created" );
- }
- logName = name;
- return logWriter;
- }
- /**
- * Creates a singleton log writer that logs to a file in a specified directory.
- * @param name the name of the singleton log writer.
- * @param filePrefix the prefix for the name of the log file.
- * @param levelName only messages at this level or higher will be logged.
- * @param dir the directory in which to create the log file.
- * @param append whether to append to an existing log file.
- * @return the singleton log writer.
- * @throws HydraRuntimeException if log writer has already been created.
- * @throws IllegalArgumentException if level is illegal.
- */
- public synchronized static LogWriter createLogWriter( String name, String filePrefix, String levelName, String dir, boolean append ) {
- if ( logWriter == null ) {
- logWriter = new AnyLogWriter( filePrefix, levelName, dir, append );
- } else {
- throw new HydraRuntimeException( "Log writer has already been created" );
- }
- logName = name;
- return logWriter;
- }
- /**
- * Creates a singleton log writer that logs to a file.
- * @param name the name of the singleton log writer.
- * @param filePrefix the prefix for files created by this log writer.
- *
- * @return the singleton log writer.
- * @throws HydraRuntimeException if file can't be created or if log writer has
- * already been created.
- * @throws IllegalArgumentException if level is illegal.
- */
- public synchronized static LogWriter createLogWriter( String name,
- String filePrefix,
- boolean fileLogging,
- String fileLogLevelName,
- int fileMaxKBPerVM ) {
- if ( logWriter == null ) {
- logWriter = new AnyLogWriter( filePrefix, fileLogging, fileLogLevelName,
- fileMaxKBPerVM );
- } else {
- throw new HydraRuntimeException( "Log writer has already been created" );
- }
- logName = name;
- return logWriter;
- }
- /**
- * Closes the singleton log writer. After this method executes, there is no
- * singleton log writer.
- * @throws HydraRuntimeException if the singleton log writer does not exist.
- */
- public static void closeLogWriter() {
- if ( logWriter == null ) {
- throw new HydraRuntimeException( "Log writer does not exist" );
- } else {
- logName = null;
- logWriter = null;
- }
- }
- /**
- * Caches the singleton log writer so another log writer can be created.
- * After this method executes, there is no singleton log writer.
- * @throws HydraRuntimeException if the singleton log writer does not exist or
- * has already been cached.
- */
- public static void cacheLogWriter() {
- if ( logWriter == null ) {
- throw new HydraRuntimeException( "Log writer has not been created" );
- } else {
- if ( cache == null )
- cache = new Hashtable();
- if ( cache.get( logName ) != null )
- throw new HydraRuntimeException( "Log writer " + logName + " has already been cached" );
- cache.put( logName, logWriter );
- logName = null;
- logWriter = null;
- }
- }
- /**
- * Uncaches the log writer with the specified name, blowing away the existing one
- * (unless it was previously cached). After this method executes, the named log
- * writer is the singleton log writer.
- * @param name the name of the log writer to uncache.
- * @return the uncached (now active) log writer.
- * @throws HydraRuntimeException if the named log writer does not exist or there
- * is already a singleton log writer.
- */
- public static LogWriter uncacheLogWriter( String name ) {
- if ( cache == null )
- throw new HydraRuntimeException( "Log writer " + name + " has not been cached" );
- if ( logWriter != null )
- throw new HydraRuntimeException( "Log writer " + name + " is still active" );
- AnyLogWriter lw = (AnyLogWriter) cache.get( name );
- if ( lw == null )
- throw new HydraRuntimeException( "Log writer " + name + " has not been cached" );
- logName = name;
- logWriter = lw;
- return logWriter;
- }
- /**
- * Fetches the singleton log writer.
- * @throws HydraRuntimeException if log writer has not been created.
- */
- public static LogWriter getLogWriter() {
- if ( logWriter == null )
- throw new HydraRuntimeException( "Attempt to getLogWriter() before createLogWriter()" );
- return logWriter;
- }
- /**
- *
- * Fetches the current log level of the singleton log writer.
- *
- */
- public static String getLogWriterLevel() {
- return LogVersionHelper.levelToString(logWriter.getLevel());
- }
- /**
- *
- * Resets the log level of the singleton log writer.
- *
- */
- public static void setLogWriterLevel( String levelName ) {
- logWriter.setLevel(LogVersionHelper.levelNameToCode(levelName));
- }
- /**
- * Small Log test program
- */
- public static void main(String[] args) {
- Thread.currentThread().setName( "chester" );
-
- Log.createLogWriter( "test", "finer" );
-
- Log.getLogWriter().fine( "fine" );
- Log.getLogWriter().finer( "finer" );
- Log.getLogWriter().finest( "finest" );
-
- Log.setLogWriterLevel( "all" );
- Log.getLogWriter().fine( "fine" );
- Log.getLogWriter().finer( "finer" );
- Log.getLogWriter().finest( "finest" );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/hydra/LogVersionHelper.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/hydra/LogVersionHelper.java b/gemfire-core/src/test/java/hydra/LogVersionHelper.java
deleted file mode 100644
index eece272..0000000
--- a/gemfire-core/src/test/java/hydra/LogVersionHelper.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.gopivotal.com/patents.
- *========================================================================
- */
-
-package hydra;
-
-import com.gemstone.gemfire.internal.logging.InternalLogWriter;
-import com.gemstone.gemfire.internal.logging.LoggingThreadGroup;
-import com.gemstone.gemfire.internal.logging.LogWriterImpl;
-import com.gemstone.gemfire.LogWriter;
-
-/**
- * Provides version-dependent support for logging changes.
- */
-public class LogVersionHelper {
-
- protected static String levelToString(int level) {
- return LogWriterImpl.levelToString(level);
- }
-
- protected static int levelNameToCode(String level) {
- return LogWriterImpl.levelNameToCode(level);
- }
-
- protected static ThreadGroup getLoggingThreadGroup(String group, LogWriter logger) {
- return LoggingThreadGroup.createThreadGroup(group, (InternalLogWriter)logger);
- }
-
- protected static String getMergeLogFilesClassName() {
- return "com.gemstone.gemfire.internal.logging.MergeLogFiles";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/hydra/MethExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/hydra/MethExecutor.java b/gemfire-core/src/test/java/hydra/MethExecutor.java
deleted file mode 100644
index c66b6b5..0000000
--- a/gemfire-core/src/test/java/hydra/MethExecutor.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.pivotal.io/patents.
- *========================================================================
- */
-
-package hydra;
-
-//import java.io.*;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-
-import com.gemstone.gemfire.SystemFailure;
-
-/**
-*
-* A class specialized for executing (via reflection) the receiver/selector
-* pairs found in TestTasks.
-*
-*/
-public class MethExecutor {
-
- // @todo lises add static args method
-
- /**
- * Helper method that searches a class (and its superclasses) for a
- * method with the given name and parameter types.
- *
- * @throws NoSuchMethodException
- * If the method cannot be found
- */
- public static Method getMethod(Class c, String methodName, Class[] paramTypes)
- throws NoSuchMethodException {
-
- ArrayList matchingMethods = new ArrayList();
- for (Class q = c; q != null; q = q.getSuperclass()) {
- Method[] methods = q.getDeclaredMethods();
- NEXT_METHOD:
- for (int i = 0; i < methods.length; i++) {
- Method m = methods[i];
- if (!m.getName().equals(methodName)) {
- continue;
- }
-
- Class[] argTypes = m.getParameterTypes();
- if (argTypes.length != paramTypes.length) {
- continue;
- }
-
- for (int j = 0; j < argTypes.length; j++) {
- if(paramTypes[j] == null) {
- if(argTypes[j].isPrimitive()) {
- //this parameter is not ok, the parameter is a primative and the value is null
- continue NEXT_METHOD;
- } else {
- //this parameter is ok, the argument is an object and the value is null
- continue;
- }
- }
- if (!argTypes[j].isAssignableFrom(paramTypes[j])) {
- Class argType = argTypes[j];
- Class paramType = paramTypes[j];
-
- if (argType.isPrimitive()) {
- if ((argType.equals(boolean.class) &&
- paramType.equals(Boolean.class)) ||
- (argType.equals(short.class) &&
- paramType.equals(Short.class)) ||
- (argType.equals(int.class) &&
- paramType.equals(Integer.class)) ||
- (argType.equals(long.class) &&
- paramType.equals(Long.class)) ||
- (argType.equals(float.class) &&
- paramType.equals(Float.class)) ||
- (argType.equals(double.class) &&
- paramType.equals(Double.class)) ||
- (argType.equals(char.class) &&
- paramType.equals(Character.class)) ||
- (argType.equals(byte.class) &&
- paramType.equals(Byte.class)) ||
- false) {
-
- // This parameter is okay, try the next arg
- continue;
- }
- }
- continue NEXT_METHOD;
- }
- }
-
- matchingMethods.add(m);
- }
-
- //We want to check to make sure there aren't two
- //ambiguous methods on the same class. But a subclass
- //can still override a method on a super class, so we'll stop
- //if we found a method on the subclass.
- if(matchingMethods.size() > 0) {
- break;
- }
- }
-
- if(matchingMethods.isEmpty()) {
- StringBuffer sb = new StringBuffer();
- sb.append("Could not find method ");
- sb.append(methodName);
- sb.append(" with ");
- sb.append(paramTypes.length);
- sb.append(" parameters [");
- for (int i = 0; i < paramTypes.length; i++) {
- String name = paramTypes[i] == null ? null : paramTypes[i].getName();
- sb.append(name);
- if (i < paramTypes.length - 1) {
- sb.append(", ");
- }
- }
- sb.append("] in class ");
- sb.append(c.getName());
- throw new NoSuchMethodException(sb.toString());
- }
- if(matchingMethods.size() > 1) {
- StringBuffer sb = new StringBuffer();
- sb.append("Method is ambiguous ");
- sb.append(methodName);
- sb.append(" with ");
- sb.append(paramTypes.length);
- sb.append(" parameters [");
- for (int i = 0; i < paramTypes.length; i++) {
- String name = paramTypes[i] == null ? null : paramTypes[i].getName();
- sb.append(name);
- if (i < paramTypes.length - 1) {
- sb.append(", ");
- }
- }
- sb.append("] in class ");
- sb.append(c.getName());
- throw new NoSuchMethodException(sb.toString());
- }
- else return (Method) matchingMethods.get(0);
- }
-
- /**
- *
- * Send the message "selector" to the class named "receiver".
- * Return the result, including stack trace (if any).
- *
- */
- public static MethExecutorResult execute(String receiver, String selector) {
- return execute(receiver, selector, null);
- }
-
- /**
- * Executes the given static method on the given class with the
- * given arguments.
- */
- public static MethExecutorResult execute(String receiver,
- String selector,
- Object[] args) {
- try {
- // get the class
- Class receiverClass = Class.forName(receiver);
-
- // invoke the method
- Object res = null;
- try {
- Class[] paramTypes;
- if (args == null) {
- paramTypes = new Class[0];
-
- } else {
- paramTypes = new Class[args.length];
- for (int i = 0; i < args.length; i++) {
- if (args[i] == null) {
- paramTypes[i] = null;
-
- } else {
- paramTypes[i] = args[i].getClass();
- }
- }
- }
-
- Method theMethod =
- getMethod(receiverClass, selector, paramTypes);
- theMethod.setAccessible(true);
- res = theMethod.invoke(receiverClass, args);
- return new MethExecutorResult( res );
-
- } catch (InvocationTargetException invTargEx) {
- Throwable targEx = invTargEx.getTargetException();
- if ( targEx == null ) {
- return new MethExecutorResult( res );
-
- } else {
- return new MethExecutorResult(targEx);
- }
- }
-
- }
- catch (VirtualMachineError e) {
- SystemFailure.initiateFailure(e);
- throw e;
- }
- catch (Throwable t) {
-// String s = "While trying to invoke " + receiver + "." +
-// selector;
-// t = new HydraConfigException(s, t);
- return new MethExecutorResult(t);
- }
- }
-
- /**
- *
- * Send the message "selector" to the object "target".
- * Return the result, including stack trace (if any).
- *
- */
- public static MethExecutorResult executeObject(Object target, String selector) {
- return executeObject(target, selector, null);
- }
-
- /**
- * Executes the given instance method on the given object with the
- * given arguments.
- */
- public static MethExecutorResult executeObject(Object target,
- String selector,
- Object[] args) {
- try {
- // get the class
- Class receiverClass = Class.forName(target.getClass().getName());
-
- // invoke the method
- Object res = null;
- try {
- Class[] paramTypes;
- if (args == null) {
- paramTypes = new Class[0];
-
- } else {
- paramTypes = new Class[args.length];
- for (int i = 0; i < args.length; i++) {
- if (args[i] == null) {
- paramTypes[i] = Object.class;
-
- } else {
- paramTypes[i] = args[i].getClass();
- }
- }
- }
-
- Method theMethod =
- getMethod(receiverClass, selector, paramTypes);
- theMethod.setAccessible(true);
- res = theMethod.invoke(target, args);
- return new MethExecutorResult( res );
-
- } catch (InvocationTargetException invTargEx) {
- Throwable targEx = invTargEx.getTargetException();
- if ( targEx == null ) {
- return new MethExecutorResult( res );
-
- } else {
- return new MethExecutorResult(targEx);
- }
- }
-
- }
- catch (VirtualMachineError e) {
- SystemFailure.initiateFailure(e);
- throw e;
- }
- catch (Throwable t) {
- return new MethExecutorResult(t);
- }
- }
-
- /**
- *
- * Send the message "selector" to an instance of the class named "receiver".
- * Return the result, including stack trace (if any).
- *
- */
- public static MethExecutorResult executeInstance( String receiver, String selector ) {
-
- try {
- // get the class
- Class receiverClass = Class.forName(receiver);
- Object target = receiverClass.newInstance();
-
- // invoke the method
- Object res = null;
- try {
- Method theMethod =
- getMethod(receiverClass, selector, new Class[0]);
- res = theMethod.invoke(target, new Object[0] );
- return new MethExecutorResult( res );
-
- } catch (InvocationTargetException invTargEx) {
- Throwable targEx = invTargEx.getTargetException();
- if ( targEx == null ) {
- return new MethExecutorResult( res );
- } else {
- return new MethExecutorResult(targEx);
- }
- }
-
- }
- catch (VirtualMachineError e) {
- SystemFailure.initiateFailure(e);
- throw e;
- }
- catch (Throwable t) {
- return new MethExecutorResult(t);
- }
- }
-
- /**
- *
- * Send the message "selector" to an instance of the class named "receiver".
- * Return the result, including stack trace (if any).
- *
- */
- public static MethExecutorResult executeInstance( String receiver, String selector,
- Class[] types, Object[] args ) {
-
- try {
- // get the class
- Class receiverClass = Class.forName(receiver);
- Constructor init =
- receiverClass.getDeclaredConstructor(new Class[0]);
- init.setAccessible(true);
- Object target = init.newInstance(new Object[0]);
-
- // invoke the method
- Object res = null;
- try {
- Method theMethod = getMethod(receiverClass, selector, types);
- res = theMethod.invoke(target, args );
- return new MethExecutorResult( res );
-
- } catch (InvocationTargetException invTargEx) {
- Throwable targEx = invTargEx.getTargetException();
- if ( targEx == null ) {
- return new MethExecutorResult( res );
-
- } else {
- return new MethExecutorResult(targEx);
- }
- }
-
- }
- catch (VirtualMachineError e) {
- SystemFailure.initiateFailure(e);
- throw e;
- }
- catch (Throwable t) {
- return new MethExecutorResult(t);
- }
- }
-
- /**
- *
- * A small program for testing this class.
- *
- */
- public static String testMethod1() {
- return "The result is: " + System.currentTimeMillis();
- }
- public static String testMethod2() {
- throw new ArrayIndexOutOfBoundsException("frip");
- }
- public static void main(String[] args) {
- MethExecutorResult result = null;
- result = MethExecutor.execute( "hydra.MethExecutor", "testMethod1" );
- System.out.println(result.toString());
- result = MethExecutor.execute( "hydra.MethExecutor", "testMethod2" );
- System.out.println(result.toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/hydra/MethExecutorResult.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/hydra/MethExecutorResult.java b/gemfire-core/src/test/java/hydra/MethExecutorResult.java
deleted file mode 100644
index 7e882ef..0000000
--- a/gemfire-core/src/test/java/hydra/MethExecutorResult.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.pivotal.io/patents.
- *========================================================================
- */
-
-package hydra;
-
-import java.io.*;
-
-/**
-*
-* The result of a MethExecutor execute method.
-*
-*/
-public class MethExecutorResult implements Serializable {
-
- /** A "result" object that indicates that an exception occurred
- * while invoking the method */
- public static final Serializable EXCEPTION_OCCURRED = new
- Serializable() {
- public boolean equals(Object o) {
- // Allows instances to be compared across VMs
- return o != null && this.getClass().equals(o.getClass());
- }
-
- public String toString() {
- return "EXCEPTION_OCCURRED";
- }
- };
-
- /** A "exception" object that indicates that an exception could not
- * be serialized. */
- public static final Throwable NONSERIALIZABLE_EXCEPTION = new
- Throwable() {
- public boolean equals(Object o) {
- // Allows instances to be compared across VMs
- return o != null && this.getClass().equals(o.getClass());
- }
-
- public String toString() {
- return "NONSERIALIZABLE_EXCEPTION";
- }
- };
-
-
- //////////////////// Instance Methods ///////////////////////////
-
- /** The result of execution (may be an exception or error type) */
- private Object result;
-
- /** The exception that resulted from invoking the method */
- private Throwable exception;
-
- /** Type of the exception (if applicable) */
- private String exceptionClassName;
-
- /** Message of the exception (if applicable) */
- private String exceptionMessage;
-
- /** Stack trace information (if applicable) */
- private String stackTrace;
-
- public MethExecutorResult() {
- this.result = null;
- }
-
- public MethExecutorResult( Object result ) {
- this.result = result;
- }
-
- /**
- * This constructor is invoked when invoking a method resulted in an
- * exception being thrown. The "result" is set to {@link
- * #EXCEPTION_OCCURRED}. If the exception could not be serialized,
- * {@link #getException()} will return IOException with the exception
- * stack as the message.
- */
- public MethExecutorResult(Throwable thr) {
- this.result = EXCEPTION_OCCURRED;
- this.exceptionClassName = thr.getClass().getName();
- this.exceptionMessage = thr.getMessage();
-
- StringWriter sw = new StringWriter();
-
- if (thr instanceof SchedulingOrder) {
- this.stackTrace = "No stack trace for SchedulingOrder\n";
- this.exception = thr;
-
-
- } else {
- thr.printStackTrace(new PrintWriter(sw, true));
- this.stackTrace = sw.toString();
-
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(thr);
- this.exception = thr;
-
- } catch (IOException ex) {
- sw = new StringWriter();
- ex.printStackTrace(new PrintWriter(sw, true));
- this.exception = new IOException(sw.toString());
- }
- }
- }
-
- public String toString() {
- StringBuffer s = new StringBuffer();
- s.append( this.getResult() );
- s.append( "\n" );
- if ( this.getStackTrace() != null ) {
- s.append( this.getStackTrace() );
- }
- return s.toString();
- }
-
- /**
- * Returns the result of the method call. If an exception was
- * thrown during the method call, {@link #EXCEPTION_OCCURRED} is
- * returned.
- *
- * @see #exceptionOccurred()
- */
- public Object getResult() {
- return this.result;
- }
-
- /**
- * Returns the name of the exception class of the exception that
- * was thrown while invoking a method. If no exception was thrown,
- * <code>null</code> is returned.
- */
- public String getExceptionClassName() {
- return this.exceptionClassName;
- }
-
- /**
- * Returns the message of the exception that was thrown while
- * invoking a method. If no exception was thrown, <code>null</code>
- * is returned.
- */
- public String getExceptionMessage() {
- return this.exceptionMessage;
- }
-
- /**
- * Returns the stack trace of the exception that was thrown while
- * invoking a method. If no exception was thrown, <code>null</code>
- * is returned.
- */
- public String getStackTrace() {
- return this.stackTrace;
- }
-
- /**
- * Returns the exception that was thrown while invoking a method.
- * If the exception could not be serialized, then {@link
- * #NONSERIALIZABLE_EXCEPTION} is returned. If no exception was
- * thrown, <code>null</code> is returned.
- */
- public Throwable getException() {
- return this.exception;
- }
-
- /**
- * Returns whether or not an exception occurred while invoking the
- * method
- */
- public boolean exceptionOccurred() {
- return EXCEPTION_OCCURRED.equals(this.result);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/hydra/SchedulingOrder.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/hydra/SchedulingOrder.java b/gemfire-core/src/test/java/hydra/SchedulingOrder.java
deleted file mode 100644
index eea317b..0000000
--- a/gemfire-core/src/test/java/hydra/SchedulingOrder.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.pivotal.io/patents.
- *========================================================================
- */
-
-package hydra;
-
-import com.gemstone.gemfire.*;
-
-/**
- * Abstract class for clients giving scheduling instructions to the
- * hydra master.
- * <p>
- * Use the arguments to give the reason for the exception.
- */
-
-public abstract class SchedulingOrder extends GemFireException {
- public SchedulingOrder() {
- super();
- }
- public SchedulingOrder(String s) {
- super(s);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/hydra/log/AnyLogWriter.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/hydra/log/AnyLogWriter.java b/gemfire-core/src/test/java/hydra/log/AnyLogWriter.java
deleted file mode 100644
index a6c6607..0000000
--- a/gemfire-core/src/test/java/hydra/log/AnyLogWriter.java
+++ /dev/null
@@ -1,546 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.pivotal.io/patents.
- *========================================================================
- */
-
-package hydra.log;
-
-import hydra.HydraRuntimeException;
-
-import com.gemstone.gemfire.*;
-import com.gemstone.gemfire.i18n.LogWriterI18n;
-import com.gemstone.gemfire.internal.logging.InternalLogWriter;
-import com.gemstone.gemfire.internal.logging.LocalLogWriter;
-import com.gemstone.gemfire.internal.logging.LogWriterImpl;
-import com.gemstone.org.jgroups.util.StringId;
-
-import java.io.*;
-
-/**
- *
- * A {@link com.gemstone.gemfire.LogWriter} that writes to a file logger,
- * depending on whether it is turned on via {@link LogPrms#file_logging}.
- * <p>
- * The log level query methods answer true if a file logger is active and
- * answer true. See {@link LogPrms#file_logLevel}.
- */
-
-public class AnyLogWriter implements InternalLogWriter {
-
- private boolean FILE_LOGGING;
-// private String filePrefix;
- private InternalLogWriter file;
-
- /**
- * Create a log writer to stdout.
- * @param levelName the log level.
- */
- public AnyLogWriter( String levelName ) {
- this.FILE_LOGGING = true;
- int level = LogWriterImpl.levelNameToCode( levelName );
- this.file = new LocalLogWriter( level, System.out );
- }
-
- /**
- * Create a log writer to a file of unlimited size.
- * @param filePrefix the prefix for the filename of the log.
- * @param levelName the log level.
- */
- public AnyLogWriter( String filePrefix, String levelName, boolean append ) {
- this.FILE_LOGGING = true;
- FileOutputStream fos;
- String fn = filePrefix + ".log";
- try {
- fos = new FileOutputStream( fn, append );
- } catch( IOException e ) {
- throw new HydraRuntimeException( "Unable to open " + fn, e );
- }
- PrintStream ps = new PrintStream( fos, true ); // autoflush
- System.setOut( ps ); System.setErr( ps );
- int level = LogWriterImpl.levelNameToCode( levelName );
- this.file = new LocalLogWriter( level, ps );
- }
-
- /**
- * Create a log writer to a file of unlimited size in the specified directory.
- * @param filePrefix the prefix for the filename of the log.
- * @param levelName the log level.
- * @param dir the directory in which to create the file.
- */
- public AnyLogWriter( String filePrefix, String levelName, String dir, boolean append ) {
- this.FILE_LOGGING = true;
- FileOutputStream fos;
- String fn = dir + File.separator + filePrefix + ".log";
- try {
- fos = new FileOutputStream( fn, append );
- } catch( IOException e ) {
- throw new HydraRuntimeException( "Unable to open " + fn, e );
- }
- PrintStream ps = new PrintStream( fos, true ); // autoflush
- System.setOut( ps ); System.setErr( ps );
- int level = LogWriterImpl.levelNameToCode( levelName );
- this.file = new LocalLogWriter( level, ps );
- }
-
- /**
- * Create a log writer to a file. May be circular.
- * @param filePrefix the prefix for names of files created by this logwriter.
- * @param fileLogging turn on logging to the file.
- * @param fileLogLevelName name of the file log level.
- * @param fileMaxKBPerVM the maximum size of the file log per VM, in kilobytes .
- */
- public AnyLogWriter( String filePrefix, boolean fileLogging,
- String fileLogLevelName, int fileMaxKBPerVM ) {
-
-// this.filePrefix = filePrefix;
- if ( fileLogging ) {
- this.FILE_LOGGING = fileLogging;
- if ( fileMaxKBPerVM < 0 )
- throw new IllegalArgumentException( "Illegal (negative) file log length: " + fileMaxKBPerVM );
- int maxBytes = fileMaxKBPerVM * 1024;
- CircularOutputStream cos;
- String fn = filePrefix + ".log";
- try {
- cos = new CircularOutputStream( fn, maxBytes );
- } catch( IOException e ) {
- throw new HydraRuntimeException( "Unable to create " + fn, e );
- }
- // create a local log writer using the circular file
- int level = LogWriterImpl.levelNameToCode( fileLogLevelName );
- this.file = new LocalLogWriter( level, new PrintStream( cos ) );
- }
- }
-
- /**
- * Gets the writer's level. Returns the level obtained from active logger.
- */
- public int getLevel() {
- if ( FILE_LOGGING )
- return ((LocalLogWriter)file).getLogWriterLevel();
- else
- return LogWriterImpl.NONE_LEVEL;
- }
- /**
- * Sets the writer's level. Applies to any active logger.
- * @throws IllegalArgumentException if level is not in legal range
- */
- public void setLevel(int newLevel) {
- if ( FILE_LOGGING )
- ((LocalLogWriter)file).setLevel( newLevel );
- }
-
- public void setLogWriterLevel(int newLevel) {
- setLevel(newLevel);
- }
-
-////////////////////////////////////////////////////////////////////////////////
-//// LOGWRITER INTERFACE /////
-////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#severeEnabled}.
- * Answers true if the file logger answers true.
- */
- public boolean severeEnabled() {
- if ( FILE_LOGGING )
- return file.severeEnabled();
- else
- return false;
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#severe(String,Throwable)}.
- */
- public void severe(String msg, Throwable ex) {
- if ( FILE_LOGGING ) file.severe(msg,ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#severe(String)}.
- */
- public void severe(String msg) {
- if ( FILE_LOGGING ) file.severe(msg);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#severe(Throwable)}.
- */
- public void severe(Throwable ex) {
- if ( FILE_LOGGING ) file.severe(ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#errorEnabled}.
- * Answers true if the file logger answers true.
- */
- public boolean errorEnabled() {
- if ( FILE_LOGGING )
- return file.errorEnabled();
- else
- return false;
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#error(String,Throwable)}.
- */
- public void error(String msg, Throwable ex) {
- if ( FILE_LOGGING ) file.error(msg, ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#error(String)}.
- */
- public void error(String msg) {
- if ( FILE_LOGGING ) file.error(msg);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#error(Throwable)}.
- */
- public void error(Throwable ex) {
- if ( FILE_LOGGING ) file.error(ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#warningEnabled}.
- * Answers true if the file logger answers true.
- */
- public boolean warningEnabled() {
- if ( FILE_LOGGING )
- return file.warningEnabled();
- else
- return false;
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#warning(String,Throwable)}.
- */
- public void warning(String msg, Throwable ex) {
- if ( FILE_LOGGING ) file.warning(msg,ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#warning(String)}.
- */
- public void warning(String msg) {
- if ( FILE_LOGGING ) file.warning(msg);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#warning(Throwable)}.
- */
- public void warning(Throwable ex) {
- if ( FILE_LOGGING ) file.warning(ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#infoEnabled}.
- * Answers true if the file logger answers true.
- */
- public boolean infoEnabled() {
- if ( FILE_LOGGING )
- return file.infoEnabled();
- else
- return false;
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#info(String,Throwable)}.
- */
- public void info(String msg, Throwable ex) {
- if ( FILE_LOGGING ) file.info(msg,ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#info(String)}.
- */
- public void info(String msg) {
- if ( FILE_LOGGING ) file.info(msg);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#info(Throwable)}.
- */
- public void info(Throwable ex) {
- if ( FILE_LOGGING ) file.info(ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#configEnabled}.
- * Answers true if the file logger answers true.
- */
- public boolean configEnabled() {
- if ( FILE_LOGGING )
- return file.configEnabled();
- else
- return false;
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#config(String,Throwable)}.
- */
- public void config(String msg, Throwable ex) {
- if ( FILE_LOGGING ) file.config(msg,ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#config(String)}.
- */
- public void config(String msg) {
- if ( FILE_LOGGING ) file.config(msg);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#config(Throwable)}.
- */
- public void config(Throwable ex) {
- if ( FILE_LOGGING ) file.config(ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#fineEnabled}.
- * Answers true if the file logger answers true.
- */
- public boolean fineEnabled() {
- if ( FILE_LOGGING )
- return file.fineEnabled();
- else
- return false;
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#fine(String,Throwable)}.
- */
- public void fine(String msg, Throwable ex) {
- if ( FILE_LOGGING ) file.fine(msg,ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#fine(String)}.
- */
- public void fine(String msg) {
- if ( FILE_LOGGING ) file.fine(msg);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#fine(Throwable)}.
- */
- public void fine(Throwable ex) {
- if ( FILE_LOGGING ) file.fine(ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#finerEnabled}.
- * Answers true if the file logger answers true.
- */
- public boolean finerEnabled() {
- if ( FILE_LOGGING )
- return file.finerEnabled();
- else
- return false;
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#finer(String,Throwable)}.
- */
- public void finer(String msg, Throwable ex) {
- if ( FILE_LOGGING ) file.finer(msg,ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#finer(String)}.
- */
- public void finer(String msg) {
- if ( FILE_LOGGING ) file.finer(msg);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#finer(Throwable)}.
- */
- public void finer(Throwable ex) {
- if ( FILE_LOGGING ) file.finer(ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#finestEnabled}.
- * Answers true if the file logger answers true.
- */
- public boolean finestEnabled() {
- if ( FILE_LOGGING )
- return file.finestEnabled();
- else
- return false;
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#finest(String,Throwable)}.
- */
- public void finest(String msg, Throwable ex) {
- if ( FILE_LOGGING ) file.finest(msg,ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#finest(String)}.
- */
- public void finest(String msg) {
- if ( FILE_LOGGING ) file.finest(msg);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#finest(Throwable)}.
- */
- public void finest(Throwable ex) {
- if ( FILE_LOGGING ) file.finest(ex);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#entering(String,String)}.
- */
- public void entering(String sourceClass, String sourceMethod) {
- if ( FILE_LOGGING ) file.entering(sourceClass,sourceMethod);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#exiting(String,String)}.
- */
- public void exiting(String sourceClass, String sourceMethod) {
- if ( FILE_LOGGING ) file.exiting(sourceClass,sourceMethod);
- }
- /**
- * Implements {@link com.gemstone.gemfire.LogWriter#throwing(String,String,Throwable)}.
- */
- public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {
- if ( FILE_LOGGING ) file.throwing(sourceClass,sourceMethod,thrown);
- }
- public java.util.logging.Handler getHandler() {
- return null;
- }
-
- public void config(StringId msgId, Object param, Throwable ex) {
- config(msgId.toLocalizedString(param), ex);
- }
-
- public void config(StringId msgId, Object param) {
- config(msgId.toLocalizedString(param));
- }
-
- public void config(StringId msgId, Object[] params, Throwable ex) {
- config(msgId.toLocalizedString(params), ex);
- }
-
- public void config(StringId msgId, Object[] params) {
- config(msgId.toLocalizedString(params));
- }
-
- public void config(StringId msgId, Throwable ex) {
- config(msgId.toLocalizedString(), ex);
- }
-
- public void config(StringId msgId) {
- config(msgId.toLocalizedString());
- }
-
- public void error(StringId msgId, Object param, Throwable ex) {
- error(msgId.toLocalizedString(param), ex);
- }
-
- public void error(StringId msgId, Object param) {
- error(msgId.toLocalizedString(param));
- }
-
- public void error(StringId msgId, Object[] params, Throwable ex) {
- error(msgId.toLocalizedString(params), ex);
- }
-
- public void error(StringId msgId, Object[] params) {
- error(msgId.toLocalizedString(params));
- }
-
- public void error(StringId msgId, Throwable ex) {
- error(msgId.toLocalizedString(), ex);
- }
-
- public void error(StringId msgId) {
- error(msgId.toLocalizedString());
- }
-
- public void info(StringId msgId, Object param, Throwable ex) {
- info(msgId.toLocalizedString(param), ex);
- }
-
- public void info(StringId msgId, Object param) {
- info(msgId.toLocalizedString(param));
- }
-
- public void info(StringId msgId, Object[] params, Throwable ex) {
- info(msgId.toLocalizedString(params), ex);
- }
-
- public void info(StringId msgId, Object[] params) {
- info(msgId.toLocalizedString(params));
- }
-
- public void info(StringId msgId, Throwable ex) {
- info(msgId.toLocalizedString(), ex);
- }
-
- public void info(StringId msgId) {
- info(msgId.toLocalizedString());
- }
-
- public void severe(StringId msgId, Object param, Throwable ex) {
- severe(msgId.toLocalizedString(param), ex);
- }
-
- public void severe(StringId msgId, Object param) {
- severe(msgId.toLocalizedString(param));
- }
-
- public void severe(StringId msgId, Object[] params, Throwable ex) {
- severe(msgId.toLocalizedString(params), ex);
- }
-
- public void severe(StringId msgId, Object[] params) {
- severe(msgId.toLocalizedString(params));
- }
-
- public void severe(StringId msgId, Throwable ex) {
- severe(msgId.toLocalizedString(), ex);
- }
-
- public void severe(StringId msgId) {
- severe(msgId.toLocalizedString());
- }
-
- public void warning(StringId msgId, Object param, Throwable ex) {
- warning(msgId.toLocalizedString(param), ex);
- }
-
- public void warning(StringId msgId, Object param) {
- warning(msgId.toLocalizedString(param));
- }
-
- public void warning(StringId msgId, Object[] params, Throwable ex) {
- warning(msgId.toLocalizedString(params), ex);
- }
-
- public void warning(StringId msgId, Object[] params) {
- warning(msgId.toLocalizedString(params));
- }
-
- public void warning(StringId msgId, Throwable ex) {
- warning(msgId.toLocalizedString(), ex);
- }
-
- public void warning(StringId msgId) {
- warning(msgId.toLocalizedString());
- }
- /* (non-Javadoc)
- * @see com.gemstone.gemfire.LogWriterI18n#convertToLogWriter()
- */
- public LogWriter convertToLogWriter() {
- return this;
- }
-
- /* (non-Javadoc)
- * @see com.gemstone.gemfire.LogWriter#convertToLogWriterI18n()
- */
- public LogWriterI18n convertToLogWriterI18n() {
- return this;
- }
-
- @Override
- public int getLogWriterLevel() {
- return file.getLogWriterLevel();
- }
-
- @Override
- public boolean isSecure() {
- return false;
- }
-
- @Override
- public String getConnectionName() {
- return null;
- }
-
- @Override
- public void put(int msgLevel, String msg, Throwable exception) {
- file.put(msgLevel, msg, exception);
- }
-
- @Override
- public void put(int msgLevel, StringId msgId, Object[] params,Throwable exception) {
- file.put(msgLevel, msgId, params, exception);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/hydra/log/CircularOutputStream.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/hydra/log/CircularOutputStream.java b/gemfire-core/src/test/java/hydra/log/CircularOutputStream.java
deleted file mode 100644
index f492321..0000000
--- a/gemfire-core/src/test/java/hydra/log/CircularOutputStream.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.pivotal.io/patents.
- *========================================================================
- */
-package hydra.log;
-
-import java.io.*;
-
-/**
- * Implements a circular output stream with an upper limit on the number of bytes
- * it contains.
- */
-public class CircularOutputStream extends OutputStream {
-
- private static byte marker = '%';
-
- String name;
- int maxBytes;
- boolean rolling = false;
- RandomAccessFile raf;
-
- /**
- * Constructs a new circular output stream.
- * @param name the name of the output stream.
- * @param maxBytes the maximum number of bytes in the output stream.
- * @throws IOException if the stream cannot be created or written.
- */
- public CircularOutputStream( String name, int maxBytes )
- throws IOException {
- this.name = name;
- this.maxBytes = maxBytes;
- this.rolling = ( maxBytes > 0 );
- try {
- this.raf = new RandomAccessFile( name, "rw" );
- } catch( FileNotFoundException e ) {
- e.printStackTrace();
- throw new IOException( "Unable to create stream named " + name );
- }
- if ( this.rolling ) {
- // write the initial marker
- this.raf.write( marker );
- }
- }
- /**
- * Implements {@link java.io.OutputStream#close}.
- */
- /*
- public void close() {
- this.raf.close();
- }
- */
- /**
- * Implements {@link java.io.OutputStream#flush}.
- */
- /*
- public void flush() {
- }
- */
- /**
- * Implements {@link java.io.OutputStream#write(byte[])}.
- */
- @Override
- public void write( byte[] b ) throws IOException {
- write( b, 0, b.length );
- }
- /**
- * Implements {@link java.io.OutputStream#write(byte[],int,int)}.
- */
- @Override
- public void write( byte[] b, int off, int len ) throws IOException {
- if ( this.rolling ) {
- // back over marker character
- long fptr = this.raf.getFilePointer() - 1;
- this.raf.seek( fptr );
- // write bytes
- int space = (int)( this.maxBytes - fptr );
- if ( len <= space ) {
- this.raf.write( b, off, len );
- } else {
- this.raf.write( b, off, space );
- this.raf.seek(0);
- this.raf.write( b, off + space, len - space );
- }
- // wrap around if landed at the end
- if ( this.raf.getFilePointer() == this.maxBytes )
- this.raf.seek(0);
- // write marker character
- this.raf.write( marker );
- } else {
- this.raf.write( b, off, len );
- }
- }
- /**
- * Implements {@link java.io.OutputStream#write(int)}.
- */
- @Override
- public void write( int b ) throws IOException {
- // back over marker character
- long fptr = this.raf.getFilePointer() - 1;
- this.raf.seek( fptr );
- // write byte
- this.raf.writeByte( b );
- // wrap around if landed at the end
- if ( this.raf.getFilePointer() == this.maxBytes )
- this.raf.seek(0);
- // write marker character
- this.raf.write( marker );
- }
-
- public static void main( String[] args ) throws IOException {
- CircularOutputStream t = new CircularOutputStream( "frip", 10 );
- PrintStream ps = new PrintStream( t, true ); // autoflush
- System.setOut( ps ); System.setErr( ps );
-
- System.out.println( "WHERE WILL THIS GO?" );
- String s = "AND WHAT ABOUT THIS?\n";
- t.write( s.getBytes() );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/parReg/query/unittest/NewPortfolio.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/parReg/query/unittest/NewPortfolio.java b/gemfire-core/src/test/java/parReg/query/unittest/NewPortfolio.java
deleted file mode 100755
index db246e8..0000000
--- a/gemfire-core/src/test/java/parReg/query/unittest/NewPortfolio.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package parReg.query.unittest;
-
-import hydra.Log;
-
-import java.io.Serializable;
-import java.util.*;
-
-/**
- * A version of the Portfolio Object used for query.
- */
-public class NewPortfolio implements Serializable {
-
- protected String myVersion;
-
- protected static final Random rng = new Random();
-
- protected int NUM_OF_TYPES = 10;
- protected int MAX_NUM_OF_POSITIONS = 5;
- protected int NUM_OF_SECURITIES = 200;
- private int MAX_QTY = 100; //max is 100*100
- private int MAX_PRICE = 100;
- protected int id = 0;
- protected String name = "name"; //key value, needs to be unique
- protected String status = "status";
- protected String type = "type";
- protected Map positions = new HashMap();
- public String undefinedTestField = null;
-
- public NewPortfolio() {
- //use default
- myVersion = "tests/parReg.query.NewPortfolio";
- }
-
- /**
- * Constructor to randomly populate the portfolio.
- * @param name
- * @param id
- */
- public NewPortfolio(String name, int id) {
- myVersion = "tests/parReg.query.NewPortfolio";
- this.name = name;
- this.id = id;
-
- this.status = id % 2 == 0 ? "active" : "inactive";
- this.type = "type" + (id % NUM_OF_TYPES);
-
- setPositions();
- }
-
- public int getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public String getStatus() {
- return status;
- }
-
- public String getType() {
- return type;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public void init( int i ) {
- this.name = new Integer(i).toString();
- this.id = i;
- this.status = i % 2 == 0 ? "active" : "inactive";
- this.type = "type" + (i % NUM_OF_TYPES);
-
- setPositions();
-
- }
-
- private void setPositions() {
- int numOfPositions = rng.nextInt(MAX_NUM_OF_POSITIONS);
- if (numOfPositions == 0)
- numOfPositions++;
-
- int secId = rng.nextInt(NUM_OF_SECURITIES);
-
- for (int i=0; i < numOfPositions; i++) {
- Properties props = getProps();
-
-// secId needs to be UNIQUE in one portfolio, keep track MAX_NUM_OF_POSITIONS and NUM_OF_SECURITIES
- secId += i * 7;
- if (secId > NUM_OF_SECURITIES)
- secId -= NUM_OF_SECURITIES;
- props.setProperty("secId", new Integer(secId).toString());
-
- Position pos = new Position();
- pos.init(props);
- this.positions.put(pos.getSecId(), pos);
- }
- }
-
- public void validate( int index ) {
- //do nothing
- }
-
- public int getIndex() {
- return this.id;
- }
-
- public Map getPositions(){
- return positions;
- }
-
- /**
- * To provide random values to populate a position.
- * @return
- */
- protected Properties getProps() {
- Properties props = new Properties();
- Double qty = new Double(rng.nextInt(MAX_QTY) * 100.00);
- Double mktValue = new Double(rng.nextDouble() * MAX_PRICE);
-
- props.setProperty("qty", qty.toString());
- props.setProperty("mktValue", mktValue.toString());
-
- return props;
- }
-
- /**
- * To enable the comparison.
- */
- public boolean equals(Object anObj) {
-
- if (anObj == null) {
- return false;
- }
-// Log.getLogWriter().info("comparing\n"+this+"\n and "+anObj);
-
- if (anObj.getClass().getName().equals(this.getClass().getName())) { // cannot do class identity check for pdx tets
-// Log.getLogWriter().info("checkpoint 1,.this class is checked " + this.getClass().getName() );
- NewPortfolio np = (NewPortfolio)anObj;
- if (!np.name.equals(this.name) || (np.id != this.id) || !np.type.equals(this.type) || !np.status.equals(this.status)) {
-// Log.getLogWriter().info("checkpoint 1,obj " +np.name + " " + np.id + " " + np.type );
- return false;
- }
-// Log.getLogWriter().info("checkpoint 2, NP name, id checked" );
-
- if (np.positions == null) {
- if (this.positions != null) {
- return false;
- }
- } else {
-// Log.getLogWriter().info("checkpoint 3, checking position size" );
- if (np.positions.size() != this.positions.size()) {
- Log.getLogWriter().info("checkpoint 3, position size failed" );
- return false;
- }
- else { //loops thru the map of positions
- Iterator itr = np.positions.values().iterator();
- Position pos;
- while (itr.hasNext()) {
-// Log.getLogWriter().info("checkpoint 4, to check iteration" );
- pos = (Position)itr.next();
-// Log.getLogWriter().info("checkpoint 4, to check pos" );
- if (!this.positions.containsValue(pos)){
-// Log.getLogWriter().info("checkpoint 5, check pos failed" );
- return false;
- }
- }
- }
- }
- } else {
- //not same class
-// Log.getLogWriter().info("checkpoint 6, not the same class");
- return false;
- }
- return true;
- }
-
- public int hashCode() {
- int result = 17;
- result = 37 * result + name.hashCode();
- result = 37 * result + status.hashCode();
- result = 37 * result + type.hashCode();
- result = 37 * result + id;
- result = 37 * result + positions.hashCode();
-
- return result;
- }
-
- /** Create a map of fields and field values to use to write to the blackboard
- * since PdxSerialiables cannot be put on the blackboard since the MasterController
- * does not have pdx objects on its classpath. For PdxSerializables
- * we put this Map on the blackboard instead.
- */
- public Map createPdxHelperMap() {
- Map fieldMap = new HashMap();
- fieldMap.put("className", this.getClass().getName());
- fieldMap.put("myVersion", myVersion);
- fieldMap.put("id", id);
- fieldMap.put("name", name);
- fieldMap.put("status", status);
- fieldMap.put("type", type);
- fieldMap.put("positions", positions);
- fieldMap.put("undefinedTestField", undefinedTestField);
-// Log.getLogWriter().info("created map in tests/parReg.query.NewPortfolio: " + fieldMap);
- return fieldMap;
- }
-
- /** Restore the fields of this instance using the values of the Map, created
- * by createPdxHelperMap()
- */
- public void restoreFromPdxHelperMap(Map aMap) {
-// Log.getLogWriter().info("restoring from map into " + this.getClass().getName() + ": " + aMap);
- this.myVersion = (String)aMap.get("myVersion");
- this.id = (Integer)aMap.get("id");
- this.name = (String)aMap.get("name");
- this.status = (String)aMap.get("status");
- this.type = (String)aMap.get("type");
- this.positions = (Map)aMap.get("positions");
- this.undefinedTestField = (String)aMap.get("undefinedTestField");
-// Log.getLogWriter().info("returning instance from map in tests/parReg.query.NewPortfolio: " + this);
- }
-
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("NewPortfolio [ID=" + this.id + " status=" + status);
- sb.append(" name=" + this.name);
-
- Iterator iter = positions.entrySet().iterator();
- sb.append(" Positions:[ ");
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
- sb.append(entry.getKey() + ":" + entry.getValue() + ", ");
- }
- sb.append("] ]");
- return sb.toString();
- }
-
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/parReg/query/unittest/Position.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/parReg/query/unittest/Position.java b/gemfire-core/src/test/java/parReg/query/unittest/Position.java
deleted file mode 100755
index 681a78a..0000000
--- a/gemfire-core/src/test/java/parReg/query/unittest/Position.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-
-package parReg.query.unittest;
-
-import java.util.*;
-import java.io.Serializable;
-import com.gemstone.gemfire.cache.Declarable;
-
-/**
- * Represents a number of shares of a stock ("security") held in a
- * {@link NewPortfolio}.
- *
- * <P>
- *
- * This class is <code>Serializable</code> because we want it to be
- * distributed to multiple members of a distributed system. Because
- * this class is <code>Declarable</code>, we can describe instances of
- * it in a GemFire <code>cache.xml</code> file.
- *
- * @author GemStone Systems, Inc.
- * @since 4.0
- */
-public class Position implements Declarable, Serializable, Comparable {
-
- private static final Random rng = new Random();
-
- protected String secId;
- protected double qty;
- protected double mktValue;
- private final int NUM_OF_SECURITIES = 200;
- private final int MAX_PRICE = 100;
-
- public void init(Properties props) {
- this.secId = props.getProperty("secId");
- this.qty = Double.parseDouble(props.getProperty("qty"));
- this.mktValue = Double.parseDouble(props.getProperty("mktValue"));
- }
-
- /**
- * Returns the id of the security held in this position.
- */
- public String getSecId(){
- return this.secId;
- }
-
- /**
- * Returns the number of shares held in this position.
- */
- public double getQty(){
- return this.qty;
- }
-
- /**
- * Returns the value of this position.
- */
- public double getMktValue() {
- return this.mktValue;
- }
-
- public String toString(){
- return "Position [secId="+secId+" qty="+this.qty+" mktValue="+mktValue+"]";
- }
-
- public static String toString(List aList) {
- StringBuffer aStr = new StringBuffer();
- aStr.append("List of size " + aList.size() + "\n");
- for (int i = 0; i < aList.size(); i++) {
- Object anObj = aList.get(i);
- if (anObj instanceof Position) {
- Position p = (Position)(anObj);
- aStr.append(p.toString());
- }
- aStr.append("\n");
- }
- return aStr.toString();
- }
-
- /**
- * To enable the comparison.
- */
- public boolean equals(Object anObj) {
- if (anObj == null) {
- return false;
- }
- if (anObj.getClass() == this.getClass()) {
- Position pos = (Position)anObj;
- if ((pos.mktValue != this.mktValue) || (pos.qty != this.qty)) {
- return false;
- }
-
- if (pos.secId == null) {
- if (this.secId != null) {
-
- return false;
- }
- } else {
- if (!(pos.secId.equals(this.secId))) {
-
- return false;
- }
- }
- } else {
-
- return false;
- }
- return true;
- }
-
- public int hashCode() {
- int result = 17;
- result = 37 * result + (int) (Double.doubleToLongBits(mktValue)^(Double.doubleToLongBits(mktValue)>>>32));
- result = 37 * result + (int) (Double.doubleToLongBits(qty)^(Double.doubleToLongBits(qty)>>>32));
- result = 37 * result + secId.hashCode();
-
- return result;
- }
-
- /**
- * to configure position using index, set quantity equal to the index
- */
- public void init(int i) {
- this.secId = new Integer(rng.nextInt(NUM_OF_SECURITIES)).toString();
- this.qty = new Double(i).doubleValue();
- this.mktValue = new Double(rng.nextDouble() * MAX_PRICE ).doubleValue();
- }
-
- public int getIndex() {
- return (int)this.qty;
- }
-
- public void validate (int index){
- }
-
- @Override
- public int compareTo(Object o) {
- if( o == this) {
- return 0;
- }else {
- if (o instanceof Position) {
- return Integer.valueOf(this.hashCode()).compareTo(Integer.valueOf(((Position)o).hashCode()));
- } else {
- return -1;
- }
- }
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/perffmwk/Formatter.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/perffmwk/Formatter.java b/gemfire-core/src/test/java/perffmwk/Formatter.java
deleted file mode 100644
index 3bfd555..0000000
--- a/gemfire-core/src/test/java/perffmwk/Formatter.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
-*========================================================================
-* Copyright (c) 2000-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.pivotal.io/patents.
-*========================================================================
-*/
-
-package perffmwk;
-
-import hydra.HydraRuntimeException;
-
-import java.io.*;
-import java.text.*;
-import java.util.*;
-
-/**
- * Contains common code used to format reports.
- */
-public class Formatter {
-
- /** The width (in characters) of the report output.
- *
- * @see #center(String, PrintWriter) */
- protected static final int WIDTH = 80;
-
- protected static final String DIVIDER =
- "================================================================================";
- protected static final String SUBDIVIDER =
- "--------------------------------------------------------------------------------";
-
- /**
- * Centers the given string on the <code>PrintWriter</code>
- */
- public static void center(String s, PrintWriter pw) {
- int indent = (WIDTH / 2) - (s.length() / 2);
- for (int i = 0; i < indent; i++) {
- pw.print(" ");
- }
- pw.println(s);
- }
- /**
- * Returns a collection of decimals based on the given collection but with
- * the doubles formatted according to the pattern. String values are ignored.
- */
- public static Vector formatDecimal( Collection c, String pattern ) {
- DecimalFormat f = new DecimalFormat( pattern );
- Vector v = new Vector();
- for ( Iterator i = c.iterator(); i.hasNext(); ) {
- Object o = i.next();
- if ( o instanceof Double )
- v.add( f.format( o ) );
- else
- v.add( o );
- }
- return v;
- }
- /**
- * Returns a collection of doubles based on the given collection but with
- * the doubles formatted according to the pattern and all entries, both
- * doubles and string, padded on the left to the length of the longest one.
- */
- public static Vector padLeft( Collection doubles, String pattern ) {
- return padLeft( formatDecimal( doubles, pattern ) );
- }
- /**
- * Returns a collection of doubles based on the given collection but with
- * the doubles formatted according to the pattern and all entries, both
- * doubles and string, padded on the right to the length of the longest one.
- */
- public static Vector padRight( Collection doubles, String pattern ) {
- return padRight( formatDecimal( doubles, pattern ) );
- }
- /**
- * Returns a collection of strings based on the given collection but with
- * all strings padded on the left to the length of the longest one.
- */
- public static Vector padLeft( Collection strings ) {
- Vector v = new Vector();
- int length = maxLength( strings );
- for ( Iterator i = strings.iterator(); i.hasNext(); ) {
- String string = (String) i.next();
- v.add( padLeft( string, length ) );
- }
- return v;
- }
- /**
- * Returns a collection of strings based on the given collection but with
- * all strings padded on the right to the length of the longest one.
- */
- public static Vector padRight( Collection strings ) {
- Vector v = new Vector();
- int length = maxLength( strings );
- for ( Iterator i = strings.iterator(); i.hasNext(); ) {
- String string = (String) i.next();
- v.add( padRight( string, length ) );
- }
- return v;
- }
- /**
- * Returns a string that is the given string padded on the left to the given length.
- */
- public static String padLeft( String s, int length ) {
- if ( s.length() > length ) {
- throw new HydraRuntimeException( s + " cannot be padded to length " + length + ", it is too long" );
- }
- String t = "";
- for ( int i = 0; i < length - s.length(); i++ ) {
- t += " ";
- }
- return t + s;
- }
- /**
- * Returns a string that is the given string padded on the right to the given length.
- */
- public static String padRight( String s, int length ) {
- if ( s.length() > length ) {
- throw new HydraRuntimeException( s + " cannot be padded to length " + length + ", it is too long" );
- }
- String t = new String( s );
- for ( int i = 0; i < length - s.length(); i++ ) {
- t += " ";
- }
- return t;
- }
- /**
- * Returns the length of the longest string in the collection (0 if the
- * collection is empty).
- */
- public static int maxLength( Collection strings ) {
- int max = 0;
- for ( Iterator i = strings.iterator(); i.hasNext(); ) {
- String string = (String) i.next();
- max = Math.max( max, string.length() );
- }
- return max;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/util/TestException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/util/TestException.java b/gemfire-core/src/test/java/util/TestException.java
deleted file mode 100644
index 68f7b12..0000000
--- a/gemfire-core/src/test/java/util/TestException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package util;
-
-import java.lang.Error;
-
-public class TestException extends Error {
-
- public TestException(String message, Throwable cause) {
- super(message, cause);
- }
-
-public TestException(String name) {
- super(name);
-}
-
-public TestException(StringBuffer name) {
- super(name.toString());
-}
-
-}
[3/3] incubator-geode git commit: Reunite open and closed source
hydra classes and various other test classes.
Posted by lg...@apache.org.
Reunite open and closed source hydra classes and various other test classes.
This is to remove the hydra dependency on gemfire-core test. Moved some
classes around and duplicated others as part of reuniting packages.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/769c2ee8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/769c2ee8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/769c2ee8
Branch: refs/heads/feature/GEODE-308
Commit: 769c2ee8e690fb9566f7968790ef7d3df544ecc9
Parents: ba74e9e
Author: Lise Storc <ls...@pivotal.io>
Authored: Thu Sep 24 09:46:15 2015 -0700
Committer: Lynn Gallinat <lg...@pivotal.io>
Committed: Tue Sep 29 16:09:06 2015 -0700
----------------------------------------------------------------------
.../batterytest/greplogs/ExpectedStrings.java | 179 ------
.../java/batterytest/greplogs/LogConsumer.java | 288 ----------
.../gemstone/gemfire/TestDataSerializer.java | 2 +-
.../com/gemstone/gemfire/UnitTestDoclet.java | 21 +-
.../management/MemoryThresholdsDUnitTest.java | 3 +-
.../gemfire/cache/query/data/NewPortfolio.java | 246 +++++++++
.../gemfire/cache/query/data/NewPosition.java | 153 ++++++
...esourceManagerWithQueryMonitorDUnitTest.java | 3 +-
.../cache/query/functional/MiscJUnitTest.java | 2 +-
.../index/CompactRangeIndexJUnitTest.java | 2 +-
.../PRColocatedEquiJoinDUnitTest.java | 5 +-
.../query/partitioned/PRQueryDUnitHelper.java | 6 +-
.../cache30/CacheSerializableRunnable.java | 1 -
.../gemfire/cache30/SearchAndLoadDUnitTest.java | 1 -
.../gemfire/distributed/internal/LDM.java | 2 +-
.../PartitionedRegionTestUtilsDUnitTest.java | 5 +-
.../internal/cache/SystemFailureDUnitTest.java | 3 +-
.../cache/control/MemoryMonitorJUnitTest.java | 2 +-
.../cache/execute/MyTransactionFunction.java | 2 +-
.../cache/execute/PRTransactionDUnitTest.java | 3 +-
.../cache/ha/HARQueueNewImplDUnitTest.java | 3 +-
.../cache/ha/HARegionQueueDUnitTest.java | 3 +-
.../PersistentRVVRecoveryDUnitTest.java | 3 +-
.../DestroyEntryPropagationDUnitTest.java | 3 +-
.../gemfire/pdx/VersionClassLoader.java | 1 -
.../src/test/java/dunit/MethExecutor.java | 384 +++++++++++++
.../src/test/java/dunit/MethExecutorResult.java | 184 +++++++
.../src/test/java/dunit/RemoteDUnitVMIF.java | 2 +-
.../src/test/java/dunit/TestException.java | 27 +
gemfire-core/src/test/java/dunit/VM.java | 2 -
.../src/test/java/dunit/standalone/ChildVM.java | 13 -
.../java/dunit/standalone/DUnitLauncher.java | 11 +-
.../java/dunit/standalone/RemoteDUnitVM.java | 5 +-
gemfire-core/src/test/java/hydra/GsRandom.java | 303 ----------
.../test/java/hydra/HydraRuntimeException.java | 24 -
gemfire-core/src/test/java/hydra/Log.java | 210 -------
.../src/test/java/hydra/LogVersionHelper.java | 36 --
.../src/test/java/hydra/MethExecutor.java | 383 -------------
.../src/test/java/hydra/MethExecutorResult.java | 177 ------
.../src/test/java/hydra/SchedulingOrder.java | 27 -
.../src/test/java/hydra/log/AnyLogWriter.java | 546 -------------------
.../java/hydra/log/CircularOutputStream.java | 122 -----
.../parReg/query/unittest/NewPortfolio.java | 263 ---------
.../java/parReg/query/unittest/Position.java | 154 ------
.../src/test/java/perffmwk/Formatter.java | 139 -----
.../src/test/java/util/TestException.java | 26 -
.../test/junit/greplogs/ExpectedStrings.java | 180 ++++++
.../test/junit/greplogs/LogConsumer.java | 289 ++++++++++
48 files changed, 1508 insertions(+), 2941 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/batterytest/greplogs/ExpectedStrings.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/batterytest/greplogs/ExpectedStrings.java b/gemfire-core/src/test/java/batterytest/greplogs/ExpectedStrings.java
deleted file mode 100644
index 3bb47d4..0000000
--- a/gemfire-core/src/test/java/batterytest/greplogs/ExpectedStrings.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-/**
- *
- */
-package batterytest.greplogs;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.regex.Pattern;
-
-/**
- * @author kbanks
- *
- */
-public class ExpectedStrings {
-
- private ExpectedStrings() {}
-
- public static boolean skipLogMsgs(String type) {
- if ( type.equals("junit")
- || type.equals("java")
- || type.equals("query")
- || type.equals("dunit")) {
- return true;
- }else {
- return false;
- }
- }
- public static List create(String type) {
- List expected = new ArrayList();
-
- expected.add(Pattern.compile("@todo"));
- expected.add(Pattern.compile("Random seed"));
- expected.add(Pattern.compile("Caused by"));
- expected.add(Pattern.compile("continuing test"));
- expected.add(Pattern.compile("continuing with test"));
- expected.add(Pattern.compile("Test failed with errors"));
- expected.add(Pattern.compile("Test reported failure"));
- expected.add(Pattern.compile("TASK REPORT"));
- expected.add(Pattern.compile("Test reported hang"));
- expected.add(Pattern.compile("Proceeding past hung test"));
- expected.add(Pattern.compile("waited too long for result"));
- expected.add(Pattern.compile("gskill"));
- expected.add(Pattern.compile("HANG --"));
- expected.add(Pattern.compile("Leaving the vms running"));
- expected.add(Pattern.compile("Non-sanctioned build detected"));
- expected.add(Pattern.compile("may result in severe civil"));
- expected.add(Pattern.compile("This concludes your test run"));
- expected.add(Pattern.compile("TEST:"));
- expected.add(Pattern.compile("\\(will reattempt\\)"));
- expected.add(Pattern.compile("Removing disk files"));
- expected.add(Pattern.compile("cannot find a successor due to shutdown:"));
- expected.add(Pattern.compile("aborted due to shutdown:"));
- expected.add(Pattern.compile("due to cache closure:"));
- expected.add(Pattern.compile("Got expected "));
- expected.add(Pattern.compile("Caught expected "));
- expected.add(Pattern.compile("caught expected "));
- expected.add(Pattern.compile("Found expected warning"));
- expected.add(Pattern.compile("CacheClosedException: The cache is closed."));
- expected.add(Pattern.compile("Invoked MembershipNotifierHook"));
- expected.add(Pattern.compile("java.io.IOException: Connection reset by peer"));
- expected.add(Pattern.compile("client connections exceeds the licensed limit"));
- //Exclude this since the only tests with securty enabled, expect to see
- //these and if they don't then the test fails
- expected.add(Pattern.compile("NotAuthorizedException"));
- expected.add(Pattern.compile("above critical heap threshold"));
- expected.add(Pattern.compile("below critical heap threshold"));
- expected.add(Pattern.compile("checkForForcedDisconnect processed Exception"));
- expected.add(Pattern.compile("operation generated expected \\S+Exception"));
-
- expected.add(Pattern.compile("ExpectedString"));
- expected.add(Pattern.compile("ExpectedStrings"));
-
- expected.add(Pattern.compile("PassWithExpectedSevereJUnitTest"));
- expected.add(Pattern.compile("FailWithErrorInOutputJUnitTest"));
- expected.add(Pattern.compile("PassWithExpectedErrorJUnitTest"));
- expected.add(Pattern.compile("FailWithSevereInOutputJUnitTest"));
- expected.add(Pattern.compile("SystemAlertManager: A simple Alert."));
-
- expected.add(Pattern.compile("com.gemstone.gemfire.management.DependenciesNotFoundException"));
-
- //expected.add(Pattern.compile("Java version older than"));
- //expected.add(Pattern.compile("Minimum system requirements not met. Unexpected behavior may result in additional errors."));
-
- if ( type.equals("junit") || type.equals("java") || type.equals("query")) {
- expected.add(Pattern.compile("TEST EXCEPTION"));
- expected.add(Pattern.compile("testLogLevels"));
- expected.add(Pattern.compile("On iteration"));
- expected.add(Pattern.compile("signal count"));
- //Remove when davidw fixes
- expected.add(Pattern.compile("Expected"));
- //below here for gfx unit tests
- expected.add(Pattern.compile("Valid documents must have a"));
- expected.add(Pattern.compile("Loaded java.lang.ClassCastException"));
- expected.add(Pattern.compile("Loaded java.io.InvalidClassException"));
- expected.add(Pattern.compile("Loaded java.lang.NullPointerException"));
- expected.add(Pattern.compile("Loaded java.lang.ArrayIndexOutOfBoundsException"));
- expected.add(Pattern.compile("Loaded java.lang.IndexOutOfBoundsException"));
- expected.add(Pattern.compile("SucessfulTest:"));
- expected.add(Pattern.compile("SQLException: Database 'newDB' not found"));
- expected.add(Pattern.compile("SQLException: Database 'newDB1' not found"));
- expected.add(Pattern.compile("IGNORE_EXCEPTION_test"));
- expected.add(Pattern.compile("Unsupported at this time"));
- expected.add(Pattern.compile("DiskAccessException occured as expected"));
- expected.add(Pattern.compile("Oplog::createOplog:Exception in preblowing the file"));
- } else if ( type.equals("dunit")) {
- expected.add(Pattern.compile("INCOMPATIBLE_ROOT"));
- expected.add(Pattern.compile("connecting to locator"));
- expected.add(Pattern.compile("ItsOkayForMyClassNotToBeFound"));
- expected.add(Pattern.compile("Test Exception"));
- expected.add(Pattern.compile("make sure exceptions from close callbacks"));
- expected.add(Pattern.compile("Please ignore"));
- expected.add(Pattern.compile("I have been thrown from TestFunction"));
- expected.add(Pattern.compile("No admin on"));
- expected.add(Pattern.compile("nonExistentMethod"));
- expected.add(Pattern.compile("Expected exception"));
- expected.add(Pattern.compile("BridgeLoaderTestNonSerializable"));
- expected.add(Pattern.compile("BridgeLoaderTestSerializableImpl"));
- expected.add(Pattern.compile("One or more DUnit tests failed"));
- expected.add(Pattern.compile("ReplyException"));
- expected.add(Pattern.compile("fine 2"));
- expected.add(Pattern.compile("TESTING A VERY UNIQUE"));
- expected.add(Pattern.compile("-01-01"));
- expected.add(Pattern.compile("testNBRegionDestructionDuringGetInitialImage"));
- expected.add(Pattern.compile("SQLException: Database 'newDB' not found"));
- expected.add(Pattern.compile("SQLException: Failed to start database 'newDB'"));
- expected.add(Pattern.compile("SQLException: Database 'newDB1' not found"));
- expected.add(Pattern.compile("INCORRECT_localhost"));
- expected.add(Pattern.compile("WARNING: Failed to check connection: java.net.ConnectException: Connection refused"));
- expected.add(Pattern.compile("WARNING: Failed to call the method close..:java.rmi.ConnectException:"));
- expected.add(Pattern.compile("WARNING: Failed to restart: java.rmi.NoSuchObjectException: no such object in table"));
- expected.add(Pattern.compile("WARNING: Failed to restart: java.rmi.ConnectException: Connection refused to host: .* nested exception is:"));
- expected.add(Pattern.compile("UnitTests terminating abnormally after a client had a fatal task error"));
- expected.add(Pattern.compile("Doing stack dump on all"));
- expected.add(Pattern.compile("Unit test result: FAILED ==> Unsuccessfully ran JUnit tests"));
- expected.add(Pattern.compile("IGNORE_EXCEPTION_test"));
- expected.add(Pattern.compile("SIGQUIT received, dumping threads"));
- expected.add(Pattern.compile("Sleeping \\d+ seconds between stack dumps"));
- expected.add(Pattern.compile("Redundancy has dropped below"));
- expected.add(Pattern.compile("Could not find any server to create redundant client"));
- expected.add(Pattern.compile("Could not find any server to create primary client"));
- expected.add(Pattern.compile("Pool unexpected closed socket on server"));
- expected.add(Pattern.compile("Could not initialize a primary queue on startup"));
- expected.add(Pattern.compile("java.lang.IllegalArgumentException: Sample timestamp must be greater than previous timestamp"));
- //The following 2 strings are ignored due to bug 52042
- expected.add(Pattern.compile("failed accepting client connection"));
- expected.add(Pattern.compile("Acceptor received unknown communication"));
- } else if ( type.equals("smoke")) {
- expected.add(Pattern.compile("Doing stack dump on all"));
- expected.add(Pattern.compile("SIGQUIT received, dumping threads"));
- expected.add(Pattern.compile("Sleeping \\d+ seconds between stack dumps"));
- expected.add(Pattern.compile("Could not find Spring Shell library"));
- } else if ( type.equals("perf")) {
- expected.add(Pattern.compile("Doing stack dump on all"));
- expected.add(Pattern.compile("SIGQUIT received, dumping threads"));
- expected.add(Pattern.compile("Sleeping \\d+ seconds between stack dumps"));
- } else if ( type.equals("moresmoke")) {
- expected.add(Pattern.compile(" expected error"));
- expected.add(Pattern.compile("Doing stack dump on all"));
- expected.add(Pattern.compile("SIGQUIT received, dumping threads"));
- expected.add(Pattern.compile("Sleeping \\d+ seconds between stack dumps"));
- } else {
- expected.add(Pattern.compile("runbattery\\(\\) returned false"));
- expected.add(Pattern.compile(" expected error"));
- expected.add(Pattern.compile("Doing stack dump on all"));
- expected.add(Pattern.compile("SIGQUIT received, dumping threads"));
- expected.add(Pattern.compile("Sleeping \\d+ seconds between stack dumps"));
- expected.add(Pattern.compile("HydraTask_initializeExpectException"));
- expected.add(Pattern.compile("java.net.ConnectException: Connection refused"));
- }
- return expected;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/batterytest/greplogs/LogConsumer.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/batterytest/greplogs/LogConsumer.java b/gemfire-core/src/test/java/batterytest/greplogs/LogConsumer.java
deleted file mode 100644
index 8f243d0..0000000
--- a/gemfire-core/src/test/java/batterytest/greplogs/LogConsumer.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package batterytest.greplogs;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class LogConsumer {
- private final List expectedExceptions = new ArrayList();
- private boolean skipLogMsgs = false;
- private boolean infoMsgFlag = false;
- private int eatLines = 0;
- private boolean tmpErrFlag = false;
- private int tmpErrLines = 0;
- private boolean saveFlag = false;
- private int savelinenum = 0;
- private final List testExpectStrs;
- StringBuilder all = null;
- private int lineNumber;
- private String fileName;
- HashMap individalErrorCount = new HashMap();
- private final int repeatLimit;
-
- private static final Pattern ExpectedExceptionPattern = Pattern.compile("<ExpectedException action=(add|remove)>(.*)</ExpectedException>");
- private static final Pattern logPattern = Pattern.compile("^\\[(?:fatal|error|warn|info|debug|trace|severe|warning|fine|finer|finest)");
- private static final Pattern blankPattern = Pattern.compile("^\\s*$");
- private static final Pattern infoOrBelowPattern = Pattern.compile("^\\[(?:info|debug|trace|fine|finer|finest)");
- private static final Pattern fatalOrErrorPattern = Pattern.compile("^\\[(?:fatal|error|severe)");
- private static final Pattern causedByPattern = Pattern.compile("Caused by");
- private static final Pattern shortErrPattern = Pattern.compile("^\\[[^\\]]+\\](.*)$", Pattern.MULTILINE | Pattern.DOTALL);
- private static final Pattern wroteExceptionPattern = Pattern.compile("\\[debug.*Wrote exception:");
- private static final Pattern rmiWarnPattern = Pattern.compile("^WARNING: Failed to .*java.rmi.ConnectException: Connection refused to host: .*; nested exception is:");
- private static final Pattern javaLangErrorPattern = Pattern.compile("^java\\.lang\\.\\S+Error$");
- private static final Pattern exceptionPattern = Pattern.compile("Exception:");
- private static final Pattern exceptionPattern2 = Pattern.compile("( [\\w\\.]+Exception: (([\\S]+ ){0,6}))");
- private static final Pattern exceptionPattern3 = Pattern.compile("( [\\w\\.]+Exception)$");
- private static final Pattern exceptionPattern4 = Pattern.compile("^([^:]+: (([\\w\"]+ ){0,6}))");
- private static final Pattern misformatedI18nMessagePattern = Pattern.compile("[^\\d]\\{\\d+\\}");
- private static final Pattern rvvBitSetMessagePattern = Pattern.compile("RegionVersionVector.+bsv\\d+.+bs=\\{\\d+\\}");
- /** Limit long errors to this many lines */
- private static int ERROR_BUFFER_LIMIT = 50;
-
-
-
-
- public LogConsumer(boolean skipLogMsgs,
- List testExpectStrs, String fileName, int repeatLimit) {
- super();
- this.skipLogMsgs = skipLogMsgs;
- this.testExpectStrs = testExpectStrs;
- this.fileName = fileName;
- this.repeatLimit = repeatLimit;
- }
-
- public StringBuilder consume(CharSequence line) {
- {
- lineNumber++;
- Matcher m = ExpectedExceptionPattern.matcher(line);
- if (m.find()) {
- if ( m.group(1).equals("add")) {
- expectedExceptions.add(Pattern.compile(m.group(2)));
- } else {
- //assume add and remove are the only choices
- expectedExceptions.remove(Pattern.compile(m.group(2)));
- }
- return null;
- }
- }
- if(skipLogMsgs) {
- if(infoMsgFlag) {
- if(logPattern.matcher(line).find()) {
- infoMsgFlag = false;
- } else if (blankPattern.matcher(line).matches()) {
- infoMsgFlag = false;
- return null;
- } else {
- return null;
- }
- }
- if (infoOrBelowPattern.matcher(line).find()){
- infoMsgFlag = true;
- return null;
- }
- }
-
- if ( eatLines != 0 ) {
- eatLines--;
- return null;
- } else {
- if(saveFlag || fatalOrErrorPattern.matcher(line).find()) {
- if(! saveFlag) {
- saveFlag = true;
- tmpErrFlag = true;
- if(checkExpectedStrs(line, expectedExceptions)) {
- saveFlag = false;
- tmpErrFlag = false;
- tmpErrLines = 0;
- }
- if(tmpErrFlag) {
- tmpErrLines=1;
- all = new StringBuilder(line);
- all.append("\n");
- savelinenum = lineNumber;
- }
- } else {
- if (causedByPattern.matcher(line).find()) {
- tmpErrFlag = false;
- tmpErrLines = 0;
- saveFlag = false;
- StringBuilder buffer = new StringBuilder();
- buffer.append("-----------------------------------------------------------------------\n");
- buffer.append("Found suspect string in ")
- .append(fileName)
- .append(" at line ")
- .append(savelinenum).append("\n\n")
- .append(all.toString());
- return buffer;
- } else if (checkExpectedStrs(line, expectedExceptions)) {
- // reset the counters and throw it all away if it matches
- // one of the registered ignorable strings
- tmpErrFlag = false;
- tmpErrLines = 0;
- saveFlag = false;
- }
-
- // We save all the lines up to the next blank line so we're
- //looking for a blank line here
- if (blankPattern.matcher(line).matches()) {
- // we found a blank line so print the suspect string
- // and reset the savetag flag
- saveFlag = false;
- Matcher m = shortErrPattern.matcher(all.toString());
- if (m.matches()) {
- String shortName = m.group(1);
- Integer i = (Integer) individalErrorCount.get(shortName);
- Integer occurances =
- new Integer((i == null) ? 1 : i.intValue() + 1);
- individalErrorCount.put(shortName, occurances);
- return enforceErrorLimit(occurances.intValue(),
- all.toString(),
- //reader.getLineNumber(),
- savelinenum,
- fileName);
-
- } else {
- //error in determining shortName, wing it
- return enforceErrorLimit(1,
- all.toString(),
- lineNumber,
- fileName);
- }
- }
-
- // we're still saving lines to append them on to all which contains
- // all the lines we're trying to save
- if ( tmpErrFlag ) {
- if ( tmpErrLines < ERROR_BUFFER_LIMIT ) {
- tmpErrLines++;
- all.append(line).append("\n");
- }
- if ( tmpErrLines == ERROR_BUFFER_LIMIT ) {
- tmpErrLines++; //increment to prevent this line from repeating
- all.append("GrepLogs: ERROR_BUFFER_LIMIT limit reached,")
- .append(" the error was too long to display completely.\n");
- }
-
- }
- }
- // unique condition for when bridge server see log exception and
- // logging level is set to fine. Message looks like this:
- //[fine 2005/10/25 17:53:13.586 PDT gemfire2 Server connection from hobbes.gemstone.com:34466-0xf4 nid=0x23e40f1] Server connection from hobbes.gemstone.com:34466: Wrote exception:
- //com.gemstone.gemfire.cache.EntryNotFoundException: remote-destroy-key
- // also now handles a JMX WARNING
- } else if(wroteExceptionPattern.matcher(line).find()
- || rmiWarnPattern.matcher(line).find()) {
- //Eat only the single EntryNotFound Exception
- eatLines=1;
- // if we are here then the line didn't have severe or error in it and
- // didn't meet any special cases that require eating lines
- // Check for other kinds of exceptions. This is by no means inclusive
- //of all types of exceptions that could occur and some ARE missed.
- } else if (exceptionPattern.matcher(line).find()
- || javaLangErrorPattern.matcher(line).find()
- || (misformatedI18nMessagePattern.matcher(line).find()
- && !(infoOrBelowPattern.matcher(line).find()
- && rvvBitSetMessagePattern.matcher(line).find())) ) {
- if(! checkExpectedStrs(line, expectedExceptions)) {
- // it's the Exception colon that we want to find
- // along with the next six words and define to shortline
- // shortline is only used for the unique sting to count the
- // number of times an exception match occurs. This is so
- // we can suppress further printing if we hit the limit
- Matcher m2 = exceptionPattern2.matcher(line);
- Matcher m3 = exceptionPattern3.matcher(line);
- Matcher m4 = exceptionPattern4.matcher(line);
- String shortName = "";
-
- if(m2.find()) {
- shortName = m2.group(1);
- } else if (m3.find()) {
- shortName = m3.group(1);
- } else if (m4.find()) {
- shortName = m4.group(1);
- }
- Integer i = (Integer) individalErrorCount.get(shortName);
- Integer occurances =
- new Integer((i == null) ? 1 : i.intValue() + 1);
- individalErrorCount.put(shortName, occurances);
- return enforceErrorLimit(occurances.intValue(),
- line + "\n",
- lineNumber,
- fileName);
- }
- }
- }
-
- return null;
- }
-
- public StringBuilder close() {
- if(saveFlag) {
- // Bug fix for severe that occurs at the end of a log file. Since we
- // collect lines up to a blank line that never happens this prints the
- // collection of in process suspect strings if we close the file and
- // we're still trying to save lines
-
- saveFlag = false;
- StringBuilder buffer = new StringBuilder();
- buffer.append("\n-----------------------------------------------------------------------\n")
- .append("Found suspect string in ")
- .append(fileName)
- .append(" at line ")
- .append(savelinenum)
- .append("\n\n")
- .append(all);
- return buffer;
- }
- return null;
- }
-
- private boolean checkExpectedStrs(CharSequence line, List expectedExceptions) {
- for(int i = 0; i < expectedExceptions.size(); i++) {
- Pattern p = (Pattern) expectedExceptions.get(i);
- if(p.matcher(line).find()) return true;
- }
- for(int i = 0; i < testExpectStrs.size(); i++) {
- Pattern p = (Pattern) testExpectStrs.get(i);
- if(p.matcher(line).find()) return true;
- }
- return false;
- }
-
- private StringBuilder enforceErrorLimit(int hits,
- String line,
- int linenum,
- String filename) {
- if ( hits <= repeatLimit ) {
- StringBuilder buffer = new StringBuilder();
- buffer.append("-----------------------------------------------------------------------\n")
- .append("Found suspect string in ")
- .append(filename)
- .append(" at line ")
- .append(linenum)
- .append("\n\n")
- .append(line)
- .append("\n");
- return buffer;
- }
- if ( hits == repeatLimit ) {
- StringBuilder buffer = new StringBuilder();
- buffer.append("\n\nHit occurrence limit of ")
- .append(hits)
- .append(" for this string.\n")
- .append("Further reporting of this type of error will be suppressed.\n");
- return buffer;
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/TestDataSerializer.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/TestDataSerializer.java b/gemfire-core/src/test/java/com/gemstone/gemfire/TestDataSerializer.java
index 838986b..6ca6c65 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/TestDataSerializer.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/TestDataSerializer.java
@@ -14,7 +14,7 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
-import util.TestException;
+import dunit.TestException;
import com.gemstone.gemfire.internal.cache.tier.sockets.DataSerializerPropogationDUnitTest;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/UnitTestDoclet.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/UnitTestDoclet.java b/gemfire-core/src/test/java/com/gemstone/gemfire/UnitTestDoclet.java
index 65f7908..21aa308 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/UnitTestDoclet.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/UnitTestDoclet.java
@@ -12,7 +12,6 @@ import java.io.*;
import java.text.BreakIterator;
import java.util.*;
import junit.framework.TestCase;
-import perffmwk.Formatter;
/**
* This class is a Javadoc <A
@@ -28,6 +27,22 @@ import perffmwk.Formatter;
*/
public class UnitTestDoclet {
+ /** The width (in characters) of the report output.
+ *
+ * @see #center(String, PrintWriter) */
+ protected static final int WIDTH = 80;
+
+ /**
+ * Centers the given string on the <code>PrintWriter</code>
+ */
+ public static void center(String s, PrintWriter pw) {
+ int indent = (WIDTH / 2) - (s.length() / 2);
+ for (int i = 0; i < indent; i++) {
+ pw.print(" ");
+ }
+ pw.println(s);
+ }
+
/**
* Returns the number of arguments for the given command option
* (include the option itself)
@@ -95,8 +110,8 @@ public class UnitTestDoclet {
try {
PrintWriter pw =
new PrintWriter(new FileWriter(outputFile));
- Formatter.center("GemFire Unit Test Summary", pw);
- Formatter.center(new Date().toString(), pw);
+ center("GemFire Unit Test Summary", pw);
+ center(new Date().toString(), pw);
pw.println("");
ClassDoc[] classes = root.classes();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
index 37f9744..9f36959 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
@@ -20,8 +20,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import util.TestException;
-
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.AttributesMutator;
import com.gemstone.gemfire.cache.Cache;
@@ -76,6 +74,7 @@ import dunit.DistributedTestCase;
import dunit.Host;
import dunit.SerializableCallable;
import dunit.SerializableRunnable;
+import dunit.TestException;
import dunit.VM;
/**
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/data/NewPortfolio.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/data/NewPortfolio.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/data/NewPortfolio.java
new file mode 100644
index 0000000..61287f7
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/data/NewPortfolio.java
@@ -0,0 +1,246 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.cache.query.data;
+
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * A version of the Portfolio Object used for query.
+ */
+public class NewPortfolio implements Serializable {
+
+ protected String myVersion;
+
+ protected static final Random rng = new Random();
+
+ protected int NUM_OF_TYPES = 10;
+ protected int MAX_NUM_OF_POSITIONS = 5;
+ protected int NUM_OF_SECURITIES = 200;
+ private int MAX_QTY = 100; //max is 100*100
+ private int MAX_PRICE = 100;
+ protected int id = 0;
+ protected String name = "name"; //key value, needs to be unique
+ protected String status = "status";
+ protected String type = "type";
+ protected Map positions = new HashMap();
+ public String undefinedTestField = null;
+
+ public NewPortfolio() {
+ //use default
+ myVersion = "tests/parReg.query.NewPortfolio";
+ }
+
+ /**
+ * Constructor to randomly populate the portfolio.
+ * @param name
+ * @param id
+ */
+ public NewPortfolio(String name, int id) {
+ myVersion = "tests/parReg.query.NewPortfolio";
+ this.name = name;
+ this.id = id;
+
+ this.status = id % 2 == 0 ? "active" : "inactive";
+ this.type = "type" + (id % NUM_OF_TYPES);
+
+ setPositions();
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void init( int i ) {
+ this.name = new Integer(i).toString();
+ this.id = i;
+ this.status = i % 2 == 0 ? "active" : "inactive";
+ this.type = "type" + (i % NUM_OF_TYPES);
+
+ setPositions();
+
+ }
+
+ private void setPositions() {
+ int numOfPositions = rng.nextInt(MAX_NUM_OF_POSITIONS);
+ if (numOfPositions == 0)
+ numOfPositions++;
+
+ int secId = rng.nextInt(NUM_OF_SECURITIES);
+
+ for (int i=0; i < numOfPositions; i++) {
+ Properties props = getProps();
+
+// secId needs to be UNIQUE in one portfolio, keep track MAX_NUM_OF_POSITIONS and NUM_OF_SECURITIES
+ secId += i * 7;
+ if (secId > NUM_OF_SECURITIES)
+ secId -= NUM_OF_SECURITIES;
+ props.setProperty("secId", new Integer(secId).toString());
+
+ NewPosition pos = new NewPosition();
+ pos.init(props);
+ this.positions.put(pos.getSecId(), pos);
+ }
+ }
+
+ public void validate( int index ) {
+ //do nothing
+ }
+
+ public int getIndex() {
+ return this.id;
+ }
+
+ public Map getPositions(){
+ return positions;
+ }
+
+ /**
+ * To provide random values to populate a position.
+ * @return
+ */
+ protected Properties getProps() {
+ Properties props = new Properties();
+ Double qty = new Double(rng.nextInt(MAX_QTY) * 100.00);
+ Double mktValue = new Double(rng.nextDouble() * MAX_PRICE);
+
+ props.setProperty("qty", qty.toString());
+ props.setProperty("mktValue", mktValue.toString());
+
+ return props;
+ }
+
+ /**
+ * To enable the comparison.
+ */
+ public boolean equals(Object anObj) {
+
+ if (anObj == null) {
+ return false;
+ }
+
+ if (anObj.getClass().getName().equals(this.getClass().getName())) { // cannot do class identity check for pdx tets
+ NewPortfolio np = (NewPortfolio)anObj;
+ if (!np.name.equals(this.name) || (np.id != this.id) || !np.type.equals(this.type) || !np.status.equals(this.status)) {
+ return false;
+ }
+
+ if (np.positions == null) {
+ if (this.positions != null) {
+ return false;
+ }
+ } else {
+ if (np.positions.size() != this.positions.size()) {
+ return false;
+ }
+ else { //loops thru the map of positions
+ Iterator itr = np.positions.values().iterator();
+ NewPosition pos;
+ while (itr.hasNext()) {
+ pos = (NewPosition)itr.next();
+ if (!this.positions.containsValue(pos)){
+ return false;
+ }
+ }
+ }
+ }
+ } else {
+ //not same class
+ return false;
+ }
+ return true;
+ }
+
+ public int hashCode() {
+ int result = 17;
+ result = 37 * result + name.hashCode();
+ result = 37 * result + status.hashCode();
+ result = 37 * result + type.hashCode();
+ result = 37 * result + id;
+ result = 37 * result + positions.hashCode();
+
+ return result;
+ }
+
+ /** Create a map of fields and field values to use to write to the blackboard
+ * since PdxSerialiables cannot be put on the blackboard since the MasterController
+ * does not have pdx objects on its classpath. For PdxSerializables
+ * we put this Map on the blackboard instead.
+ */
+ public Map createPdxHelperMap() {
+ Map fieldMap = new HashMap();
+ fieldMap.put("className", this.getClass().getName());
+ fieldMap.put("myVersion", myVersion);
+ fieldMap.put("id", id);
+ fieldMap.put("name", name);
+ fieldMap.put("status", status);
+ fieldMap.put("type", type);
+ fieldMap.put("positions", positions);
+ fieldMap.put("undefinedTestField", undefinedTestField);
+ return fieldMap;
+ }
+
+ /** Restore the fields of this instance using the values of the Map, created
+ * by createPdxHelperMap()
+ */
+ public void restoreFromPdxHelperMap(Map aMap) {
+ this.myVersion = (String)aMap.get("myVersion");
+ this.id = (Integer)aMap.get("id");
+ this.name = (String)aMap.get("name");
+ this.status = (String)aMap.get("status");
+ this.type = (String)aMap.get("type");
+ this.positions = (Map)aMap.get("positions");
+ this.undefinedTestField = (String)aMap.get("undefinedTestField");
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("NewPortfolio [ID=" + this.id + " status=" + status);
+ sb.append(" name=" + this.name);
+
+ Iterator iter = positions.entrySet().iterator();
+ sb.append(" NewPositions:[ ");
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ sb.append(entry.getKey() + ":" + entry.getValue() + ", ");
+ }
+ sb.append("] ]");
+ return sb.toString();
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/data/NewPosition.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/data/NewPosition.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/data/NewPosition.java
new file mode 100644
index 0000000..5b67d94
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/data/NewPosition.java
@@ -0,0 +1,153 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+package com.gemstone.gemfire.cache.query.data;
+
+import java.util.*;
+import java.io.Serializable;
+import com.gemstone.gemfire.cache.Declarable;
+
+/**
+ * Represents a number of shares of a stock ("security") held in a
+ * {@link NewPortfolio}.
+ *
+ * <P>
+ *
+ * This class is <code>Serializable</code> because we want it to be
+ * distributed to multiple members of a distributed system. Because
+ * this class is <code>Declarable</code>, we can describe instances of
+ * it in a GemFire <code>cache.xml</code> file.
+ *
+ * @author GemStone Systems, Inc.
+ * @since 4.0
+ */
+public class NewPosition implements Declarable, Serializable, Comparable {
+
+ private static final Random rng = new Random();
+
+ protected String secId;
+ protected double qty;
+ protected double mktValue;
+ private final int NUM_OF_SECURITIES = 200;
+ private final int MAX_PRICE = 100;
+
+ public void init(Properties props) {
+ this.secId = props.getProperty("secId");
+ this.qty = Double.parseDouble(props.getProperty("qty"));
+ this.mktValue = Double.parseDouble(props.getProperty("mktValue"));
+ }
+
+ /**
+ * Returns the id of the security held in this position.
+ */
+ public String getSecId(){
+ return this.secId;
+ }
+
+ /**
+ * Returns the number of shares held in this position.
+ */
+ public double getQty(){
+ return this.qty;
+ }
+
+ /**
+ * Returns the value of this position.
+ */
+ public double getMktValue() {
+ return this.mktValue;
+ }
+
+ public String toString(){
+ return "NewPosition [secId="+secId+" qty="+this.qty+" mktValue="+mktValue+"]";
+ }
+
+ public static String toString(List aList) {
+ StringBuffer aStr = new StringBuffer();
+ aStr.append("List of size " + aList.size() + "\n");
+ for (int i = 0; i < aList.size(); i++) {
+ Object anObj = aList.get(i);
+ if (anObj instanceof NewPosition) {
+ NewPosition p = (NewPosition)(anObj);
+ aStr.append(p.toString());
+ }
+ aStr.append("\n");
+ }
+ return aStr.toString();
+ }
+
+ /**
+ * To enable the comparison.
+ */
+ public boolean equals(Object anObj) {
+ if (anObj == null) {
+ return false;
+ }
+ if (anObj.getClass() == this.getClass()) {
+ NewPosition pos = (NewPosition)anObj;
+ if ((pos.mktValue != this.mktValue) || (pos.qty != this.qty)) {
+ return false;
+ }
+
+ if (pos.secId == null) {
+ if (this.secId != null) {
+
+ return false;
+ }
+ } else {
+ if (!(pos.secId.equals(this.secId))) {
+
+ return false;
+ }
+ }
+ } else {
+
+ return false;
+ }
+ return true;
+ }
+
+ public int hashCode() {
+ int result = 17;
+ result = 37 * result + (int) (Double.doubleToLongBits(mktValue)^(Double.doubleToLongBits(mktValue)>>>32));
+ result = 37 * result + (int) (Double.doubleToLongBits(qty)^(Double.doubleToLongBits(qty)>>>32));
+ result = 37 * result + secId.hashCode();
+
+ return result;
+ }
+
+ /**
+ * to configure position using index, set quantity equal to the index
+ */
+ public void init(int i) {
+ this.secId = new Integer(rng.nextInt(NUM_OF_SECURITIES)).toString();
+ this.qty = new Double(i).doubleValue();
+ this.mktValue = new Double(rng.nextDouble() * MAX_PRICE ).doubleValue();
+ }
+
+ public int getIndex() {
+ return (int)this.qty;
+ }
+
+ public void validate (int index){
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ if( o == this) {
+ return 0;
+ }else {
+ if (o instanceof NewPosition) {
+ return Integer.valueOf(this.hashCode()).compareTo(Integer.valueOf(((NewPosition)o).hashCode()));
+ } else {
+ return -1;
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
index cdd03b3..3dd0424 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
@@ -13,8 +13,6 @@ import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import util.TestException;
-
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.CacheException;
import com.gemstone.gemfire.cache.DataPolicy;
@@ -61,6 +59,7 @@ import dunit.AsyncInvocation;
import dunit.DistributedTestCase;
import dunit.Host;
import dunit.SerializableCallable;
+import dunit.TestException;
import dunit.VM;
public class ResourceManagerWithQueryMonitorDUnitTest extends BridgeTestCase {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/functional/MiscJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/functional/MiscJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/functional/MiscJUnitTest.java
index 7a86e9c..cdf39c0 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/functional/MiscJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/functional/MiscJUnitTest.java
@@ -27,6 +27,7 @@ import com.gemstone.gemfire.cache.query.FunctionDomainException;
import com.gemstone.gemfire.cache.query.Index;
import com.gemstone.gemfire.cache.query.IndexType;
import com.gemstone.gemfire.cache.query.NameResolutionException;
+import com.gemstone.gemfire.cache.query.data.NewPortfolio;
import com.gemstone.gemfire.cache.query.Query;
import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
import com.gemstone.gemfire.cache.query.QueryService;
@@ -49,7 +50,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import parReg.query.unittest.NewPortfolio;
import static org.junit.Assert.*;
import junit.framework.*;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CompactRangeIndexJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CompactRangeIndexJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CompactRangeIndexJUnitTest.java
index 5be500b..4df4e4f 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CompactRangeIndexJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CompactRangeIndexJUnitTest.java
@@ -25,7 +25,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import util.TestException;
+import dunit.TestException;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.query.Index;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/partitioned/PRColocatedEquiJoinDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/partitioned/PRColocatedEquiJoinDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/partitioned/PRColocatedEquiJoinDUnitTest.java
index 7aef6de..a57e23a 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/partitioned/PRColocatedEquiJoinDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/partitioned/PRColocatedEquiJoinDUnitTest.java
@@ -12,9 +12,6 @@ package com.gemstone.gemfire.cache.query.partitioned;
import java.util.ArrayList;
-import parReg.query.unittest.NewPortfolio;
-import util.TestException;
-
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheClosedException;
@@ -36,6 +33,7 @@ import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
import com.gemstone.gemfire.cache.query.QueryService;
import com.gemstone.gemfire.cache.query.RegionNotFoundException;
import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.data.NewPortfolio;
import com.gemstone.gemfire.cache.query.data.Portfolio;
import com.gemstone.gemfire.cache.query.partitioned.PRQueryDUnitHelper.TestQueryFunction;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
@@ -46,6 +44,7 @@ import com.gemstone.gemfire.internal.cache.PartitionedRegionDUnitTestCase;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import dunit.Host;
+import dunit.TestException;
import dunit.VM;
/**
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/partitioned/PRQueryDUnitHelper.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/partitioned/PRQueryDUnitHelper.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/partitioned/PRQueryDUnitHelper.java
index 3135a26..3b89151 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/partitioned/PRQueryDUnitHelper.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/partitioned/PRQueryDUnitHelper.java
@@ -23,9 +23,6 @@ import java.util.Random;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
-import parReg.query.unittest.NewPortfolio;
-import util.TestException;
-
import com.gemstone.gemfire.CancelException;
import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.cache.AttributesFactory;
@@ -60,6 +57,7 @@ import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
import com.gemstone.gemfire.cache.query.QueryService;
import com.gemstone.gemfire.cache.query.RegionNotFoundException;
import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.data.NewPortfolio;
import com.gemstone.gemfire.cache.query.data.Portfolio;
import com.gemstone.gemfire.cache.query.data.PortfolioData;
import com.gemstone.gemfire.cache.query.data.Position;
@@ -81,6 +79,8 @@ import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator;
import com.gemstone.gemfire.util.test.TestUtil;
import dunit.SerializableRunnable;
+import dunit.TestException;
+
/**
* This is a helper class for the various Partitioned Query DUnit Test Cases
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheSerializableRunnable.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheSerializableRunnable.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheSerializableRunnable.java
index e25c87e..3adfbfd 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheSerializableRunnable.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheSerializableRunnable.java
@@ -9,7 +9,6 @@ package com.gemstone.gemfire.cache30;
import com.gemstone.gemfire.cache.*;
-import util.TestException;
import dunit.*;
import junit.framework.AssertionFailedError;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/SearchAndLoadDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/SearchAndLoadDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/SearchAndLoadDUnitTest.java
index fad5f79..a4a1ab8 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/SearchAndLoadDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/SearchAndLoadDUnitTest.java
@@ -11,7 +11,6 @@ package com.gemstone.gemfire.cache30;
import com.gemstone.gemfire.cache.*;
import dunit.*;
-//import hydra.ClientMgr;
/**
* This class tests various search load and write scenarios for distributed regions
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/LDM.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/LDM.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/LDM.java
index 6c88136..e6e5b9a 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/LDM.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/LDM.java
@@ -11,7 +11,7 @@ import java.util.Properties;
import org.apache.logging.log4j.Logger;
-import util.TestException;
+import dunit.TestException;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.internal.logging.LogService;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionTestUtilsDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionTestUtilsDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionTestUtilsDUnitTest.java
index df780b9..857265b 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionTestUtilsDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionTestUtilsDUnitTest.java
@@ -9,8 +9,6 @@
package com.gemstone.gemfire.internal.cache;
-import hydra.GsRandom;
-
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@@ -18,6 +16,7 @@ import java.io.Serializable;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Random;
import java.util.Set;
import com.gemstone.gemfire.DataSerializable;
@@ -80,7 +79,7 @@ public class PartitionedRegionTestUtilsDUnitTest extends
vm0.invoke(new CacheSerializableRunnable("GetSomeKeys") {
public void run2() throws CacheException {
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(r);
- GsRandom rand = new GsRandom(123);
+ Random rand = new Random(123);
// Assert that its empty
for(int i=0; i<5; i++) {
getLogWriter().info("Invocation " + i + " of getSomeKeys");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/SystemFailureDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/SystemFailureDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/SystemFailureDUnitTest.java
index 7c9d6f0..c638b3c 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/SystemFailureDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/SystemFailureDUnitTest.java
@@ -18,13 +18,12 @@ import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
import dunit.Host;
import dunit.RMIException;
+import dunit.TestException;
import dunit.VM;
import java.io.Serializable;
import java.util.ArrayList;
-import util.TestException;
-
import junit.framework.Assert;
/**
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/control/MemoryMonitorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/control/MemoryMonitorJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/control/MemoryMonitorJUnitTest.java
index 772a994..cdfc705 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/control/MemoryMonitorJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/control/MemoryMonitorJUnitTest.java
@@ -24,7 +24,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import util.TestException;
+import dunit.TestException;
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.CacheFactory;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MyTransactionFunction.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MyTransactionFunction.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MyTransactionFunction.java
index 61449d2..5241f75 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MyTransactionFunction.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MyTransactionFunction.java
@@ -10,7 +10,7 @@ package com.gemstone.gemfire.internal.cache.execute;
import java.util.ArrayList;
import java.util.Iterator;
-import util.TestException;
+import dunit.TestException;
import com.gemstone.gemfire.cache.CacheTransactionManager;
import com.gemstone.gemfire.cache.CommitConflictException;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/PRTransactionDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/PRTransactionDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/PRTransactionDUnitTest.java
index 5e68ae0..babe1df 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/PRTransactionDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/PRTransactionDUnitTest.java
@@ -12,8 +12,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import util.TestException;
-
import com.gemstone.gemfire.cache.CacheTransactionManager;
import com.gemstone.gemfire.cache.EntryEvent;
import com.gemstone.gemfire.cache.Region;
@@ -36,6 +34,7 @@ import com.gemstone.gemfire.internal.cache.execute.data.Shipment;
import com.gemstone.gemfire.internal.cache.execute.data.ShipmentId;
import dunit.SerializableCallable;
+import dunit.TestException;
/**
* Test for co-located PR transactions.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARQueueNewImplDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARQueueNewImplDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARQueueNewImplDUnitTest.java
index ae2519c..9e8de9d 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARQueueNewImplDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARQueueNewImplDUnitTest.java
@@ -46,10 +46,9 @@ import com.gemstone.gemfire.internal.cache.tier.sockets.HAEventWrapper;
import dunit.DistributedTestCase;
import dunit.Host;
+import dunit.TestException;
import dunit.VM;
-import util.TestException;
-
/**
* This DUnit contains various tests to ensure new implementation of ha region
* queues works as expected.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueDUnitTest.java
index 0d095ab..c8d0576 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueDUnitTest.java
@@ -13,8 +13,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import util.TestException;
-
import junit.framework.Assert;
import com.gemstone.gemfire.LogWriter;
@@ -37,6 +35,7 @@ import com.gemstone.gemfire.internal.cache.HARegion;
import dunit.DistributedTestCase;
import dunit.Host;
+import dunit.TestException;
import dunit.VM;
/**
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/persistence/PersistentRVVRecoveryDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/persistence/PersistentRVVRecoveryDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/persistence/PersistentRVVRecoveryDUnitTest.java
index 62e16c5..92492b6 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/persistence/PersistentRVVRecoveryDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/persistence/PersistentRVVRecoveryDUnitTest.java
@@ -16,8 +16,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import util.TestException;
-
import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
@@ -61,6 +59,7 @@ import dunit.AsyncInvocation;
import dunit.Host;
import dunit.SerializableCallable;
import dunit.SerializableRunnable;
+import dunit.TestException;
import dunit.VM;
public class PersistentRVVRecoveryDUnitTest extends PersistentReplicatedTestBase {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
index b0b9912..b05b0b5 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
@@ -12,8 +12,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Properties;
-import util.TestException;
-
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheException;
@@ -39,6 +37,7 @@ import com.gemstone.gemfire.cache.client.internal.Connection;
import dunit.DistributedTestCase;
import dunit.Host;
+import dunit.TestException;
import dunit.VM;
/**
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/VersionClassLoader.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/VersionClassLoader.java b/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/VersionClassLoader.java
index 31497eb..e32addd 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/VersionClassLoader.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/VersionClassLoader.java
@@ -29,7 +29,6 @@ import java.util.ArrayList;
import java.util.List;
import junit.framework.Assert;
-import util.TestException;
public class VersionClassLoader {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/dunit/MethExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/dunit/MethExecutor.java b/gemfire-core/src/test/java/dunit/MethExecutor.java
new file mode 100644
index 0000000..31dd303
--- /dev/null
+++ b/gemfire-core/src/test/java/dunit/MethExecutor.java
@@ -0,0 +1,384 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+
+package dunit;
+
+//import java.io.*;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+import com.gemstone.gemfire.SystemFailure;
+
+/**
+*
+* A class specialized for executing (via reflection) the receiver/selector
+* pairs found in TestTasks.
+*
+*/
+public class MethExecutor {
+
+ // @todo lises add static args method
+
+ /**
+ * Helper method that searches a class (and its superclasses) for a
+ * method with the given name and parameter types.
+ *
+ * @throws NoSuchMethodException
+ * If the method cannot be found
+ */
+ public static Method getMethod(Class c, String methodName, Class[] paramTypes)
+ throws NoSuchMethodException {
+
+ ArrayList matchingMethods = new ArrayList();
+ for (Class q = c; q != null; q = q.getSuperclass()) {
+ Method[] methods = q.getDeclaredMethods();
+ NEXT_METHOD:
+ for (int i = 0; i < methods.length; i++) {
+ Method m = methods[i];
+ if (!m.getName().equals(methodName)) {
+ continue;
+ }
+
+ Class[] argTypes = m.getParameterTypes();
+ if (argTypes.length != paramTypes.length) {
+ continue;
+ }
+
+ for (int j = 0; j < argTypes.length; j++) {
+ if(paramTypes[j] == null) {
+ if(argTypes[j].isPrimitive()) {
+ //this parameter is not ok, the parameter is a primative and the value is null
+ continue NEXT_METHOD;
+ } else {
+ //this parameter is ok, the argument is an object and the value is null
+ continue;
+ }
+ }
+ if (!argTypes[j].isAssignableFrom(paramTypes[j])) {
+ Class argType = argTypes[j];
+ Class paramType = paramTypes[j];
+
+ if (argType.isPrimitive()) {
+ if ((argType.equals(boolean.class) &&
+ paramType.equals(Boolean.class)) ||
+ (argType.equals(short.class) &&
+ paramType.equals(Short.class)) ||
+ (argType.equals(int.class) &&
+ paramType.equals(Integer.class)) ||
+ (argType.equals(long.class) &&
+ paramType.equals(Long.class)) ||
+ (argType.equals(float.class) &&
+ paramType.equals(Float.class)) ||
+ (argType.equals(double.class) &&
+ paramType.equals(Double.class)) ||
+ (argType.equals(char.class) &&
+ paramType.equals(Character.class)) ||
+ (argType.equals(byte.class) &&
+ paramType.equals(Byte.class)) ||
+ false) {
+
+ // This parameter is okay, try the next arg
+ continue;
+ }
+ }
+ continue NEXT_METHOD;
+ }
+ }
+
+ matchingMethods.add(m);
+ }
+
+ //We want to check to make sure there aren't two
+ //ambiguous methods on the same class. But a subclass
+ //can still override a method on a super class, so we'll stop
+ //if we found a method on the subclass.
+ if(matchingMethods.size() > 0) {
+ break;
+ }
+ }
+
+ if(matchingMethods.isEmpty()) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Could not find method ");
+ sb.append(methodName);
+ sb.append(" with ");
+ sb.append(paramTypes.length);
+ sb.append(" parameters [");
+ for (int i = 0; i < paramTypes.length; i++) {
+ String name = paramTypes[i] == null ? null : paramTypes[i].getName();
+ sb.append(name);
+ if (i < paramTypes.length - 1) {
+ sb.append(", ");
+ }
+ }
+ sb.append("] in class ");
+ sb.append(c.getName());
+ throw new NoSuchMethodException(sb.toString());
+ }
+ if(matchingMethods.size() > 1) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Method is ambiguous ");
+ sb.append(methodName);
+ sb.append(" with ");
+ sb.append(paramTypes.length);
+ sb.append(" parameters [");
+ for (int i = 0; i < paramTypes.length; i++) {
+ String name = paramTypes[i] == null ? null : paramTypes[i].getName();
+ sb.append(name);
+ if (i < paramTypes.length - 1) {
+ sb.append(", ");
+ }
+ }
+ sb.append("] in class ");
+ sb.append(c.getName());
+ throw new NoSuchMethodException(sb.toString());
+ }
+ else return (Method) matchingMethods.get(0);
+ }
+
+ /**
+ *
+ * Send the message "selector" to the class named "receiver".
+ * Return the result, including stack trace (if any).
+ *
+ */
+ public static MethExecutorResult execute(String receiver, String selector) {
+ return execute(receiver, selector, null);
+ }
+
+ /**
+ * Executes the given static method on the given class with the
+ * given arguments.
+ */
+ public static MethExecutorResult execute(String receiver,
+ String selector,
+ Object[] args) {
+ try {
+ // get the class
+ Class receiverClass = Class.forName(receiver);
+
+ // invoke the method
+ Object res = null;
+ try {
+ Class[] paramTypes;
+ if (args == null) {
+ paramTypes = new Class[0];
+
+ } else {
+ paramTypes = new Class[args.length];
+ for (int i = 0; i < args.length; i++) {
+ if (args[i] == null) {
+ paramTypes[i] = null;
+
+ } else {
+ paramTypes[i] = args[i].getClass();
+ }
+ }
+ }
+
+ Method theMethod =
+ getMethod(receiverClass, selector, paramTypes);
+ theMethod.setAccessible(true);
+ res = theMethod.invoke(receiverClass, args);
+ return new MethExecutorResult( res );
+
+ } catch (InvocationTargetException invTargEx) {
+ Throwable targEx = invTargEx.getTargetException();
+ if ( targEx == null ) {
+ return new MethExecutorResult( res );
+
+ } else {
+ return new MethExecutorResult(targEx);
+ }
+ }
+
+ }
+ catch (VirtualMachineError e) {
+ SystemFailure.initiateFailure(e);
+ throw e;
+ }
+ catch (Throwable t) {
+// String s = "While trying to invoke " + receiver + "." +
+// selector;
+// t = new HydraConfigException(s, t);
+ return new MethExecutorResult(t);
+ }
+ }
+
+ /**
+ *
+ * Send the message "selector" to the object "target".
+ * Return the result, including stack trace (if any).
+ *
+ */
+ public static MethExecutorResult executeObject(Object target, String selector) {
+ return executeObject(target, selector, null);
+ }
+
+ /**
+ * Executes the given instance method on the given object with the
+ * given arguments.
+ */
+ public static MethExecutorResult executeObject(Object target,
+ String selector,
+ Object[] args) {
+ try {
+ // get the class
+ Class receiverClass = Class.forName(target.getClass().getName());
+
+ // invoke the method
+ Object res = null;
+ try {
+ Class[] paramTypes;
+ if (args == null) {
+ paramTypes = new Class[0];
+
+ } else {
+ paramTypes = new Class[args.length];
+ for (int i = 0; i < args.length; i++) {
+ if (args[i] == null) {
+ paramTypes[i] = Object.class;
+
+ } else {
+ paramTypes[i] = args[i].getClass();
+ }
+ }
+ }
+
+ Method theMethod =
+ getMethod(receiverClass, selector, paramTypes);
+ theMethod.setAccessible(true);
+ res = theMethod.invoke(target, args);
+ return new MethExecutorResult( res );
+
+ } catch (InvocationTargetException invTargEx) {
+ Throwable targEx = invTargEx.getTargetException();
+ if ( targEx == null ) {
+ return new MethExecutorResult( res );
+
+ } else {
+ return new MethExecutorResult(targEx);
+ }
+ }
+
+ }
+ catch (VirtualMachineError e) {
+ SystemFailure.initiateFailure(e);
+ throw e;
+ }
+ catch (Throwable t) {
+ return new MethExecutorResult(t);
+ }
+ }
+
+ /**
+ *
+ * Send the message "selector" to an instance of the class named "receiver".
+ * Return the result, including stack trace (if any).
+ *
+ */
+ public static MethExecutorResult executeInstance( String receiver, String selector ) {
+
+ try {
+ // get the class
+ Class receiverClass = Class.forName(receiver);
+ Object target = receiverClass.newInstance();
+
+ // invoke the method
+ Object res = null;
+ try {
+ Method theMethod =
+ getMethod(receiverClass, selector, new Class[0]);
+ res = theMethod.invoke(target, new Object[0] );
+ return new MethExecutorResult( res );
+
+ } catch (InvocationTargetException invTargEx) {
+ Throwable targEx = invTargEx.getTargetException();
+ if ( targEx == null ) {
+ return new MethExecutorResult( res );
+ } else {
+ return new MethExecutorResult(targEx);
+ }
+ }
+
+ }
+ catch (VirtualMachineError e) {
+ SystemFailure.initiateFailure(e);
+ throw e;
+ }
+ catch (Throwable t) {
+ return new MethExecutorResult(t);
+ }
+ }
+
+ /**
+ *
+ * Send the message "selector" to an instance of the class named "receiver".
+ * Return the result, including stack trace (if any).
+ *
+ */
+ public static MethExecutorResult executeInstance( String receiver, String selector,
+ Class[] types, Object[] args ) {
+
+ try {
+ // get the class
+ Class receiverClass = Class.forName(receiver);
+ Constructor init =
+ receiverClass.getDeclaredConstructor(new Class[0]);
+ init.setAccessible(true);
+ Object target = init.newInstance(new Object[0]);
+
+ // invoke the method
+ Object res = null;
+ try {
+ Method theMethod = getMethod(receiverClass, selector, types);
+ res = theMethod.invoke(target, args );
+ return new MethExecutorResult( res );
+
+ } catch (InvocationTargetException invTargEx) {
+ Throwable targEx = invTargEx.getTargetException();
+ if ( targEx == null ) {
+ return new MethExecutorResult( res );
+
+ } else {
+ return new MethExecutorResult(targEx);
+ }
+ }
+
+ }
+ catch (VirtualMachineError e) {
+ SystemFailure.initiateFailure(e);
+ throw e;
+ }
+ catch (Throwable t) {
+ return new MethExecutorResult(t);
+ }
+ }
+
+ /**
+ *
+ * A small program for testing this class.
+ *
+ */
+ public static String testMethod1() {
+ return "The result is: " + System.currentTimeMillis();
+ }
+ public static String testMethod2() {
+ throw new ArrayIndexOutOfBoundsException("frip");
+ }
+ public static void main(String[] args) {
+ MethExecutorResult result = null;
+ result = MethExecutor.execute( "dunit.MethExecutor", "testMethod1" );
+ System.out.println(result.toString());
+ result = MethExecutor.execute( "dunit.MethExecutor", "testMethod2" );
+ System.out.println(result.toString());
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/dunit/MethExecutorResult.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/dunit/MethExecutorResult.java b/gemfire-core/src/test/java/dunit/MethExecutorResult.java
new file mode 100644
index 0000000..6355652
--- /dev/null
+++ b/gemfire-core/src/test/java/dunit/MethExecutorResult.java
@@ -0,0 +1,184 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+
+package dunit;
+
+import java.io.*;
+
+/**
+*
+* The result of a MethExecutor execute method.
+*
+*/
+public class MethExecutorResult implements Serializable {
+
+ /** A "result" object that indicates that an exception occurred
+ * while invoking the method */
+ public static final Serializable EXCEPTION_OCCURRED = new
+ Serializable() {
+ public boolean equals(Object o) {
+ // Allows instances to be compared across VMs
+ return o != null && this.getClass().equals(o.getClass());
+ }
+
+ public String toString() {
+ return "EXCEPTION_OCCURRED";
+ }
+ };
+
+ /** A "exception" object that indicates that an exception could not
+ * be serialized. */
+ public static final Throwable NONSERIALIZABLE_EXCEPTION = new
+ Throwable() {
+ public boolean equals(Object o) {
+ // Allows instances to be compared across VMs
+ return o != null && this.getClass().equals(o.getClass());
+ }
+
+ public String toString() {
+ return "NONSERIALIZABLE_EXCEPTION";
+ }
+ };
+
+
+ //////////////////// Instance Methods ///////////////////////////
+
+ /** The result of execution (may be an exception or error type) */
+ private Object result;
+
+ /** The exception that resulted from invoking the method */
+ private Throwable exception;
+
+ /** Type of the exception (if applicable) */
+ private String exceptionClassName;
+
+ /** Message of the exception (if applicable) */
+ private String exceptionMessage;
+
+ /** Stack trace information (if applicable) */
+ private String stackTrace;
+
+ public MethExecutorResult() {
+ this.result = null;
+ }
+
+ public MethExecutorResult( Object result ) {
+ this.result = result;
+ }
+
+ /**
+ * This constructor is invoked from the closed-source hydra-based
+ * dunit when converting a hydra.MethExecutorResult to a
+ * dunit.MethExecutorResult.
+ */
+ public MethExecutorResult(Object aResult, Throwable anException, String anExceptionClassName, String anExceptionMessage, String aStackTrace) {
+ this.result = aResult;
+ this.exception = anException;
+ this.exceptionClassName = anExceptionClassName;
+ this.exceptionMessage = anExceptionMessage;
+ this.stackTrace = aStackTrace;
+ }
+
+ /**
+ * This constructor is invoked when invoking a method resulted in an
+ * exception being thrown. The "result" is set to {@link
+ * #EXCEPTION_OCCURRED}. If the exception could not be serialized,
+ * {@link #getException()} will return IOException with the exception
+ * stack as the message.
+ */
+ public MethExecutorResult(Throwable thr) {
+ this.result = EXCEPTION_OCCURRED;
+ this.exceptionClassName = thr.getClass().getName();
+ this.exceptionMessage = thr.getMessage();
+
+ StringWriter sw = new StringWriter();
+
+ thr.printStackTrace(new PrintWriter(sw, true));
+ this.stackTrace = sw.toString();
+
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(thr);
+ this.exception = thr;
+
+ } catch (IOException ex) {
+ sw = new StringWriter();
+ ex.printStackTrace(new PrintWriter(sw, true));
+ this.exception = new IOException(sw.toString());
+ }
+ }
+
+ public String toString() {
+ StringBuffer s = new StringBuffer();
+ s.append( this.getResult() );
+ s.append( "\n" );
+ if ( this.getStackTrace() != null ) {
+ s.append( this.getStackTrace() );
+ }
+ return s.toString();
+ }
+
+ /**
+ * Returns the result of the method call. If an exception was
+ * thrown during the method call, {@link #EXCEPTION_OCCURRED} is
+ * returned.
+ *
+ * @see #exceptionOccurred()
+ */
+ public Object getResult() {
+ return this.result;
+ }
+
+ /**
+ * Returns the name of the exception class of the exception that
+ * was thrown while invoking a method. If no exception was thrown,
+ * <code>null</code> is returned.
+ */
+ public String getExceptionClassName() {
+ return this.exceptionClassName;
+ }
+
+ /**
+ * Returns the message of the exception that was thrown while
+ * invoking a method. If no exception was thrown, <code>null</code>
+ * is returned.
+ */
+ public String getExceptionMessage() {
+ return this.exceptionMessage;
+ }
+
+ /**
+ * Returns the stack trace of the exception that was thrown while
+ * invoking a method. If no exception was thrown, <code>null</code>
+ * is returned.
+ */
+ public String getStackTrace() {
+ return this.stackTrace;
+ }
+
+ /**
+ * Returns the exception that was thrown while invoking a method.
+ * If the exception could not be serialized, then {@link
+ * #NONSERIALIZABLE_EXCEPTION} is returned. If no exception was
+ * thrown, <code>null</code> is returned.
+ */
+ public Throwable getException() {
+ return this.exception;
+ }
+
+ /**
+ * Returns whether or not an exception occurred while invoking the
+ * method
+ */
+ public boolean exceptionOccurred() {
+ return EXCEPTION_OCCURRED.equals(this.result);
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/dunit/RemoteDUnitVMIF.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/dunit/RemoteDUnitVMIF.java b/gemfire-core/src/test/java/dunit/RemoteDUnitVMIF.java
index de84292..2489ebd 100644
--- a/gemfire-core/src/test/java/dunit/RemoteDUnitVMIF.java
+++ b/gemfire-core/src/test/java/dunit/RemoteDUnitVMIF.java
@@ -1,6 +1,6 @@
package dunit;
-import hydra.MethExecutorResult;
+import dunit.MethExecutorResult;
import java.rmi.Remote;
import java.rmi.RemoteException;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/dunit/TestException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/dunit/TestException.java b/gemfire-core/src/test/java/dunit/TestException.java
new file mode 100644
index 0000000..e071442
--- /dev/null
+++ b/gemfire-core/src/test/java/dunit/TestException.java
@@ -0,0 +1,27 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package dunit;
+
+import java.lang.Error;
+
+public class TestException extends Error {
+
+ public TestException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+public TestException(String name) {
+ super(name);
+}
+
+public TestException(StringBuffer name) {
+ super(name.toString());
+}
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/dunit/VM.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/dunit/VM.java b/gemfire-core/src/test/java/dunit/VM.java
index 323dbfb..59772ce 100644
--- a/gemfire-core/src/test/java/dunit/VM.java
+++ b/gemfire-core/src/test/java/dunit/VM.java
@@ -7,8 +7,6 @@
*/
package dunit;
-import hydra.MethExecutorResult;
-
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/dunit/standalone/ChildVM.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/dunit/standalone/ChildVM.java b/gemfire-core/src/test/java/dunit/standalone/ChildVM.java
index 24c741e..adf078d 100644
--- a/gemfire-core/src/test/java/dunit/standalone/ChildVM.java
+++ b/gemfire-core/src/test/java/dunit/standalone/ChildVM.java
@@ -7,9 +7,6 @@
*/
package dunit.standalone;
-import hydra.HydraRuntimeException;
-import hydra.Log;
-
import java.rmi.Naming;
import org.apache.logging.log4j.Logger;
@@ -25,10 +22,6 @@ import dunit.standalone.DUnitLauncher.MasterRemote;
*/
public class ChildVM {
- static {
- createHydraLogWriter();
- }
-
private final static Logger logger = LogService.getLogger();
public static void main(String[] args) throws Throwable {
@@ -53,10 +46,4 @@ public class ChildVM {
}
}
- private static void createHydraLogWriter() {
- try {
- Log.createLogWriter("dunit-childvm", "fine");
- } catch (HydraRuntimeException ignore) {
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/dunit/standalone/DUnitLauncher.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/dunit/standalone/DUnitLauncher.java b/gemfire-core/src/test/java/dunit/standalone/DUnitLauncher.java
index a686204..fb5953b 100644
--- a/gemfire-core/src/test/java/dunit/standalone/DUnitLauncher.java
+++ b/gemfire-core/src/test/java/dunit/standalone/DUnitLauncher.java
@@ -7,9 +7,6 @@
*/
package dunit.standalone;
-import hydra.Log;
-import hydra.MethExecutorResult;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
@@ -40,8 +37,8 @@ import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.junit.Assert;
-import batterytest.greplogs.ExpectedStrings;
-import batterytest.greplogs.LogConsumer;
+import com.gemstone.gemfire.test.junit.greplogs.ExpectedStrings;
+import com.gemstone.gemfire.test.junit.greplogs.LogConsumer;
import com.gemstone.gemfire.distributed.Locator;
import com.gemstone.gemfire.internal.AvailablePortHelper;
@@ -50,6 +47,7 @@ import com.gemstone.gemfire.internal.logging.LogService;
import dunit.BounceResult;
import dunit.DUnitEnv;
import dunit.Host;
+import dunit.MethExecutorResult;
import dunit.RemoteDUnitVMIF;
import dunit.SerializableCallable;
import dunit.VM;
@@ -136,9 +134,6 @@ public class DUnitLauncher {
private static void launch() throws URISyntaxException, AlreadyBoundException, IOException, InterruptedException, NotBoundException {
-// initialize the log writer that hydra uses
- Log.createLogWriter( "dunit-master", LOG_LEVEL );
-
DUNIT_SUSPECT_FILE = new File(SUSPECT_FILENAME);
DUNIT_SUSPECT_FILE.delete();
DUNIT_SUSPECT_FILE.deleteOnExit();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/769c2ee8/gemfire-core/src/test/java/dunit/standalone/RemoteDUnitVM.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/dunit/standalone/RemoteDUnitVM.java b/gemfire-core/src/test/java/dunit/standalone/RemoteDUnitVM.java
index f3da32f..15712d0 100644
--- a/gemfire-core/src/test/java/dunit/standalone/RemoteDUnitVM.java
+++ b/gemfire-core/src/test/java/dunit/standalone/RemoteDUnitVM.java
@@ -7,9 +7,6 @@
*/
package dunit.standalone;
-import hydra.MethExecutor;
-import hydra.MethExecutorResult;
-
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
@@ -17,6 +14,8 @@ import org.apache.logging.log4j.Logger;
import com.gemstone.gemfire.internal.logging.LogService;
+import dunit.MethExecutor;
+import dunit.MethExecutorResult;
import dunit.RemoteDUnitVMIF;
/**