jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r149525 [2/2] - in incubator/jackrabbit/trunk: ./ applications/test/ applications/test/repository/ applications/test/repository/nodetypes/ applications/test/workspaces/ applications/test/workspaces/default/ applications/test/workspaces/test/ src/java/org/apache/jackrabbit/core/search/lucene/ src/test/org/apache/jackrabbit/test/ src/test/org/apache/jackrabbit/test/api/ src/test/org/apache/jackrabbit/test/api/version/ src/test/org/apache/jackrabbit/test/observation/ src/test/org/apache/jackrabbit/test/search/
Date Wed, 02 Feb 2005 15:58:34 GMT
Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionGraphTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionGraphTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionGraphTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionGraphTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.test.api.version;
+
+import javax.jcr.version.Version;
+import javax.jcr.RepositoryException;
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.ReferenceValue;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+/**
+ * <code>VersionGraphTest</code> contains test methods related to version graph
+ * issues.
+ *
+ * @test
+ * @sources VersionGraphTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.VersionGraphTest
+ * @keywords versioning
+ */
+public class VersionGraphTest extends AbstractVersionTest {
+
+    /**
+     * Test that the initial base version after creation of a versionable node
+     * points to the root version.
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testInitialBaseVersionPointsToRootVersion() throws RepositoryException {
+
+        Version rV = versionableNode.getVersionHistory().getRootVersion();
+        Version bV = versionableNode.getBaseVersion();
+
+        assertEquals("After creation of a versionable node the node's baseVersion must point to the rootVersion in the version history.", rV, bV);
+    }
+
+    /**
+     * Test if after creation of a versionable node N the multi-value
+     * REFERENCE property jcr:predecessors of N is initialized to contain a
+     * single UUID, that of the root version (the same as jcr:baseVersion).
+     *
+     * @throws RepositoryException
+     */
+    public void testInitialNodePredecessors() throws RepositoryException {
+
+        Property predecessors = versionableNode.getProperty(jcrPredecessors);
+        Value[] values = predecessors.getValues();
+        Version rV = versionableNode.getVersionHistory().getRootVersion();
+        if (values.length != 1) {
+            fail("The jcr:predecessors property of a versionable node must be initialized to contain a single value");
+        }
+
+        ReferenceValue initialVal = (ReferenceValue) values[0];
+
+        assertTrue("The jcr:predecessors property of a versionable node is initialized to contain a single UUID, that of the root version", initialVal.equals(new ReferenceValue(rV)));
+    }
+
+    /**
+     * Test if the root version does not have any predecessor versions.
+     *
+     * @throws RepositoryException
+     */
+    public void testRootVersionHasNoPredecessor() throws RepositoryException {
+        Version[] predec = versionableNode.getVersionHistory().getRootVersion().getPredecessors();
+        assertTrue("The root version may not have any predecessors.", predec.length == 0);
+    }
+
+    /**
+     * Test if UnsupportedRepositoryOperationException is thrown when calling
+     * Node.getVersionHistory() on a non-versionable node.
+     *
+     * @throws RepositoryException
+     */
+    public void testGetBaseVersionOnNonVersionableNode() throws RepositoryException {
+        try {
+            nonVersionableNode.getBaseVersion();
+            fail("Node.getBaseVersion() must throw UnsupportedRepositoryOperationException if the node is not versionable.");
+        } catch (UnsupportedRepositoryOperationException e) {
+            //success
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionGraphTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.test.api.version;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.version.VersionHistory;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionIterator;
+import java.util.HashSet;
+
+/**
+ * <code>VersionHistoryTest</code> provides test methods related to version
+ * history methods and general version history issues.
+ *
+ * @test
+ * @sources VersionHistoryTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.VersionHistoryTest
+ * @keywords versioning
+ */
+public class VersionHistoryTest extends AbstractVersionTest {
+
+    protected VersionHistory vHistory;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        vHistory = versionableNode.getVersionHistory();
+
+        if (vHistory == null) {
+            fail("VersionHistory must be created on persistent creation of a versionable node.");
+        }
+    }
+
+    /**
+     * Test if initially there is an auto-created root version present in the version history.
+     *
+     * @throws RepositoryException
+     */
+    public void testAutocreatedRootVersion() throws RepositoryException {
+        Version rootVersion = vHistory.getRootVersion();
+        if (rootVersion == null) {
+            fail("The version history must contain an autocreated root version");
+        }
+    }
+
+    /**
+     * The version history must initially contain a single version (root version).
+     *
+     * @throws RepositoryException
+     */
+    public void testInitialNumberOfVersions() throws RepositoryException {
+        long initialSize = getNumberOfVersions(vHistory);
+        assertTrue("VersionHistory.getAllVersions() initially returns an iterator with a single version.", initialSize == 1);
+    }
+
+    /**
+     * Test if the iterator returned by {@link javax.jcr.version.VersionHistory#getAllVersions()}
+     * contains the root version upon creation of the version history.
+     *
+     * @throws RepositoryException
+     * @see javax.jcr.version.VersionHistory#getRootVersion()
+     */
+    public void testInitallyGetAllVersionsContainsTheRootVersion() throws RepositoryException {
+        Version rootVersion = vHistory.getRootVersion();
+        Version v = null;
+        VersionIterator it = vHistory.getAllVersions();
+        while(it.hasNext()) {
+            // break after the first version, that MUST be the root version
+            v = it.nextVersion();
+            break;
+        }
+        assertEquals("The version that is autocreated on version history creation must be the root version", rootVersion, v);
+    }
+
+    /**
+     * Test that {@link VersionHistory#getAllVersions()} returns an iterator containing the
+     * root version and all versions that have been created by Node.checkin().
+     *
+     * @throws RepositoryException
+     * @see javax.jcr.version.VersionHistory#getAllVersions()
+     */
+    public void testGetAllVersions() throws RepositoryException {
+        int cnt = 5;
+        HashSet versions = new HashSet();
+        versions.add(vHistory.getRootVersion());
+        for (int i = 0; i < cnt; i++) {
+            versions.add(versionableNode.checkin());
+            versionableNode.checkout();
+        }
+
+        VersionIterator it = vHistory.getAllVersions();
+        while (it.hasNext()) {
+            Version v = it.nextVersion();
+            if (!versions.contains(v)) {
+                fail("VersionHistory.getAllVersions() must only contain the root version and versions, that have been created by a Node.checkin() call.");
+            }
+            versions.remove(v);
+        }
+        assertTrue("VersionHistory.getAllVersions() must contain the root version and all versions that have been created with a Node.checkin() call.", versions.isEmpty());
+    }
+
+    /**
+     * Test if UnsupportedRepositoryOperationException is thrown when calling
+     * Node.getVersionHistory() on a non-versionable node.
+     *
+     * @throws RepositoryException
+     */
+    public void testGetVersionHistoryOnNonVersionableNode() throws RepositoryException {
+        try {
+            nonVersionableNode.getVersionHistory();
+            fail("Node.getVersionHistory() must throw UnsupportedRepositoryOperationException if the node is not versionable.");
+        } catch (UnsupportedRepositoryOperationException e) {
+            //success
+        }
+    }
+
+    /**
+     * Test VersionHistory.getVersion(String versionName) if 'versionName' is
+     * the name of an existing version (created by Node.checkin()).
+     *
+     * @throws RepositoryException
+     * @see VersionHistory#getVersion(String)
+     */
+    public void testGetVersion() throws RepositoryException {
+
+        Version v = versionableNode.checkin();
+        Version v2 = vHistory.getVersion(v.getName());
+
+        assertEquals("VersionHistory.getVersion(String versionName) must return the version that is identified by the versionName specified, if versionName is the name of a version created by Node.checkin().", v, v2);
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionLabelTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionLabelTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionLabelTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionLabelTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,314 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.test.api.version;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.version.VersionHistory;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import java.util.HashSet;
+import java.util.Arrays;
+
+/**
+ * <code>VersionLabelTest</code> covers methods related to version label such as
+ * <ul>
+ * <li>{@link VersionHistory#addVersionLabel(String, String, boolean)}</li>
+ * <li>{@link VersionHistory#removeVersionLabel(String)}</li>
+ * <li>{@link VersionHistory#restoreByLabel(String, boolean)} </li>
+ * <li>{@link VersionHistory#getVersionByLabel(String)}</li>
+ * <li>{@link javax.jcr.version.VersionHistory#getVersionLabels()} </li>
+ * <li>{@link javax.jcr.version.VersionHistory#hasVersionLabel(javax.jcr.version.Version, String)}</li>
+ * <li>{@link VersionHistory#hasVersionLabel(String)}</li>
+ * <li>{@link VersionHistory#hasVersionLabel(javax.jcr.version.Version, String)} </li>
+ * </ul>
+ *
+ * @test
+ * @sources VersionLabelTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.VersionLabelTest
+ * @keywords versioning
+ */
+public class VersionLabelTest extends AbstractVersionTest {
+
+    protected String versionLabel = "foo";
+    protected String versionLabel2 = "bar";
+
+    protected VersionHistory vHistory;
+    protected Version rootVersion;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        vHistory = versionableNode.getVersionHistory();
+        rootVersion = vHistory.getRootVersion();
+
+        if (vHistory.hasVersionLabel(versionLabel)) {
+            fail("Version label '"+versionLabel+"' is already present in this version history. Label test cannot be performed.");
+        }
+
+        if (vHistory.hasVersionLabel(versionLabel2)) {
+            fail("Version label '"+versionLabel2+"' is already present in this version history. Label test cannot be performed.");
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        try {
+            // clean up: remove the version labels again.
+            vHistory.removeVersionLabel(versionLabel);
+            vHistory.removeVersionLabel(versionLabel2);
+        } catch (RepositoryException e) {
+            // ignore
+        }
+        super.tearDown();
+    }
+
+    /**
+     * Test if the number of labels available in the version history is increased
+     * by added a new label.
+     *
+     * @throws RepositoryException
+     * @see VersionHistory#addVersionLabel(String, String, boolean)
+     */
+    public void testAddVersionLabel() throws RepositoryException {
+        int initialLength = vHistory.getVersionLabels().length;
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        String[] labels = vHistory.getVersionLabels();
+
+        assertEquals("A version label that has been successfully added must increes the total number of version labels available in the history.", initialLength + 1, labels.length);
+    }
+
+    /**
+     * Test if the a label added with VersionHistory.addVersionLabel(String, String, boolean)
+     * is present in the array returned by VersionHistory.getVersionLabels(), if
+     * the label has not been present before.
+     *
+     * @throws RepositoryException
+     * @see VersionHistory#addVersionLabel(String, String, boolean)
+     */
+    public void testAddVersionLabel2() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        String[] labels = vHistory.getVersionLabels();
+        boolean found = false;
+        for (int i = 0; i < labels.length; i++) {
+            if (labels[i].equals(versionLabel)) {
+                found = true;
+                break;
+            }
+        }
+        assertTrue("The version label that has been successfully added must be present in the array containing all labels.", found);
+    }
+
+    /**
+     * Test if VersionHistory.hasVersionLabel(String) returns true, if the label
+     * has beed successfully added before.
+     *
+     * @throws RepositoryException
+     * @see VersionHistory#hasVersionLabel(String)
+     */
+    public void testHasVersionLabel() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        assertTrue("VersionHistory.hasVersionLabel(String) must return true if the label has been sucessfully added.", vHistory.hasVersionLabel(versionLabel));
+    }
+
+    /**
+     * Test if VersionHistory.hasVersionLabel(Version, String) returns true, if the label
+     * has beed successfully added before to the specified version.
+     *
+     * @throws RepositoryException
+     * @see VersionHistory#hasVersionLabel(javax.jcr.version.Version, String)
+     */
+    public void testHasVersionLabelForVersion() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        assertTrue("VersionHistory.hasVersionLabel(Version, String) must return true if the label has been sucessfully added.", vHistory.hasVersionLabel(rootVersion, versionLabel));
+    }
+
+    /**
+     * Test if multiple distinct version labels can be added for a given version.
+     *
+     * @throws RepositoryException
+     */
+    public void testAddMultipleVersionLabels() throws RepositoryException {
+        try {
+            vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+            vHistory.addVersionLabel(rootVersion.getName(), versionLabel2, false);
+        } catch (VersionException e) {
+            fail("Adding multiple distict version labels to a version must be allowed.");
+        }
+    }
+
+    /**
+     * Test if VersionHistory.addVersionLabel(versionName, label, moveLabel)
+     * throws VersionException the label already exists and if moveLabel is false)
+     *
+     * @throws RepositoryException
+     */
+    public void testAddDuplicateVersionLabel() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        try {
+            versionableNode.checkout();
+            Version v = versionableNode.checkin();
+            vHistory.addVersionLabel(v.getName(), versionLabel, false);
+
+            fail("Adding a version label that already exist in the version history must throw a VersionException.");
+        } catch (VersionException e) {
+            //success
+        }
+    }
+
+    /**
+     * Test if the 'moveLabel' flag moves an existing version label.
+     *
+     * @throws RepositoryException
+     * @see VersionHistory#addVersionLabel(String, String, boolean)  with boolan flag equals true.
+     */
+    public void testMoveLabel() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        try {
+            versionableNode.checkout();
+            Version v = versionableNode.checkin();
+            vHistory.addVersionLabel(v.getName(), versionLabel, true);
+
+            if (!vHistory.hasVersionLabel(v, versionLabel)) {
+               fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
+            }
+
+        } catch (VersionException e) {
+            fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
+        }
+    }
+
+    /**
+     * Test the removal of an version label that does not exist (must throw VersionException).
+     *
+     * @throws RepositoryException
+     */
+    public void testRemoveNonExistingLabel() throws RepositoryException {
+        if (vHistory.hasVersionLabel(versionLabel)) {
+            fail("Testing the removal on a non-existing version label failed: '"+versionLabel+"' exists on version history.");
+        }
+        try {
+            vHistory.removeVersionLabel(versionLabel);
+            fail("VersionHistory.removeLabel(String) must throw a VersionException if the label does not exist.");
+        } catch (VersionException e) {
+            // success
+        }
+    }
+
+    /**
+     * Test the removal of an version label that has successfully been added
+     * before.
+     *
+     * @throws RepositoryException
+     * @see VersionHistory#removeVersionLabel(String)
+     */
+    public void testRemoveLabel() throws RepositoryException {
+
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        vHistory.removeVersionLabel(versionLabel);
+
+        assertFalse("VersionHistory.removeLabel(String) must remove the version label if it exists (has successfully been added before).", vHistory.hasVersionLabel(versionLabel));
+    }
+
+    /**
+     * Test if VersionHistory.getVersionByLabel(String) returns the version that
+     * has been specified with the addVersionLabel call.
+     *
+     * @throws RepositoryException
+     * @see VersionHistory#getVersionByLabel(String)
+     */
+    public void testGetVersionByLabel() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, true);
+        Version v = vHistory.getVersionByLabel(versionLabel);
+
+        assertEquals("VersionHistory.getVersionByLabel(String) must retrieve the particular version that was specified in addVersionLabel call.", v, rootVersion);
+    }
+
+    /**
+     * Test VersionHistory.getVersionLabels() returns all labels present on the version history.
+     *
+     * @throws RepositoryException
+     * @see javax.jcr.version.VersionHistory#getVersionLabels()
+     */
+    public void testGetVersionLabels() throws RepositoryException {
+
+        HashSet testLabels = new HashSet(Arrays.asList(vHistory.getVersionLabels()));
+        versionableNode.checkout();
+        Version v = versionableNode.checkin();
+
+        vHistory.addVersionLabel(v.getName(), versionLabel, false);
+        testLabels.add(versionLabel);
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel2, false);
+        testLabels.add(versionLabel2);
+
+        String[] labels = vHistory.getVersionLabels();
+        for (int i = 0; i < labels.length; i++) {
+            String l = labels[i];
+            if (!testLabels.contains(l)) {
+                fail("VersionHistory.getVersionLabels() must only return labels, that have been added to the history.");
+            }
+            testLabels.remove(l);
+        }
+
+        assertTrue("VersionHistory.getVersionLabels() must return all labels, that have been added to the history.", testLabels.isEmpty());
+    }
+
+    /**
+     * Test VersionHistory.getVersionLabels(Version) only returns all labels present
+     * for the specified version.
+     * 
+     * @throws RepositoryException
+     * @see VersionHistory#getVersionLabels(javax.jcr.version.Version)
+     */
+    public void testGetVersionLabelsForVersion() throws RepositoryException {
+
+        HashSet testLabels = new HashSet(Arrays.asList(vHistory.getVersionLabels(rootVersion)));
+
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        testLabels.add(versionLabel);
+
+        // add a version label to another version (not added to the testLabel set)
+        versionableNode.checkout();
+        Version v = versionableNode.checkin();
+        vHistory.addVersionLabel(v.getName(), versionLabel2, false);
+
+        String[] labels = vHistory.getVersionLabels(rootVersion);
+        for (int i = 0; i < labels.length; i++) {
+            String l = labels[i];
+            if (!testLabels.contains(l)) {
+                fail("VersionHistory.getVersionLabels(Version) must only return labels, that have been added for this version.");
+            }
+            testLabels.remove(l);
+        }
+
+        assertTrue("VersionHistory.getVersionLabels(Version)  must return all labels, that have been added for this version.", testLabels.isEmpty());
+    }
+
+    /**
+     * Test calling Node.restoreByLabel(String, boolean) on a non-versionable node.
+     *
+     * @throws javax.jcr.RepositoryException
+     * @see javax.jcr.Node#restoreByLabel(String, boolean)
+     */
+    public void testRestoreByLabelNonVersionableNode() throws RepositoryException {
+        try {
+            nonVersionableNode.restoreByLabel(versionLabel, true);
+            fail("Node.restoreByLabel(String, boolean) on a non versionable node must throw UnsupportedRepositoryOperationException");
+        } catch (UnsupportedRepositoryOperationException e) {
+            //success
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionLabelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,246 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.test.api.version;
+
+import org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.nodetype.NodeDef;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import javax.jcr.version.OnParentVersionAction;
+import javax.jcr.Session;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.ItemExistsException;
+
+/**
+ * <code>WorkspaceRestoreTest</code> provides test methods for the {@link javax.jcr.Workspace#restore(javax.jcr.version.Version[], boolean)}
+ * method.
+ *
+ * @test
+ * @sources WorkspaceRestoreTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.WorkspaceRestoreTest
+ * @keywords versioning
+ */
+public class WorkspaceRestoreTest extends RestoreTest {
+
+    Session wSuperuser;
+    Node wTestRoot;
+    Node wVersionableNode;
+    Node wVersionableNode2;
+    Node wVersionableChildNode;
+
+    Version wChildVersion;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        try {
+            wSuperuser = helper.getSuperuserSession(workspaceName);
+        } catch (RepositoryException e) {
+            fail("Failed to retrieve superuser session for second workspace '"+workspaceName+"': "+e.getMessage());
+        }
+
+        // test if the required nodes exist in the second workspace if not try to clone them
+        try {
+            testRootNode.getCorrespondingNodePath(workspaceName);
+        } catch (ItemNotFoundException e) {
+            // clone testRoot
+            wSuperuser.getWorkspace().clone(superuser.getWorkspace().getName(), testRoot, testRoot, true);
+        }
+
+        try {
+            versionableNode.getCorrespondingNodePath(workspaceName);
+        } catch (ItemNotFoundException e) {
+            // clone versionable node
+            wSuperuser.getWorkspace().clone(superuser.getWorkspace().getName(), versionableNode.getPath(), versionableNode.getPath(), true);
+        }
+
+        try {
+            versionableNode2.getCorrespondingNodePath(workspaceName);
+        } catch (ItemNotFoundException e) {
+            // clone second versionable node
+            wSuperuser.getWorkspace().clone(superuser.getWorkspace().getName(), versionableNode2.getPath(), versionableNode2.getPath(), true);
+        }
+
+        try {
+            // set node-fields (wTestRoot, wVersionableNode, wVersionableNode2)
+            // and check versionable nodes out.
+            wTestRoot = wSuperuser.getNodeByUUID(testRootNode.getUUID());
+
+            wVersionableNode = wSuperuser.getNodeByUUID(versionableNode.getUUID());
+            wVersionableNode.checkout();
+
+            wVersionableNode2 = wSuperuser.getNodeByUUID(versionableNode2.getUUID());
+            wVersionableNode2.checkout();
+
+        } catch (RepositoryException e) {
+            fail("Failed to setup test environment in workspace: "+e.getMessage());
+        }
+
+        // create persistent versionable CHILD-node below wVersionableNode in workspace 2
+        // that is not present in the default workspace.
+        try {
+            wVersionableChildNode = createVersionableNode(wVersionableNode, nodeName4, versionableNodeType);
+        } catch (RepositoryException e) {
+            fail("Failed to create versionable child node in second workspace: " + e.getMessage());
+        }
+
+        // create a version of the versionable child node
+        wVersionableChildNode.checkout();
+        wChildVersion = wVersionableChildNode.checkin();
+        wVersionableChildNode.checkout();
+    }
+
+
+    protected void tearDown() throws Exception {
+        try {
+            // remove all versionable nodes below the test
+            wVersionableNode.remove();
+            wVersionableNode2.remove();
+            wTestRoot.save();
+        } finally {
+            super.tearDown();
+        }
+    }
+
+    /**
+     * Test if InvalidItemStateException is thrown if the session affected by
+     * Workspace.restore(Version[], boolean) has pending changes.
+     */
+    public void testWorkspaceRestoreWithPendingChanges() throws RepositoryException {
+        versionableNode.checkout();
+        try {
+            // modify node without calling save()
+            versionableNode.setProperty(propertyName1, propertyValue);
+
+            // create version in second workspace
+            Version v = wVersionableNode.checkin();
+            // try to restore that version
+            superuser.getWorkspace().restore(new Version[] {v}, false);
+
+            fail("InvalidItemStateException must be thrown on attempt to call Workspace.restore(Version[], boolean) in a session having any unsaved changes pending.");
+        } catch (InvalidItemStateException e) {
+            // success
+        }
+    }
+
+    /**
+     * Test if VersionException is thrown if the specified version array does
+     * not contain a version that has a corresponding node in this workspace.
+     */
+    public void testWorkspaceRestoreHasCorrespondingNode() throws RepositoryException {
+        try {
+            superuser.getWorkspace().restore(new Version[] {wChildVersion}, false);
+            fail("Workspace.restore(Version[], boolean) must throw VersionException if non of the specified versions has a corresponding node in the workspace.");
+        } catch (VersionException e) {
+            // success
+        }
+    }
+
+    /**
+     * Test if Workspace.restore(Version[], boolean) succeeds if the following two
+     * preconditions are fulfilled:<ul>
+     * <li>For every version V in S that corresponds to a missing node in the workspace,
+     * there must also be a parent of V in S.</li>
+     * <li>S must contain at least one version that corresponds to an existing
+     * node in the workspace.</li>
+     * </ul>
+     */
+    public void testWorkspaceRestoreWithParent() throws RepositoryException {
+
+        try {
+            Version parentV = wVersionableNode.checkin();
+            superuser.getWorkspace().restore(new Version[] {parentV, wChildVersion}, false);
+        } catch (RepositoryException e) {
+            fail("Workspace.restore(Version[], boolean) with a version that has no corresponding node must succeed if a version of a parent with correspondance is present in the version array.");
+        }
+    }
+
+    /**
+     * Test if the removeExisting-flag removes an existing node in case of uuid conflict.
+     */
+    public void testWorkspaceRestoreWithRemoveExisting()  throws NotExecutableException, RepositoryException {
+        // assert proper child node definition
+        NodeDef d = wVersionableChildNode.getDefinition();
+        if (d.getOnParentVersion() != OnParentVersionAction.COPY || d.getOnParentVersion() != OnParentVersionAction.VERSION) {
+            fail("Childnode must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict");
+        }
+
+        // create version for parentNode of childNode
+        Version parentV = versionableNode.checkin();
+
+        // move child node in order to produce the uuid conflict
+        String newChildPath = wVersionableNode2.getPath() + "/" + wVersionableChildNode.getName();
+        wSuperuser.move(wVersionableChildNode.getPath(), newChildPath);
+        wTestRoot.save();
+
+        // restore the parent with removeExisting == true >> moved child node
+        // must be removed.
+        wSuperuser.getWorkspace().restore(new Version[] {parentV}, true);
+        if (wSuperuser.itemExists(newChildPath)) {
+            fail("Workspace.restore(Version[], boolean) with the boolean flag set to true, must remove the existing node in case of Uuid conflict.");
+        }
+    }
+
+    /**
+     * Tests if restoring the <code>Version</code> of an existing node throws an
+     * <code>ItemExistsException</code> if removeExisting is set to FALSE.
+     */
+    public void testWorkspaceRestoreWithUUIDConflict() throws RepositoryException, NotExecutableException {
+        try {
+            // Verify that nodes used for the test are indeed versionable
+            NodeDef nd = wVersionableNode.getDefinition();
+            if ( nd.getOnParentVersion() != OnParentVersionAction.COPY || nd.getOnParentVersion() != OnParentVersionAction.VERSION ) {
+                throw new NotExecutableException( "Nodes must be versionable in order to run this test." );
+            }
+
+            Version v = wVersionableNode.checkin();
+
+            wSuperuser.move( wVersionableChildNode.getPath(), wVersionableNode2.getPath() + "/" + wVersionableChildNode.getName() );
+            wSuperuser.getWorkspace().restore( new Version[] { v }, false );
+
+            fail( "Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false." );
+        } catch (ItemExistsException e ) {
+            // success
+        }
+    }
+
+
+    /**
+     * Test if workspace-restoring a node works on checked-in node.
+     */
+    public void testWorkspaceRestoreOnCheckedInNode() throws RepositoryException {
+        if ( versionableNode.isCheckedOut() ) {
+            versionableNode.checkin();
+        }
+        superuser.getWorkspace().restore( new Version[] { rootVersion }, true);
+    }
+
+    /**
+     * Test if workspace-restoring a node works on checked-out node.
+     */
+    public void testWorkspaceRestoreOnCheckedOutNode() throws RepositoryException {
+        if ( !versionableNode.isCheckedOut() ) {
+            versionableNode.checkout();
+        }
+        superuser.getWorkspace().restore( new Version[] { rootVersion }, true);
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/NodeRemovedTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/NodeRemovedTest.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/NodeRemovedTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/NodeRemovedTest.java Wed Feb  2 07:57:27 2005
@@ -29,7 +29,7 @@
     public void testSingleNodeRemoved() throws RepositoryException {
         EventResult result = new EventResult(log);
         addEventListener(result, Event.NODE_REMOVED);
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         testRootNode.save();
         foo.remove();
         testRootNode.save();
@@ -41,8 +41,8 @@
     public void testMultiNodesRemoved() throws RepositoryException {
         EventResult result = new EventResult(log);
         addEventListener(result, Event.NODE_REMOVED);
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
-        foo.addNode("bar", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
+        foo.addNode("bar");
         testRootNode.save();
         foo.remove();
         testRootNode.save();
@@ -54,9 +54,9 @@
     public void testMultiNodesRemovedWithRemaining() throws RepositoryException {
         EventResult result = new EventResult(log);
         addEventListener(result, Event.NODE_REMOVED);
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
-        testRootNode.addNode("foobar", NT_UNSTRUCTURED);
-        foo.addNode("bar", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
+        testRootNode.addNode("foobar");
+        foo.addNode("bar");
         testRootNode.save();
         foo.remove();
         testRootNode.save();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyAddedTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyAddedTest.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyAddedTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyAddedTest.java Wed Feb  2 07:57:27 2005
@@ -29,19 +29,19 @@
     public void testSinglePropertyAdded() throws RepositoryException {
         EventResult result = new EventResult(log);
         addEventListener(result, Event.PROPERTY_ADDED);
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("prop1", new String[]{"foo"});
         testRootNode.save();
         removeEventListener(result);
         Event[] events = result.getEvents(DEFAULT_WAIT_TIMEOUT);
         checkPropertyAdded(events, new String[]{"foo/prop1",
-                                                "foo/" + JCR_PRIMARY_TYPE});
+                                                "foo/" + jcrPrimaryType});
     }
 
     public void testMultiPropertyAdded() throws RepositoryException {
         EventResult result = new EventResult(log);
         addEventListener(result, Event.PROPERTY_ADDED);
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("prop1", new String[]{"foo"});
         foo.setProperty("prop2", new String[]{"bar"});
         testRootNode.save();
@@ -49,7 +49,7 @@
         Event[] events = result.getEvents(DEFAULT_WAIT_TIMEOUT);
         checkPropertyAdded(events, new String[]{"foo/prop1",
                                                 "foo/prop2",
-                                                "foo/" + JCR_PRIMARY_TYPE});
+                                                "foo/" + jcrPrimaryType});
     }
 
 

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyChangedTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyChangedTest.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyChangedTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyChangedTest.java Wed Feb  2 07:57:27 2005
@@ -28,7 +28,7 @@
 
     public void testSinglePropertyChanged() throws RepositoryException {
         EventResult result = new EventResult(log);
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("bar", new String[]{"foo"});
         testRootNode.save();
         addEventListener(result, Event.PROPERTY_CHANGED);
@@ -41,7 +41,7 @@
 
     public void testMultiPropertyChanged() throws RepositoryException {
         EventResult result = new EventResult(log);
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("prop1", new String[]{"foo"});
         foo.setProperty("prop2", new String[]{"bar"});
         testRootNode.save();
@@ -56,7 +56,7 @@
 
     public void testSinglePropertyChangedWithAdded() throws RepositoryException {
         EventResult result = new EventResult(log);
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("bar", new String[]{"foo"});
         testRootNode.save();
         addEventListener(result, Event.PROPERTY_CHANGED);
@@ -70,7 +70,7 @@
 
     public void testMultiPropertyChangedWithAdded() throws RepositoryException {
         EventResult result = new EventResult(log);
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("prop1", new String[]{"foo"});
         foo.setProperty("prop2", new String[]{"bar"});
         testRootNode.save();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyRemovedTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyRemovedTest.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyRemovedTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyRemovedTest.java Wed Feb  2 07:57:27 2005
@@ -30,7 +30,7 @@
     public void testSinglePropertyRemoved() throws RepositoryException {
         EventResult result = new EventResult(log);
         addEventListener(result, Event.PROPERTY_REMOVED);
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         Property prop1 = foo.setProperty("prop1", new String[]{"foo"});
         foo.setProperty("prop2", new String[]{"bar"});
         testRootNode.save();
@@ -44,7 +44,7 @@
     public void testMultiPropertyRemoved() throws RepositoryException {
         EventResult result = new EventResult(log);
         addEventListener(result, Event.PROPERTY_REMOVED);
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         Property prop1 = foo.setProperty("prop1", new String[]{"foo"});
         Property prop2 = foo.setProperty("prop2", new String[]{"bar"});
         testRootNode.save();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/FulltextQueryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/FulltextQueryTest.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/FulltextQueryTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/FulltextQueryTest.java Wed Feb  2 07:57:27 2005
@@ -26,13 +26,13 @@
 public class FulltextQueryTest extends AbstractQueryTest {
 
     public void testFulltextSimpleSQL1() throws Exception {
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
 
         testRootNode.save();
 
-        String sql = "SELECT * FROM \"" + NT_UNSTRUCTURED
-                + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/%"
+        String sql = "SELECT * FROM nt:unstructured"
+                + " WHERE jcr:path LIKE '" + testRoot + "/%"
                 + "' AND CONTAINS('fox')";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();
@@ -40,13 +40,13 @@
     }
 
     public void testFulltextSimpleSQL2() throws Exception {
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
 
         testRootNode.save();
 
-        String sql = "SELECT * FROM \"" + NT_UNSTRUCTURED
-                + "\" WHERE \"jcr:path\" = '" + testRoot + "/foo"
+        String sql = "SELECT * FROM nt:unstructured"
+                + " WHERE \"jcr:path\" = '" + testRoot + "/foo"
                 + "' AND CONTAINS('fox')";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();
@@ -54,18 +54,18 @@
     }
 
     public void testFulltextMultiWordSQL() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("title", new String[]{"test text"});
         n.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
 
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("title", new String[]{"other text"});
         n.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
 
         testRootNode.save();
 
-        String sql = "SELECT * FROM \"" + NT_UNSTRUCTURED
-                + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/%"
+        String sql = "SELECT * FROM nt:unstructured"
+                + " WHERE \"jcr:path\" LIKE '" + testRoot + "/%"
                 + "' AND CONTAINS('fox test')";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();
@@ -73,18 +73,18 @@
     }
 
     public void testFulltextPhraseSQL() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("title", new String[]{"test text"});
         n.setProperty("mytext", new String[]{"the quick brown jumps fox over the lazy dog."});
 
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("title", new String[]{"other text"});
         n.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
 
         testRootNode.save();
 
-        String sql = "SELECT * FROM \"" + NT_UNSTRUCTURED
-                + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/%"
+        String sql = "SELECT * FROM nt:unstructured"
+                + " WHERE \"jcr:path\" LIKE '" + testRoot + "/%"
                 + "' AND CONTAINS('text ''fox jumps''')";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();
@@ -92,18 +92,18 @@
     }
 
     public void testFulltextExcludeSQL() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("title", new String[]{"test text"});
         n.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
 
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("title", new String[]{"other text"});
         n.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
 
         superuser.getRootNode().save();
 
-        String sql = "SELECT * FROM \"" + NT_UNSTRUCTURED
-                + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/%"
+        String sql = "SELECT * FROM nt:unstructured"
+                + " WHERE \"jcr:path\" LIKE '" + testRoot + "/%"
                 + "' AND CONTAINS('text ''fox jumps'' -other')";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();
@@ -111,18 +111,18 @@
     }
 
     public void testFulltextOrSQL() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("title", new String[]{"test text"});
         n.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
 
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("title", new String[]{"other text"});
         n.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
 
         testRootNode.save();
 
-        String sql = "SELECT * FROM \"" + NT_UNSTRUCTURED
-                + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/%"
+        String sql = "SELECT * FROM nt:unstructured"
+                + " WHERE \"jcr:path\" LIKE '" + testRoot + "/%"
                 + "' AND CONTAINS('''fox jumps'' test OR other')";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();
@@ -130,18 +130,18 @@
     }
 
     public void testFulltextIntercapSQL() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("title", new String[]{"tEst text"});
         n.setProperty("mytext", new String[]{"The quick brown Fox jumps over the lazy dog."});
 
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("title", new String[]{"Other text"});
         n.setProperty("mytext", new String[]{"the quick brown FOX jumPs over the lazy dog."});
 
         testRootNode.save();
 
-        String sql = "SELECT * FROM \"" + NT_UNSTRUCTURED
-                + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/%"
+        String sql = "SELECT * FROM nt:unstructured"
+                + " WHERE \"jcr:path\" LIKE '" + testRoot + "/%"
                 + "' AND CONTAINS('''fox juMps'' Test OR otheR')";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SQLTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SQLTest.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SQLTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SQLTest.java Wed Feb  2 07:57:27 2005
@@ -26,36 +26,36 @@
 
 
     public void testSimpleQuery1() throws Exception {
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("bla", new String[]{"bla"});
 
         testRootNode.save();
 
-        String sql = "SELECT * FROM \"nt:unstructured\" WHERE bla='bla'";
+        String sql = "SELECT * FROM nt:unstructured WHERE bla='bla'";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();
         checkResult(result, 1);
     }
 
     public void testFulltextSimple() throws Exception {
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
 
         testRootNode.save();
 
-        String sql = "SELECT * FROM \"nt:unstructured\" WHERE contains('fox')";
+        String sql = "SELECT * FROM nt:unstructured WHERE contains('fox')";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();
         checkResult(result, 1);
     }
 
     public void testFulltextComplex() throws Exception {
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
 
         testRootNode.save();
 
-        String sql = "SELECT * FROM \"nt:unstructured\" WHERE contains('fox') AND NOT contains('bla')";
+        String sql = "SELECT * FROM nt:unstructured WHERE contains('fox') AND NOT contains('bla')";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();
         checkResult(result, 1);

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SelectClauseTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SelectClauseTest.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SelectClauseTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SelectClauseTest.java Wed Feb  2 07:57:27 2005
@@ -27,63 +27,63 @@
 public class SelectClauseTest extends AbstractQueryTest {
 
     public void testSelectSQL() throws RepositoryException {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("myvalue", "foo");
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("myvalue", "bar");
-        n = testRootNode.addNode("node3", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node3");
         n.setProperty("yourvalue", "foo");
 
         testRootNode.save();
 
-        String sql = "SELECT myvalue FROM \"" + NT_BASE
+        String sql = "SELECT myvalue FROM \"" + ntBase
                 + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/%'";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();
         checkResult(result, 2);
 
-        sql = "SELECT myvalue FROM \"" + NT_BASE
+        sql = "SELECT myvalue FROM \"" + ntBase
                 + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/%'"
                 + " AND yourvalue = 'foo'";
         q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         result = q.execute();
         checkResult(result, 0);
 
-        sql = "SELECT myvalue FROM \"" + NT_BASE + "\"";
+        sql = "SELECT myvalue FROM \"" + ntBase + "\"";
         q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         result = q.execute();
         checkResult(result, 2);
     }
 
     public void testPropertyCountSQL() throws RepositoryException {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("myvalue", "foo");
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("myvalue", "bar");
-        n = testRootNode.addNode("node3", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node3");
         n.setProperty("yourvalue", "foo");
 
         testRootNode.save();
 
-        String sql = "SELECT myvalue FROM \"" + NT_BASE
+        String sql = "SELECT myvalue FROM \"" + ntBase
                 + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/%'";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();
         checkResult(result, 2, 2);
 
-        sql = "SELECT myvalue FROM \"" + NT_BASE
+        sql = "SELECT myvalue FROM \"" + ntBase
                 + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/%'"
                 + " AND yourvalue = 'foo'";
         q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         result = q.execute();
         checkResult(result, 0, 0);
 
-        sql = "SELECT myvalue FROM \"" + NT_BASE + "\"";
+        sql = "SELECT myvalue FROM \"" + ntBase + "\"";
         q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         result = q.execute();
         checkResult(result, 2, 2);
 
-        sql = "SELECT * FROM \"" + NT_BASE
+        sql = "SELECT * FROM \"" + ntBase
                 + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/%'"
                 + " AND myvalue LIKE '%'";
         q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
@@ -92,16 +92,16 @@
     }
 
     public void testSameNameSiblingSQL() throws RepositoryException {
-        Node n = testRootNode.addNode("node", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node");
         n.setProperty("myvalue", "foo");
-        n = testRootNode.addNode("node", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node");
         n.setProperty("myvalue", "bar");
-        n = testRootNode.addNode("node", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node");
         n.setProperty("yourvalue", "foo");
 
         testRootNode.save();
 
-        String sql = "SELECT myvalue FROM \"" + NT_BASE
+        String sql = "SELECT myvalue FROM \"" + ntBase
                 + "\" WHERE \"jcr:path\" LIKE '" + testRoot + "/node'";
         Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
         QueryResult result = q.execute();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SimpleQueryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SimpleQueryTest.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SimpleQueryTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SimpleQueryTest.java Wed Feb  2 07:57:27 2005
@@ -28,7 +28,7 @@
 
 
     public void testSimpleQuerySQL1() throws Exception {
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("bla", new String[]{"bla"});
 
         testRootNode.save();
@@ -42,9 +42,9 @@
     }
 
     public void testSimpleQuerySQL2() throws Exception {
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("bla", new String[]{"bla"});
-        Node bla = testRootNode.addNode("bla", NT_UNSTRUCTURED);
+        Node bla = testRootNode.addNode("bla");
         bla.setProperty("bla", new String[]{"bla"});
 
         superuser.getRootNode().save();
@@ -58,9 +58,9 @@
     }
 
     public void testSimpleQuerySQL3() throws Exception {
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("bla", new String[]{"bla"});
-        Node bla = testRootNode.addNode("bla", NT_UNSTRUCTURED);
+        Node bla = testRootNode.addNode("bla");
         bla.setProperty("bla", new String[]{"bla"});
 
         testRootNode.save();
@@ -74,9 +74,9 @@
     }
 
     public void testSimpleQuerySQL4() throws Exception {
-        Node foo = testRootNode.addNode("foo", NT_UNSTRUCTURED);
+        Node foo = testRootNode.addNode("foo");
         foo.setProperty("bla", new String[]{"bla"});
-        Node bla = testRootNode.addNode("bla", NT_UNSTRUCTURED);
+        Node bla = testRootNode.addNode("bla");
         bla.setProperty("bla", new String[]{"bla"});
 
         testRootNode.save();
@@ -88,12 +88,12 @@
     }
 
     public void testDateField1() throws Exception {
-        Node n = testRootNode.addNode("marcel", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("marcel");
         Calendar marcel = Calendar.getInstance();
         marcel.set(1976, 4, 20, 15, 40);
         n.setProperty("birth", new Value[]{new DateValue(marcel)});
 
-        n = testRootNode.addNode("vanessa", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("vanessa");
         Calendar vanessa = Calendar.getInstance();
         vanessa.set(1975, 4, 10, 13, 30);
         n.setProperty("birth", new Value[]{new DateValue(vanessa)});
@@ -112,11 +112,11 @@
     }
 
     public void testDoubleField() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("value", new Value[]{new DoubleValue(1.9928375d)});
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("value", new Value[]{new DoubleValue(0.0d)});
-        n = testRootNode.addNode("node3", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node3");
         n.setProperty("value", new Value[]{new DoubleValue(-1.42982475d)});
 
         testRootNode.save();
@@ -138,11 +138,11 @@
     }
 
     public void testLongField() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("value", new Value[]{new LongValue(1)});
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("value", new Value[]{new LongValue(0)});
-        n = testRootNode.addNode("node3", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node3");
         n.setProperty("value", new Value[]{new LongValue(-1)});
 
         testRootNode.save();
@@ -164,11 +164,11 @@
     }
 
     public void testLikePattern() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("value", new String[]{"king"});
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("value", new String[]{"ping"});
-        n = testRootNode.addNode("node3", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node3");
         n.setProperty("value", new String[]{"ching"});
 
         testRootNode.save();
@@ -190,11 +190,11 @@
     }
 
     public void testLikePatternBetween() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("value", new String[]{"ping"});
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("value", new String[]{"pong"});
-        n = testRootNode.addNode("node3", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node3");
         n.setProperty("value", new String[]{"puung"});
 
         testRootNode.save();
@@ -216,11 +216,11 @@
     }
 
     public void testLikePatternEnd() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("value", new String[]{"bli"});
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("value", new String[]{"bla"});
-        n = testRootNode.addNode("node3", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node3");
         n.setProperty("value", new String[]{"blub"});
 
         testRootNode.save();
@@ -242,13 +242,13 @@
     }
 
     public void testLikePatternEscaped() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("value", new String[]{"foo\\_bar"});
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("value", new String[]{"foobar"});
-        n = testRootNode.addNode("node3", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node3");
         n.setProperty("value", new String[]{"foo_bar"});
-        n = testRootNode.addNode("node4", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node4");
         n.setProperty("value", new String[]{"foolbar"});
 
         testRootNode.save();
@@ -280,11 +280,11 @@
     }
 
     public void testNotEqual() throws Exception {
-        Node n = testRootNode.addNode("node1", NT_UNSTRUCTURED);
+        Node n = testRootNode.addNode("node1");
         n.setProperty("value", new String[]{"foo"});
-        n = testRootNode.addNode("node2", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node2");
         n.setProperty("value", new String[]{"bar"});
-        n = testRootNode.addNode("node3", NT_UNSTRUCTURED);
+        n = testRootNode.addNode("node3");
         n.setProperty("value", new String[]{"foobar"});
 
         testRootNode.save();



Mime
View raw message