[exo-jcr-commits] exo-jcr SVN: r5443 - in jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr: api/writing and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Jan 12 03:07:56 EST 2012
Author: andrew.plotnikov
Date: 2012-01-12 03:07:55 -0500 (Thu, 12 Jan 2012)
New Revision: 5443
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/namespaces/TestNamespaceRegistry.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionCleaner.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java
Log:
EXOJCR-1703: Writed tests to classes JCRName, NamespaceRegistryImpl, PropertyImpl
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/namespaces/TestNamespaceRegistry.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/namespaces/TestNamespaceRegistry.java 2012-01-12 07:12:27 UTC (rev 5442)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/namespaces/TestNamespaceRegistry.java 2012-01-12 08:07:55 UTC (rev 5443)
@@ -23,9 +23,11 @@
import org.exoplatform.services.jcr.JcrAPIBaseTest;
import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
import org.exoplatform.services.jcr.impl.core.ExtendedNamespaceRegistry;
+import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.query.RepositoryIndexSearcherHolder;
+import java.util.Arrays;
import java.util.Set;
import javax.jcr.NamespaceException;
@@ -89,6 +91,8 @@
}
assertTrue(prefixes.length >= 7);
+ assertTrue(Arrays.asList(session.getWorkspace().getNamespaceRegistry().getPrefixes()).containsAll(
+ Arrays.asList(namespaceRegistry.getPrefixes())));
}
public void testGetURIs() throws RepositoryException
@@ -359,4 +363,40 @@
fail();
}
}
-}
+
+ public void testIsDefaultPrefix()
+ {
+ assertTrue(((NamespaceRegistryImpl)namespaceRegistry).isDefaultPrefix("nt"));
+ assertFalse(((NamespaceRegistryImpl)namespaceRegistry).isDefaultPrefix("somePrefix"));
+ }
+
+ public void testIsDefaultNamespace() throws NamespaceException, RepositoryException
+ {
+ NamespaceRegistryImpl nameSpace = (NamespaceRegistryImpl)namespaceRegistry;
+ String uri = workspace.getNamespaceRegistry().getURI("nt");
+
+ assertTrue(nameSpace.isDefaultNamespace(uri));
+ assertFalse(nameSpace.isDefaultNamespace(" "));
+ }
+
+ public void testValidateNamespace() throws RepositoryException
+ {
+ try
+ {
+ ((NamespaceRegistryImpl)namespaceRegistry).validateNamespace("some:text", "");
+ fail();
+ }
+ catch (RepositoryException e)
+ {
+ }
+
+ try
+ {
+ ((NamespaceRegistryImpl)namespaceRegistry).validateNamespace("nt", null);
+ fail();
+ }
+ catch (NamespaceException e)
+ {
+ }
+ }
+}
\ No newline at end of file
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java 2012-01-12 07:12:27 UTC (rev 5442)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java 2012-01-12 08:07:55 UTC (rev 5443)
@@ -41,6 +41,7 @@
import javax.jcr.Session;
import javax.jcr.Value;
import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.version.OnParentVersionAction;
/**
@@ -325,6 +326,33 @@
catch (ValueFormatException e)
{
}
+
+ try
+ {
+ node.setProperty("jcr:versionStorage", 20D);
+ fail("exception should have been thrown");
+ }
+ catch (ConstraintViolationException e)
+ {
+ }
+
+ try
+ {
+ node.setProperty("jcr:versionStorage", valueFactory.createValue(20L), PropertyType.LONG);
+ fail("exception should have been thrown");
+ }
+ catch (ConstraintViolationException e)
+ {
+ }
+
+ try
+ {
+ node.setProperty("jcr:versionStorage", "20", PropertyType.LONG);
+ fail("exception should have been thrown");
+ }
+ catch (ConstraintViolationException e)
+ {
+ }
}
public void testSetPathProperty() throws RepositoryException
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java 2012-01-12 07:12:27 UTC (rev 5442)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java 2012-01-12 08:07:55 UTC (rev 5443)
@@ -862,5 +862,4 @@
assertEquals(marysNode.getACL().getPermissions("mary").size(), 0);
assertEquals(((NodeData)marysNode.getData()).getACL().getOwner(), "admin");
}
-
-}
+}
\ No newline at end of file
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionCleaner.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionCleaner.java 2012-01-12 07:12:27 UTC (rev 5442)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionCleaner.java 2012-01-12 08:07:55 UTC (rev 5443)
@@ -80,6 +80,5 @@
// The weak reference must now be null
assertNull(ref.get());
-
}
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java 2012-01-12 07:12:27 UTC (rev 5442)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java 2012-01-12 08:07:55 UTC (rev 5443)
@@ -26,6 +26,8 @@
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS.
*
@@ -116,10 +118,17 @@
}
- public void testEquals() throws Exception
+ public void testEqualsJCRPath() throws Exception
{
JCRPath path = factory.parseAbsPath("/jcr:node/node1[2]/exo:node2");
assertFalse(path.equals(null));
assertFalse(path.equals(new Object()));
}
+
+ public void testEqualsJCRName() throws RepositoryException
+ {
+ JCRName name = factory.parseAbsPath("/jcr:node/node1[2]/exo:node2").getName();
+ assertFalse(name.equals(null));
+ assertFalse(name.equals(new Object()));
+ }
}
\ No newline at end of file
More information about the exo-jcr-commits
mailing list