Skip to content

Instantly share code, notes, and snippets.

@iocanel
iocanel / gist:1979041
Created March 5, 2012 16:08
Configuring ServiceMix as a pax-exam-karaf test container
@Configuration
public Option[] config() {
return new Option[]{ karafDistributionConfiguration().frameworkUrl(
maven().groupId("org.apache.servicemix").artifactId("apache-servicemix").type("zip").versionAsInProject())
.karafVersion("2.2.2").name("Apache Servicemix")};
}
@iocanel
iocanel / gist:1979047
Created March 5, 2012 16:11
Setting pax-exam probe to import packages with provisional status.
@ProbeBuilder
public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
probe.setHeader(Constants.DYNAMICIMPORT_PACKAGE, "*;status=provisional");
return probe;
}
@iocanel
iocanel / gist:1979051
Created March 5, 2012 16:12
Creating a method for invoking Karaf shell from inside a pax-exam karaf unit test
@Inject
CommandProcessor commandProcessor;
protected String executeCommands(final String ...commands) {
String response;
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final PrintStream printStream = new PrintStream(byteArrayOutputStream);
final CommandSession commandSession = commandProcessor.createSession(System.in, printStream, System.err);
FutureTask<string> commandFuture = new FutureTask<string>(
new Callable<string>() {
@iocanel
iocanel / gist:1979056
Created March 5, 2012 16:13
Using Karaf's AdminService for creating instances from a pax-exam karaf unit test
public void createInstances() {
//Install broker feature that is provided by FuseESB
executeCommands("admin:create --feature broker brokerChildInstance");
//Install producer feature that provided by imaginary feature repo.
executeCommands("admin:create --featureURL mvn:imaginary/repo/1.0/xml/features --feature producer producerChildInstance");
//Install producer feature that provided by imaginary feature repo.
executeCommands("admin:create --featureURL mvn:imaginary/repo/1.0/xml/features --feature consumer consumerChildInstance");
//start child instances
executeCommands("admin:start brokerChildInstance");
@iocanel
iocanel / gist:1979062
Created March 5, 2012 16:15
Executing a camel command to a child instance from a pax-exam karaf unit test
String routeInfo = executeCommands("admin:connect consumerChildInstance camel:route-info myconsumerRoute");
@iocanel
iocanel / gist:1979232
Created March 5, 2012 16:50
Creating a recurring task with camel and quartz
<from uri="quartz://cloudTimer?trigger.repeatInterval=3600000&amp;trigger.repeatCount=-1">
@iocanel
iocanel / gist:1979244
Created March 5, 2012 16:53
Initializing camel-jclouds component with spring xml
<bean class="org.apache.camel.component.jclouds.JcloudsComponent" id="jclouds">
<property name="computeServices">
<list>
<ref bean="computeService"/>
</list>
</property>
</bean>
<bean class="org.jclouds.compute.ComputeServiceContextFactory" id="computeCF"/>
@iocanel
iocanel / gist:1979249
Created March 5, 2012 16:54
Listing RUNNING nodes using camel-jclouds
<to uri="jclouds:compute:{{jclouds.provider}}?operation=CamelJcloudsListNodes&amp;nodeState=RUNNING"/>
@iocanel
iocanel / gist:1979256
Created March 5, 2012 16:56
Filtering empty lists from a camel route
<filter>
<simple>${body.size} != 0</simple>
<to uri="my:final-destination"/>
</filter>
@iocanel
iocanel / gist:1979265
Created March 5, 2012 16:57
Setting headers for camel-mail component in spring xml
<setheader headername="To">
<constant>target@gmail.com</constant>
</setheader>
<setheader headername="From">
<constant>sender@gmail.com</constant>
</setheader>
<setheader headername="Subject">
<constant>Running nodes in the cloud</constant>
</setheader>