On Mon, Aug 12, 2013 at 2:43 AM, Dishara Wijewardana < [email protected]> wrote:
> Hi Ian, > Thank you very much for this detailed steps. This was what I was looking > to gather from docs. > > In step1, on services, there is no CassandraResourceProvider. I searched > for the name and there is no such. But in bundles I have it in active > state. I tried refreshing it again too. But still I cannot see the service. > In my provider class @Service annotation is defined > as @Service(ResourceProvider.class). Instead do I need to make it > as @Service(CassandraResourceProvider.class) ? How does the services > generated from bundles ?. > (I also verified this by uninstalling and then installing the cassandra > bundle and check whether service count decreases/increases) > > I tried this also. But no effect and same result. Seems @Service(ResourceProvider) is fine with it. Following is the bundle info. Symbolic Name org.apache.sling.cassandra Version 0.0.1.SNAPSHOT Bundle Location inputstream:org.apache.sling.cassandra-0.0.1-SNAPSHOT.jar Last Modification Mon Aug 12 02:48:13 IST 2013 Description Provides a ResourceProvider implementation supporting Apache Cassandra based resources. Start Level 20 Bundle Classpath .,hector-core-1.0-2.jar,jaxp-ri-1.4.jar,FastInfoset-1.2.8.jar,cassandra-thrift-1.1.0.jar,commons-pool-1.5.5.jar,libthrift-0.9.0.jar,httpclient-4.2.jar,httpcore-4.2.jar Exported Packages org.apache.sling.cassandra.resource.provider,version=0.0.1.SNAPSHOT org.apache.sling.cassandra.resource.provider.mapper,version=0.0.1.SNAPSHOT org.apache.sling.cassandra.resource.provider.util,version=0.0.1.SNAPSHOT Imported Packages com.google.common.base,version=10.0.0 from com.google.guava (103) com.google.common.collect,version=10.0.0 from com.google.guava (103) javax.crypto,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.crypto.spec,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.management,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.naming,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.naming.spi,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.net,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.net.ssl,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.security.auth,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.security.auth.callback,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.security.auth.login,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.security.auth.x500,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.security.sasl,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.servlet,version=2.5.0 from org.apache.felix.http.jetty (1) javax.servlet.http,version=2.5.0 from org.apache.felix.http.jetty (1) javax.swing,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.swing.border,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.swing.event,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) javax.xml.bind,version=2.1.0 from org.apache.felix.framework (0) javax.xml.datatype,version=2.1.0 from org.apache.felix.framework (0) javax.xml.namespace,version=0.0.0.fragment_xml from org.apache.felix.framework (0) javax.xml.parsers,version=0.0.0.fragment_xml from org.apache.felix.framework (0) javax.xml.stream,version=1.0.0 from org.apache.felix.framework (0) javax.xml.stream.events,version=1.0.0 from org.apache.felix.framework (0) javax.xml.stream.util,version=1.0.0 from org.apache.felix.framework (0) javax.xml.transform,version=0.0.0.fragment_xml from org.apache.felix.framework (0) javax.xml.transform.dom,version=0.0.0.fragment_xml from org.apache.felix.framework (0) javax.xml.transform.sax,version=0.0.0.fragment_xml from org.apache.felix.framework (0) javax.xml.transform.stax,version=0.0.0.fragment_xml from org.apache.felix.framework (0) javax.xml.transform.stream,version=0.0.0.fragment_xml from org.apache.felix.framework (0) javax.xml.validation,version=0.0.0.fragment_xml from org.apache.felix.framework (0) javax.xml.xpath,version=0.0.0.fragment_xml from org.apache.felix.framework (0) org.apache.commons.codec.binary,version=1.6.0 from org.apache.commons.codec (87) org.apache.commons.lang,version=2.5.0 from org.apache.commons.lang (85) org.apache.commons.lang.builder,version=2.5.0 from org.apache.commons.lang (85) org.apache.commons.lang.math,version=2.5.0 from org.apache.commons.lang (85) org.apache.commons.logging,version=1.1.1 from jcl.over.slf4j (3) org.apache.sling.api.resource,version=2.3.2 from org.apache.sling.api (98) org.ietf.jgss,version=0.0.0.1_006_JavaSE from org.apache.felix.framework (0) org.slf4j,version=1.6.4 from slf4j.api (6) org.w3c.dom,version=0.0.0.fragment_xml from org.apache.felix.framework (0) org.w3c.dom.events,version=0.0.0.fragment_xml from org.apache.felix.framework (0) org.w3c.dom.html,version=0.0.0.fragment_xml from org.apache.felix.framework (0) org.w3c.dom.ls,version=0.0.0.fragment_xml from org.apache.felix.framework (0) org.w3c.dom.ranges,version=0.0.0.fragment_xml from org.apache.felix.framework (0) org.w3c.dom.traversal,version=0.0.0.fragment_xml from org.apache.felix.framework (0) org.w3c.dom.xpath,version=0.0.0.fragment_xml from org.apache.felix.framework (0) org.xml.sax,version=0.0.0.fragment_xml from org.apache.felix.framework (0) org.xml.sax.ext,version=0.0.0.fragment_xml from org.apache.felix.framework (0) org.xml.sax.helpers,version=0.0.0.fragment_xml from org.apache.felix.framework (0) Manifest Headers Bnd-LastModified: 1376255749768 Build-Jdk: 1.6.0_26 Built-By: dishara Bundle-ClassPath: ., hector-core-1.0-2.jar, jaxp-ri-1.4.jar, FastInfoset-1.2.8.jar, cassandra-thrift-1.1.0.jar, commons-pool-1.5.5.jar, libthrift-0.9.0.jar, httpclient-4.2.jar, httpcore-4.2.jar Bundle-Description: Provides a ResourceProvider implementation supporting Apache Cassandra based resources. Bundle-ManifestVersion: 2 Bundle-Name: Apache Sling Cassandra Resource Provider Bundle-SymbolicName: org.apache.sling.cassandra Bundle-Version: 0.0.1.SNAPSHOT Created-By: Apache Maven Bundle Plugin Embed-Dependency: hector-core, jaxp-ri, FastInfoset, cassandra-thrift, commons-pool, libthrift, httpclient, httpcore Embed-Transitive: true Embedded-Artifacts: hector-core-1.0-2.jar; g="me.prettyprint"; a="hector-core"; v="1.0-2", jaxp-ri-1.4.jar; g="com.sun.org.apache"; a="jaxp-ri"; v="1.4", FastInfoset-1.2.8.jar; g="com.sun.xml.fastinfoset"; a="FastInfoset"; v="1.2.8", cassandra-thrift-1.1.0.jar; g="org.apache.cassandra"; a="cassandra-thrift"; v="1.1.0", commons-pool-1.5.5.jar; g="commons-pool"; a="commons-pool"; v="1.5.5", libthrift-0.9.0.jar; g="org.apache.thrift"; a="libthrift"; v="0.9.0", httpclient-4.2.jar; g="org.apache.httpcomponents"; a="httpclient"; v="4.2", httpcore-4.2.jar; g="org.apache.httpcomponents"; a="httpcore"; v="4.2" Export-Package: org.apache.sling.cassandra.resource.provider.mapper; version="0.0.1.SNAPSHOT", org.apache.sling.cassandra.resource.provider; uses:="javax.servlet.http, org.apache.sling.api.resource, org.apache.sling.cassandra.resource.provider.mapper"; version="0.0.1.SNAPSHOT", org.apache.sling.cassandra.resource.provider.util; uses:="org.apache.sling.api.resource, org.apache.sling.cassandra.resource.provider"; version="0.0.1.SNAPSHOT" Import-Package: com.google.common.base, com.google.common.collect, javax.crypto, javax.crypto.spec, javax.management, javax.naming, javax.naming.spi, javax.net, javax.net.ssl, javax.security.auth, javax.security.auth.callback, javax.security.auth.login, javax.security.auth.x500, javax.security.sasl, javax.servlet, javax.servlet.http, javax.swing, javax.swing.border, javax.swing.event, javax.xml.bind, javax.xml.datatype, javax.xml.namespace, javax.xml.parsers, javax.xml.stream, javax.xml.stream.events, javax.xml.stream.util, javax.xml.transform, javax.xml.transform.dom, javax.xml.transform.sax, javax.xml.transform.stax, javax.xml.transform.stream, javax.xml.validation, javax.xml.xpath, org.apache.commons.codec.binary; version="[1.6, 2)", org.apache.commons.lang; version="[2.4, 3)", org.apache.commons.lang.builder; version="[2.4, 3)", org.apache.commons.lang.math; version="[2.4, 3)", org.apache.commons.logging, org.apache.sling.api.resource; version="[2.3, 3)", org.ietf.jgss, org.slf4j; version="[1.5, 2)", org.w3c.dom, org.w3c.dom.events, org.w3c.dom.html, org.w3c.dom.ls, org.w3c.dom.ranges, org.w3c.dom.traversal, org.w3c.dom.xpath, org.xml.sax, org.xml.sax.ext, org.xml.sax.helpers Manifest-Version: 1.0 Tool: Bnd-2.1.0.20130426-122213 > > On Sun, Aug 11, 2013 at 2:49 PM, Ian Boston <[email protected]> wrote: > >> Hi Dishara, >> The Resource is not being found. >> >> Things to check. >> >> 1. Check that the CassandraResourceProvider is registered with the >> ResourceResolver at the correct path. >> >> Got to >> http://localhost:8080/system/console/services (login admin:admin) >> Locate the CassandraResourceProvider and take a note of the service ID >> (first column). >> Locate the service for >> org.apache.sling.api.resource.ResourceResolverFactory >> Click on the bundle link in the left hand column, in my case >> http://localhost:8080/system/console/bundles/146 >> Check that the the service ID for the CassandraResourceProvider is >> used by this bundle. >> >> 2. Put some Log statements in the CassandraResourceProvider to prove >> that the ResourceResolver is calling it. >> >> >> 3. Make certain that the Resource that the CassandrResourceProvider is >> returning is properly formed. It has resource metadata with a >> resourceType and path. >> >> You can use http://localhost:8080/system/console/jcrresolver to check >> how URLs are resolved, or use a curl command. >> >> HTH >> Ian >> >> On 11 August 2013 01:08, Dishara Wijewardana <[email protected]> >> wrote: >> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz < >> [email protected] >> >> wrote: >> > >> >> Hi, >> >> >> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana >> >> <[email protected]> wrote: >> >> > ...The integration tests >> >> > calls to HTTP REST endpoints. So there should be a place that I >> should be >> >> > writing something like JAX-RS using sling APIs... >> >> >> >> You don't need JAX-RS, Sling provides RESTful HTTP APIs out of the box. >> >> >> >> > ...Apparently what I should be >> >> > writing is something similar to PlanetsResourceProviderTest.... >> >> >> >> Yeah can be a good starting point - setup a Sling instance with your >> >> resource provider active and create, retrieve, update and delete >> >> resources via Sling's HTTP API. >> >> >> >> You can also probably test your ResourceProvider without a Sling >> >> instance, either with unit tests or pax exam integration tests. If you >> >> can demonstrate there that it works according to the ResourceProvider >> >> semantics, integration tests can be minimal and just verify that your >> >> provider hooks up in the right way when activated. >> >> >> > >> > Hi Bertrand >> > You are quite right. My provider works standalone and wants to make sure >> > whether my provider picked up by the sling engine. Where should I >> specify >> > my provider when calling the HTTP endpoint. Or if I call to a correct >> > resource path, will it picked it up ? >> > >> > I tried writing something similar to PlanetsResourceProviderTest and >> did a >> > HTTP GET call to the endpoint " >> > http://localhost:8080/content/cassandra/movies/foo" and when I remotely >> > debug the test, the http client of HTTPTestBase receives a 404 for that >> GET >> > call.. >> > >> > NOTE: /content/cassandra/movies/foo is an existing resource node in >> > cassandra and my provider capable of returning it in standalone mode. >> > >> > This is the BE error log.. >> > >> > unning >> > >> org.apache.sling.launchpad.webapp.integrationtest.resourceprovider.CassandraResourceProviderTest >> > Checking if the required Sling services are started (timeout 62 >> seconds)... >> > (base URLs=http://localhost:8080 and http://localhost:8080; servlet >> > context=) >> > Sling services seem to be started, continuing with integration tests. >> > Listening for transport dt_socket at address: 5006 >> > Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.472 >> sec >> > <<< FAILURE! >> > >> testMovieResource(org.apache.sling.launchpad.webapp.integrationtest.resourceprovider.CassandraResourceProviderTest) >> > Time elapsed: 0.437 sec <<< FAILURE! >> > junit.framework.AssertionFailedError: Expected status 200 for >> > http://localhost:8080/content/cassandra/movies/foo (content=<!DOCTYPE >> HTML >> > PUBLIC "-//IETF//DTD HTML 2.0//EN"> >> > <html> >> > <head> >> > <title>404 No resource found</title> >> > </head> >> > <body> >> > <h1>No resource found (404)</h1> >> > <p>The requested URL /content/cassandra/movies/foo resulted in an error >> in >> > >> org.apache.sling.servlets.resolver.internal.defaults.DefaultErrorHandlerServlet.</p> >> > <h3>Request Progress:</h3> >> > <pre> >> > 0 (2013-08-11 05:25:39) TIMER_START{Request Processing} >> > 0 (2013-08-11 05:25:39) COMMENT timer_end format is {<elapsed >> > msec>,<timer name>} <optional message> >> > 0 (2013-08-11 05:25:39) LOG Method=GET, >> > PathInfo=/content/cassandra/movies/foo >> > 0 (2013-08-11 05:25:39) TIMER_START{ResourceResolution} >> > 2 (2013-08-11 05:25:39) TIMER_END{2,ResourceResolution} >> > URI=/content/cassandra/movies/foo resolves to >> Resource=NonExistingResource, >> > path=/content/cassandra/movies/foo >> > 3 (2013-08-11 05:25:39) LOG Resource Path Info: >> SlingRequestPathInfo: >> > path='/content/cassandra/movies/foo', selectorString='null', >> > extension='null', suffix='null' >> > 3 (2013-08-11 05:25:39) TIMER_START{ServletResolution} >> > 3 (2013-08-11 05:25:39) >> > TIMER_START{resolveServlet(NonExistingResource, >> > path=/content/cassandra/movies/foo)} >> > 3 (2013-08-11 05:25:39) >> > TIMER_END{0,resolveServlet(NonExistingResource, >> > path=/content/cassandra/movies/foo)} Using servlet >> > org.apache.sling.servlets.get.DefaultGetServlet >> > 3 (2013-08-11 05:25:39) TIMER_END{0,ServletResolution} >> > URI=/content/cassandra/movies/foo handled by >> > Servlet=org.apache.sling.servlets.get.DefaultGetServlet >> > 3 (2013-08-11 05:25:39) LOG Applying Requestfilters >> > 3 (2013-08-11 05:25:39) LOG Calling filter: >> > org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter >> > 3 (2013-08-11 05:25:39) >> > TIMER_START{org.apache.sling.servlets.get.DefaultGetServlet#0} >> > 3 (2013-08-11 05:25:39) >> > TIMER_END{0,org.apache.sling.servlets.get.DefaultGetServlet#0} >> > 3 (2013-08-11 05:25:39) TIMER_START{handleError:status=404} >> > 4 (2013-08-11 05:25:39) TIMER_END{1,handleError:status=404} Using >> > handler >> > >> org.apache.sling.servlets.resolver.internal.defaults.DefaultErrorHandlerServlet >> > 5 (2013-08-11 05:25:39) TIMER_END{5,Request Processing} Dumping >> > SlingRequestProgressTracker Entries >> > </pre> >> > <hr> >> > <address>ApacheSling/2.2 (jetty/6.1.x, OpenJDK 64-Bit Server VM >> 1.6.0_27, >> > Linux 3.0.0-12-generic amd64)</address> >> > </body> >> > </html> >> > ) expected:<200> but was:<404> >> > at junit.framework.Assert.fail(Assert.java:47) >> > at junit.framework.Assert.failNotEquals(Assert.java:277) >> > at junit.framework.Assert.assertEquals(Assert.java:64) >> > at junit.framework.Assert.assertEquals(Assert.java:195) >> > at >> > >> org.apache.sling.commons.testing.integration.HttpTestBase.getContent(HttpTestBase.java:380) >> > at >> > >> org.apache.sling.commons.testing.integration.HttpTestBase.getContent(HttpTestBase.java:355) >> > at >> > >> org.apache.sling.commons.testing.integration.HttpTestBase.getContent(HttpTestBase.java:347) >> > at >> > >> org.apache.sling.commons.testing.integration.HttpTestBase.getContent(HttpTestBase.java:342) >> > at >> > >> org.apache.sling.launchpad.webapp.integrationtest.resourceprovider.CassandraResourceProviderTest.assertStrings(CassandraResourceProviderTest.java:27) >> > at >> > >> org.apache.sling.launchpad.webapp.integrationtest.resourceprovider.CassandraResourceProviderTest.testMovieResource(CassandraResourceProviderTest.java:64) >> > 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 junit.framework.TestCase.runTest(TestCase.java:168) >> > at junit.framework.TestCase.runBare(TestCase.java:134) >> > at junit.framework.TestResult$1.protect(TestResult.java:110) >> > at junit.framework.TestResult.runProtected(TestResult.java:128) >> > at junit.framework.TestResult.run(TestResult.java:113) >> > at junit.framework.TestCase.run(TestCase.java:124) >> > at junit.framework.TestSuite.runTest(TestSuite.java:232) >> > at junit.framework.TestSuite.run(TestSuite.java:227) >> > at >> > >> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81) >> > at >> > >> org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) >> > at >> > >> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) >> > at >> > >> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) >> > 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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) >> > at >> > >> org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) >> > at >> > >> org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) >> > at >> > >> org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) >> > at >> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) >> > >> > >> > Results : >> > >> > Failed tests: >> > >> testMovieResource(org.apache.sling.launchpad.webapp.integrationtest.resourceprovider.CassandraResourceProviderTest): >> > Expected status 200 for >> > http://localhost:8080/content/cassandra/movies/foo(content=<!DOCTYPE >> > HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">(..) >> > >> > Tests run: 1, Failures: 1, Errors: 0, Skipped: 0 >> > >> > [INFO] >> > ------------------------------------------------------------------------ >> > [INFO] BUILD FAILURE >> > [ >> > >> > >> > >> >> >> >> -Bertrand >> >> >> > >> > >> > >> > -- >> > Thanks >> > /Dishara >> > > > > -- > Thanks > /Dishara > -- Thanks /Dishara
