activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] git commit: Fixed karaf itest. Testing by hot deploying by copying a .xml file into deploy folder need to be done differently.
Date Thu, 03 Oct 2013 14:50:03 GMT
Updated Branches:
  refs/heads/trunk a5ac1a363 -> ac5ba4082


Fixed karaf itest. Testing by hot deploying by copying a .xml file into deploy folder need
to be done differently.


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/ac5ba408
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/ac5ba408
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/ac5ba408

Branch: refs/heads/trunk
Commit: ac5ba4082924fca214cf6f261d887fe3ebdffe23
Parents: f28ac6d
Author: Claus Ibsen <claus.ibsen@gmail.com>
Authored: Thu Oct 3 16:49:45 2013 +0200
Committer: Claus Ibsen <claus.ibsen@gmail.com>
Committed: Thu Oct 3 16:49:53 2013 +0200

----------------------------------------------------------------------
 .../karaf/itest/AbstractJmsFeatureTest.java     | 24 ++++++++++++++++++++
 ...ctiveMQBrokerNdExternalCamelFeatureTest.java | 14 ++++++++++--
 .../org/apache/activemq/karaf/itest/camel.xml   |  2 +-
 3 files changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/ac5ba408/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractJmsFeatureTest.java
----------------------------------------------------------------------
diff --git a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractJmsFeatureTest.java
b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractJmsFeatureTest.java
index 54482ce..609fb37 100644
--- a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractJmsFeatureTest.java
+++ b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractJmsFeatureTest.java
@@ -16,6 +16,11 @@
  */
 package org.apache.activemq.karaf.itest;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
 import javax.jms.Connection;
 import javax.jms.MessageConsumer;
 import javax.jms.Session;
@@ -24,6 +29,25 @@ import org.apache.activemq.ActiveMQConnectionFactory;
 
 public abstract class AbstractJmsFeatureTest extends AbstractFeatureTest {
 
+    public static void copyFile(File from, File to) throws IOException {
+        FileChannel in = new FileInputStream(from).getChannel();
+        FileChannel out = new FileOutputStream(to).getChannel();
+        try {
+            long size = in.size();
+            long position = 0;
+            while (position < size) {
+                position += in.transferTo(position, 8192, out);
+            }
+        } finally {
+            try {
+                in.close();
+                out.close();
+            } catch (Exception e) {
+                // ignore
+            }
+        }
+    }
+
     protected String consumeMessage(String nameAndPayload) throws Exception {
         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
         Connection connection = factory.createConnection(AbstractFeatureTest.USER, AbstractFeatureTest.PASSWORD);

http://git-wip-us.apache.org/repos/asf/activemq/blob/ac5ba408/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdExternalCamelFeatureTest.java
----------------------------------------------------------------------
diff --git a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdExternalCamelFeatureTest.java
b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdExternalCamelFeatureTest.java
index 7b913db..35bea63 100644
--- a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdExternalCamelFeatureTest.java
+++ b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdExternalCamelFeatureTest.java
@@ -18,6 +18,7 @@ package org.apache.activemq.karaf.itest;
 
 import java.io.File;
 import java.util.concurrent.Callable;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.MavenUtils;
@@ -35,8 +36,9 @@ public class ActiveMQBrokerNdExternalCamelFeatureTest extends AbstractJmsFeature
 
     @Configuration
     public static Option[] configure() {
+        // copy camel.xml into a temporary directory in karaf, so we later can hot-deploy
it
         Option[] baseOptions = append(
-                replaceConfigurationFile("deploy/camel.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/camel.xml")),
+                replaceConfigurationFile("data/tmp/camel.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/camel.xml")),
                 configure("activemq"));
         return configureBrokerStart(append(scanFeatures(getCamelFeatureUrl(
                 MavenUtils.getArtifactVersion("org.apache.camel.karaf", "apache-camel")
@@ -45,8 +47,8 @@ public class ActiveMQBrokerNdExternalCamelFeatureTest extends AbstractJmsFeature
 
     @Test
     public void test() throws Throwable {
+
         System.err.println(executeCommand("features:list").trim());
-        System.err.println(executeCommand("osgi:ls").trim());
         System.err.println(executeCommand("osgi:list").trim());
 
         withinReason(new Callable<Boolean>() {
@@ -68,6 +70,14 @@ public class ActiveMQBrokerNdExternalCamelFeatureTest extends AbstractJmsFeature
 
         System.err.println(executeCommand("activemq:bstat").trim());
 
+        // hot deploy the camel.xml file by copying it to the deploy directory
+        System.err.println("Karaf is running in dir: " + System.getProperty("karaf.base"));
+        String karafDir = System.getProperty("karaf.base");
+        System.err.println("Hot deploying Camel application");
+        copyFile(new File(karafDir + "/data/tmp/camel.xml"), new File(karafDir + "/deploy/camel.xml"));
+        Thread.sleep(3 * 1000);
+        System.err.println("Continuing...");
+
         // produce and consume
         final String nameAndPayload = String.valueOf(System.currentTimeMillis());
         produceMessage("camel_in");

http://git-wip-us.apache.org/repos/asf/activemq/blob/ac5ba408/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/camel.xml
----------------------------------------------------------------------
diff --git a/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/camel.xml
b/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/camel.xml
index ba7aa9c..641c46a 100644
--- a/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/camel.xml
+++ b/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/camel.xml
@@ -20,7 +20,7 @@
 <beans
   xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 
     <bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">


Mime
View raw message