You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Dishara Wijewardana <dd...@gmail.com> on 2013/08/09 05:28:27 UTC

Read Sling resources remotely

Hi,
Can we access sling resources from a java client ? Is there any
sample/links to refer ?
This is just to test the Cassandra impl on Sling. Now the Cassandra bundle
is installed in sling server. There is a documentation on editing the JCR
content through SlingPostServlet. Can I call  this servlet and test my
resource provider ?


-- 
Thanks
/Dishara

Re: Read Sling resources remotely

Posted by Dishara Wijewardana <dd...@gmail.com>.
On Mon, Aug 12, 2013 at 3:10 AM, Robert Munteanu <ro...@lmn.ro> wrote:

> On Mon, Aug 12, 2013 at 12:33 AM, Dishara Wijewardana
> <dd...@gmail.com> wrote:
> > On Mon, Aug 12, 2013 at 2:54 AM, Robert Munteanu <ro...@lmn.ro> wrote:
> >
> >> On Mon, Aug 12, 2013 at 12:13 AM, Dishara Wijewardana
> >> <dd...@gmail.com> 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 ?.
> >>
> >> Hi Robert,
> > Thank you very much for the quick response.
> >
> >> @ServiceProvider is the right one to add, but IUUC you also need to
> >> add @Component . See the maven-scr-plugin docs [1] for more details.
> >>
> >
> > I could not find an annotation called ServiceProvider.
>
> Ugh, I meant @Service. But the annotations seem to be set up properly
> on the CassandraResourceProvider [1]
>
> [1]:
> http://cassandra-backend-for-sling.googlecode.com/svn/trunk/main/cassandra/src/main/java/org/apache/sling/cassandra/resource/provider/CassandraResourceProvider.java
>
> >
> >
> >>
> >> I can't remember where your code is posted, can you please paste a
> >> link? Perhaps the maven-scr-plugin is not properly integrated in the
> >> build.
> >>
> >
> > Here is the link: Please find the pom inside this folder for scr plugin
> > information.
> >
> https://cassandra-backend-for-sling.googlecode.com/svn/trunk/main/cassandra
>
> You haven't set up any execution of the maven-scr-plugin, so it's not
> getting invoked. See [2] for how it should appear . Something like (
> excuse the indentation ):
>
> Index: pom.xml
> ===================================================================
> --- pom.xml    (revision 17)
> +++ pom.xml    (working copy)
> @@ -71,6 +71,14 @@
>                  <configuration>
>                      <specVersion>1.1</specVersion>
>                  </configuration>
> +        <executions>
> +          <execution>
> +            <id>generate-scr-scrdescriptor</id>
> +            <goals>
> +              <goal>scr</goal>
> +            </goals>
> +          </execution>
> +        </executions>
>              </plugin>
>              <plugin>
>                  <groupId>org.apache.sling</groupId>
>
>
> Thanks Robert,
Yes, that was the exact issue. Awesome ! Thank you very much for helping me
sorting out this.


