Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OHFJIRA-45 - Stop processing synchronous requests in stopping mode
- Loading branch information
1 parent
06df415
commit 7864129
Showing
14 changed files
with
404 additions
and
34 deletions.
There are no files selected for viewing
5 changes: 4 additions & 1 deletion
5
...amework/openhub/api/entity/RouteType.java → ...ramework/openhub/api/route/RouteType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
core/src/main/java/org/openhubframework/openhub/core/common/route/RouteTypeEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
...rg/openhubframework/openhub/core/common/handlemessage/HandleMessagePolicyFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
package org.openhubframework.openhub.core.common.handlemessage; | ||
|
||
import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; | ||
import static org.hamcrest.CoreMatchers.instanceOf; | ||
import static org.junit.Assert.assertThat; | ||
import static org.openhubframework.openhub.api.configuration.CoreProps.URI_INPUT_PATTERN_FILTER; | ||
|
||
import org.apache.camel.EndpointInject; | ||
import org.apache.camel.Produce; | ||
import org.apache.camel.ProducerTemplate; | ||
import org.apache.camel.component.mock.MockEndpoint; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
import org.openhubframework.openhub.api.entity.MutableNode; | ||
import org.openhubframework.openhub.api.exception.IntegrationException; | ||
import org.openhubframework.openhub.api.route.AbstractBasicRoute; | ||
import org.openhubframework.openhub.core.AbstractCoreTest; | ||
import org.openhubframework.openhub.core.common.asynch.ExceptionTranslationRoute; | ||
import org.openhubframework.openhub.spi.node.ChangeNodeCallback; | ||
import org.openhubframework.openhub.spi.node.NodeService; | ||
import org.openhubframework.openhub.test.data.ExternalSystemTestEnum; | ||
import org.openhubframework.openhub.test.data.ServiceTestEnum; | ||
import org.openhubframework.openhub.test.route.ActiveRoutes; | ||
|
||
/** | ||
* Test for {@link HandleMessagePolicyFactory}. | ||
* | ||
* @author Roman Havlicek | ||
* @see HandleMessagePolicyFactory | ||
* @since 2.0 | ||
*/ | ||
@ActiveRoutes(classes = ExceptionTranslationRoute.class) | ||
@TestPropertySource(properties = {URI_INPUT_PATTERN_FILTER + "=direct:inputUri"}) | ||
public class HandleMessagePolicyFactoryTest extends AbstractCoreTest { | ||
|
||
@EndpointInject(uri = "mock:inputRoute") | ||
private MockEndpoint inputRouteMock; | ||
|
||
@EndpointInject(uri = "mock:inputUri") | ||
private MockEndpoint inputUriMock; | ||
|
||
@EndpointInject(uri = "mock:outputRoute") | ||
private MockEndpoint outputRouteMock; | ||
|
||
@Produce | ||
private ProducerTemplate producer; | ||
|
||
@Autowired | ||
private NodeService nodeService; | ||
|
||
/** | ||
* Init routes for test. | ||
* | ||
* @throws Exception all errors | ||
*/ | ||
@Before | ||
public void init() throws Exception { | ||
getCamelContext().addRoutes(new AbstractBasicRoute() { | ||
@Override | ||
protected void doConfigure() throws Exception { | ||
from("direct:inputRoute") | ||
.routeId(getInRouteId(ServiceTestEnum.ACCOUNT, "input")) | ||
.to(inputRouteMock); | ||
|
||
from("direct:inputUri") | ||
.routeId(getRouteId(ServiceTestEnum.CUSTOMER, "create")) | ||
.to(inputUriMock); | ||
|
||
from("direct:outputRoute") | ||
.routeId(getExternalRouteId(ExternalSystemTestEnum.BILLING, "output")) | ||
.to(outputRouteMock); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Test when actual node is running. | ||
* | ||
* @throws Exception all errors | ||
*/ | ||
@Test | ||
public void testNodeRun() throws Exception { | ||
inputRouteMock.setExpectedMessageCount(1); | ||
inputUriMock.setExpectedMessageCount(1); | ||
outputRouteMock.setExpectedMessageCount(1); | ||
|
||
producer.sendBody("direct:inputRoute", "Body"); | ||
producer.sendBody("direct:inputUri", "Body"); | ||
producer.sendBody("direct:outputRoute", "Body"); | ||
|
||
assertIsSatisfied(inputRouteMock, inputUriMock, outputRouteMock); | ||
} | ||
|
||
/** | ||
* Test when actual node is stopped. | ||
* | ||
* @throws Exception all errors | ||
*/ | ||
@Test | ||
public void testNodeStop() throws Exception { | ||
nodeService.update(nodeService.getActualNode(), new ChangeNodeCallback() { | ||
@Override | ||
public void updateNode(MutableNode node) { | ||
node.setStoppedState(); | ||
} | ||
}); | ||
|
||
inputRouteMock.setExpectedMessageCount(0); | ||
inputUriMock.setExpectedMessageCount(0); | ||
outputRouteMock.setExpectedMessageCount(1); | ||
|
||
try { | ||
producer.sendBody("direct:inputRoute", "Body"); | ||
} catch (Exception e) { | ||
assertThat(e.getCause(), instanceOf(IntegrationException.class)); | ||
} | ||
try { | ||
producer.sendBody("direct:inputUri", "Body"); | ||
} catch (Exception e) { | ||
assertThat(e.getCause(), instanceOf(IntegrationException.class)); | ||
} | ||
producer.sendBody("direct:outputRoute", "Body"); | ||
|
||
assertIsSatisfied(inputRouteMock, inputUriMock, outputRouteMock); | ||
} | ||
} |
Oops, something went wrong.