Have you extended your test class with CamelSpringTestSupport? There you've to override a method which loads the camel context. So the beans should be loaded (you can simply test this by setting a break point into the descriptor of your bean).

Where comes this 'input4Endpoint' from? It should template.sendBody("direct://start", "foo"). But for this you have to use CamelSpringTestSupport. The "foo" body will never consumed by your method, because there is no method attribute. The sendBody method should be find for your usecase.

assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS); doesn't help here, because you've no mock endpoints.You can find here some information about testing: http://camel.apache.org/testing.html

Am Mittwoch, den 15.06.2011, 09:51 +0200 schrieb Andrè <morpheusan...@web.de>:
so
i wrote an unit test
        @Test
        public void testDirectSending() throws Exception{
// lets route from the output endpoints to our mock endpoints so we can
assert expectations
                context.addRoutes(new RouteBuilder() {
                        @Override
                        public void configure() throws Exception {
                                from("bean:pdp").to(outputEndpoint);
                        }
                });
                input4Endpoint.sendBody("direct:start", "foo");
                assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS);

my routes:
   <route>
        <from uri="activemq:topic:xacml.authzRequests"/>
        <log message="request consumed hopefully"/>
        <to uri="bean:pdp"/>
    </route>
    <route>
        <from uri="direct:start"/>
        <bean method="genRequest" ref="xacmlRequest"/>
        <log message="request generated"/>
        <to uri="activemq:topic:xacml.authzRequests"/>
    </route>

and the class:

public class XacmlRequester {

        @EndpointInject(uri = "activemq:topic:xacml.authzRequests")
        ProducerTemplate producer;

        @InOnly
        public void genRequest(){
                try {
                        producer.sendBody(new FileInputStream(new
File("src/requests/request.xml")));
                } catch (FileNotFoundException e) {
                        System.out.println("datei nicht gefunden");
                        e.printStackTrace();
                }
        }
}
the bean:pdp is an XACML PDP, which evalutes the request give this to
System.out
<Response>
  <Result ResourceId="">
    <Decision>Permit</Decision>
    <Status>
      <StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
    </Status>
  </Result>
</Response>
 so in the testcase everything is fine
but when i let the camel:run  it doesnt work
so what is the difference ? it has to be this:sendBody("direct:start",
"foo"); what does this mean ? in my scenario ?

--
View this message in context:

http://camel.465427.n5.nabble.com/what-did-i-forgot-Bean-integration-through-direct-start-tp4490510p4491916.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to