Skip to content

Instantly share code, notes, and snippets.

@mproch
Created March 31, 2011 19:52
Show Gist options
  • Save mproch/897109 to your computer and use it in GitHub Desktop.
Save mproch/897109 to your computer and use it in GitHub Desktop.
profile("felix.fileinstall"),
systemProperty("felix.fileinstall.dir").value(resources + "etc"),
systemProperty("felix.fileinstall.filter").value(".*\\.cfg"),
systemProperty("felix.fileinstall.poll").value("1000"),
systemProperty("felix.fileinstall.noInitialDelay").value("true"),
mavenBundle("org.apache.felix", "org.apache.felix.configadmin").startLevel(2),
mavenBundle("org.apache.felix", "org.apache.felix.fileinstall").startLevel(2),
protected <T> T getBean(Class<T> klazz, String beanName) throws Exception {
ServiceTracker tracker = new ServiceTracker(bundleContext, bundleContext.createFilter(
"(&(objectClass=" + klazz.getName() + ")(org.springframework.osgi.bean.name=" + beanName + "))"), null);
tracker.open();
T bean = (T) tracker.waitForService(10000);
tracker.close();
assertNotNull(bean);
return bean;
}
org.osgi.framework.system.packages = \
com.sun.org.apache.xalan.internal.xsltc.trax, \
com.sun.org.apache.xerces.internal.dom, \
com.sun.org.apache.xerces.internal.jaxp, \
com.sun.org.apache.xerces.internal.xni, \
com.sun.org.apache.xpath.internal.jaxp, \
com.sun.org.apache.xerces.internal.jaxp.validation, \
...
# javax.xml.soap, \
# javax.xml.stream, \
# javax.xml.stream.events, \
# javax.xml.stream.util, \
...
public static Option[] configuration() throws Exception {
String resources = BasicIntegrationTest.class.getResource("/").getFile();
System.setProperty("org.ops4j.pax.runner.platform.ee", "file://" + resources + "etc/jre.properties");
systemProperty("karaf.startLocalConsole").value("false"),
systemProperty("karaf.home").value(resources),
systemProperty("karaf.startRemoteShell").value("false"),
mavenBundle("org.apache.karaf.shell", "org.apache.karaf.shell.console", karafVersion).startLevel(3),
mavenBundle("org.apache.karaf", "org.apache.karaf.management", karafVersion).startLevel(3),
mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint", "0.2-incubating").startLevel(2),
@Configuration
public static Option[] configuration() throws Exception {
return options(
//...
);
}
@Test
public void sendMessage() throws Exception {
Thread.sleep(1000);
Source out= sendMessage("{http://touk.pl/smx4/paxexam}service1", "<request/>");
String response = XPathBuilder.xpath("//ns:response/text()").namespace("ns", "http://touk.pl/smx4/paxexam")
.evaluate(getCamelContext("serviceContext"), out)
assertEquals("response", response);
Assert.assertEquals(1, ((Listener) getBean(ExchangeListener.class, "listener")).exchanges.size());
}
protected Source sendMessage(String service, String message) throws Exception {
NMR nmr = getNMR();
ExchangeImpl ei = new ExchangeImpl(Pattern.InOut);
ei.getIn().setBody(new StringSource(message));
Reference ref = nmr.getEndpointRegistry().lookup(Collections.singletonMap("SERVICE_NAME", service));
ei.setTarget(ref);
Channel channel = nmr.createChannel();
channel.sendSync(ei);
Source out = ei.getOut().getBody(Source.class);
ei.setStatus(Status.Done);
channel.send(ei);
channel.close();
return out;
}
mavenBundle("org.apache.xbean", "xbean-blueprint", "3.7").startLevel(4),
mavenBundle("org.apache.commons", "commons-jexl", "2.0.1").startLevel(4),
mavenBundle("org.apache.servicemix.specs",
"org.apache.servicemix.specs.scripting-api-1.0", "1.7.0").startLevel(4),
scanFeatures(
maven().groupId("org.apache.servicemix")
.artifactId("apache-servicemix")
.type("xml").classifier("features")
.version("4.3.0"),
"servicemix-camel", "servicemix-cxf-bc", "camel-nmr"
).startLevel(4),
return options(
workingDirectory(resources + "paxExam"),
felix(),
logProfile(),
profile("spring.dm", "1.2.0"),
profile("spring"),
systemProperty("javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema")
.value("com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl"),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment