org.apache.camel.builder.AdviceWithRouteBuilder Java Examples

The following examples show how to use org.apache.camel.builder.AdviceWithRouteBuilder. 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: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testAuditFilterNearMatch() throws Exception {

    context.getRouteDefinition("FcrepoTriplestoreIndexer").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo:*");
            mockEndpointsAndSkip("http:*");
            mockEndpointsAndSkip("direct:delete.triplestore");
            mockEndpointsAndSkip("direct:index.triplestore");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:delete.triplestore").expectedMessageCount(1);
    getMockEndpoint("mock:direct:update.triplestore").expectedMessageCount(0);

    template.sendBodyAndHeaders(
            IOUtils.toString(loadResourceAsStream("container.rdf"), "UTF-8"),
            createEvent(auditContainer + "orium" + fileID,
                asList(AS_NS + "Create"), asList(REPOSITORY + "Resource")));

    assertMockEndpointsSatisfied();
}
 
Example #2
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testEventTypeRouter() throws Exception {

    final List<String> eventTypes = asList(EVENT_NS + "Delete");

    context.getRouteDefinition("FcrepoSolrRouter").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("direct:index.solr");
            mockEndpointsAndSkip("direct:delete.solr");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:delete.solr").expectedMessageCount(1);
    getMockEndpoint("mock:direct:index.solr").expectedMessageCount(0);

    template.sendBodyAndHeaders(loadResourceAsStream("event_delete_resource.json"),
            createEvent(baseURL + fileID, eventTypes));

    assertMockEndpointsSatisfied();
}
 
Example #3
Source File: WeaveByToUriTest.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testWeaveByToUri() throws Exception {
    RouteDefinition route = context.getRouteDefinition("quotes");
    route.adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            // replace all to("seda:line") with a mock:line instead
            weaveByToUri("seda:line").replace().to("mock:line");
        }
    });

    context.start();

    getMockEndpoint("mock:line").expectedBodiesReceived("camel rules", "donkey is bad");
    getMockEndpoint("mock:combined").expectedMessageCount(1);
    getMockEndpoint("mock:combined").message(0).body().isInstanceOf(List.class);

    template.sendBody("seda:quotes", "Camel Rules,Donkey is Bad");

    assertMockEndpointsSatisfied();
}
 
Example #4
Source File: FixedEndpointSpringTest.java    From camel-cookbook-examples with Apache License 2.0 6 votes vote down vote up
@Test
public void testOverriddenEndpoints() throws Exception {
    context.getRouteDefinition("modifyPayloadBetweenQueues")
        .adviceWith(context, new AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {
                replaceFromWith("direct:in");

                interceptSendToEndpoint("activemq:out")
                    .skipSendToOriginalEndpoint()
                    .to("mock:out");
            }
        });
    context.start();

    MockEndpoint out = getMockEndpoint("mock:out");
    out.setExpectedMessageCount(1);
    out.message(0).body().isEqualTo("Modified: Cheese");

    template.sendBody("direct:in", "Cheese");

    assertMockEndpointsSatisfied();
}
 
Example #5
Source File: FixedEndpointEnhancedSpringTest.java    From camel-cookbook-examples with Apache License 2.0 6 votes vote down vote up
@Test
public void testOverriddenEndpoints() throws Exception {
    context.getRouteDefinition("modifyPayloadBetweenQueues")
        .adviceWith(context, new AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {
                replaceFromWith("direct:in");

                interceptSendToEndpoint("activemq:out")
                    .skipSendToOriginalEndpoint()
                    .to("mock:out");
            }
        });
    context.start();

    MockEndpoint out = context.getEndpoint("mock:out", MockEndpoint.class);
    out.setExpectedMessageCount(1);
    out.message(0).body().isEqualTo("Modified: Cheese");

    ProducerTemplate template = context.createProducerTemplate();
    template.sendBody("direct:in", "Cheese");

    out.assertIsSatisfied();
}
 
