org.apache.jackrabbit.test.api
Class StringPropertyTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.jackrabbit.test.JUnitTest
              extended by org.apache.jackrabbit.test.AbstractJCRTest
                  extended by org.apache.jackrabbit.test.api.StringPropertyTest
All Implemented Interfaces:
junit.framework.Test

public class StringPropertyTest
extends AbstractJCRTest

StringPropertyTest tests a String property against the conversions to other Properties (except Name and Path property). If no String property is found or only a multivalue String property with an empty array, a NotExecutableException is thrown on setUp. More precisely, the tests are:

- Value.getString() should return a string equals to Property.getString(), and in case of a multivalue property the failure of Property.getString() is checked.

- Value.getBoolean() Conversion to Boolean property.

- Value.getDate() Conversion to Date property is only valid when the String follows the required Date pattern (6.2.5.1 of jsr170 specification).

- Value.getDouble() Conversion to Double are only valid when the String follows the correct patterns as required by the according Java classes.

- Value.getLong() Conversion to Double are only valid when the String follows the correct patterns as required by the according Java classes.

- Value.getStream() Conversion to a Binary property follows the rules of Value.getStream() as explained in chapter 6.2.7 of the jsr170 specification. The required encoding is utf-8.

- Property.getNode() Conversion to a Reference property is tested with Property.getNode. The String should match the UUID pattern but this doesn't guarantee to be a reference (which especially requires integrity).

- Property.getLength() .

- Property.getLengths() .

- Property.getType() is compared to Value.getType() .


Field Summary
protected  boolean multiple
          true if the property is multi valued
protected  Property prop
           
protected  Session session
          A read only session
protected static String UTF8
          String encoding in a stream
 
Fields inherited from class org.apache.jackrabbit.test.AbstractJCRTest
helper, isReadOnly, jcrBaseVersion, jcrCreated, jcrFrozenNode, jcrFrozenUuid, jcrlockIsDeep, jcrLockOwner, jcrMergeFailed, jcrMixinTypes, jcrPredecessors, jcrPrimaryType, jcrRootVersion, jcrSuccessors, jcrSystem, jcrUUID, jcrVersionHistory, mixLockable, mixReferenceable, mixVersionable, nodeName1, nodeName2, nodeName3, nodeName4, NS_JCR_URI, NS_MIX_URI, NS_NT_URI, NS_SV_URI, ntBase, ntFrozenNode, ntQuery, ntVersion, ntVersionHistory, ntVersionLabels, propertyName1, propertyName2, superuser, testNodeType, testNodeTypeNoChildren, testPath, testRoot, testRootNode, workspaceName
 
Fields inherited from class org.apache.jackrabbit.test.JUnitTest
log
 
Constructor Summary
StringPropertyTest()
           
 
Method Summary
protected  void cleanUp()
           
protected  int getPropertyType()
          Returns PropertyType.STRING.
protected  void setUp()
          Sets up the fixture for the tests.
protected  void tearDown()
          Releases the session aquired in setUp().
 void testAsReference()
          Tests conversion from String type to Reference type.
 void testGetBoolean()
          Tests conversion from String type to Boolean type.
 void testGetDate()
          Tests conversion from String type to Date type.
 void testGetDouble()
          Tests conversion from String type to Double type.
 void testGetLength()
          Tests the Property.getLength() method.
 void testGetLengths()
          Tests the Property.getLengths() method.
 void testGetLong()
          Tests conversion from String type to Long type.
 void testGetStream()
          Tests conversion from String type to Binary type.
 void testGetType()
          Tests if Value.getType() returns the same as Property.getType() and also tests that prop.getDefinition().getRequiredType() returns the same type in case it is not of Undefined type.
 void testValue()
          Tests that Property.getString() delivers a string equal to the string received with Value.getString().
 
Methods inherited from class org.apache.jackrabbit.test.AbstractJCRTest
cleanUpTestRoot, createRandomString, ensureCanSetProperty, ensureCanSetProperty, ensureMultipleWorkspacesSupported, getNonExistingWorkspaceName, getProperty, getSize, isSupported, run
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UTF8

protected static String UTF8
String encoding in a stream


session

protected Session session
A read only session


prop

protected Property prop

multiple

protected boolean multiple
true if the property is multi valued

Constructor Detail

StringPropertyTest

public StringPropertyTest()
Method Detail

getPropertyType

protected int getPropertyType()
Returns PropertyType.STRING.

Returns:
PropertyType.STRING.

testValue

public void testValue()
               throws RepositoryException
Tests that Property.getString() delivers a string equal to the string received with Value.getString().

Throws:
RepositoryException

testGetBoolean

public void testGetBoolean()
                    throws RepositoryException
Tests conversion from String type to Boolean type.

Throws:
RepositoryException

testGetDate

public void testGetDate()
                 throws RepositoryException
Tests conversion from String type to Date type.

Throws:
RepositoryException

testGetDouble

public void testGetDouble()
                   throws RepositoryException
Tests conversion from String type to Double type.

Throws:
RepositoryException

testGetLong

public void testGetLong()
                 throws RepositoryException
Tests conversion from String type to Long type.

Throws:
RepositoryException

testGetStream

public void testGetStream()
                   throws RepositoryException,
                          IOException
Tests conversion from String type to Binary type.

Throws:
RepositoryException
IOException

testAsReference

public void testAsReference()
                     throws RepositoryException,
                            NotExecutableException
Tests conversion from String type to Reference type.

Throws:
RepositoryException
NotExecutableException

testGetLength

public void testGetLength()
                   throws RepositoryException
Tests the Property.getLength() method. The length returned is either -1 or it is the length of the string.

Throws:
RepositoryException

testGetLengths

public void testGetLengths()
                    throws RepositoryException
Tests the Property.getLengths() method. The returned values are either -1 or the lengths of the according strings.

Throws:
RepositoryException

testGetType

public void testGetType()
                 throws RepositoryException
Tests if Value.getType() returns the same as Property.getType() and also tests that prop.getDefinition().getRequiredType() returns the same type in case it is not of Undefined type.

Throws:
RepositoryException

setUp

protected void setUp()
              throws Exception
Sets up the fixture for the tests.

Overrides:
setUp in class AbstractJCRTest
Throws:
Exception

cleanUp

protected void cleanUp()
                throws Exception
Overrides:
cleanUp in class AbstractJCRTest
Throws:
Exception

tearDown

protected void tearDown()
                 throws Exception
Releases the session aquired in setUp().

Overrides:
tearDown in class AbstractJCRTest
Throws:
Exception


Copyright © 2004-2007 The Apache Software Foundation. All Rights Reserved.