use of org.apache.camel.spring.SpringCamelContext in project camel by apache.
the class SpringCamelContextCustomDefaultThreadPoolProfileTest method testDefaultThreadPoolProfile.
public void testDefaultThreadPoolProfile() throws Exception {
SpringCamelContext context = applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();
ThreadPoolProfile profile = context.getExecutorServiceManager().getDefaultThreadPoolProfile();
assertEquals(5, profile.getPoolSize().intValue());
assertEquals(15, profile.getMaxPoolSize().intValue());
assertEquals(25, profile.getKeepAliveTime().longValue());
assertEquals(250, profile.getMaxQueueSize().intValue());
assertEquals(true, profile.getAllowCoreThreadTimeOut().booleanValue());
assertEquals(ThreadPoolRejectedPolicy.Abort, profile.getRejectedPolicy());
}
use of org.apache.camel.spring.SpringCamelContext in project camel by apache.
the class CamelSpringTestContextLoader method handleShutdownTimeout.
/**
* Handles updating shutdown timeouts on Camel contexts based on {@link ShutdownTimeout}.
*
* @param context the initialized Spring context
* @param testClass the test class being executed
*/
protected void handleShutdownTimeout(GenericApplicationContext context, Class<?> testClass) throws Exception {
final int shutdownTimeout;
final TimeUnit shutdownTimeUnit;
if (testClass.isAnnotationPresent(ShutdownTimeout.class)) {
shutdownTimeout = testClass.getAnnotation(ShutdownTimeout.class).value();
shutdownTimeUnit = testClass.getAnnotation(ShutdownTimeout.class).timeUnit();
} else {
shutdownTimeout = 10;
shutdownTimeUnit = TimeUnit.SECONDS;
}
CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
@Override
public void execute(String contextName, SpringCamelContext camelContext) throws Exception {
LOG.info("Setting shutdown timeout to [{} {}] on CamelContext with name [{}].", new Object[] { shutdownTimeout, shutdownTimeUnit, contextName });
camelContext.getShutdownStrategy().setTimeout(shutdownTimeout);
camelContext.getShutdownStrategy().setTimeUnit(shutdownTimeUnit);
}
});
}
use of org.apache.camel.spring.SpringCamelContext in project camel by apache.
the class CamelAnnotationsHandler method handleProvidesBreakpoint.
public static void handleProvidesBreakpoint(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
Collection<Method> methods = getAllMethods(testClass);
final List<Breakpoint> breakpoints = new LinkedList<Breakpoint>();
for (Method method : methods) {
if (AnnotationUtils.findAnnotation(method, ProvidesBreakpoint.class) != null) {
Class<?>[] argTypes = method.getParameterTypes();
if (argTypes.length != 0) {
throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but is not a no-argument method.");
} else if (!Breakpoint.class.isAssignableFrom(method.getReturnType())) {
throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but does not return a Breakpoint.");
} else if (!Modifier.isStatic(method.getModifiers())) {
throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but is not static.");
} else if (!Modifier.isPublic(method.getModifiers())) {
throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but is not public.");
}
try {
breakpoints.add((Breakpoint) method.invoke(null));
} catch (Exception e) {
throw new RuntimeException("Method [" + method.getName() + "] threw exception during evaluation.", e);
}
}
}
if (breakpoints.size() != 0) {
CamelSpringTestHelper.doToSpringCamelContexts(context, new CamelSpringTestHelper.DoToSpringCamelContextsStrategy() {
public void execute(String contextName, SpringCamelContext camelContext) throws Exception {
Debugger debugger = camelContext.getDebugger();
if (debugger == null) {
debugger = new DefaultDebugger();
camelContext.setDebugger(debugger);
}
for (Breakpoint breakpoint : breakpoints) {
LOGGER.info("Adding Breakpoint [{}] to CamelContext with name [{}].", breakpoint, contextName);
debugger.addBreakpoint(breakpoint);
}
}
});
}
}
use of org.apache.camel.spring.SpringCamelContext in project camel by apache.
the class PojoCallable method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
spring = new ClassPathXmlApplicationContext("org/apache/camel/component/javaspace/spring.xml");
SpringCamelContext ctx = SpringCamelContext.springCamelContext(spring);
return ctx;
}
use of org.apache.camel.spring.SpringCamelContext in project camel by apache.
the class JavaSpaceSendReceiveTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
spring = new ClassPathXmlApplicationContext("org/apache/camel/component/javaspace/spring.xml");
SpringCamelContext ctx = SpringCamelContext.springCamelContext(spring);
return ctx;
}
Aggregations