Example #6
Source File: OrderProcessingRouteTest.java    From camel-cookbook-examples with Apache License 2.0 6 votes vote down vote up
@Test
public void testRoutingLogic() throws Exception {
    context.getRouteDefinition(ID)
            .adviceWith(context, new AdviceWithRouteBuilder() {
                @Override
                public void configure() throws Exception {
                    replaceFromWith("direct:in");

                    interceptSendToEndpoint("file://output")
                            .skipSendToOriginalEndpoint()
                            .to("mock:out");
                }
            });
    context.start();

    final MockEndpoint mockOut = getMockEndpoint("mock:out");
    mockOut.setExpectedMessageCount(1);
    mockOut.message(0).body().startsWith("2013-11-23");
    mockOut.message(0).header(Exchange.FILE_NAME).isEqualTo("2013-11-23.csv");

    fluentTemplate().to("direct:in").withBody("23-11-2013,1,Geology rocks t-shirt").send();

    assertMockEndpointsSatisfied();
}
 
Example #7
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterAuditEvents() throws Exception {

    final List<String> eventTypes = asList(EVENT_NS + "ResourceCreation");

    context.getRouteDefinition("FcrepoSolrIndexer").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo*");
            mockEndpointsAndSkip("direct:update.solr");
            mockEndpointsAndSkip("direct:delete.solr");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:delete.solr").expectedMessageCount(0);
    getMockEndpoint("mock:direct:update.solr").expectedMessageCount(0);

    template.sendBodyAndHeaders(
            IOUtils.toString(loadResourceAsStream("indexable.rdf"), "UTF-8"),
            createEvent(baseURL + auditContainer + fileID, eventTypes));

    assertMockEndpointsSatisfied();
}
 
Example #8
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterAuditExactMatch() throws Exception {

    final List<String> eventTypes = asList(EVENT_NS + "ResourceModification");

    context.getRouteDefinition("FcrepoSolrIndexer").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo*");
            mockEndpointsAndSkip("direct:update.solr");
            mockEndpointsAndSkip("direct:delete.solr");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:delete.solr").expectedMessageCount(0);
    getMockEndpoint("mock:direct:update.solr").expectedMessageCount(0);

    template.sendBodyAndHeaders(
            IOUtils.toString(loadResourceAsStream("indexable.rdf"), "UTF-8"),
            createEvent(baseURL + auditContainer, eventTypes));

    assertMockEndpointsSatisfied();
}
 
Example #9
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterAuditNearMatch() throws Exception {

    final List<String> eventTypes = asList(EVENT_NS + "ResourceCreation");

    context.getRouteDefinition("FcrepoSolrIndexer").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo*");
            mockEndpointsAndSkip("direct:update.solr");
            mockEndpointsAndSkip("direct:delete.solr");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:delete.solr").expectedMessageCount(0);
    getMockEndpoint("mock:direct:update.solr").expectedMessageCount(1);

    template.sendBodyAndHeaders(
            IOUtils.toString(loadResourceAsStream("indexable.rdf"), "UTF-8"),
            createEvent(baseURL + auditContainer + "orium" + fileID, eventTypes, asList(INDEXABLE)));

    assertMockEndpointsSatisfied();
}
 
Example #10
Source File: ResponseToJSONRouteTest.java    From hacep with Apache License 2.0 6 votes vote down vote up
@Test
public void testResponseToJSON() throws Exception {
    context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
                @Override
                public void configure() throws Exception {
                    replaceFromWith("direct:test");
                }
            }
    );


    ResponseMessage message = new ResponseMessage(ResponseCode.SUCCESS, "MESSAGE");

    context.start();

    Object object = template.requestBody("direct:test", message);

    Assert.assertTrue(object instanceof String);
}
 
Example #11
Source File: ApplicationTest.java    From kubernetes-integration-test with Apache License 2.0 6 votes vote down vote up
@Before
public void before() throws Exception{

    if (context.getStatus()==ServiceStatus.Stopped) {
        //Execute adviseWith only once
        context.getRouteDefinition("user.in").adviceWith(context, new AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {
                replaceFromWith("direct:user.in");
            }
        });


    }

    //Reset mock endpoint
    mockUserOut.reset();
    addressByEmail.reset();
}
 
Example #12
Source File: BinaryDisabledRouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testMetadataUpdaterIndexable() throws Exception {
    context.getRouteDefinition("FcrepoSerializationMetadataUpdater").adviceWith(context,
          new AdviceWithRouteBuilder() {
              @Override
              public void configure() throws Exception {
                  replaceFromWith("direct:start");
                  mockEndpointsAndSkip("fcrepo:*");
                  mockEndpointsAndSkip("file:*");
                  weaveAddLast().to("mock:result");
              }
          });
    context.start();

    resultEndpoint.expectedMessageCount(1);

    // send a file!
    template.sendBody(loadResourceAsStream("indexable.rdf"));

    assertMockEndpointsSatisfied();
}
 
