We're updating the issue view to help you get more done. 

Page creation fails when using a template loaded from JSON (JCR_OAK)

Description

Page creation fails when creating a page with a specified template, because of the PageManager implementation which tries to copy the jcr:created property from the template (which is protected). This issue only occurs when using the JCR_OAK resolver type.

Sample code at https://github.com/dplaton/test-aem-mocks/blob/master/src/test/java/com/day/cq/testing/TestPageCreation.java

The stacktrace:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 java.lang.IllegalArgumentException: Value for key jcr:created can't be put into node: java.util.GregorianCalendar[time=1478771597478,areFieldsSet=true,areAllFieldsSet=true,lenient=false,zone=sun.util.calendar.ZoneInfo[id="GMT+02:00", <snip> at org.apache.sling.jcr.resource.internal.JcrModifiableValueMap.put(JcrModifiableValueMap.java:458) at org.apache.sling.jcr.resource.internal.JcrModifiableValueMap.put(JcrModifiableValueMap.java:47) at io.wcm.testing.mock.aem.MockPageManager.copyContent(MockPageManager.java:130) at io.wcm.testing.mock.aem.MockPageManager.create(MockPageManager.java:109) at com.day.cq.testing.TestPageCreation.testPageCreation(TestPageCreation.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) 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:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) <snip>

Environment

None

Status

Assignee

Unassigned

Reporter

Daniel Platon

Labels

None

Components

Fix versions

Affects versions

AEM Mocks 2.0.2

Priority

Major