mirror of https://github.com/apache/activemq.git
Fixed karaf itest. Testing by hot deploying by copying a .xml file into deploy folder need to be done differently.
This commit is contained in:
parent
f28ac6d5e4
commit
ac5ba40829
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in New Issue