Example #13
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testEventTypeRouter() throws Exception {

    context.getRouteDefinition("FcrepoTriplestoreRouter").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("direct:index.triplestore");
            mockEndpointsAndSkip("direct:delete.triplestore");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:delete.triplestore").expectedMessageCount(1);
    getMockEndpoint("mock:direct:index.triplestore").expectedMessageCount(0);

    template.sendBody(
            IOUtils.toString(loadResourceAsStream("event_delete_resource.json"), "UTF-8"));

    assertMockEndpointsSatisfied();
}
 
Example #14
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testAuditFilter() throws Exception {

    context.getRouteDefinition("FcrepoTriplestoreIndexer").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo:*");
            mockEndpointsAndSkip("http:*");
            mockEndpointsAndSkip("direct:delete.triplestore");
            mockEndpointsAndSkip("direct:index.triplestore");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:delete.triplestore").expectedMessageCount(0);
    getMockEndpoint("mock:direct:update.triplestore").expectedMessageCount(0);

    template.sendBodyAndHeaders("",
            createEvent(auditContainer + fileID, asList(AS_NS + "Update"), asList(REPOSITORY + "Binary")));
    template.sendBodyAndHeaders("",
            createEvent(auditContainer + fileID, asList(AS_NS + "Delete"), asList(REPOSITORY + "Binary")));

    assertMockEndpointsSatisfied();
}
 
Example #15
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testAuditFilterExactMatch() throws Exception {

    context.getRouteDefinition("FcrepoTriplestoreIndexer").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo:*");
            mockEndpointsAndSkip("http:*");
            mockEndpointsAndSkip("direct:delete.triplestore");
            mockEndpointsAndSkip("direct:index.triplestore");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:delete.triplestore").expectedMessageCount(0);
    getMockEndpoint("mock:direct:update.triplestore").expectedMessageCount(0);

    template.sendBodyAndHeaders("",
            createEvent(auditContainer, asList(AS_NS + "Update"), asList(REPOSITORY + "Binary")));
    template.sendBodyAndHeaders("",
            createEvent(auditContainer, asList(AS_NS + "Delete"), asList(REPOSITORY + "Binary")));

    assertMockEndpointsSatisfied();
}
 
Example #16
Source File: BinaryDisabledRouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testMetadataReSerialization() throws Exception {
    context.getRouteDefinition("FcrepoReSerialization").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("direct:metadata");
            mockEndpointsAndSkip("direct:binary");
            mockEndpointsAndSkip("direct:delete");
            mockEndpointsAndSkip("fcrepo:*");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:metadata").expectedMessageCount(1);
    getMockEndpoint("mock:direct:binary").expectedMessageCount(1);

    template.sendBodyAndHeader(loadResourceAsStream("binary.rdf"), FCREPO_URI, baseURL);

    assertMockEndpointsSatisfied();
}
 
Example #17
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testAuditFilterNearMatchIndexable() throws Exception {

    context.getRouteDefinition("FcrepoTriplestoreIndexer").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo:*");
            mockEndpointsAndSkip("direct:delete.triplestore");
            mockEndpointsAndSkip("direct:update.triplestore");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:delete.triplestore").expectedMessageCount(0);
    getMockEndpoint("mock:direct:update.triplestore").expectedMessageCount(1);

    template.sendBodyAndHeaders(
            IOUtils.toString(loadResourceAsStream("indexable.rdf"), "UTF-8"),
            createEvent(auditContainer + "orium" + fileID,
                asList(AS_NS + "Create"), asList(REPOSITORY + "Container")));

    assertMockEndpointsSatisfied();
}
 
Example #18
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testPrepareRouterIndexable() throws Exception {

    context.getRouteDefinition("FcrepoTriplestoreRouter").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo*");
            mockEndpointsAndSkip("direct:index.triplestore");
            mockEndpointsAndSkip("direct:delete.triplestore");
        }
    });

    context.start();

    getMockEndpoint("mock:direct:index.triplestore").expectedMessageCount(1);
    getMockEndpoint("mock:direct:delete.triplestore").expectedMessageCount(0);

    template.sendBodyAndHeaders(
            IOUtils.toString(loadResourceAsStream("event.json"), "UTF-8"),
            createEvent(fileID, asList(AS_NS + "Create"), asList(INDEXABLE)));

    assertMockEndpointsSatisfied();
}
 
