Unit Tests without jndi.properties

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Unit Tests without jndi.properties

jpcook01
I have upgraded to Camel 2 and I'm trying to write a unit test.

Before I just extended from ContextTestSupport but now it seems I have to extend from CamelTestSupport.

I have a really simple unit test:
public void testObservationsRouteBuilder() throws InterruptedException {
                //log.debug("testGroovy()");
       
        /*MockEndpoint resultEndpoint = context.getEndpoint("mock:After", MockEndpoint.class);
        resultEndpoint.expectedBodiesReceived(
        "/mobile/fixtures/index.wml"
        ,"/mobile/fixtures/1/index.wml"
        );

        sendBody("seda:groovytest", "testbody");
               
        resultEndpoint.assertIsSatisfied();*/
        }
       
        @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new ObservationsRouteBuilder();        
    }

But it just blows up complaining that it can't find jndi.properties on the classpath. I've looked at the source for CamelTestSupport and seems this is the problem.

protected Context createJndiContext() throws Exception {
        InputStream in = getClass().getClassLoader().getResourceAsStream("jndi.properties");
        assertNotNull("Cannot find jndi.properties on the classpath!", in);
        Properties properties = new Properties();
        properties.load(in);
        return new InitialContext(new Hashtable(properties));
    }

Do I really have to have this file which was part of camel-core-1.4.0-tests.jar and if so why and where do I put it now?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Unit Tests without jndi.properties

Claus Ibsen-2
Hi

Thanks for reporting. Yeah looks like its missing in the
camel-test.jar distribution.

camel-test.jar is meant for unit testing as its a regular maven .jar
(eg not a testjar type).

If you have the time feel free to ceate a ticket in JIRA so we wont
forget, to fix it.



On Thu, May 7, 2009 at 5:24 PM, jpcook <[hidden email]> wrote:

>
> I have upgraded to Camel 2 and I'm trying to write a unit test.
>
> Before I just extended from ContextTestSupport but now it seems I have to
> extend from CamelTestSupport.
>
> I have a really simple unit test:
> public void testObservationsRouteBuilder() throws InterruptedException {
>                //log.debug("testGroovy()");
>
>        /*MockEndpoint resultEndpoint = context.getEndpoint("mock:After",
> MockEndpoint.class);
>        resultEndpoint.expectedBodiesReceived(
>                        "/mobile/fixtures/index.wml"
>                        ,"/mobile/fixtures/1/index.wml"
>                        );
>
>        sendBody("seda:groovytest", "testbody");
>
>        resultEndpoint.assertIsSatisfied();*/
>        }
>
>        @Override
>    protected RouteBuilder createRouteBuilder() throws Exception {
>        return new ObservationsRouteBuilder();
>    }
>
> But it just blows up complaining that it can't find jndi.properties on the
> classpath. I've looked at the source for CamelTestSupport and seems this is
> the problem.
>
> protected Context createJndiContext() throws Exception {
>        InputStream in =
> getClass().getClassLoader().getResourceAsStream("jndi.properties");
>        assertNotNull("Cannot find jndi.properties on the classpath!", in);
>        Properties properties = new Properties();
>        properties.load(in);
>        return new InitialContext(new Hashtable(properties));
>    }
>
> Do I really have to have this file which was part of
> camel-core-1.4.0-tests.jar and if so why and where do I put it now?
>
> Thanks
> --
> View this message in context: http://www.nabble.com/Unit-Tests-without-jndi.properties-tp23428533p23428533.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
Reply | Threaded
Open this post in threaded view
|

Re: Unit Tests without jndi.properties

Claus Ibsen-2
Hi

I had time so I have created the ticket CAMEL-1590 and committed a fix
to Camel trunk.

Thanks for reporting.
A workaround is to put a empty jndi.properties in your own
src/test/resources folder.


On Thu, May 7, 2009 at 5:30 PM, Claus Ibsen <[hidden email]> wrote:

