Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CB3BD10ADB for ; Thu, 3 Oct 2013 14:50:06 +0000 (UTC) Received: (qmail 22674 invoked by uid 500); 3 Oct 2013 14:50:05 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 22602 invoked by uid 500); 3 Oct 2013 14:50:04 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 22588 invoked by uid 99); 3 Oct 2013 14:50:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Oct 2013 14:50:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B730A90E827; Thu, 3 Oct 2013 14:50:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@activemq.apache.org Date: Thu, 03 Oct 2013 14:50:03 -0000 Message-Id: <816dde44e4304cef8d12734e241b7ed3@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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. 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 Authored: Thu Oct 3 16:49:45 2013 +0200 Committer: Claus Ibsen 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() { @@ -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 @@