users@jersey.java.net

[Jersey] Multiple root contexts in tests

From: Arnaud Bailly <arnaud.oqube_at_gmail.com>
Date: Fri, 18 Mar 2011 03:24:30 -0700 (PDT)

Hello,
I use jersey (1.5) in memory container to test basic REST interaction and I
am encountering an annoying issue: It does not seem to be possible to give
multiple root packages to the the WebAppDescriptor.Builder instance. Here is
what I do:

  public AppDescriptor configure() {
    return new WebAppDescriptor.Builder(new String[]
"my.package.root","my.package.root.test"}).contextPath("").build();
  }

And here is the stack trace I get:

com.sun.jersey.api.container.ContainerException: The ResourceConfig instance
does not contain any root resource classes.
        at
com.sun.jersey.server.impl.application.RootResourceUriRules.(RootResourceUriRules.java:103)
        at
com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1184)
        at
com.sun.jersey.server.impl.application.WebApplicationImpl.access$600(WebApplicationImpl.java:159)
        at
com.sun.jersey.server.impl.application.WebApplicationImpl$12.f(WebApplicationImpl.java:700)
        at
com.sun.jersey.server.impl.application.WebApplicationImpl$12.f(WebApplicationImpl.java:697)
        at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
        at
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:697)
        at
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:692)
        at
com.sun.jersey.test.framework.spi.container.inmemory.InMemoryTestContainerFactory$InMemoryTestContainer.start(InMemoryTestContainerFactory.java:140)
        at com.sun.jersey.test.framework.JerseyTest.setUp(JerseyTest.java:301)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
        at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
        at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
        at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


What I want to achieve is to use different @Provider in test and run
contexts, so I want to have different packages scanned when executing tests
and when running application.

Help greatly appreciated,
Arnaud

--
View this message in context: http://jersey.576304.n2.nabble.com/Multiple-root-contexts-in-tests-tp6184016p6184016.html
Sent from the Jersey mailing list archive at Nabble.com.