You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by an...@apache.org on 2012/10/26 14:46:36 UTC
svn commit: r1402487 - in /jackrabbit/oak/trunk:
oak-core/src/test/java/org/apache/jackrabbit/oak/api/UniquePropertyTest.java
oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Author: angela
Date: Fri Oct 26 12:46:36 2012
New Revision: 1402487
URL: http://svn.apache.org/viewvc?rev=1402487&view=rev
Log:
OAK-406 : RepositoryTest#testUniqueness should be moved to oak-level
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/api/UniquePropertyTest.java
Modified:
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/api/UniquePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/api/UniquePropertyTest.java?rev=1402487&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/api/UniquePropertyTest.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/api/UniquePropertyTest.java Fri Oct 26 12:46:36 2012
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.oak.api;
+
+import java.util.UUID;
+
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.oak.Oak;
+import org.apache.jackrabbit.oak.plugins.index.IndexHookManager;
+import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexHookProvider;
+import org.apache.jackrabbit.oak.plugins.nodetype.InitialContent;
+import org.apache.jackrabbit.oak.util.NodeUtil;
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+
+/**
+ * UniquePropertyTest...
+ */
+public class UniquePropertyTest {
+
+ @Test
+ public void testUniqueness() throws CommitFailedException {
+
+ Root root = new Oak()
+ .with(new IndexHookManager(new PropertyIndexHookProvider()))
+ .with(new InitialContent()).createRoot();
+
+ NodeUtil node = new NodeUtil(root.getTree("/"));
+ String uuid = UUID.randomUUID().toString();
+ node.setString(JcrConstants.JCR_UUID, uuid);
+ root.commit();
+
+ NodeUtil child = new NodeUtil(root.getTree("/")).addChild("another", "rep:User");
+ child.setString(JcrConstants.JCR_UUID, uuid);
+ try {
+ root.commit();
+ fail("Duplicate jcr:uuid should be detected.");
+ } catch (CommitFailedException e) {
+ // expected
+ }
+ }
+
+}
\ No newline at end of file
Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1402487&r1=1402486&r2=1402487&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java Fri Oct 26 12:46:36 2012
@@ -27,7 +27,6 @@ import java.util.Calendar;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
@@ -1883,26 +1882,6 @@ public class RepositoryTest extends Abst
assertTrue(c2.hasProperty("pc2"));
}
- @Test
- public void testUniqueness() throws RepositoryException {
- Session session = getAdminSession();
-
- Node node = getNode("/foo");
- node.addMixin("mix:referenceable");
- node.setProperty("jcr:uuid", UUID.randomUUID().toString());
- session.save();
-
- Node node2 = node.addNode("foo2");
- node2.addMixin("mix:referenceable");
- node2.setProperty("jcr:uuid", node.getProperty("jcr:uuid").getValue());
- try {
- session.save();
- fail();
- } catch (RepositoryException e) {
- // expected
- }
- }
-
//------------------------------------------------------------< private >---
private Node getNode(String path) throws RepositoryException {