[
https://issues.apache.org/jira/browse/SLING-4548?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14483961#comment-14483961
]
Stefan Seifert commented on SLING-4548:
---------------------------------------
hmm - difficult to solve nicely.
the problem arises because the JcrNodeResource implementation of
sling.jcr.resource hardcoded tries to access a "jcr:created" property when
encountering a primary node type "nt:file". i first tried to implemented a
workaround in the contentloader when such nodes get imported - but this does
not work because the sling.jcr.resource implementation at the same times
ignored properties passed on resource creation with name "jcr:created".
with resourceresolver-mock it works because JcrNodeResources it not used at all
there. with jackrabbit it should work because the real JCR repository respects
the node type definition of nt:file which demands automatically setting a
jcr:created property on creation.
so the only possibility seems to implement a hack in jcr-mock at least for the
nt:file node type so JcrNodeResource can set its metadata for nt:file node
properties.
> Loading files with the JCR_MOCK resource resolver type logs leads to
> exceptions being logged
> --------------------------------------------------------------------------------------------
>
> Key: SLING-4548
> URL: https://issues.apache.org/jira/browse/SLING-4548
> Project: Sling
> Issue Type: Bug
> Components: Testing
> Affects Versions: Testing Sling Mock 1.2.0
> Reporter: Robert Munteanu
> Fix For: Testing Sling Mock 1.2.2
>
>
> When importing nt:file nodes with the JCR_MOCK resource resolver type
> exceptions are logged at INFO level. I've pushed a minimal project at
> https://github.com/rombert/jcr-mock-sample , just run {{mvn test}} to see the
> exceptions.
> {noformat}499 [main] INFO
> org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource -
> setMetaData: Problem extracting metadata information for
> /sling-test/sling/assert.js
> javax.jcr.PathNotFoundException: No item found at:
> /sling-test/sling/assert.js/jcr:created.
> at
> org.apache.sling.testing.mock.jcr.MockSession.getItem(MockSession.java:83)
> at
> org.apache.sling.testing.mock.jcr.MockSession.getProperty(MockSession.java:109)
> at
> org.apache.sling.testing.mock.jcr.MockNode.getProperty(MockNode.java:125)
> at
> org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource.setMetaData(JcrNodeResource.java:274)
> at
> org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource.<init>(JcrNodeResource.java:97)
> at
> org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.create(JcrResourceProvider.java:464)
> at
> org.apache.sling.resourceresolver.impl.tree.ResourceProviderEntry.create(ResourceProviderEntry.java:479)
> at
> org.apache.sling.resourceresolver.impl.ResourceResolverImpl.create(ResourceResolverImpl.java:1053)
> at
> org.apache.sling.testing.mock.sling.loader.ContentLoader.createResource(ContentLoader.java:233)
> at
> org.apache.sling.testing.mock.sling.loader.ContentLoader.createResource(ContentLoader.java:247)
> at
> org.apache.sling.testing.mock.sling.loader.ContentLoader.createResource(ContentLoader.java:247)
> at
> org.apache.sling.testing.mock.sling.loader.ContentLoader.json(ContentLoader.java:175)
> at
> org.apache.sling.testing.mock.sling.loader.ContentLoader.json(ContentLoader.java:132)
> at
> org.apache.sling.sample.jcrmock.ImportTest.importSlingTest(ImportTest.java:18)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
> at org.junit.rules.RunRules.evaluate(RunRules.java:20)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192){noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)