Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #96 from OpenWiseSolutions/feature/OHFJIRA-96-came…
Browse files Browse the repository at this point in the history
…l-upgrade

[OHFJIRA-96] : Camel core version updated to 2.21.3
  • Loading branch information
kkovarik committed Nov 26, 2018
2 parents 2df2925 + 3ceaf4b commit 16d9c70
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 53 deletions.
Expand Up @@ -33,6 +33,7 @@
import org.springframework.context.event.ApplicationContextEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.ContextStartedEvent;
import org.springframework.core.Ordered;
import org.springframework.util.Assert;

/**
Expand All @@ -44,10 +45,17 @@
* @see DefaultCamelContext#setRegistry(Registry)
* @since 2.0
*/
public class ApplicationContextsRegistry implements Registry, ApplicationListener<ApplicationContextEvent> {
public class ApplicationContextsRegistry implements Registry, ApplicationListener<ApplicationContextEvent>, Ordered {

private static final Logger LOG = LoggerFactory.getLogger(ApplicationContextsRegistry.class);

/**
* Order of listener for application events.
* It is important to receive event ContextRefreshedEvent before
* {@link org.apache.camel.spring.boot.RoutesCollector} does.
*/
public static final int ORDER = LOWEST_PRECEDENCE - 20;

/**
* List of registers for all application contexts.
*/
Expand Down Expand Up @@ -145,4 +153,9 @@ public void onApplicationEvent(ApplicationContextEvent event) {
applicationContextsRegistry.put(applicationContext, new ApplicationContextRegistry(applicationContext));
}
}

@Override
public int getOrder() {
return ORDER;
}
}
Expand Up @@ -440,6 +440,11 @@ public TriggerState getTriggerState(TriggerKey triggerKey) throws SchedulerExcep
return getScheduler().getTriggerState(triggerKey);
}

@Override
public void resetTriggerFromErrorState(final TriggerKey triggerKey) throws SchedulerException {
getScheduler().resetTriggerFromErrorState(triggerKey);
}

@Override
public void addCalendar(String calName, Calendar calendar, boolean replace, boolean updateTriggers) throws SchedulerException {
getScheduler().addCalendar(calName, calendar, replace, updateTriggers);
Expand Down
Expand Up @@ -175,54 +175,6 @@ public void testSavingRequest() throws Exception {
assertThat(requestList.get(0), is(req));
}

/**
* Test saving response only, there is no request.
*/
@Test
public void testSavingResponseOnly() throws Exception {
setPrivateField(reqSendingEventNotifier, "enable", new FixedConfigurationItem<>(Boolean.FALSE));

// prepare target route
prepareTargetRoute(TARGET_URI, null);

// action
mock.expectedMessageCount(1);
producer.sendBody(REQUEST);

// verify
TypedQuery<Request> queryReq = em.createQuery("FROM " + Request.class.getName(), Request.class);
List<Request> requests = queryReq.getResultList();
assertThat(requests.size(), is(0));

TypedQuery<Response> queryRes = em.createQuery("FROM " + Response.class.getName(), Response.class);
List<Response> responses = queryRes.getResultList();
assertThat(responses.size(), is(1));
}

/**
* Test saving response with message only, there is no request.
*/
@Test
@Transactional
public void testSavingResponseWithMsgOnly() throws Exception {
setPrivateField(reqSendingEventNotifier, "enable", new FixedConfigurationItem<>(Boolean.FALSE));

// prepare target route
prepareTargetRoute(TARGET_URI, null);

// action
mock.expectedMessageCount(1);

Message msg = insertMessage();

producer.sendBodyAndHeader(REQUEST, AsynchConstants.MSG_HEADER, msg);

// verify
TypedQuery<Response> queryRes = em.createQuery("FROM " + Response.class.getName(), Response.class);
List<Response> responses = queryRes.getResultList();
assertThat(responses.size(), is(1));
}

/**
* Test saving asynchronous request/response with correct calling target endpoint.
*/
Expand Down
20 changes: 19 additions & 1 deletion pom.xml
Expand Up @@ -197,7 +197,7 @@
<spring-boot.version>1.5.17.RELEASE</spring-boot.version>
<start-class>org.openhubframework.openhub.OpenHubApplication</start-class>

<camel-version>2.18.2</camel-version>
<camel-version>2.21.3</camel-version>

<!-- persistence -->
<postgresql-version>9.4-1201-jdbc41</postgresql-version>
Expand Down Expand Up @@ -282,6 +282,24 @@
<scope>import</scope>
</dependency>

<!-- Apache Camel libraries -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz2</artifactId>
<version>${camel-version}</version>
<exclusions>
<!-- using HikariCP artifact -->
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-java6</artifactId>
</exclusion>
<exclusion>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Enabled configuration properties in OHF classes -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Expand Up @@ -129,9 +129,7 @@ private void addRoutes(CamelContext camelContext) throws Exception {
for (RoutesBuilder routesBuilder : applicationContext.getBeansOfType(RoutesBuilder.class).values()) {
// filter out abstract classes
boolean abs = Modifier.isAbstract(routesBuilder.getClass().getModifiers());
// filter out FatJarRouter which can be in the spring app context
boolean farJarRouter = FatJarRouter.class.equals(routesBuilder.getClass());
if (!abs && !farJarRouter) {
if (!abs) {
try {
if (initAllRoutes) {
LOG.debug("Injecting following route into the CamelContext: {}", routesBuilder);
Expand Down

0 comments on commit 16d9c70

Please sign in to comment.