> Robert
>
> [2]:
> http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/apache-felix-maven-scr-plugin-use.html
>
> >
> >
> >>
> >> Robert
> >>
> >> [1]:
> >>
> http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html#component
> >>
> >> > (I also verified this by uninstalling and then installing the
> cassandra
> >> > bundle and check whether service count decreases/increases)
> >> >
> >> >
> >> > On Sun, Aug 11, 2013 at 2:49 PM, Ian Boston <ie...@tfd.co.uk> 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 <
> ddwijewardana@gmail.com>
> >> >> wrote:
> >> >> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <
> >> >> bdelacretaz@apache.org
> >> >> >> wrote:
> >> >> >
> >> >> >> Hi,
> >> >> >>
> >> >> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
> >> >> >> <dd...@gmail.com> 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
> {&lt;elapsed
> >> >> > msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
> >> >> >       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
> >>
> >>
> >>
> >> --
> >> Sent from my (old) computer
> >>
> >
> >
> >
> > --
> > Thanks
> > /Dishara
>
>
>
> --
> Sent from my (old) computer
>



-- 
Thanks
/Dishara

Re: Read Sling resources remotely

Posted by Robert Munteanu <ro...@lmn.ro>.
On Mon, Aug 12, 2013 at 12:33 AM, Dishara Wijewardana
<dd...@gmail.com> wrote:
> On Mon, Aug 12, 2013 at 2:54 AM, Robert Munteanu <ro...@lmn.ro> wrote:
>
>> On Mon, Aug 12, 2013 at 12:13 AM, Dishara Wijewardana
>> <dd...@gmail.com> 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 ?.
>>
>> Hi Robert,
> Thank you very much for the quick response.
>
>> @ServiceProvider is the right one to add, but IUUC you also need to
>> add @Component . See the maven-scr-plugin docs [1] for more details.
>>
>
> I could not find an annotation called ServiceProvider.

Ugh, I meant @Service. But the annotations seem to be set up properly
on the CassandraResourceProvider [1]

[1]: http://cassandra-backend-for-sling.googlecode.com/svn/trunk/main/cassandra/src/main/java/org/apache/sling/cassandra/resource/provider/CassandraResourceProvider.java

>
>
>>
>> I can't remember where your code is posted, can you please paste a
>> link? Perhaps the maven-scr-plugin is not properly integrated in the
>> build.
>>
>
> Here is the link: Please find the pom inside this folder for scr plugin
> information.
> https://cassandra-backend-for-sling.googlecode.com/svn/trunk/main/cassandra

You haven't set up any execution of the maven-scr-plugin, so it's not
getting invoked. See [2] for how it should appear . Something like (
excuse the indentation ):

Index: pom.xml
===================================================================
--- pom.xml    (revision 17)
+++ pom.xml    (working copy)
@@ -71,6 +71,14 @@
                 <configuration>
                     <specVersion>1.1</specVersion>
                 </configuration>
+        <executions>
+          <execution>
+            <id>generate-scr-scrdescriptor</id>
+            <goals>
+              <goal>scr</goal>
+            </goals>
+          </execution>
+        </executions>
             </plugin>
             <plugin>
                 <groupId>org.apache.sling</groupId>


Robert

[2]: http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/apache-felix-maven-scr-plugin-use.html

>
>
>>
>> Robert
>>
>> [1]:
>> http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html#component
>>
>> > (I also verified this by uninstalling and then installing the cassandra
>> > bundle and check whether service count decreases/increases)
>> >
>> >
>> > On Sun, Aug 11, 2013 at 2:49 PM, Ian Boston <ie...@tfd.co.uk> 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 <dd...@gmail.com>
>> >> wrote:
>> >> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <
>> >> bdelacretaz@apache.org
>> >> >> wrote:
>> >> >
>> >> >> Hi,
>> >> >>
>> >> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
>> >> >> <dd...@gmail.com> 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 {&lt;elapsed
>> >> > msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
>> >> >       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
>>
>>
>>
>> --
>> Sent from my (old) computer
>>
>
>
>
> --
> Thanks
> /Dishara



-- 
Sent from my (old) computer

Re: Read Sling resources remotely

Posted by Dishara Wijewardana <dd...@gmail.com>.
On Mon, Aug 12, 2013 at 2:54 AM, Robert Munteanu <ro...@lmn.ro> wrote:

> On Mon, Aug 12, 2013 at 12:13 AM, Dishara Wijewardana
> <dd...@gmail.com> 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 ?.
>
> Hi Robert,
Thank you very much for the quick response.

> @ServiceProvider is the right one to add, but IUUC you also need to
> add @Component . See the maven-scr-plugin docs [1] for more details.
>

I could not find an annotation called ServiceProvider.


>
> I can't remember where your code is posted, can you please paste a
> link? Perhaps the maven-scr-plugin is not properly integrated in the
> build.
>

Here is the link: Please find the pom inside this folder for scr plugin
information.
https://cassandra-backend-for-sling.googlecode.com/svn/trunk/main/cassandra


>
> Robert
>
> [1]:
> http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html#component
>
> > (I also verified this by uninstalling and then installing the cassandra
> > bundle and check whether service count decreases/increases)
> >
> >
> > On Sun, Aug 11, 2013 at 2:49 PM, Ian Boston <ie...@tfd.co.uk> 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 <dd...@gmail.com>
> >> wrote:
> >> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <
> >> bdelacretaz@apache.org
> >> >> wrote:
> >> >
> >> >> Hi,
> >> >>
> >> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
> >> >> <dd...@gmail.com> 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 {&lt;elapsed
> >> > msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
> >> >       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
>
>
>
> --
> Sent from my (old) computer
>



-- 
Thanks
/Dishara

Re: Read Sling resources remotely

Posted by Robert Munteanu <ro...@lmn.ro>.
On Mon, Aug 12, 2013 at 12:13 AM, Dishara Wijewardana
<dd...@gmail.com> 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 ?.

@ServiceProvider is the right one to add, but IUUC you also need to
add @Component . See the maven-scr-plugin docs [1] for more details.

I can't remember where your code is posted, can you please paste a
link? Perhaps the maven-scr-plugin is not properly integrated in the
build.

Robert

[1]: http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html#component

> (I also verified this by uninstalling and then installing the cassandra
> bundle and check whether service count decreases/increases)
>
>
> On Sun, Aug 11, 2013 at 2:49 PM, Ian Boston <ie...@tfd.co.uk> 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 <dd...@gmail.com>
>> wrote:
>> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <
>> bdelacretaz@apache.org
>> >> wrote:
>> >
>> >> Hi,
>> >>
>> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
>> >> <dd...@gmail.com> 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 {&lt;elapsed
>> > msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
>> >       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



-- 
Sent from my (old) computer

Re: Read Sling resources remotely

Posted by Dishara Wijewardana <dd...@gmail.com>.
On Mon, Aug 12, 2013 at 2:43 AM, Dishara Wijewardana <
ddwijewardana@gmail.com> 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 <ie...@tfd.co.uk> 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 <dd...@gmail.com>
>> wrote:
>> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <
>> bdelacretaz@apache.org
>> >> wrote:
>> >
>> >> Hi,
>> >>
>> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
>> >> <dd...@gmail.com> 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 {&lt;elapsed
>> > msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
>> >       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

Re: Read Sling resources remotely

Posted by Dishara Wijewardana <dd...@gmail.com>.
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)


On Sun, Aug 11, 2013 at 2:49 PM, Ian Boston <ie...@tfd.co.uk> 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 <dd...@gmail.com>
> wrote:
> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <
> bdelacretaz@apache.org
> >> wrote:
> >
> >> Hi,
> >>
> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
> >> <dd...@gmail.com> 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 {&lt;elapsed
> > msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
> >       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

Re: Read Sling resources remotely

Posted by Dishara Wijewardana <dd...@gmail.com>.
Hi Ian,
I added and commited a new load test class which adds bulk data to
cassandra. Can find all info how to configure it and run to add bulk data
in under a defined parent as you mentioned. But still I am blocking on the
issue I raised on using HTTP call to such added data.


On Wed, Aug 14, 2013 at 2:23 PM, Ian Boston <ie...@tfd.co.uk> wrote:

> Hi DIshara,
> Excelent news.
>
> Before you start on the next phase I would like to see some stats,
> even if they are only rudimentary.
>
> Can you build a test profile that adds
> 1K,10K,100K,1M items to Cassandra, each under 1 parent collection.
> eg
> /content/cassandra/1K/0   to /content/cassandra/1K/999
> /content/cassandra/10K/0   to /content/cassandra/10K/9999
> /content/cassandra/100K/0   to /content/cassandra/100K/99999
> /content/cassandra/1M/0   to /content/cassandra/1M/999999
>
> Then report on the http request time to retrieve 1 of those items from
> each of those collections for he first request and for subsequent
> requests. Use ApacheBenchmark for the timings.  (eg ab -n1
> http://localhost:8080/content/cassandra/1M/393452.json)
>
> IIRC Cassandra will take writes at about 4K/s which so it should take
> about 10 minutes to populate with 1M items. (my figures are probably
> very old).
>
> The reason for doing this is to get an rough idea of how this scales
> and to provide a base line to see the impact of adding ACLs.
>
> Thanks, great work!
>
> Best Regards
> Ian
>
> On 14 August 2013 01:05, Dishara Wijewardana <dd...@gmail.com>
> wrote:
> > Hi Ian,
> > I followed the steps you aforementioned and it worked fine ! (I had to
> fix
> > couple of bugs I had in the code). This is Wonderful. It gives me the
> > asking resource if it is there. Unless says resource not exists. I tested
> > it having Cassandra running in back ground. I will start a new thread to
> > discuss on how to proceed with the rest of the impl.
> >
> > Thank you very much :-).
> >
> >
> > On Mon, Aug 12, 2013 at 1:57 PM, Ian Boston <ie...@tfd.co.uk> wrote:
> >
> >> Hi Dishara,
> >>
> >> The ResourceResolverFactory bundle should not be using any bundle
> >> implementing a ResourceProvider, as that would imply a circular
> >> dependency.
> >>
> >> It looks like your service is starting correctly as its listed as
> >> service ID 257, component ID 103.
> >>
> >> Looking at the code, I dont think you have defined where the
> >> CassandraResourceProvider is "mounted", you need to set the
> >> provider.roots property.
> >>
> >> ie
> >>
> >> @Component(immediate=true, metatype=true)
> >> @Service(ResourceProvider.class)
> >> @Properties({
> >>      @Property(name="provider.roots", value={ "/content/cassandra"})
> >> })
> >>
> >> public class CassandraResourceProvider implements ResourceProvider {
> >>
> >>
> >> This tells the ResourceResolver where in the resource tree the
> >> CassandraResourceProvider should be registered. IIRC its required for
> >> registration. If you look at the logs carefully you might find the
> >> ResourceResolver reporting a problem with registration.
> >>
> >> HTH
> >> Ian
> >>
> >> On 11 August 2013 23:22, Dishara Wijewardana <dd...@gmail.com>
> >> wrote:
> >> > On Sun, Aug 11, 2013 at 2:49 PM, Ian Boston <ie...@tfd.co.uk> 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.
> >> >>
> >> > Hi Ian, ResourceResolverFactory dos not include my bundle under using
> >> > bundles category. Do I need to add a dependency/import to the pom
> which
> >> > includes ResourceResolverFactory class ?
> >> >
> >> > Refer following for more information
> >> >
> >> > [org.apache.sling.api.resource.ResourceResolverFactory]
> >> > Service Description Apache Sling Resource Resolver Factory
> >> > Service Vendor The Apache Software Foundation
> >> > Using Bundles org.apache.sling.event (52)
> >> > org.apache.sling.jcr.resource (90)
> >> > org.apache.sling.auth.form (91)
> >> > org.apache.sling.servlets.resolver (71)
> >> > org.apache.sling.auth.core (86)
> >> > org.apache.sling.discovery.impl (75)
> >> >
> >> > *and here is my bundle service information.*
> >> >
> >> > 257 [org.apache.sling.api.resource.ResourceProvider]
> >> > component.id 103
> >> > component.name
> >> > org.apache.sling.cassandra.resource.provider.CassandraResourceProvider
> >> > Service PID
> >> > org.apache.sling.cassandra.resource.provider.CassandraResourceProvider
> >> > Using Bundles org.apache.sling.bundleresource.impl (74)
> >> > org.apache.sling.resourceresolver (57)
> >> >
> >> >
> >> >> 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 <
> ddwijewardana@gmail.com>
> >> >> wrote:
> >> >> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <
> >> >> bdelacretaz@apache.org
> >> >> >> wrote:
> >> >> >
> >> >> >> Hi,
> >> >> >>
> >> >> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
> >> >> >> <dd...@gmail.com> 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
> {&lt;elapsed
> >> >> > msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
> >> >> >       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
>



-- 
Thanks
/Dishara

Re: Read Sling resources remotely

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Fri, Aug 16, 2013 at 5:31 AM, Dishara Wijewardana
<dd...@gmail.com> wrote:
> ...java.lang.NullPointerException
>         at org.apache.sling.servlets.resolver.internal.SlingServletResolver.resolveServlet(SlingServletResolver.java:581)...

There's no code in trunk at that line, you'll need to debug the
version of the code that you are using to find out what's happening.

In general, as your ResourceProvider interacts heavily with the Sling
core code, you will need to get used to debugging some of the Sling
code.

It's quite possible that we still have some bugs in there as we
haven't been using lots of different ResourceProviders so far, or it
might be your provider that's still missing some features - only
debugging will tell you what's happening.

-Bertrand

Re: Read Sling resources remotely

Posted by Dishara Wijewardana <dd...@gmail.com>.
HI,
Is there a reason why I can resolve my cassandra paths at
/content/cassandra/movies/foo/bar1/test/bbb.json  but fails on
http://localhost:8080/content/cassandra/movies/foo/bar1/test/bbb.json with
a

Internal Server Error (500)

The requested URL /content/cassandra/movies/foo/bar1/test/bbb.json resulted
in an error in Sling (Ad Hoc) Default Error Handler Servlet.
Exception:

java.lang.NullPointerException
	at org.apache.sling.servlets.resolver.internal.SlingServletResolver.resolveServlet(SlingServletResolver.java:581)
	at org.apache.sling.servlets.resolver.internal.SlingServletResolver.resolveServlet(SlingServletResolver.java:273)
	at org.apache.sling.engine.impl.request.RequestData.initServlet(RequestData.java:228)
	at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:141)
	at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:207)
	at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
	at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
	at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
	at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
	at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
	at org.apache.sling.engine.impl.log.RequestLoggerFilter.doFilter(RequestLoggerFilter.java:75)
	at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
	at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
	at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
	at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
	at org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
	at org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
	at org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:326)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

Request Progress:

      0 (2013-08-16 07:38:16) TIMER_START{Request Processing}
      0 (2013-08-16 07:38:16) COMMENT timer_end format is {<elapsed
msec>,<timer name>} <optional message>
      0 (2013-08-16 07:38:16) LOG Method=GET,
PathInfo=/content/cassandra/movies/foo/bar1/test/bbb.json
      0 (2013-08-16 07:38:16) TIMER_START{ResourceResolution}
      4 (2013-08-16 07:38:16) TIMER_END{4,ResourceResolution}
URI=/content/cassandra/movies/foo/bar1/test/bbb.json resolves to
Resource=org.apache.sling.cassandra.resource.provider.CassandraResource@53436f66
      4 (2013-08-16 07:38:16) LOG Resource Path Info:
SlingRequestPathInfo:
path='/content/cassandra/movies/foo/bar1/test/bbb.json',
selectorString='null', extension='null',
suffix='/content/cassandra/movies/foo/bar1/test/bbb.json'
      4 (2013-08-16 07:38:16) TIMER_START{ServletResolution}
      4 (2013-08-16 07:38:16)
TIMER_START{resolveServlet(org.apache.sling.cassandra.resource.provider.CassandraResource@53436f66)}
      4 (2013-08-16 07:38:16)
TIMER_START{handleError:throwable=java.lang.NullPointerException}
      5 (2013-08-16 07:38:16)
TIMER_END{1,handleError:throwable=java.lang.NullPointerException}
Using handler Sling (Ad Hoc) Default Error Handler Servlet
      6 (2013-08-16 07:38:16) TIMER_END{6,Request Processing} Dumping
SlingRequestProgressTracker Entries




On Wed, Aug 14, 2013 at 3:45 PM, Ian Boston <ie...@tfd.co.uk> wrote:

> On 14 August 2013 09:55, Bertrand Delacretaz <bd...@apache.org>
> wrote:
> > On Wed, Aug 14, 2013 at 10:53 AM, Ian Boston <ie...@tfd.co.uk> wrote:
> >> ...Before you start on the next phase I would like to see some stats,
> >> even if they are only rudimentary....
> >
> > Would be good IMO to collect these stats in a jira issue, so that we
> > can keep track of the evolution.
>
> Agreed.
> Ian
>
> >
> > -Bertrand
>



-- 
Thanks
/Dishara

Re: Read Sling resources remotely

Posted by Ian Boston <ie...@tfd.co.uk>.
On 14 August 2013 09:55, Bertrand Delacretaz <bd...@apache.org> wrote:
> On Wed, Aug 14, 2013 at 10:53 AM, Ian Boston <ie...@tfd.co.uk> wrote:
>> ...Before you start on the next phase I would like to see some stats,
>> even if they are only rudimentary....
>
> Would be good IMO to collect these stats in a jira issue, so that we
> can keep track of the evolution.

Agreed.
Ian

>
> -Bertrand

Re: Read Sling resources remotely

Posted by Dishara Wijewardana <dd...@gmail.com>.
Hi all,
I have created the JIRA [1] and attached the Apache Bench Mark results as
requested. All the reports and graphs attached to JIRA. I did it in 2
modes.
- All tests based on single server startup.
- Each test based on a fresh server startup.

[1] - https://issues.apache.org/jira/browse/SLING-3026


On Wed, Aug 14, 2013 at 2:25 PM, Bertrand Delacretaz <bdelacretaz@apache.org
> wrote:

> On Wed, Aug 14, 2013 at 10:53 AM, Ian Boston <ie...@tfd.co.uk> wrote:
> > ...Before you start on the next phase I would like to see some stats,
> > even if they are only rudimentary....
>
> Would be good IMO to collect these stats in a jira issue, so that we
> can keep track of the evolution.
>
> -Bertrand
>



-- 
Thanks
/Dishara

Re: Read Sling resources remotely

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, Aug 14, 2013 at 10:53 AM, Ian Boston <ie...@tfd.co.uk> wrote:
> ...Before you start on the next phase I would like to see some stats,
> even if they are only rudimentary....

Would be good IMO to collect these stats in a jira issue, so that we
can keep track of the evolution.

-Bertrand

Re: Read Sling resources remotely

Posted by Ian Boston <ie...@tfd.co.uk>.
Hi DIshara,
Excelent news.

Before you start on the next phase I would like to see some stats,
even if they are only rudimentary.

Can you build a test profile that adds
1K,10K,100K,1M items to Cassandra, each under 1 parent collection.
eg
/content/cassandra/1K/0   to /content/cassandra/1K/999
/content/cassandra/10K/0   to /content/cassandra/10K/9999
/content/cassandra/100K/0   to /content/cassandra/100K/99999
/content/cassandra/1M/0   to /content/cassandra/1M/999999

Then report on the http request time to retrieve 1 of those items from
each of those collections for he first request and for subsequent
requests. Use ApacheBenchmark for the timings.  (eg ab -n1
http://localhost:8080/content/cassandra/1M/393452.json)

IIRC Cassandra will take writes at about 4K/s which so it should take
about 10 minutes to populate with 1M items. (my figures are probably
very old).

The reason for doing this is to get an rough idea of how this scales
and to provide a base line to see the impact of adding ACLs.

Thanks, great work!

Best Regards
Ian

On 14 August 2013 01:05, Dishara Wijewardana <dd...@gmail.com> wrote:
> Hi Ian,
> I followed the steps you aforementioned and it worked fine ! (I had to fix
> couple of bugs I had in the code). This is Wonderful. It gives me the
> asking resource if it is there. Unless says resource not exists. I tested
> it having Cassandra running in back ground. I will start a new thread to
> discuss on how to proceed with the rest of the impl.
>
> Thank you very much :-).
>
>
> On Mon, Aug 12, 2013 at 1:57 PM, Ian Boston <ie...@tfd.co.uk> wrote:
>
>> Hi Dishara,
>>
>> The ResourceResolverFactory bundle should not be using any bundle
>> implementing a ResourceProvider, as that would imply a circular
>> dependency.
>>
>> It looks like your service is starting correctly as its listed as
>> service ID 257, component ID 103.
>>
>> Looking at the code, I dont think you have defined where the
>> CassandraResourceProvider is "mounted", you need to set the
>> provider.roots property.
>>
>> ie
>>
>> @Component(immediate=true, metatype=true)
>> @Service(ResourceProvider.class)
>> @Properties({
>>      @Property(name="provider.roots", value={ "/content/cassandra"})
>> })
>>
>> public class CassandraResourceProvider implements ResourceProvider {
>>
>>
>> This tells the ResourceResolver where in the resource tree the
>> CassandraResourceProvider should be registered. IIRC its required for
>> registration. If you look at the logs carefully you might find the
>> ResourceResolver reporting a problem with registration.
>>
>> HTH
>> Ian
>>
>> On 11 August 2013 23:22, Dishara Wijewardana <dd...@gmail.com>
>> wrote:
>> > On Sun, Aug 11, 2013 at 2:49 PM, Ian Boston <ie...@tfd.co.uk> 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.
>> >>
>> > Hi Ian, ResourceResolverFactory dos not include my bundle under using
>> > bundles category. Do I need to add a dependency/import to the pom which
>> > includes ResourceResolverFactory class ?
>> >
>> > Refer following for more information
>> >
>> > [org.apache.sling.api.resource.ResourceResolverFactory]
>> > Service Description Apache Sling Resource Resolver Factory
>> > Service Vendor The Apache Software Foundation
>> > Using Bundles org.apache.sling.event (52)
>> > org.apache.sling.jcr.resource (90)
>> > org.apache.sling.auth.form (91)
>> > org.apache.sling.servlets.resolver (71)
>> > org.apache.sling.auth.core (86)
>> > org.apache.sling.discovery.impl (75)
>> >
>> > *and here is my bundle service information.*
>> >
>> > 257 [org.apache.sling.api.resource.ResourceProvider]
>> > component.id 103
>> > component.name
>> > org.apache.sling.cassandra.resource.provider.CassandraResourceProvider
>> > Service PID
>> > org.apache.sling.cassandra.resource.provider.CassandraResourceProvider
>> > Using Bundles org.apache.sling.bundleresource.impl (74)
>> > org.apache.sling.resourceresolver (57)
>> >
>> >
>> >> 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 <dd...@gmail.com>
>> >> wrote:
>> >> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <
>> >> bdelacretaz@apache.org
>> >> >> wrote:
>> >> >
>> >> >> Hi,
>> >> >>
>> >> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
>> >> >> <dd...@gmail.com> 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 {&lt;elapsed
>> >> > msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
>> >> >       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

Re: Read Sling resources remotely

Posted by Dishara Wijewardana <dd...@gmail.com>.
Hi Ian,
I followed the steps you aforementioned and it worked fine ! (I had to fix
couple of bugs I had in the code). This is Wonderful. It gives me the
asking resource if it is there. Unless says resource not exists. I tested
it having Cassandra running in back ground. I will start a new thread to
discuss on how to proceed with the rest of the impl.

Thank you very much :-).


On Mon, Aug 12, 2013 at 1:57 PM, Ian Boston <ie...@tfd.co.uk> wrote:

> Hi Dishara,
>
> The ResourceResolverFactory bundle should not be using any bundle
> implementing a ResourceProvider, as that would imply a circular
> dependency.
>
> It looks like your service is starting correctly as its listed as
> service ID 257, component ID 103.
>
> Looking at the code, I dont think you have defined where the
> CassandraResourceProvider is "mounted", you need to set the
> provider.roots property.
>
> ie
>
> @Component(immediate=true, metatype=true)
> @Service(ResourceProvider.class)
> @Properties({
>      @Property(name="provider.roots", value={ "/content/cassandra"})
> })
>
> public class CassandraResourceProvider implements ResourceProvider {
>
>
> This tells the ResourceResolver where in the resource tree the
> CassandraResourceProvider should be registered. IIRC its required for
> registration. If you look at the logs carefully you might find the
> ResourceResolver reporting a problem with registration.
>
> HTH
> Ian
>
> On 11 August 2013 23:22, Dishara Wijewardana <dd...@gmail.com>
> wrote:
> > On Sun, Aug 11, 2013 at 2:49 PM, Ian Boston <ie...@tfd.co.uk> 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.
> >>
> > Hi Ian, ResourceResolverFactory dos not include my bundle under using
> > bundles category. Do I need to add a dependency/import to the pom which
> > includes ResourceResolverFactory class ?
> >
> > Refer following for more information
> >
> > [org.apache.sling.api.resource.ResourceResolverFactory]
> > Service Description Apache Sling Resource Resolver Factory
> > Service Vendor The Apache Software Foundation
> > Using Bundles org.apache.sling.event (52)
> > org.apache.sling.jcr.resource (90)
> > org.apache.sling.auth.form (91)
> > org.apache.sling.servlets.resolver (71)
> > org.apache.sling.auth.core (86)
> > org.apache.sling.discovery.impl (75)
> >
> > *and here is my bundle service information.*
> >
> > 257 [org.apache.sling.api.resource.ResourceProvider]
> > component.id 103
> > component.name
> > org.apache.sling.cassandra.resource.provider.CassandraResourceProvider
> > Service PID
> > org.apache.sling.cassandra.resource.provider.CassandraResourceProvider
> > Using Bundles org.apache.sling.bundleresource.impl (74)
> > org.apache.sling.resourceresolver (57)
> >
> >
> >> 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 <dd...@gmail.com>
> >> wrote:
> >> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <
> >> bdelacretaz@apache.org
> >> >> wrote:
> >> >
> >> >> Hi,
> >> >>
> >> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
> >> >> <dd...@gmail.com> 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 {&lt;elapsed
> >> > msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
> >> >       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

Re: Read Sling resources remotely

Posted by Ian Boston <ie...@tfd.co.uk>.
Hi Dishara,

The ResourceResolverFactory bundle should not be using any bundle
implementing a ResourceProvider, as that would imply a circular
dependency.

It looks like your service is starting correctly as its listed as
service ID 257, component ID 103.

Looking at the code, I dont think you have defined where the
CassandraResourceProvider is "mounted", you need to set the
provider.roots property.

ie

@Component(immediate=true, metatype=true)
@Service(ResourceProvider.class)
@Properties({
     @Property(name="provider.roots", value={ "/content/cassandra"})
})

public class CassandraResourceProvider implements ResourceProvider {


This tells the ResourceResolver where in the resource tree the
CassandraResourceProvider should be registered. IIRC its required for
registration. If you look at the logs carefully you might find the
ResourceResolver reporting a problem with registration.

HTH
Ian

On 11 August 2013 23:22, Dishara Wijewardana <dd...@gmail.com> wrote:
> On Sun, Aug 11, 2013 at 2:49 PM, Ian Boston <ie...@tfd.co.uk> 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.
>>
> Hi Ian, ResourceResolverFactory dos not include my bundle under using
> bundles category. Do I need to add a dependency/import to the pom which
> includes ResourceResolverFactory class ?
>
> Refer following for more information
>
> [org.apache.sling.api.resource.ResourceResolverFactory]
> Service Description Apache Sling Resource Resolver Factory
> Service Vendor The Apache Software Foundation
> Using Bundles org.apache.sling.event (52)
> org.apache.sling.jcr.resource (90)
> org.apache.sling.auth.form (91)
> org.apache.sling.servlets.resolver (71)
> org.apache.sling.auth.core (86)
> org.apache.sling.discovery.impl (75)
>
> *and here is my bundle service information.*
>
> 257 [org.apache.sling.api.resource.ResourceProvider]
> component.id 103
> component.name
> org.apache.sling.cassandra.resource.provider.CassandraResourceProvider
> Service PID
> org.apache.sling.cassandra.resource.provider.CassandraResourceProvider
> Using Bundles org.apache.sling.bundleresource.impl (74)
> org.apache.sling.resourceresolver (57)
>
>
>> 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 <dd...@gmail.com>
>> wrote:
>> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <
>> bdelacretaz@apache.org
>> >> wrote:
>> >
>> >> Hi,
>> >>
>> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
>> >> <dd...@gmail.com> 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 {&lt;elapsed
>> > msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
>> >       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

Re: Read Sling resources remotely

Posted by Dishara Wijewardana <dd...@gmail.com>.
On Sun, Aug 11, 2013 at 2:49 PM, Ian Boston <ie...@tfd.co.uk> 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.
>
Hi Ian, ResourceResolverFactory dos not include my bundle under using
bundles category. Do I need to add a dependency/import to the pom which
includes ResourceResolverFactory class ?

Refer following for more information

[org.apache.sling.api.resource.ResourceResolverFactory]
Service Description Apache Sling Resource Resolver Factory
Service Vendor The Apache Software Foundation
Using Bundles org.apache.sling.event (52)
org.apache.sling.jcr.resource (90)
org.apache.sling.auth.form (91)
org.apache.sling.servlets.resolver (71)
org.apache.sling.auth.core (86)
org.apache.sling.discovery.impl (75)

*and here is my bundle service information.*

257 [org.apache.sling.api.resource.ResourceProvider]
component.id 103
component.name
org.apache.sling.cassandra.resource.provider.CassandraResourceProvider
Service PID
org.apache.sling.cassandra.resource.provider.CassandraResourceProvider
Using Bundles org.apache.sling.bundleresource.impl (74)
org.apache.sling.resourceresolver (57)


> 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 <dd...@gmail.com>
> wrote:
> > On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <
> bdelacretaz@apache.org
> >> wrote:
> >
> >> Hi,
> >>
> >> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
> >> <dd...@gmail.com> 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 {&lt;elapsed
> > msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
> >       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

Re: Read Sling resources remotely

Posted by Ian Boston <ie...@tfd.co.uk>.
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 <dd...@gmail.com> wrote:
> On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <bdelacretaz@apache.org
>> wrote:
>
>> Hi,
>>
>> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
>> <dd...@gmail.com> 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 {&lt;elapsed
> msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
>       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

Re: Read Sling resources remotely

Posted by Dishara Wijewardana <dd...@gmail.com>.
On Sat, Aug 10, 2013 at 1:47 PM, Bertrand Delacretaz <bdelacretaz@apache.org
> wrote:

> Hi,
>
> On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
> <dd...@gmail.com> 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 {&lt;elapsed
msec&gt;,&lt;timer name&gt;} &lt;optional message&gt;
      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

Re: Read Sling resources remotely

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Sat, Aug 10, 2013 at 7:02 AM, Dishara Wijewardana
<dd...@gmail.com> 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.

-Bertrand

Re: Read Sling resources remotely

Posted by Dishara Wijewardana <dd...@gmail.com>.
Hi all,
Thanks for the links and references. I looked in to the integration tests
since eventually that is the place I should be adding the Cassandra
Provider.
I looked inside the Test classes and base tests. 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 . (ResourceProviders and
etc) ? Or am I missing something in understanding this?
Hi Ian,
Since my next step is to test this within sling runtime, what is the best
way to access my provider and read resources ? Apparently what I should be
writing is something similar to PlanetsResourceProviderTest.

On Fri, Aug 9, 2013 at 12:53 PM, Bertrand Delacretaz <bdelacretaz@apache.org
> wrote:

> Hi,
>
> On Fri, Aug 9, 2013 at 5:28 AM, Dishara Wijewardana
> <dd...@gmail.com> wrote:
> > ...Can we access sling resources from a java client ? Is there any
> > sample/links to refer ?..
>
> Besides the POST servlets docs mentioned by Shashank, this has the basics:
>
> http://sling.apache.org/documentation/getting-started/discover-sling-in-15-minutes.html
>
> > This is just to test the Cassandra impl on Sling...
>
> Most of our integration tests under launchpad/integration-tests use
> HTTP requests to test a Sling instance, that's probably what you want.
>
> However, in the meantime we have a more modern test framework that's
> demonstrated at testing/samples/integration-tests, you might want to
> have a look as well. Radu has been using that in his validation module
> (it-http module in org.apache.sling.validation-2.zip  patch in
> SLING-2803), I like how that makes integration tests local to a single
> module or small group of modules, that's probably a good choice in
> your case.
>
> See also
> http://sling.apache.org/documentation/tutorials-how-tos/testing-sling-based-applications.html
> for thoughts and best practices about testing.
>
> HTH,
> -Bertrand
>



-- 
Thanks
/Dishara

Re: Read Sling resources remotely

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Fri, Aug 9, 2013 at 5:28 AM, Dishara Wijewardana
<dd...@gmail.com> wrote:
> ...Can we access sling resources from a java client ? Is there any
> sample/links to refer ?..

Besides the POST servlets docs mentioned by Shashank, this has the basics:
http://sling.apache.org/documentation/getting-started/discover-sling-in-15-minutes.html

> This is just to test the Cassandra impl on Sling...

Most of our integration tests under launchpad/integration-tests use
HTTP requests to test a Sling instance, that's probably what you want.

However, in the meantime we have a more modern test framework that's
demonstrated at testing/samples/integration-tests, you might want to
have a look as well. Radu has been using that in his validation module
(it-http module in org.apache.sling.validation-2.zip  patch in
SLING-2803), I like how that makes integration tests local to a single
module or small group of modules, that's probably a good choice in
your case.

See also http://sling.apache.org/documentation/tutorials-how-tos/testing-sling-based-applications.html
for thoughts and best practices about testing.

HTH,
-Bertrand

RE: Read Sling resources remotely

Posted by Shashank Gupta <sh...@adobe.com>.
Hi Dishara,

Following link[1] documents usage of slingpostservlet to manipulate content.  You can use   httpcomponents [2 ] in java client to make http calls.

Thanks,
-shashank


[1] http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html

[2] http://hc.apache.org/




-----Original Message-----
From: Dishara Wijewardana [mailto:ddwijewardana@gmail.com] 
Sent: 09 August 2013 08:58
To: dev@sling.apache.org
Subject: Read Sling resources remotely

Hi,
Can we access sling resources from a java client ? Is there any sample/links to refer ?
This is just to test the Cassandra impl on Sling. Now the Cassandra bundle is installed in sling server. There is a documentation on editing the JCR content through SlingPostServlet. Can I call  this servlet and test my resource provider ?


--
Thanks
/Dishara