camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Testing REST DSL routes
Date Thu, 03 Sep 2015 15:03:43 GMT
camel-test-blueprint is a simple simulated osgi framework. It does not
offer HTTP/web services and whatnot. For that you need to use karaf
pax-exam testing which boot up a real karaf container for testing.

On Fri, Aug 28, 2015 at 3:08 PM, MimerPlusPlus <dbh@miracle.dk> wrote:
> Hi
>
> I've been having trouble testing my REST DSL routes in jUnit. It seems that
> my camelContext does nok have a HttpSession, which probably is due to some
> missing components in my pom.
>
> What id like to do is something like the following test case, which i added
> to the example project found her:
>
> https://github.com/apache/camel/tree/master/examples/camel-example-servlet-rest-blueprint
>
> I added the following to the pom, but other than that, the project is as it
> is in GitHub:
>
>  <dependency>
>       <groupId>org.apache.camel</groupId>
>       <artifactId>camel-test-blueprint</artifactId>
>       <scope>test</scope>
>       <version>2.15.3</version>
>   </dependency>
>
> And the testcase i'd like to run, is also pretty basic:
>
> public class RestRouteTest extends CamelBlueprintTestSupport {
>
>     @Override
>     protected String getBlueprintDescriptor() {
>         return "OSGI-INF/blueprint/camel.xml";
>     }
>
>     @Test
>     public void testPut() throws Exception {
>         String payload = "{ \"id\": 666, \"name\": \"The devil\"}";
>         Exchange exchange = createExchangeWithBody(payload);
>
> template.send("http://localhost:9090//camel-example-servlet-rest-blueprint/rest/user/123",
> exchange);
>         assertMockEndpointsSatisfied();
>     }
> }
>
> But all i get is the following output, where it complains that it's "waiting
> for dependencies [(objectClass=org.osgi.service.http.HttpService)]" , and in
> the end "Gave up waiting for service
> (objectClass=org.apache.camel.CamelContext)"...
>
> What am i missing? What is the best way of testing REST routes?
>
> 2015-08-28 14:40:34,351 [main           ] INFO  CamelBlueprintHelper
> - Using Blueprint XML file:
> /projects/fuse/camel/examples/camel-example-servlet-rest-blueprint/target/classes/OSGI-INF/blueprint/camel.xml
> 2015-08-28 14:40:34,434 [Thread-0       ] INFO  RawBuilder
> - Copy thread finished.
> 2015-08-28 14:40:34,485 [main           ] INFO  Activator
> - Camel activator starting
> 2015-08-28 14:40:34,498 [main           ] INFO  Activator
> - Camel activator started
> SLF4J: Class path contains multiple SLF4J bindings.
> SLF4J: Found binding in
> [jar:file:/Users/dbh/.m2/repository/org/slf4j/slf4j-log4j12/1.7.10/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: Found binding in
> [jar:file:/Users/dbh/.m2/repository/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
> explanation.
> SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
> 2015-08-28 14:40:35,881 [int Extender: 1] INFO  BlueprintContainerImpl
> - Bundle RestRouteTest is waiting for dependencies
> [(objectClass=org.osgi.service.http.HttpService)]
> 2015-08-28 14:41:04,760 [main           ] INFO  RestRouteTest
> -
> ********************************************************************************
> 2015-08-28 14:41:04,760 [main           ] INFO  RestRouteTest
> - Testing: testGet(org.apache.camel.example.RestRouteTest)
> 2015-08-28 14:41:04,761 [main           ] INFO  RestRouteTest
> -
> ********************************************************************************
> 2015-08-28 14:41:34,765 [main           ] WARN  CamelBlueprintHelper
> - Test bundle headers: Bundle-ManifestVersion=2, Bundle-Name=System Bundle,
> Bundle-SymbolicName=org.apache.felix.connect, Bundle-Vendor=Apache Software
> Foundation, Bundle-Version=0.0.0
> 2015-08-28 14:41:34,767 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.camel.spi.DataFormatResolver], bundle:
> org.apache.camel.camel-core [1], symbolicName: org.apache.camel.camel-core
> 2015-08-28 14:41:34,768 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.felix.cm.PersistenceManager], bundle:
> org.apache.felix.configadmin [38], symbolicName:
> org.apache.felix.configadmin
> 2015-08-28 14:41:34,769 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.camel.spi.ComponentResolver], bundle:
> org.apache.camel.camel-core [1], symbolicName: org.apache.camel.camel-core
> 2015-08-28 14:41:34,769 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle:
> org.apache.aries.blueprint.core [24], symbolicName:
> org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,770 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.osgi.service.cm.ManagedServiceFactory], bundle:
> org.apache.felix.fileinstall [39], symbolicName:
> org.apache.felix.fileinstall
> 2015-08-28 14:41:34,771 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.camel.spi.LanguageResolver], bundle:
> org.apache.camel.camel-core [1], symbolicName: org.apache.camel.camel-core
> 2015-08-28 14:41:34,771 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.osgi.framework.hooks.bundle.EventHook], bundle:
> org.apache.aries.blueprint.core [24], symbolicName:
> org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,772 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle:
> org.apache.aries.blueprint.core [24], symbolicName:
> org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,773 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference:
> [org.osgi.service.blueprint.container.BlueprintContainer], bundle:
> org.apache.aries.blueprint.cm [26], symbolicName:
> org.apache.aries.blueprint.cm
> 2015-08-28 14:41:34,773 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.osgi.service.url.URLStreamHandlerService], bundle:
> org.apache.felix.fileinstall [39], symbolicName:
> org.apache.felix.fileinstall
> 2015-08-28 14:41:34,774 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.camel.spi.DataFormatResolver], bundle:
> org.apache.camel.camel-jackson [10], symbolicName:
> org.apache.camel.camel-jackson
> 2015-08-28 14:41:34,774 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle:
> org.apache.aries.blueprint.core [24], symbolicName:
> org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,775 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.services.ParserService],
> bundle: org.apache.aries.blueprint.core [24], symbolicName:
> org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,776 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.camel.spi.TypeConverterLoader], bundle:
> org.apache.camel.camel-http [8], symbolicName: org.apache.camel.camel-http
> 2015-08-28 14:41:34,776 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.osgi.service.packageadmin.PackageAdmin], bundle:
> org.apache.felix.connect [0], symbolicName: org.apache.felix.connect
> 2015-08-28 14:41:34,777 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle:
> org.apache.aries.blueprint.cm [26], symbolicName:
> org.apache.aries.blueprint.cm
> 2015-08-28 14:41:34,777 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.proxy.ProxyManager], bundle:
> org.apache.aries.proxy.impl [22], symbolicName: org.apache.aries.proxy.impl
> 2015-08-28 14:41:34,778 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle:
> org.apache.aries.blueprint.core [24], symbolicName:
> org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,779 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference:
> [org.osgi.service.blueprint.container.BlueprintContainer], bundle:
> org.apache.camel.camel-blueprint [5], symbolicName:
> org.apache.camel.camel-blueprint
> 2015-08-28 14:41:34,779 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference:
> [org.apache.aries.quiesce.participant.QuiesceParticipant], bundle:
> org.apache.aries.blueprint.core [24], symbolicName:
> org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,780 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle:
> org.apache.aries.blueprint.cm [26], symbolicName:
> org.apache.aries.blueprint.cm
> 2015-08-28 14:41:34,780 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle:
> org.apache.aries.blueprint.cm [26], symbolicName:
> org.apache.aries.blueprint.cm
> 2015-08-28 14:41:34,781 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle:
> org.apache.aries.blueprint.core [24], symbolicName:
> org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,781 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.camel.spi.TypeConverterLoader], bundle:
> org.apache.camel.camel-core [1], symbolicName: org.apache.camel.camel-core
> 2015-08-28 14:41:34,782 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference:
> [org.osgi.service.blueprint.container.BlueprintContainer], bundle:
> org.apache.aries.blueprint.core [24], symbolicName:
> org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,782 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle:
> org.apache.aries.blueprint.cm [26], symbolicName:
> org.apache.aries.blueprint.cm
> 2015-08-28 14:41:34,783 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.osgi.service.cm.ConfigurationAdmin], bundle:
> org.apache.felix.configadmin [38], symbolicName:
> org.apache.felix.configadmin
> 2015-08-28 14:41:34,783 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle:
> org.apache.aries.blueprint.core [24], symbolicName:
> org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,784 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle:
> org.apache.camel.camel-blueprint [5], symbolicName:
> org.apache.camel.camel-blueprint
> 2015-08-28 14:41:34,784 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.camel.spi.TypeConverterLoader], bundle:
> org.apache.felix.connect [0], symbolicName: org.apache.felix.connect
> 2015-08-28 14:41:34,784 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.camel.spi.ComponentResolver], bundle:
> org.apache.camel.camel-servlet [7], symbolicName:
> org.apache.camel.camel-servlet
> 2015-08-28 14:41:34,785 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.osgi.service.startlevel.StartLevel], bundle:
> org.apache.felix.connect [0], symbolicName: org.apache.felix.connect
> 2015-08-28 14:41:34,785 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.osgi.service.cm.ConfigurationListener,
> org.apache.felix.fileinstall.ArtifactListener,
> org.apache.felix.fileinstall.ArtifactInstaller], bundle:
> org.apache.felix.fileinstall [39], symbolicName:
> org.apache.felix.fileinstall
> 2015-08-28 14:41:34,786 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference:
> [org.apache.aries.blueprint.services.BlueprintExtenderService], bundle:
> org.apache.aries.blueprint.core [24], symbolicName:
> org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,787 [main           ] WARN  CamelBlueprintHelper
> - ServiceReference: [org.apache.camel.spi.ComponentResolver], bundle:
> org.apache.camel.camel-http [8], symbolicName: org.apache.camel.camel-http
> 2015-08-28 14:41:34,787 [main           ] INFO  RestRouteTest
> -
> ********************************************************************************
> 2015-08-28 14:41:34,788 [main           ] INFO  RestRouteTest
> - Testing done: testGet(org.apache.camel.example.RestRouteTest)
> 2015-08-28 14:41:34,789 [main           ] INFO  RestRouteTest
> - Took: 1 minute (60460 millis)
> 2015-08-28 14:41:34,789 [main           ] INFO  RestRouteTest
> -
> ********************************************************************************
> 2015-08-28 14:41:34,790 [main           ] INFO  BlueprintExtender
> - Destroying BlueprintContainer for bundle RestRouteTest
> 2015-08-28 14:41:34,794 [main           ] INFO  BlueprintExtender
> - Destroying BlueprintContainer for bundle org.apache.aries.blueprint.cm
> 2015-08-28 14:41:34,799 [main           ] INFO  BlueprintExtender
> - Destroying BlueprintContainer for bundle org.apache.aries.blueprint.core
> 2015-08-28 14:41:34,800 [main           ] INFO  BlueprintExtender
> - Destroying BlueprintContainer for bundle org.apache.camel.camel-blueprint
>
> java.lang.RuntimeException: Gave up waiting for service
> (objectClass=org.apache.camel.CamelContext)
>         at
> org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:265)
>         at
> org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:226)
>         at
> org.apache.camel.test.blueprint.CamelBlueprintTestSupport.createCamelContext(CamelBlueprintTestSupport.java:409)
>
> 2015-08-28 14:41:34,803 [main           ] INFO  Activator
> - Camel activator stopping
> 2015-08-28 14:41:34,803 [main           ] INFO  Activator
> - Camel activator stopped
> 2015-08-28 14:41:34,804 [main           ] INFO  CamelBlueprintHelper
> - Deleting work directory target/bundles/1440765634352
>
> Process finished with exit code 255
>
> Regards,
> Dennis
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Testing-REST-DSL-routes-tp5771058.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition: http://www.manning.com/ibsen2

Mime
View raw message