Repository: activemq-artemis
Updated Branches:
  refs/heads/master 88914e9fd -> f80e87768


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/OldAddressSpaceTest.java
----------------------------------------------------------------------
diff --git 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/OldAddressSpaceTest.java
 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/OldAddressSpaceTest.java
index a0803b8..da55daf 100644
--- 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/OldAddressSpaceTest.java
+++ 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/OldAddressSpaceTest.java
@@ -23,6 +23,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase;
 import org.apache.activemq.artemis.utils.FileUtil;
 import org.junit.After;
 import org.junit.Assert;
@@ -35,7 +36,7 @@ import static 
org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE
 import static 
org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT;
 
 @RunWith(Parameterized.class)
-public class OldAddressSpaceTest extends VersionedBaseTest {
+public class OldAddressSpaceTest extends VersionedBase {
 
    @Parameterized.Parameters(name = "server={0}, producer={1}, consumer={2}")
    public static Collection getParameters() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/PrefixSendAckTest.java
----------------------------------------------------------------------
diff --git 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/PrefixSendAckTest.java
 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/PrefixSendAckTest.java
index 3bdb23a..c4b0d87 100644
--- 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/PrefixSendAckTest.java
+++ 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/PrefixSendAckTest.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.activemq.artemis.tests.compatibility.base.ServerBase;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -31,7 +32,7 @@ import static 
org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT
 import static 
org.apache.activemq.artemis.tests.compatibility.GroovyRun.TWO_FOUR;
 
 @RunWith(Parameterized.class)
-public class PrefixSendAckTest extends ServerBaseTest {
+public class PrefixSendAckTest extends ServerBase {
    @Parameterized.Parameters(name = "server={0}, producer={1}, consumer={2}")
    public static Collection getParameters() {
       List<Object[]> combinations = new ArrayList<>();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ReplyToTest.java
----------------------------------------------------------------------
diff --git 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ReplyToTest.java
 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ReplyToTest.java
new file mode 100644
index 0000000..fb7846c
--- /dev/null
+++ 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ReplyToTest.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.compatibility;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.artemis.tests.compatibility.base.ServerBase;
+import org.apache.activemq.artemis.utils.FileUtil;
+import org.junit.After;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static 
org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE;
+import static 
org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT;
+
+/**
+ * To run this test on the IDE and debug it, run the compatibility-tests 
through a command line once:
+ *
+ * cd /compatibility-tests
+ * mvn install -Ptests | tee output.log
+ *
+ * on the output.log you will see the output generated by {@link 
#getClasspath(String)}
+ *
+ * On your IDE, edit the Run Configuration to your test and add those -D as 
parameters to your test.
+ * On Idea you would do the following:
+ *
+ * Run->Edit Configuration->Add ArtemisMeshTest and add your properties.
+ */
+@RunWith(Parameterized.class)
+public class ReplyToTest extends ServerBase {
+
+   @Before
+   @Override
+   public void setUp() throws Throwable {
+
+      FileUtil.deleteDirectory(serverFolder.getRoot());
+      serverFolder.getRoot().mkdirs();
+
+      File file = serverFolder.newFile(ActiveMQJMSClient.class.getName() + 
".properties");
+      FileOutputStream fileOutputStream = new FileOutputStream(file);
+      PrintStream stream = new PrintStream(fileOutputStream);
+      stream.println("enable1xPrefixes=true");
+      stream.close();
+
+      setVariable(serverClassloader, "persistent", Boolean.FALSE);
+      startServer(serverFolder.getRoot(), serverClassloader, "live");
+   }
+
+   @After
+   @Override
+   public void tearDown() throws Throwable {
+      super.tearDown();
+   }
+
+   @Override
+   public ClassLoader getClasspath(String name) throws Exception {
+      if (name.equals(SNAPSHOT)) {
+
+         String snapshotPath = System.getProperty(SNAPSHOT);
+         Assume.assumeNotNull(snapshotPath);
+
+         String path = serverFolder.getRoot().getAbsolutePath() + 
File.pathSeparator + snapshotPath;
+
+         ClassLoader loader = defineClassLoader(path);
+
+         clearGroovy(loader);
+
+         return loader;
+      } else {
+         return super.getClasspath(name);
+      }
+   }
+
+   // this will ensure that all tests in this class are run twice,
+   // once with "true" passed to the class' constructor and once with "false"
+   @Parameterized.Parameters(name = "server={0}, producer={1}, consumer={2}")
+   public static Collection getParameters() {
+      // we don't need every single version ever released..
+      // if we keep testing current one against 2.4 and 1.4.. we are sure the 
wire and API won't change over time
+      List<Object[]> combinations = new ArrayList<>();
+
+      /*
+      // during development sometimes is useful to comment out the combinations
+      // and add the ones you are interested.. example:
+       */
+      //      combinations.add(new Object[]{SNAPSHOT, ONE_FIVE, ONE_FIVE});
+      //      combinations.add(new Object[]{ONE_FIVE, ONE_FIVE, ONE_FIVE});
+
+      combinations.add(new Object[]{SNAPSHOT, ONE_FIVE, ONE_FIVE});
+      combinations.add(new Object[]{ONE_FIVE, SNAPSHOT, SNAPSHOT});
+
+      // TODO: It's not currently possible to mix reply to between 1.x and 
SNAPSHOT. Both sides need to be on the same version!
+      // combinations.addAll(combinatory(SNAPSHOT, new Object[]{SNAPSHOT, 
ONE_FIVE}, new Object[]{SNAPSHOT, ONE_FIVE}, new Object[]{SNAPSHOT, ONE_FIVE}));
+      return combinations;
+   }
+
+   public ReplyToTest(String server, String sender, String receiver) throws 
Exception {
+      super(server, sender, receiver);
+   }
+
+   @Test
+   public void testSendReceive() throws Throwable {
+
+      setVariable(receiverClassloader, "latch", null);
+      evaluate(senderClassloader, "ReplyToTest/replyToSend.groovy");
+      evaluate(receiverClassloader, "ReplyToTest/replyToReceive.groovy");
+   }
+
+}
+

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SendAckTest.java
----------------------------------------------------------------------
diff --git 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SendAckTest.java
 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SendAckTest.java
index 168a56f..9df38e3 100644
--- 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SendAckTest.java
+++ 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SendAckTest.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.activemq.artemis.tests.compatibility.base.ServerBase;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -44,7 +45,7 @@ import static 
org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE
  * Run->Edit Configuration->Add ArtemisMeshTest and add your properties.
  */
 @RunWith(Parameterized.class)
-public class SendAckTest extends ServerBaseTest {
+public class SendAckTest extends ServerBase {
 
    // this will ensure that all tests in this class are run twice,
    // once with "true" passed to the class' constructor and once with "false"

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SerializationTest.java
----------------------------------------------------------------------
diff --git 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SerializationTest.java
 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SerializationTest.java
index bb23816..f7c6192 100644
--- 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SerializationTest.java
+++ 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SerializationTest.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase;
 import org.apache.activemq.artemis.utils.FileUtil;
 import org.junit.After;
 import org.junit.Before;
@@ -46,7 +47,7 @@ import static 
org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT
  * Run->Edit Configuration->Add ArtemisMeshTest and add your properties.
  */
 @RunWith(Parameterized.class)
-public class SerializationTest extends VersionedBaseTest {
+public class SerializationTest extends VersionedBase {
 
    // this will ensure that all tests in this class are run twice,
    // once with "true" passed to the class' constructor and once with "false"

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ServerBaseTest.java
----------------------------------------------------------------------
diff --git 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ServerBaseTest.java
 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ServerBaseTest.java
deleted file mode 100644
index f519eab..0000000
--- 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ServerBaseTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.activemq.artemis.tests.compatibility;
-
-import org.apache.activemq.artemis.utils.FileUtil;
-import org.junit.After;
-import org.junit.Before;
-
-public class ServerBaseTest extends VersionedBaseTest {
-
-   public ServerBaseTest(String server, String sender, String receiver) throws 
Exception {
-      super(server, sender, receiver);
-   }
-
-   @Before
-   public void setUp() throws Throwable {
-      FileUtil.deleteDirectory(serverFolder.getRoot());
-      setVariable(serverClassloader, "persistent", Boolean.FALSE);
-      startServer(serverFolder.getRoot(), serverClassloader, "live");
-   }
-
-   @After
-   public void tearDown() throws Throwable {
-      stopServer(serverClassloader);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/VersionedBaseTest.java
----------------------------------------------------------------------
diff --git 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/VersionedBaseTest.java
 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/VersionedBaseTest.java
deleted file mode 100644
index ab5331d..0000000
--- 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/VersionedBaseTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.activemq.artemis.tests.compatibility;
-
-import java.io.File;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.junit.AfterClass;
-
-public abstract class VersionedBaseTest extends ClasspathBaseTest {
-
-   protected final String server;
-   protected final String sender;
-   protected final String receiver;
-
-   protected ClassLoader serverClassloader;
-   protected ClassLoader senderClassloader;
-   protected ClassLoader receiverClassloader;
-
-   public VersionedBaseTest(String server, String sender, String receiver) 
throws Exception {
-      if (server == null) {
-         server = sender;
-      }
-      this.server = server;
-      this.sender = sender;
-      this.receiver = receiver;
-      this.serverClassloader = getClasspath(server);
-      this.senderClassloader = getClasspath(sender);
-      this.receiverClassloader = getClasspath(receiver);
-   }
-
-   @AfterClass
-   public static void cleanup() {
-      loaderMap.clear();
-   }
-
-   protected static List<Object[]> combinatory(Object[] rootSide, Object[] 
sideLeft, Object[] sideRight) {
-      LinkedList<Object[]> combinations = new LinkedList<>();
-
-      for (Object root : rootSide) {
-         for (Object left : sideLeft) {
-            for (Object right : sideRight) {
-               combinations.add(new Object[]{root, left, right});
-            }
-         }
-      }
-
-      return combinations;
-   }
-
-   public void startServer(File folder, ClassLoader loader, String serverName) 
throws Throwable {
-      startServer(folder, loader, serverName, null);
-   }
-
-   public void startServer(File folder, ClassLoader loader, String serverName, 
String globalMaxSize) throws Throwable {
-      startServer(folder, loader, serverName, globalMaxSize, false);
-
-   }
-
-   public void startServer(File folder,
-                           ClassLoader loader,
-                           String serverName,
-                           String globalMaxSize,
-                           boolean setAddressSettings) throws Throwable {
-      folder.mkdirs();
-
-      String scriptToUse;
-      if (getServerScriptToUse() != null && getServerScriptToUse().length() != 
0) {
-         scriptToUse = getServerScriptToUse();
-      } else if (server.startsWith("ARTEMIS")) {
-         scriptToUse = "servers/artemisServer.groovy";
-      } else {
-         scriptToUse = "servers/hornetqServer.groovy";
-      }
-
-      setVariable(loader, "setAddressSettings", setAddressSettings);
-      evaluate(loader, scriptToUse, folder.getAbsolutePath(), serverName, 
server, sender, receiver, globalMaxSize);
-   }
-
-   public void stopServer(ClassLoader loader) throws Throwable {
-      execute(loader, "server.stop()");
-   }
-
-   public String getServerScriptToUse() {
-      return null;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/ClasspathBase.java
----------------------------------------------------------------------
diff --git 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/ClasspathBase.java
 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/ClasspathBase.java
new file mode 100644
index 0000000..0f821df
--- /dev/null
+++ 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/ClasspathBase.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.compatibility.base;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.apache.activemq.artemis.tests.compatibility.GroovyRun;
+import org.junit.Assume;
+import org.junit.ClassRule;
+import org.junit.rules.TemporaryFolder;
+
+import static 
org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT;
+
+public class ClasspathBase {
+
+
+   @ClassRule
+   public static TemporaryFolder serverFolder;
+
+   static {
+      File parent = new File("./target/tmp");
+      parent.mkdirs();
+      serverFolder = new TemporaryFolder(parent);
+   }
+
+   protected static Map<String, ClassLoader> loaderMap = new HashMap<>();
+
+   private static HashSet<String> printed = new HashSet<>();
+
+   protected ClassLoader defineClassLoader(String classPath) throws 
MalformedURLException {
+      String[] classPathArray = classPath.split(File.pathSeparator);
+      URL[] elements = new URL[classPathArray.length];
+      for (int i = 0; i < classPathArray.length; i++) {
+         elements[i] = new File(classPathArray[i]).toPath().toUri().toURL();
+      }
+
+      return new URLClassLoader(elements, null);
+   }
+
+   protected ClassLoader getClasspath(String name) throws Exception {
+      return getClasspath(name, false);
+   }
+
+   protected ClassLoader getClasspath(String name, boolean forceNew) throws 
Exception {
+
+      if (!forceNew) {
+         if (name.equals(SNAPSHOT)) {
+            GroovyRun.clear();
+            return VersionedBase.class.getClassLoader();
+         }
+
+         ClassLoader loader = loaderMap.get(name);
+         if (loader != null && !forceNew) {
+            clearGroovy(loader);
+            return loader;
+         }
+      }
+
+      String value = System.getProperty(name);
+
+      if (!printed.contains(name)) {
+         boolean ok = value != null && !value.trim().isEmpty();
+         if (!ok) {
+            System.out.println("Add \"-D" + name + "=\'CLASSPATH\'\" into your 
VM settings");
+            System.out.println("You will see it in the output from mvn install 
at the compatibility-tests");
+            System.out.println("... look for output from dependency-scan");
+
+            // our dependency scan used at the pom under 
compatibility-tests/pom.xml will generate these, example:
+            // [INFO] dependency-scan setting: 
-DARTEMIS-140="/Users/someuser/....."
+            // copy that into your IDE setting and you should be able to debug 
it
+         }
+         Assume.assumeTrue("Cannot run these tests, no classpath found", ok);
+      }
+
+      ClassLoader loader = defineClassLoader(value);
+      if (!forceNew) {
+         // if we are forcing a new one, there's no point in caching it
+         loaderMap.put(name, loader);
+      }
+
+      return loader;
+   }
+
+   protected static Object evaluate(ClassLoader loader, String script, 
String... arguments) throws Exception {
+      return tclCall(loader, () -> {
+         Class clazz = loader.loadClass(GroovyRun.class.getName());
+         Method method = clazz.getMethod("evaluate", String.class, 
String[].class);
+         return method.invoke(null, script, arguments);
+      });
+   }
+
+   protected static void setVariable(ClassLoader loader, String name, Object 
object) throws Exception {
+      tclCall(loader, () -> {
+         Class clazz = loader.loadClass(GroovyRun.class.getName());
+         Method method = clazz.getMethod("setVariable", String.class, 
Object.class);
+         method.invoke(null, name, object);
+         return null;
+      });
+   }
+
+   protected static void clearGroovy(ClassLoader loader) throws Exception {
+      tclCall(loader, () -> {
+         Class clazz = loader.loadClass(GroovyRun.class.getName());
+         Method method = clazz.getMethod("clear");
+         method.invoke(null);
+         return null;
+      });
+   }
+
+   protected static Object setVariable(ClassLoader loader, String name) throws 
Exception {
+      return tclCall(loader, () -> {
+         Class clazz = loader.loadClass(GroovyRun.class.getName());
+         Method method = clazz.getMethod("getVariable", String.class);
+         return method.invoke(null, name);
+      });
+   }
+
+   protected static Object execute(ClassLoader loader, String script) throws 
Exception {
+      return tclCall(loader, () -> {
+         Class clazz = loader.loadClass(GroovyRun.class.getName());
+         Method method = clazz.getMethod("execute", String.class);
+         return method.invoke(null, script);
+      });
+   }
+
+   protected static Object tclCall(ClassLoader loader, CallIt run) throws 
Exception {
+
+      ClassLoader original = Thread.currentThread().getContextClassLoader();
+      Thread.currentThread().setContextClassLoader(loader);
+      try {
+         return run.run();
+      } finally {
+         Thread.currentThread().setContextClassLoader(original);
+      }
+   }
+
+   public interface CallIt {
+
+      Object run() throws Exception;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/ServerBase.java
----------------------------------------------------------------------
diff --git 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/ServerBase.java
 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/ServerBase.java
new file mode 100644
index 0000000..8c73c63
--- /dev/null
+++ 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/ServerBase.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.compatibility.base;
+
+import org.apache.activemq.artemis.utils.FileUtil;
+import org.junit.After;
+import org.junit.Before;
+
+public class ServerBase extends VersionedBase {
+
+   public ServerBase(String server, String sender, String receiver) throws 
Exception {
+      super(server, sender, receiver);
+   }
+
+   @Before
+   public void setUp() throws Throwable {
+      FileUtil.deleteDirectory(serverFolder.getRoot());
+      setVariable(serverClassloader, "persistent", Boolean.FALSE);
+      startServer(serverFolder.getRoot(), serverClassloader, "live");
+   }
+
+   @After
+   public void tearDown() throws Throwable {
+      stopServer(serverClassloader);
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/VersionedBase.java
----------------------------------------------------------------------
diff --git 
a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/VersionedBase.java
 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/VersionedBase.java
new file mode 100644
index 0000000..1c5b244
--- /dev/null
+++ 
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/base/VersionedBase.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.compatibility.base;
+
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.junit.AfterClass;
+
+public abstract class VersionedBase extends ClasspathBase {
+
+   protected final String server;
+   protected final String sender;
+   protected final String receiver;
+
+   protected final ClassLoader serverClassloader;
+   protected final ClassLoader senderClassloader;
+   protected final ClassLoader receiverClassloader;
+
+   public VersionedBase(String server, String sender, String receiver) throws 
Exception {
+      if (server == null) {
+         server = sender;
+      }
+      this.server = server;
+      this.sender = sender;
+      this.receiver = receiver;
+      this.serverClassloader = getClasspath(server);
+      this.senderClassloader = getClasspath(sender);
+      this.receiverClassloader = getClasspath(receiver);
+      clearGroovy(senderClassloader);
+      clearGroovy(receiverClassloader);
+      clearGroovy(serverClassloader);
+   }
+
+   @AfterClass
+   public static void cleanup() {
+      loaderMap.clear();
+   }
+
+   protected static List<Object[]> combinatory(Object[] rootSide, Object[] 
sideLeft, Object[] sideRight) {
+      return combinatory(null, rootSide, sideLeft, sideRight);
+   }
+
+   protected static List<Object[]> combinatory(Object required,
+                                               Object[] rootSide,
+                                               Object[] sideLeft,
+                                               Object[] sideRight) {
+      LinkedList<Object[]> combinations = new LinkedList<>();
+
+      for (Object root : rootSide) {
+         for (Object left : sideLeft) {
+            for (Object right : sideRight) {
+               if (required == null || root.equals(required) || 
left.equals(required) || right.equals(required)) {
+                  combinations.add(new Object[]{root, left, right});
+               }
+            }
+         }
+      }
+
+      return combinations;
+   }
+
+   public void startServer(File folder, ClassLoader loader, String serverName) 
throws Throwable {
+      startServer(folder, loader, serverName, null);
+   }
+
+   public void startServer(File folder, ClassLoader loader, String serverName, 
String globalMaxSize) throws Throwable {
+      startServer(folder, loader, serverName, globalMaxSize, false);
+
+   }
+
+   public void startServer(File folder,
+                           ClassLoader loader,
+                           String serverName,
+                           String globalMaxSize,
+                           boolean setAddressSettings) throws Throwable {
+      folder.mkdirs();
+
+      String scriptToUse;
+      if (getServerScriptToUse() != null && getServerScriptToUse().length() != 
0) {
+         scriptToUse = getServerScriptToUse();
+      } else if (server.startsWith("ARTEMIS")) {
+         scriptToUse = "servers/artemisServer.groovy";
+      } else {
+         scriptToUse = "servers/hornetqServer.groovy";
+      }
+
+      setVariable(loader, "setAddressSettings", setAddressSettings);
+      evaluate(loader, scriptToUse, folder.getAbsolutePath(), serverName, 
server, sender, receiver, globalMaxSize);
+   }
+
+   public void stopServer(ClassLoader loader) throws Throwable {
+      execute(loader, "server.stop()");
+   }
+
+   public String getServerScriptToUse() {
+      return null;
+   }
+}

Reply via email to