Java Code Examples for org.apache.camel.ProducerTemplate#sendBody()
The following examples show how to use
org.apache.camel.ProducerTemplate#sendBody() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TokenizeLanguageIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void testTokenize() throws Exception { CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") .split().tokenize(",") .to("mock:result"); } }); camelctx.start(); try { MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class); mockEndpoint.expectedBodiesReceived("foo", "bar", "cheese"); ProducerTemplate template = camelctx.createProducerTemplate(); template.sendBody("direct:start", "foo,bar,cheese"); mockEndpoint.assertIsSatisfied(); } finally { camelctx.close(); } }
Example 2
Source File: MicrometerTimerIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void testOverrideMetricsName() throws Exception { CamelContext camelctx = createCamelContext(); camelctx.start(); try { Object body = new Object(); MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:out", MockEndpoint.class); mockEndpoint.expectedBodiesReceived(body); ProducerTemplate template = camelctx.createProducerTemplate(); template.sendBody("direct:in-1", body); Timer timer = metricsRegistry.find("B").timer(); Assert.assertEquals(1L, timer.count()); Assert.assertTrue(timer.max(TimeUnit.MILLISECONDS) > 0.0D); mockEndpoint.assertIsSatisfied(); } finally { camelctx.close(); } }
Example 3
Source File: JmxNamingContextCamelApplication.java From camel-cookbook-examples with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { JmxNamingContextCamelApplication camelApp = new JmxNamingContextCamelApplication(); try { camelApp.setup(); camelApp.start(); // Send a couple of messages to get some route statistics final ProducerTemplate template = camelApp.getContext().createProducerTemplate(); template.sendBody("direct:start", "Hello Camel"); template.sendBody("direct:start", "Camel Rocks!"); template.sendBody("direct:startOther", "Hello Other Camel"); template.sendBody("direct:startOther", "Other Camel Rocks!"); // let the Camel runtime do its job for a while Thread.sleep(60000); } finally { camelApp.tearDown(); } }
Example 4
Source File: FirstPrinciplesRouteBuilderTest.java From camel-cookbook-examples with Apache License 2.0 | 5 votes |
@Test public void testPayloadIsTransformed() throws InterruptedException { MockEndpoint out = camelContext.getEndpoint("mock:out", MockEndpoint.class); out.setExpectedMessageCount(1); out.message(0).body().isEqualTo("Modified: Cheese"); ProducerTemplate producerTemplate = camelContext.createProducerTemplate(); producerTemplate.sendBody("direct:in", "Cheese"); out.assertIsSatisfied(); }
Example 5
Source File: ElasticsearchIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testGet() throws Exception { CamelContext camelctx = createCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:index") .to("elasticsearch-rest://elasticsearch?operation=Index&indexName=twitter&hostAddresses=" + getElasticsearchHost()); from("direct:get") .to("elasticsearch-rest://elasticsearch?operation=GetById&indexName=twitter&hostAddresses=" + getElasticsearchHost()); } }); camelctx.start(); try { ProducerTemplate template = camelctx.createProducerTemplate(); //first, Index a value Map<String, String> map = createIndexedData("testGet"); template.sendBody("direct:index", map); String indexId = template.requestBody("direct:index", map, String.class); Assert.assertNotNull("indexId should be set", indexId); //now, verify GET succeeded GetResponse response = template.requestBody("direct:get", indexId, GetResponse.class); Assert.assertNotNull("response should not be null", response); Assert.assertNotNull("response source should not be null", response.getSource()); } finally { camelctx.close(); } }
Example 6
Source File: ZipkinIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testZipkin() throws Exception { CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("seda:dude").routeId("dude") .log("routing at ${routeId}") .delay(simple("${random(1000,2000)}")); } }); ZipkinTracer zipkin = new ZipkinTracer(); zipkin.setServiceName("dude"); zipkin.setSpanReporter(new LoggingReporter()); zipkin.init(camelctx); NotifyBuilder notify = new NotifyBuilder(camelctx).whenDone(5).create(); camelctx.start(); try { ProducerTemplate template = camelctx.createProducerTemplate(); for (int i = 0; i < 5; i++) { template.sendBody("seda:dude", "Hello World"); } Assert.assertTrue(notify.matches(30, TimeUnit.SECONDS)); } finally { camelctx.close(); } }
Example 7
Source File: CouchDBIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testCouchDBProducer() throws Exception { CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") .toF("couchdb:http://%s:5984/%s?username=%s&password=%s", TestUtils.getDockerHost(), COUCHDB_NAME, COUCHDB_USERNAME, COUCHDB_PASSWORD) .to("mock:result"); } }); MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class); mockEndpoint.expectedMessageCount(1); camelctx.start(); try { JsonElement element = new Gson().fromJson(getJSONString(), JsonElement.class); ProducerTemplate template = camelctx.createProducerTemplate(); template.sendBody("direct:start", element); mockEndpoint.assertIsSatisfied(); Map<String, Object> headers = mockEndpoint.getExchanges().get(0).getIn().getHeaders(); Assert.assertTrue(headers.containsKey(CouchDbConstants.HEADER_DOC_ID)); Assert.assertTrue(headers.containsKey(CouchDbConstants.HEADER_DOC_REV)); } finally { camelctx.close(); } }
Example 8
Source File: CryptoCmsIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testCryptoCmsDecryptVerifyBinary() throws Exception { Assume.assumeFalse("[#2241] CryptoCmsIntegrationTest fails on IBM JDK", EnvironmentUtils.isIbmJDK() || EnvironmentUtils.isOpenJDK()); CamelContext camelctx = new DefaultCamelContext(new JndiBeanRepository()); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") .to("crypto-cms:decrypt://testdecrypt?fromBase64=true&keyStoreParameters=#keyStoreParameters") .to("crypto-cms:verify://testverify?keyStoreParameters=#keyStoreParameters") .to("mock:result"); } }); KeyStoreParameters keyStoreParameters = new KeyStoreParameters(); keyStoreParameters.setType("JCEKS"); keyStoreParameters.setResource("/crypto.keystore"); keyStoreParameters.setPassword("Abcd1234"); context.bind("keyStoreParameters", keyStoreParameters); MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class); mockEndpoint.expectedBodiesReceived("Testmessage"); camelctx.start(); try { InputStream input = CryptoCmsIntegrationTest.class.getResourceAsStream("/signed.bin"); ProducerTemplate template = camelctx.createProducerTemplate(); template.sendBody("direct:start", input); mockEndpoint.assertIsSatisfied(); } finally { camelctx.close(); context.unbind("keyStoreParameters"); } }
Example 9
Source File: ODataReadTests.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void testReadODataRouteKeyPredicateWithSubPredicate() throws Exception { Connector odataConnector = createODataConnector(new PropertyBuilder<String>() .property(SERVICE_URI, REF_SERVICE_URI)); String resourcePath = "Airports"; ObjectNode keyPredicateJson = OBJECT_MAPPER.createObjectNode(); keyPredicateJson.put(KEY_PREDICATE, "('KLAX')/Location"); Step directStep = createDirectStep(); Step odataStep = createODataStep(odataConnector, resourcePath); Step mockStep = createMockStep(); Integration odataIntegration = createIntegration(directStep, odataStep, mockStep); RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration); context.addRoutes(routes); MockEndpoint result = initMockEndpoint(); result.setExpectedMessageCount(1); DirectEndpoint directEndpoint = context.getEndpoint("direct://start", DirectEndpoint.class); ProducerTemplate template = context.createProducerTemplate(); context.start(); String inputJson = OBJECT_MAPPER.writeValueAsString(keyPredicateJson); template.sendBody(directEndpoint, inputJson); result.assertIsSatisfied(); String entityJson = extractJsonFromExchgMsg(result, 0, String.class); assertThatJson(entityJson).isEqualTo(testData(REF_SERVER_PEOPLE_DATA_KLAX_LOC, AbstractODataReadRouteTest.class)); }
Example 10
Source File: ComponentProxySplitTokenizeTest.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void testSplit() throws InterruptedException { final ProducerTemplate template = camelContext.createProducerTemplate(); final MockEndpoint mock = camelContext.getEndpoint("mock:result", MockEndpoint.class); final String values = "a,b,c"; final String[] result = values.split(","); mock.expectedMessageCount(result.length); mock.expectedBodiesReceived((Object[])result); template.sendBody("direct:start", values); mock.assertIsSatisfied(); }
Example 11
Source File: HazelcastMapProducerIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test(expected = CamelExecutionException.class) public void testWithInvalidOperation() throws Exception { CamelContext camelctx = createCamelContext(); camelctx.start(); try { ProducerTemplate template = camelctx.createProducerTemplate(); template.sendBody("direct:putInvalid", "my-foo"); } finally { camelctx.close(); } }
Example 12
Source File: ODataReadTests.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void testReadODataRoute() throws Exception { int initialResultCount = defaultTestServer.getResultCount(); Connector odataConnector = createODataConnector(new PropertyBuilder<String>() .property(SERVICE_URI, defaultTestServer.servicePlainUri())); String resourcePath = defaultTestServer.resourcePath(); ObjectNode keyPredicateJson = OBJECT_MAPPER.createObjectNode(); keyPredicateJson.put(KEY_PREDICATE, "1"); Step directStep = createDirectStep(); Step odataStep = createODataStep(odataConnector, resourcePath); Step mockStep = createMockStep(); Integration odataIntegration = createIntegration(directStep, odataStep, mockStep); RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration); context.addRoutes(routes); MockEndpoint result = initMockEndpoint(); result.setExpectedMessageCount(1); DirectEndpoint directEndpoint = context.getEndpoint("direct://start", DirectEndpoint.class); ProducerTemplate template = context.createProducerTemplate(); context.start(); String inputJson = OBJECT_MAPPER.writeValueAsString(keyPredicateJson); template.sendBody(directEndpoint, inputJson); result.assertIsSatisfied(); String entityJson = extractJsonFromExchgMsg(result, 0, String.class); assertThatJson(entityJson).isEqualTo(testData(TEST_SERVER_DATA_1, AbstractODataReadRouteTest.class)); assertEquals(initialResultCount, defaultTestServer.getResultCount()); }
Example 13
Source File: MsvIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testMsvSchemaValidationFailure() throws Exception { CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") .doTry() .to("msv:/schema.rng") .to("mock:valid") .doCatch(ValidationException.class) .to("mock:invalid"); } }); MockEndpoint mockEndpointValid = camelctx.getEndpoint("mock:valid", MockEndpoint.class); mockEndpointValid.expectedMessageCount(0); MockEndpoint mockEndpointInvalid = camelctx.getEndpoint("mock:invalid", MockEndpoint.class); mockEndpointInvalid.expectedMessageCount(1); camelctx.start(); try { ProducerTemplate template = camelctx.createProducerTemplate(); template.sendBody("direct:start", ORDER_XML_INVALID); mockEndpointValid.assertIsSatisfied(); mockEndpointInvalid.assertIsSatisfied(); } finally { camelctx.close(); } }
Example 14
Source File: ODataReadTests.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void testReadODataRouteKeyPredicateFilter() throws Exception { int initialResultCount = defaultTestServer.getResultCount(); Connector odataConnector = createODataConnector(new PropertyBuilder<String>() .property(SERVICE_URI, defaultTestServer.servicePlainUri())); String resourcePath = defaultTestServer.resourcePath(); ObjectNode keyPredicateJson = OBJECT_MAPPER.createObjectNode(); keyPredicateJson.put(KEY_PREDICATE, "ID=2"); Step directStep = createDirectStep(); Step odataStep = createODataStep(odataConnector, resourcePath); Step mockStep = createMockStep(); Integration odataIntegration = createIntegration(directStep, odataStep, mockStep); RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration); context.addRoutes(routes); MockEndpoint result = initMockEndpoint(); result.setExpectedMessageCount(1); DirectEndpoint directEndpoint = context.getEndpoint("direct://start", DirectEndpoint.class); ProducerTemplate template = context.createProducerTemplate(); context.start(); String inputJson = OBJECT_MAPPER.writeValueAsString(keyPredicateJson); template.sendBody(directEndpoint, inputJson); result.assertIsSatisfied(); String entityJson = extractJsonFromExchgMsg(result, 0, String.class); assertThatJson(entityJson).isEqualTo(testData(TEST_SERVER_DATA_2, AbstractODataReadRouteTest.class)); assertEquals(initialResultCount, defaultTestServer.getResultCount()); }
Example 15
Source File: ODataDeleteTests.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void testDeleteODataRoute() throws Exception { int initialResultCount = defaultTestServer.getResultCount(); Step directStep = createDirectStep(); Connector odataConnector = createODataConnector(new PropertyBuilder<String>() .property(SERVICE_URI, defaultTestServer.servicePlainUri())); String resourcePath = defaultTestServer.resourcePath(); ObjectNode keyPredicateJson = OBJECT_MAPPER.createObjectNode(); keyPredicateJson.put(KEY_PREDICATE, "1"); Step odataStep = createODataStep(odataConnector, resourcePath); Step mockStep = createMockStep(); Integration odataIntegration = createIntegration(directStep, odataStep, mockStep); RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration); context.addRoutes(routes); MockEndpoint result = initMockEndpoint(); result.setExpectedMessageCount(1); DirectEndpoint directEndpoint = context.getEndpoint("direct://start", DirectEndpoint.class); ProducerTemplate template = context.createProducerTemplate(); context.start(); String inputJson = OBJECT_MAPPER.writeValueAsString(keyPredicateJson); template.sendBody(directEndpoint, inputJson); result.assertIsSatisfied(); String status = extractJsonFromExchgMsg(result, 0); String expected = createResponseJson(HttpStatusCode.NO_CONTENT); assertThatJson(status).isEqualTo(expected); assertEquals(initialResultCount - 1, defaultTestServer.getResultCount()); }
Example 16
Source File: EMailSendRouteTest.java From syndesis with Apache License 2.0 | 4 votes |
@Test public void testPriorityOfValuesInjectedData() throws Exception { server = smtpServer(); Step directStep = createDirectStep(); Connector mailConnector = RouteUtils.createEMailConnector(server, new PropertyBuilder<String>() .property(PROTOCOL, Protocol.SMTP.id()) .property(HOST, server.getHost()) .property(PORT, Integer.toString(server.getPort())) .property(USER, TEST_ADDRESS) .property(PASSWORD, TEST_PASSWORD)); EMailMessageModel injectedDataModel = new EMailMessageModel(); injectedDataModel.setSubject("Injected Data Email 1"); injectedDataModel.setFrom(TEST_ADDRESS); injectedDataModel.setTo(TEST_ADDRESS); injectedDataModel.setContent("Hello, this is an email from injected data!\r\n"); String inputValueSubject = "Input Values Email 1"; String inputValueText = "Hello, this is an email using inputted values!"; PropertyBuilder<String> builder = new PropertyBuilder<>(); builder.property(PRIORITY, Priority.CONSUMED_DATA.toString()); builder.property(MAIL_SUBJECT, inputValueSubject); builder.property(MAIL_TEXT, inputValueText); Step mailStep = RouteUtils.createEMailStep(mailConnector, this::createConnectorAction, builder.build()); Integration mailIntegration = RouteUtils.createIntegrationWithMock(directStep, mailStep); RouteBuilder routes = RouteUtils.newIntegrationRouteBuilder(mailIntegration); context.addRoutes(routes); MockEndpoint result = RouteUtils.initMockEndpoint(context); result.setExpectedMessageCount(1); DirectEndpoint directEndpoint = context.getEndpoint("direct://start", DirectEndpoint.class); ProducerTemplate template = context.createProducerTemplate(); context.start(); // // Sending through injected data model as if consumed from another connection // template.sendBody(directEndpoint, injectedDataModel); result.assertIsSatisfied(); List<EMailMessageModel> emails = server.getEmails(); assertEquals(1, emails.size()); // // The email is consistent with the injected data and has overridden // the values set by the inputted values // assertEquals(injectedDataModel, emails.get(0)); }
Example 17
Source File: ThriftIntegrationTest.java From wildfly-camel with Apache License 2.0 | 4 votes |
@Test public void testMarshalAndUnmarshal() throws Exception { CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { ThriftDataFormat format = new ThriftDataFormat(new Work()); from("direct:in").marshal(format); from("direct:back").unmarshal(format).to("mock:reverse"); } }); camelctx.start(); try { Work input = new Work(); input.num1 = WORK_TEST_NUM1; input.num2 = WORK_TEST_NUM2; input.op = WORK_TEST_OPERATION; input.comment = WORK_TEST_COMMENT; MockEndpoint mock = camelctx.getEndpoint("mock:reverse", MockEndpoint.class); mock.expectedMessageCount(1); mock.message(0).body().isInstanceOf(Work.class); mock.message(0).body().isEqualTo(input); ProducerTemplate template = camelctx.createProducerTemplate(); Object marshalled = template.requestBody("direct:in", input); template.sendBody("direct:back", marshalled); mock.assertIsSatisfied(); Work output = mock.getReceivedExchanges().get(0).getIn().getBody(Work.class); Assert.assertEquals(WORK_TEST_COMMENT, output.getComment()); Assert.assertEquals(WORK_TEST_OPERATION, output.getOp()); Assert.assertEquals(WORK_TEST_NUM2, output.getNum2()); } finally { camelctx.close(); } }
Example 18
Source File: ChoiceStepHandlerTest.java From syndesis with Apache License 2.0 | 4 votes |
@Test public void testChoiceStepWithDefaultFlow() throws Exception { final DefaultCamelContext context = new DefaultCamelContext(); try { final RouteBuilder integrationRoute = newIntegrationRouteBuilder(activityTracker, new Step.Builder() .id(START_STEP) .stepKind(StepKind.endpoint) .action(new ConnectorAction.Builder() .descriptor(new ConnectorDescriptor.Builder() .componentScheme("direct") .putConfiguredProperty("name", "flow") .build()) .build()) .build(), new Step.Builder() .id(CHOICE_STEP) .stepKind(StepKind.choice) .putConfiguredProperty("routingScheme", "mock") .putConfiguredProperty("default", "default-flow") .putConfiguredProperty("flows", "[" + "{\"condition\": \"${body} contains 'Hello'\", \"flow\": \"hello-flow\"}," + "{\"condition\": \"${body} contains 'Bye'\", \"flow\": \"bye-flow\"}" + "]") .build(), new Step.Builder() .id(MOCK_STEP) .stepKind(StepKind.endpoint) .action(new ConnectorAction.Builder() .descriptor(new ConnectorDescriptor.Builder() .componentScheme("mock") .putConfiguredProperty("name", "result") .build()) .build()) .build() ); // Set up the camel context context.setUuidGenerator(KeyGenerator::createKey); context.addLogListener(new IntegrationLoggingListener(activityTracker)); context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker)); context.addRoutes(integrationRoute); context.start(); // Dump routes as XML for troubleshooting dumpRoutes(context); final ProducerTemplate template = context.createProducerTemplate(); final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.class); final MockEndpoint defaultResult = context.getEndpoint("mock:default-flow", MockEndpoint.class); final MockEndpoint helloResult = context.getEndpoint("mock:hello-flow", MockEndpoint.class); final MockEndpoint byeResult = context.getEndpoint("mock:bye-flow", MockEndpoint.class); final List<String> messages = Arrays.asList("Hello Camel!", "Bye Camel!", "And Now for Something Completely Different"); result.expectedBodiesReceived(messages); defaultResult.expectedBodiesReceived("And Now for Something Completely Different"); helloResult.expectedBodiesReceived("Hello Camel!"); byeResult.expectedBodiesReceived("Bye Camel!"); for (String message : messages) { template.sendBody("direct:flow", message); } result.assertIsSatisfied(); helloResult.assertIsSatisfied(); byeResult.assertIsSatisfied(); verify(activityTracker, times(3)).startTracking(any(Exchange.class)); verifyActivityStepTracking(CHOICE_STEP, 3); verifyActivityStepTracking(MOCK_STEP, 3); verify(activityTracker, times(3)).finishTracking(any(Exchange.class)); } finally { context.stop(); } }
Example 19
Source File: EMailSendRouteTest.java From syndesis with Apache License 2.0 | 4 votes |
@Test public void testSmtpsSenderRoute() throws Exception { server = smtpsServer(); Step directStep = createDirectStep(); // // Even though protocol is set to 'smtp', it will be changed to 'smtps' // by the EMailComponent due to secure being true // Connector mailConnector = RouteUtils.createEMailConnector(server, new PropertyBuilder<String>() .property(PROTOCOL, Protocol.SMTP.id()) .property(SECURE_TYPE, SecureType.SSL_TLS.id()) .property(HOST, server.getHost()) .property(PORT, Integer.toString(server.getPort())) .property(USER, TEST_ADDRESS) .property(PASSWORD, TEST_PASSWORD) .property(SERVER_CERTIFICATE, server.getCertificate())); Step mailStep = RouteUtils.createEMailStep(mailConnector, this::createConnectorAction); Integration mailIntegration = RouteUtils.createIntegrationWithMock(directStep, mailStep); RouteBuilder routes = RouteUtils.newIntegrationRouteBuilder(mailIntegration); context.addRoutes(routes); MockEndpoint result = RouteUtils.initMockEndpoint(context); result.setExpectedMessageCount(1); DirectEndpoint directEndpoint = context.getEndpoint("direct://start", DirectEndpoint.class); ProducerTemplate template = context.createProducerTemplate(); context.start(); EMailMessageModel msgModel = new EMailMessageModel(); msgModel.setSubject("Test Email 1"); msgModel.setFrom(TEST_ADDRESS); msgModel.setTo(TEST_ADDRESS); msgModel.setContent("Hello, I am sending emails to myself again!\r\n"); template.sendBody(directEndpoint, msgModel); result.assertIsSatisfied(); List<EMailMessageModel> emails = server.getEmails(); assertEquals(1, emails.size()); assertEquals(msgModel, emails.get(0)); }
Example 20
Source File: ODataUpdateTests.java From syndesis with Apache License 2.0 | 4 votes |
/** * Tests alternative key predicate that is a string value * @see https://github.com/syndesisio/syndesis/issues/5241 */ @Test public void testPatchODataRouteOnRefServer() throws Exception { Step directStep = createDirectStep(); // // Ensure we are using our own individual RW URI so not to impinge // on other tests seeing as we're modifying data // String refServiceURI = getRealRefServiceUrl(REF_SERVICE_URI); Connector odataConnector = createODataConnector(new PropertyBuilder<String>() .property(SERVICE_URI, refServiceURI)); String resourcePath = "People"; String keyPredicate = "russellwhyte"; String nameProperty = "MiddleName"; String originalName = queryProperty(refServiceURI, resourcePath, keyPredicate, nameProperty); Step odataStep = createODataStep(odataConnector, resourcePath); ObjectNode newProduct = OBJECT_MAPPER.createObjectNode(); // Append time to ensure old name is different from new name String newMiddleName = "Quentin" + System.currentTimeMillis(); newProduct.put(nameProperty, newMiddleName); newProduct.put(KEY_PREDICATE, keyPredicate); Step mockStep = createMockStep(); Integration odataIntegration = createIntegration(directStep, odataStep, mockStep); RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration); context.addRoutes(routes); MockEndpoint result = initMockEndpoint(); result.setExpectedMessageCount(1); DirectEndpoint directEndpoint = context.getEndpoint("direct://start", DirectEndpoint.class); ProducerTemplate template = context.createProducerTemplate(); try { context.start(); String inputJson = OBJECT_MAPPER.writeValueAsString(newProduct); template.sendBody(directEndpoint, inputJson); result.assertIsSatisfied(); String status = extractJsonFromExchgMsg(result, 0); String expected = createResponseJson(HttpStatusCode.NO_CONTENT); assertThatJson(status).isEqualTo(expected); String newName = queryProperty(refServiceURI, resourcePath, keyPredicate, nameProperty); assertEquals(newMiddleName, newName); assertNotEquals(originalName, newName); } finally { // // Reset property back to original value // Not strictly necessary as our own special service created but // just in case it ever pops up again. // updateProperty(refServiceURI, resourcePath, keyPredicate, nameProperty, originalName); } }