Example #19
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testIndexRouterContainer() throws Exception {

    context.getRouteDefinition("FcrepoTriplestoreIndexer").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo*");
            mockEndpointsAndSkip("direct:update.triplestore");
            mockEndpointsAndSkip("direct:delete.triplestore");
        }
    });

    context.start();

    getMockEndpoint("mock:direct:update.triplestore").expectedMessageCount(0);
    getMockEndpoint("mock:direct:delete.triplestore").expectedMessageCount(1);

    template.sendBodyAndHeaders(
            IOUtils.toString(loadResourceAsStream("container.rdf"), "UTF-8"),
            createEvent(fileID, asList(AS_NS + "Create"), asList(REPOSITORY + "Container")));

    assertMockEndpointsSatisfied();
}
 
Example #20
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testIndexRouterIndexable() throws Exception {

    context.getRouteDefinition("FcrepoTriplestoreIndexer").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo*");
            mockEndpointsAndSkip("direct:update.triplestore");
            mockEndpointsAndSkip("direct:delete.triplestore");
        }
    });

    context.start();

    getMockEndpoint("mock:direct:update.triplestore").expectedMessageCount(1);
    getMockEndpoint("mock:direct:delete.triplestore").expectedMessageCount(0);

    template.sendBodyAndHeaders(
            IOUtils.toString(loadResourceAsStream("indexable.rdf"), "UTF-8"),
            createEvent(fileID, asList(AS_NS + "Create"), asList(INDEXABLE)));

    assertMockEndpointsSatisfied();
}
 
Example #21
Source File: BinaryDisabledRouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
   public void testMetadataSerializationRemoveNode() throws Exception {
    context.getRouteDefinition("FcrepoSerialization").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("direct:metadata");
            mockEndpointsAndSkip("direct:binary");
            mockEndpointsAndSkip("direct:delete");
            mockEndpointsAndSkip("fcrepo:*");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:metadata").expectedMessageCount(0);
    getMockEndpoint("mock:direct:binary").expectedMessageCount(0);
    getMockEndpoint("mock:direct:delete").expectedMessageCount(1);

    template.sendBody(loadResourceAsStream("event_delete_resource.json"));

    assertMockEndpointsSatisfied();
}
 
Example #22
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeleteRouter() throws Exception {

    final String eventTypes = REPOSITORY + "NODE_REMOVED";
    final String eventProps = REPOSITORY + "hasContent";

    context.getRouteDefinition("FcrepoTriplestoreDeleter").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            mockEndpointsAndSkip("http*");
        }
    });

    context.start();

    getMockEndpoint("mock:http:localhost:8080/fuseki/test/update").expectedMessageCount(1);
    getMockEndpoint("mock:http:localhost:8080/fuseki/test/update")
        .expectedHeaderReceived(Exchange.CONTENT_TYPE, "application/x-www-form-urlencoded; charset=utf-8");
    getMockEndpoint("mock:http:localhost:8080/fuseki/test/update")
        .expectedHeaderReceived(Exchange.HTTP_METHOD, "POST");

    template.sendBodyAndHeaders("direct:delete.triplestore", "",
            createEvent(fileID, asList(AS_NS + "Delete")));

    assertMockEndpointsSatisfied();
}
 
Example #23
Source File: RouteWithFunctionsTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testOptions() throws Exception {
    getMockEndpoint("mock:language:simple:resource:classpath:org/fcrepo/camel/ldpath/options.ttl")
    .expectedMessageCount(1);

    context.getRouteDefinition("FcrepoLDPathRest").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("language:simple:resource:classpath:org/fcrepo/camel/ldpath/options.ttl");
        }
    });
    context.start();

    template.sendBodyAndHeader(null, HTTP_METHOD, "OPTIONS");
    assertMockEndpointsSatisfied();
}
 
Example #24
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testBinaryFixitySuccess() throws Exception {

    context.getRouteDefinition("FcrepoFixity").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo:*");
        }
    });
    context.start();

    getMockEndpoint("mock:failure").expectedMessageCount(0);
    getMockEndpoint("mock:success").expectedMessageCount(1);

    final String body = IOUtils.toString(loadResourceAsStream("fixity.rdf"), "UTF-8");
    template.sendBodyAndHeader(body, FCREPO_URI, baseURL + identifier);

    assertMockEndpointsSatisfied();
}
 
