You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2006/12/01 17:55:33 UTC
svn commit: r481295 - in
/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi:
RefreshFalseTest.java RefreshTrue.java
Author: angela
Date: Fri Dec 1 08:55:32 2006
New Revision: 481295
URL: http://svn.apache.org/viewvc?view=rev&rev=481295
Log:
work in progress
- tests
Added:
jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshFalseTest.java (with props)
jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshTrue.java (with props)
Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshFalseTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshFalseTest.java?view=auto&rev=481295
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshFalseTest.java (added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshFalseTest.java Fri Dec 1 08:55:32 2006
@@ -0,0 +1,118 @@
+/*
+ * 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.jcr2spi;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.lock.LockException;
+
+/**
+ * <code>RefreshFalseTest</code>...
+ */
+public class RefreshFalseTest extends AbstractJCRTest {
+
+ private static Logger log = LoggerFactory.getLogger(RefreshFalseTest.class);
+
+ private Value testValue;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ if (testRootNode.hasProperty(propertyName1)) {
+ testRootNode.getProperty(propertyName1).remove();
+ testRootNode.save();
+ }
+
+ testValue = testRootNode.getSession().getValueFactory().createValue("anyString");
+ if (!testRootNode.getPrimaryNodeType().canSetProperty(propertyName1, testValue)) {
+ throw new NotExecutableException("");
+ }
+ }
+
+ public void testNewProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
+ Property p = testRootNode.setProperty(propertyName1, testValue);
+ testRootNode.refresh(false);
+
+ try {
+ p.getString();
+ fail("Refresh 'false' must invalidate a new child property");
+ } catch (InvalidItemStateException e) {
+ // ok
+ }
+ assertFalse("Refresh 'false' must remove a new child property", testRootNode.hasProperty(propertyName1));
+ }
+
+ public void testRemovedNewProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
+ Property p = testRootNode.setProperty(propertyName1, testValue);
+ p.remove();
+
+ testRootNode.refresh(false);
+
+ try {
+ p.getString();
+ fail("Refresh 'false' must not bring a removed new child property back to life.");
+ } catch (InvalidItemStateException e) {
+ // ok
+ }
+ assertFalse("Refresh 'false' must not bring a removed new child property back to life.", testRootNode.hasProperty(propertyName1));
+ }
+
+ public void testRemovedProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
+ Property p = testRootNode.setProperty(propertyName1, testValue);
+ testRootNode.save();
+
+ p.remove();
+ testRootNode.refresh(false);
+
+ // Property p must be reverted to 'existing' -> getString must succeed.
+ p.getString();
+ // similarly accessing the property again must succeed.
+ testRootNode.getProperty(propertyName1);
+ }
+
+ public void testShadowingProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
+ Property p = testRootNode.setProperty(propertyName1, testValue);
+ testRootNode.save();
+
+ p.remove();
+ Property pNew = testRootNode.setProperty(propertyName1, "SomeOtherTestValue");
+
+ testRootNode.refresh(false);
+
+ try {
+ pNew.getString();
+ fail("Refresh 'false' must remove a new (shadowing) property and bring 'removed' persistent property back to life.");
+ } catch (InvalidItemStateException e) {
+ // ok
+ }
+
+ // Property p must be reverted to 'existing' -> getString must succeed.
+ p.getString();
+ // similarly accessing the property again must succeed.
+ Property pAgain = testRootNode.getProperty(propertyName1);
+ assertTrue("Refresh 'false' must remove a new property and bring 'removed' persistent property back to life.", p.isSame(pAgain));
+ }
+}
\ No newline at end of file
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshFalseTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshFalseTest.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshTrue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshTrue.java?view=auto&rev=481295
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshTrue.java (added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshTrue.java Fri Dec 1 08:55:32 2006
@@ -0,0 +1,77 @@
+/*
+ * 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.jcr2spi;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Value;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.lock.LockException;
+
+/**
+ * <code>RefreshTrue</code>...
+ */
+public class RefreshTrue extends AbstractJCRTest {
+
+ private static Logger log = LoggerFactory.getLogger(RefreshTrue.class);
+
+ private Value testValue;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ testValue = testRootNode.getSession().getValueFactory().createValue("anyString");
+ if (!testRootNode.getPrimaryNodeType().canSetProperty(propertyName1, testValue)) {
+ throw new NotExecutableException("");
+ }
+ }
+
+ public void testNewProperty() throws RepositoryException {
+ Property p = testRootNode.setProperty(propertyName1, testValue);
+ testRootNode.refresh(true);
+
+ // p must still be accessible
+ p.getString();
+ assertTrue("Refresh 'true' must not affect a new Property.", testRootNode.hasProperty(propertyName1));
+ Property pAgain = testRootNode.getProperty(propertyName1);
+ assertTrue("Refresh 'true' must not affect a new Property.", p.isSame(pAgain));
+ }
+
+ public void testRemovedProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
+ Property p = testRootNode.setProperty(propertyName1, testValue);
+ testRootNode.save();
+
+ p.remove();
+ testRootNode.refresh(true);
+
+ // Property p must remain removed
+ try {
+ p.getString();
+ fail("Refresh 'true' must not revert removal of an item.");
+ } catch (InvalidItemStateException e) {
+ //ok
+ }
+ assertFalse("Refresh 'true' must not revert removal of an item.", testRootNode.hasProperty(propertyName1));
+ }
+}
\ No newline at end of file
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshTrue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RefreshTrue.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url