Author: rombert Date: Sun Oct 12 22:26:29 2014 New Revision: 1631262 URL: http://svn.apache.org/r1631262 Log: SLING-4036 - Changing the jcr primary type does not work if mandatory properties are added
Added an ignored test Added: sling/trunk/tooling/ide/impl-vlt-test/src/test/resources/org/apache/sling/ide/impl/vlt/mandatory.cnd Modified: sling/trunk/tooling/ide/impl-vlt-test/src/test/java/org/apache/sling/ide/impl/vlt/AddOrUpdateNodeCommandTest.java Modified: sling/trunk/tooling/ide/impl-vlt-test/src/test/java/org/apache/sling/ide/impl/vlt/AddOrUpdateNodeCommandTest.java URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-vlt-test/src/test/java/org/apache/sling/ide/impl/vlt/AddOrUpdateNodeCommandTest.java?rev=1631262&r1=1631261&r2=1631262&view=diff ============================================================================== --- sling/trunk/tooling/ide/impl-vlt-test/src/test/java/org/apache/sling/ide/impl/vlt/AddOrUpdateNodeCommandTest.java (original) +++ sling/trunk/tooling/ide/impl-vlt-test/src/test/java/org/apache/sling/ide/impl/vlt/AddOrUpdateNodeCommandTest.java Sun Oct 12 22:26:29 2014 @@ -36,6 +36,7 @@ import org.apache.jackrabbit.commons.cnd import org.apache.jackrabbit.core.TransientRepository; import org.apache.sling.ide.log.Logger; import org.apache.sling.ide.transport.ResourceProxy; +import org.junit.Ignore; import org.junit.Test; public class AddOrUpdateNodeCommandTest { @@ -198,6 +199,43 @@ public class AddOrUpdateNodeCommandTest } } + @Test + @Ignore("SLING-4036") + public void updateNtUnstructuredToNodeWithRequiredProperty() throws Exception { + + File out = new File(new File("target"), "jackrabbit"); + TransientRepository repo = new TransientRepository(new File(out, "repository.xml"), new File(out, "repository")); + SimpleCredentials credentials = new SimpleCredentials("admin", "admin".toCharArray()); + Session session = repo.login(credentials); + + InputStream cndInput = getClass().getResourceAsStream("mandatory.cnd"); // TODO - should be test-definitions.cnd + CndImporter.registerNodeTypes(new InputStreamReader(cndInput), session); + + try { + Node content = session.getRootNode().addNode("content", "nt:unstructured"); + + session.save(); + + ResourceProxy resource = newResource("/content", "custom"); + resource.getProperties().put("attribute", "some value"); + + AddOrUpdateNodeCommand cmd = new AddOrUpdateNodeCommand(repo, credentials, null, resource, logger); + cmd.execute().get(); + + session.refresh(false); + + content = session.getRootNode().getNode("content"); + assertThat(content.getPrimaryNodeType().getName(), equalTo("custom")); + + } finally { + session.removeItem("/content"); + session.save(); + session.logout(); + + IOUtils.closeQuietly(cndInput); + } + } + private ResourceProxy newResource(String path, String primaryType) { ResourceProxy resource = new ResourceProxy(path); Added: sling/trunk/tooling/ide/impl-vlt-test/src/test/resources/org/apache/sling/ide/impl/vlt/mandatory.cnd URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-vlt-test/src/test/resources/org/apache/sling/ide/impl/vlt/mandatory.cnd?rev=1631262&view=auto ============================================================================== --- sling/trunk/tooling/ide/impl-vlt-test/src/test/resources/org/apache/sling/ide/impl/vlt/mandatory.cnd (added) +++ sling/trunk/tooling/ide/impl-vlt-test/src/test/resources/org/apache/sling/ide/impl/vlt/mandatory.cnd Sun Oct 12 22:26:29 2014 @@ -0,0 +1,23 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +//----------------------------------------------------------------------------- +// Simple node type with a mandatory property +[custom] +- attribute (string) mandatory \ No newline at end of file