Example #25
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testBinaryFixityFailure() throws Exception {

    context.getRouteDefinition("FcrepoFixity").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo:*");
        }
    });
    context.start();

    getMockEndpoint("mock:failure").expectedMessageCount(1);
    getMockEndpoint("mock:success").expectedMessageCount(0);

    final String body = IOUtils.toString(loadResourceAsStream("fixityFailure.rdf"), "UTF-8");
    template.sendBodyAndHeader(body, FCREPO_URI, baseURL + identifier);

    assertMockEndpointsSatisfied();
}
 
Example #26
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonBinary() throws Exception {

    context.getRouteDefinition("FcrepoFixity").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("fcrepo:*");
        }
    });
    context.start();

    getMockEndpoint("mock:failure").expectedMessageCount(0);
    getMockEndpoint("mock:success").expectedMessageCount(0);

    final String body = IOUtils.toString(loadResourceAsStream("container.rdf"), "UTF-8");
    template.sendBodyAndHeader(body, FCREPO_URI, baseURL + identifier);

    assertMockEndpointsSatisfied();
}
 
Example #27
Source File: BinaryDisabledRouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testMetatdataSerialization() throws Exception {
    context.getRouteDefinition("FcrepoSerialization").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("direct:metadata");
            mockEndpointsAndSkip("direct:binary");
            mockEndpointsAndSkip("direct:delete");
            mockEndpointsAndSkip("fcrepo:*");
        }
    });
    context.start();

    getMockEndpoint("mock:direct:metadata").expectedMessageCount(1);
    getMockEndpoint("mock:direct:binary").expectedMessageCount(1);
    getMockEndpoint("mock:direct:delete").expectedMessageCount(0);

    // send a file!
    template.sendBody(loadResourceAsStream("event.json"));

    assertMockEndpointsSatisfied();
}
 
Example #28
Source File: BinaryEnabledRouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testMetadataUpdaterBinary() throws Exception {
    context.getRouteDefinition("FcrepoSerializationBinaryUpdater").adviceWith(context,
      new AdviceWithRouteBuilder() {
          @Override
          public void configure() throws Exception {
              replaceFromWith("direct:start");
                    mockEndpointsAndSkip("fcrepo:*");
                    mockEndpointsAndSkip("file:*");
          }
    });
    context.start();

    getMockEndpoint("mock:file:binary_file").expectedMessageCount(1);
    getMockEndpoint("mock:file:binary_file").expectedHeaderReceived(FILE_NAME, "/foo");

    // send a file!
    final String body = IOUtils.toString(loadResourceAsStream("binary.rdf"), "UTF-8");

    template.sendBodyAndHeader(body, SERIALIZATION_PATH, "/foo");

    assertMockEndpointsSatisfied();
}
 
Example #29
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeleteRouter() throws Exception {

    final List<String> eventTypes = asList(EVENT_NS + "ResourceDeletion");

    context.getRouteDefinition("FcrepoSolrDeleter").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            mockEndpointsAndSkip("http4*");
        }
    });
    context.start();

    getMockEndpoint("mock:" + solrURL + "/update").expectedMessageCount(1);
    getMockEndpoint("mock:" + solrURL + "/update")
        .expectedHeaderReceived(Exchange.CONTENT_TYPE, "application/json");
    getMockEndpoint("mock:" + solrURL + "/update")
        .expectedHeaderReceived(Exchange.HTTP_METHOD, "POST");

    template.sendBodyAndHeaders("direct:delete.solr", "",
            createEvent(baseURL + fileID, eventTypes));

    assertMockEndpointsSatisfied();
}
 
Example #30
Source File: RouteTest.java    From fcrepo-camel-toolbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testOptions() throws Exception {
    getMockEndpoint("mock:language:simple:resource:classpath:org/fcrepo/camel/ldpath/options.ttl")
        .expectedMessageCount(1);

    context.getRouteDefinition("FcrepoLDPathRest").adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:start");
            mockEndpointsAndSkip("language:simple:resource:classpath:org/fcrepo/camel/ldpath/options.ttl");
        }
    });
    context.start();

    template.sendBodyAndHeader(null, HTTP_METHOD, "OPTIONS");
    assertMockEndpointsSatisfied();
}