> Hi
>
> Thanks for reporting. Yeah looks like its missing in the
> camel-test.jar distribution.
>
> camel-test.jar is meant for unit testing as its a regular maven .jar
> (eg not a testjar type).
>
> If you have the time feel free to ceate a ticket in JIRA so we wont
> forget, to fix it.
>
>
>
> On Thu, May 7, 2009 at 5:24 PM, jpcook <[hidden email]> wrote:
>>
>> I have upgraded to Camel 2 and I'm trying to write a unit test.
>>
>> Before I just extended from ContextTestSupport but now it seems I have to
>> extend from CamelTestSupport.
>>
>> I have a really simple unit test:
>> public void testObservationsRouteBuilder() throws InterruptedException {
>>                //log.debug("testGroovy()");
>>
>>        /*MockEndpoint resultEndpoint = context.getEndpoint("mock:After",
>> MockEndpoint.class);
>>        resultEndpoint.expectedBodiesReceived(
>>                        "/mobile/fixtures/index.wml"
>>                        ,"/mobile/fixtures/1/index.wml"
>>                        );
>>
>>        sendBody("seda:groovytest", "testbody");
>>
>>        resultEndpoint.assertIsSatisfied();*/
>>        }
>>
>>        @Override
>>    protected RouteBuilder createRouteBuilder() throws Exception {
>>        return new ObservationsRouteBuilder();
>>    }
>>
>> But it just blows up complaining that it can't find jndi.properties on the
>> classpath. I've looked at the source for CamelTestSupport and seems this is
>> the problem.
>>
>> protected Context createJndiContext() throws Exception {
>>        InputStream in =
>> getClass().getClassLoader().getResourceAsStream("jndi.properties");
>>        assertNotNull("Cannot find jndi.properties on the classpath!", in);
>>        Properties properties = new Properties();
>>        properties.load(in);
>>        return new InitialContext(new Hashtable(properties));
>>    }
>>
>> Do I really have to have this file which was part of
>> camel-core-1.4.0-tests.jar and if so why and where do I put it now?
>>
>> Thanks
>> --
>> View this message in context: http://www.nabble.com/Unit-Tests-without-jndi.properties-tp23428533p23428533.html
>> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> Apache Camel Reference Card:
> http://refcardz.dzone.com/refcardz/enterprise-integration
> Interview with me:
> http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
Reply | Threaded
Open this post in threaded view
|

Re: Unit Tests without jndi.properties

jpcook01
Thanks. That is what I did. Shame that was an easy one to fix :)
Claus Ibsen-2 wrote
Hi

I had time so I have created the ticket CAMEL-1590 and committed a fix
to Camel trunk.

Thanks for reporting.
A workaround is to put a empty jndi.properties in your own
src/test/resources folder.


On Thu, May 7, 2009 at 5:30 PM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
> Hi
>
> Thanks for reporting. Yeah looks like its missing in the
> camel-test.jar distribution.
>
> camel-test.jar is meant for unit testing as its a regular maven .jar
> (eg not a testjar type).
>
> If you have the time feel free to ceate a ticket in JIRA so we wont
> forget, to fix it.
>
>
>
> On Thu, May 7, 2009 at 5:24 PM, jpcook <jonathan.cook@erars.plus.com> wrote:
>>
>> I have upgraded to Camel 2 and I'm trying to write a unit test.
>>
>> Before I just extended from ContextTestSupport but now it seems I have to
>> extend from CamelTestSupport.
>>
>> I have a really simple unit test:
>> public void testObservationsRouteBuilder() throws InterruptedException {
>>                //log.debug("testGroovy()");
>>
>>        /*MockEndpoint resultEndpoint = context.getEndpoint("mock:After",
>> MockEndpoint.class);
>>        resultEndpoint.expectedBodiesReceived(
>>                        "/mobile/fixtures/index.wml"
>>                        ,"/mobile/fixtures/1/index.wml"
>>                        );
>>
>>        sendBody("seda:groovytest", "testbody");
>>
>>        resultEndpoint.assertIsSatisfied();*/
>>        }
>>
>>        @Override
>>    protected RouteBuilder createRouteBuilder() throws Exception {
>>        return new ObservationsRouteBuilder();
>>    }
>>
>> But it just blows up complaining that it can't find jndi.properties on the
>> classpath. I've looked at the source for CamelTestSupport and seems this is
>> the problem.
>>
>> protected Context createJndiContext() throws Exception {
>>        InputStream in =
>> getClass().getClassLoader().getResourceAsStream("jndi.properties");
>>        assertNotNull("Cannot find jndi.properties on the classpath!", in);
>>        Properties properties = new Properties();
>>        properties.load(in);
>>        return new InitialContext(new Hashtable(properties));
>>    }
>>
>> Do I really have to have this file which was part of
>> camel-core-1.4.0-tests.jar and if so why and where do I put it now?
>>
>> Thanks
>> --
>> View this message in context: http://www.nabble.com/Unit-Tests-without-jndi.properties-tp23428533p23428533.html
>> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> Apache Camel Reference Card:
> http://refcardz.dzone.com/refcardz/enterprise-integration
> Interview with me:
> http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress