org.apache.jackrabbit.test.api
Class SerializationTest

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.SerializationTest
All Implemented Interfaces:
junit.framework.Test

public class SerializationTest
extends AbstractJCRTest

SerializationTest contains the test cases for the method Workspace.exportSysView() and Session.importSysView().

This class exports and re-imports the repository. The tests check for differences between the original and the re-imported repository.


Field Summary
protected  boolean CONTENTHANDLER
           
protected  java.io.File file
           
protected  boolean NORECURSE
           
protected  boolean RECURSE
           
protected  boolean SAVEBINARY
           
protected  javax.jcr.Session session
           
protected  boolean SESSION
           
protected  boolean SKIPBINARY
           
protected  boolean STREAM
           
protected  org.apache.jackrabbit.test.api.TreeComparator treeComparator
           
protected  javax.jcr.Workspace workspace
           
protected  boolean WORKSPACE
           
 
Fields inherited from class org.apache.jackrabbit.test.AbstractJCRTest
isReadOnly, jcrBaseVersion, jcrCopiedFrom, jcrCreated, jcrFrozenNode, jcrFrozenUuid, jcrIsCheckedOut, jcrlockIsDeep, jcrLockOwner, jcrMergeFailed, jcrMixinTypes, jcrPredecessors, jcrPrimaryType, jcrRootVersion, jcrSuccessors, jcrSystem, jcrUUID, jcrVersionHistory, mixLockable, mixReferenceable, mixShareable, mixSimpleVersionable, mixVersionable, nodeName1, nodeName2, nodeName3, nodeName4, NS_JCR_URI, NS_MIX_URI, NS_NT_URI, NS_SV_URI, ntBase, ntFrozenNode, ntQuery, ntUnstructured, ntVersion, ntVersionHistory, ntVersionLabels, propertyName1, propertyName2, superuser, testNodeType, testNodeTypeNoChildren, testPath, testRoot, testRootNode, vf, workspaceName
 
Fields inherited from class org.apache.jackrabbit.test.JUnitTest
log
 
Constructor Summary
SerializationTest()
           
 
Method Summary
 void doImport(java.lang.String absPath, java.io.FileInputStream in, boolean useWorkspace, boolean useHandler)
          Helper method which imports the given FileInputStream using Workspace or Session and via the methods importXML respective getImportContentHandler.
 void doImportNoSave(java.lang.String absPath, java.io.FileInputStream in, boolean useHandler)
           
 void doTestLockException(boolean useWorkspace, boolean useHandler)
          Tests whether importing a tree respects locking.
 void doTestNodeTypeConstraintViolation(boolean useWorkspace, boolean useHandler)
          Create a node named ntBase with node type nt:base and creates a tree in the repository which will be exported and reimported below the node ntBase.
 void doTestOverwriteException(boolean useWorkspace, boolean useHandler)
          Tries to overwrite an existing node.
 void doTestVersioningExceptionFileChild(boolean useWorkspace, boolean useHandler)
           
 void doTestVersioningExceptionFileParent(boolean useWorkspace, boolean useHandler)
           
 void importRepository(boolean useHandler, boolean workspace)
          Imports the repository
protected  javax.jcr.Node initVersioningException(boolean returnParent)
          Creates a simple target tree consisting of a checked-in node and an ordinary child node below.
 void setUp()
           
 void tearDown()
           
 void testExportSysView_handler_session_saveBinary_noRecurse()
           
 void testExportSysView_handler_session_saveBinary_recurse()
           
 void testExportSysView_handler_session_skipBinary_noRecurse()
           
 void testExportSysView_handler_session_skipBinary_recurse()
           
 void testExportSysView_handler_workspace_saveBinary_noRecurse()
           
 void testExportSysView_handler_workspace_saveBinary_recurse()
           
 void testExportSysView_handler_workspace_skipBinary_noRecurse()
           
 void testExportSysView_handler_workspace_skipBinary_recurse()
           
 void testExportSysView_stream_session_saveBinary_noRecurse()
           
 void testExportSysView_stream_session_saveBinary_recurse()
           
 void testExportSysView_stream_session_skipBinary_noRecurse()
           
 void testExportSysView_stream_session_skipBinary_recurse()
           
 void testExportSysView_stream_workspace_saveBinary_noRecurse()
           
 void testExportSysView_stream_workspace_saveBinary_recurse()
           
 void testExportSysView_stream_workspace_skipBinary_noRecurse()
           
 void testExportSysView_stream_workspace_skipBinary_recurse()
           
 void testInvalidXmlThrowsInvalidSerializedDataException()
          Tests whether importing an invalid XML file throws a InvalidSerializedDataException.
 void testInvalidXmlThrowsSaxException()
          Tests whether importing an invalid XML file throws a SAX exception.
 void testLockExceptionSession()
           
 void testLockExceptionSessionWithHandler()
           
 void testLockExceptionWorkspace()
           
 void testLockExceptionWorkspaceWithHandler()
           
 void testNodeTypeConstraintViolationSession()
           
 void testNodeTypeConstraintViolationSessionWithHandler()
           
 void testNodeTypeConstraintViolationWorkspace()
           
 void testNodeTypeConstraintViolationWorkspaceWithHandler()
           
 void testOverwriteExceptionSession()
           
 void testOverwriteExceptionSessionWithHandler()
           
 void testOverwriteExceptionWorkspace()
           
 void testOverwriteExceptionWorkspaceWithHandler()
           
 void testSessionGetContentHandler()
          Makes sure that importing into the session does not save anything if the session is closed.
 void testSessionGetImportContentHandlerExceptions()
          Supplying an invalid repository path for import must throw a PathNotFoundException
 void testSessionImportXml()
          Makes sure that importing into the session does not save anything if the session is closed.
 void testSessionImportXmlExceptions()
          Tests the exception when importing: If the parent node does not exist.
 void testVersioningExceptionFileChildSession()
           
 void testVersioningExceptionFileChildSessionContentHandler()
           
 void testVersioningExceptionFileChildWorkspace()
           
 void testVersioningExceptionFileChildWorkspaceContentHandler()
           
 void testVersioningExceptionFileParentSession()
           
 void testVersioningExceptionFileParentSessionContentHandler()
           
 void testVersioningExceptionFileParentWorkspace()
           
 void testVersioningExceptionFileParentWorkspaceContentHandler()
           
 void testWorkspaceGetImportContentHandlerExceptions()
          Supplying an invalid repository path for import must throw a PathNotFoundException
 void testWorkspaceImportXmlExceptions()
          Tests the exceptions when importing: If the parent node does not exist, and if an IO error occurs.
 
Methods inherited from class org.apache.jackrabbit.test.AbstractJCRTest
checkSupportedOption, cleanUp, cleanUpTestRoot, createRandomString, ensureCanSetProperty, ensureCanSetProperty, ensureCanSetProperty, ensureKnowsNodeType, ensureMixinType, ensureMultipleWorkspacesSupported, getHelper, getJcrValue, getLocalName, getNonExistingWorkspaceName, getProperty, getProperty, getSize, isSupported, needsMixin, 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, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

workspace

protected javax.jcr.Workspace workspace

file

protected java.io.File file

treeComparator

protected org.apache.jackrabbit.test.api.TreeComparator treeComparator

CONTENTHANDLER

protected final boolean CONTENTHANDLER
See Also:
Constant Field Values

STREAM

protected final boolean STREAM
See Also:
Constant Field Values

WORKSPACE

protected final boolean WORKSPACE
See Also:
Constant Field Values

SESSION

protected final boolean SESSION
See Also:
Constant Field Values

SKIPBINARY

protected final boolean SKIPBINARY
See Also:
Constant Field Values

SAVEBINARY

protected final boolean SAVEBINARY
See Also:
Constant Field Values

NORECURSE

protected final boolean NORECURSE
See Also:
Constant Field Values

RECURSE

protected final boolean RECURSE
See Also:
Constant Field Values

session

protected javax.jcr.Session session
Constructor Detail

SerializationTest

public SerializationTest()
Method Detail

setUp

public void setUp()
           throws javax.jcr.RepositoryException,
                  java.lang.Exception
Overrides:
setUp in class AbstractJCRTest
Throws:
javax.jcr.RepositoryException
java.lang.Exception

tearDown

public void tearDown()
              throws java.lang.Exception
Overrides:
tearDown in class AbstractJCRTest
Throws:
java.lang.Exception

initVersioningException

protected javax.jcr.Node initVersioningException(boolean returnParent)
                                          throws javax.jcr.RepositoryException,
                                                 NotExecutableException,
                                                 java.io.IOException
Creates a simple target tree consisting of a checked-in node and an ordinary child node below. Throws a NotExecutableException if AbstractJCRTest.testNodeType is not versionable.

Parameters:
returnParent - Whether the method returns a checked-in parent or the child of a checked-in parent.
Returns:
The requested node (a node that is checked in or that has a parent that is checked in).
Throws:
javax.jcr.RepositoryException
NotExecutableException
java.io.IOException

doTestVersioningExceptionFileParent

public void doTestVersioningExceptionFileParent(boolean useWorkspace,
                                                boolean useHandler)
                                         throws java.lang.Exception
Throws:
java.lang.Exception

doTestVersioningExceptionFileChild

public void doTestVersioningExceptionFileChild(boolean useWorkspace,
                                               boolean useHandler)
                                        throws java.lang.Exception
Throws:
java.lang.Exception

testVersioningExceptionFileParentWorkspaceContentHandler

public void testVersioningExceptionFileParentWorkspaceContentHandler()
                                                              throws java.lang.Exception
Throws:
java.lang.Exception

testVersioningExceptionFileParentSessionContentHandler

public void testVersioningExceptionFileParentSessionContentHandler()
                                                            throws java.lang.Exception
Throws:
java.lang.Exception

testVersioningExceptionFileParentWorkspace

public void testVersioningExceptionFileParentWorkspace()
                                                throws java.lang.Exception
Throws:
java.lang.Exception

testVersioningExceptionFileParentSession

public void testVersioningExceptionFileParentSession()
                                              throws java.lang.Exception
Throws:
java.lang.Exception

testVersioningExceptionFileChildWorkspaceContentHandler

public void testVersioningExceptionFileChildWorkspaceContentHandler()
                                                             throws java.lang.Exception
Throws:
java.lang.Exception

testVersioningExceptionFileChildSessionContentHandler

public void testVersioningExceptionFileChildSessionContentHandler()
                                                           throws java.lang.Exception
Throws:
java.lang.Exception

testVersioningExceptionFileChildWorkspace

public void testVersioningExceptionFileChildWorkspace()
                                               throws java.lang.Exception
Throws:
java.lang.Exception

testVersioningExceptionFileChildSession

public void testVersioningExceptionFileChildSession()
                                             throws java.lang.Exception
Throws:
java.lang.Exception

doTestLockException

public void doTestLockException(boolean useWorkspace,
                                boolean useHandler)
                         throws java.lang.Exception
Tests whether importing a tree respects locking.

Throws:
java.lang.Exception

testLockExceptionWorkspaceWithHandler

public void testLockExceptionWorkspaceWithHandler()
                                           throws java.lang.Exception
Throws:
java.lang.Exception

testLockExceptionSessionWithHandler

public void testLockExceptionSessionWithHandler()
                                         throws java.lang.Exception
Throws:
java.lang.Exception

testLockExceptionWorkspace

public void testLockExceptionWorkspace()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testLockExceptionSession

public void testLockExceptionSession()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testInvalidXmlThrowsSaxException

public void testInvalidXmlThrowsSaxException()
                                      throws java.io.IOException,
                                             javax.xml.parsers.ParserConfigurationException
Tests whether importing an invalid XML file throws a SAX exception. The file used here is more or less garbage.

Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException

testInvalidXmlThrowsInvalidSerializedDataException

public void testInvalidXmlThrowsInvalidSerializedDataException()
                                                        throws javax.jcr.RepositoryException,
                                                               java.io.IOException
Tests whether importing an invalid XML file throws a InvalidSerializedDataException. The file used here is more or less garbage.

Throws:
javax.jcr.RepositoryException
java.io.IOException

testWorkspaceGetImportContentHandlerExceptions

public void testWorkspaceGetImportContentHandlerExceptions()
                                                    throws javax.jcr.RepositoryException
Supplying an invalid repository path for import must throw a PathNotFoundException

Throws:
javax.jcr.RepositoryException

testSessionGetImportContentHandlerExceptions

public void testSessionGetImportContentHandlerExceptions()
                                                  throws javax.jcr.RepositoryException
Supplying an invalid repository path for import must throw a PathNotFoundException

Throws:
javax.jcr.RepositoryException

testSessionImportXmlExceptions

public void testSessionImportXmlExceptions()
                                    throws javax.jcr.RepositoryException,
                                           java.io.IOException
Tests the exception when importing: If the parent node does not exist.

Throws:
javax.jcr.RepositoryException
java.io.IOException

testWorkspaceImportXmlExceptions

public void testWorkspaceImportXmlExceptions()
                                      throws javax.jcr.RepositoryException,
                                             java.io.IOException
Tests the exceptions when importing: If the parent node does not exist, and if an IO error occurs.

Throws:
javax.jcr.RepositoryException
java.io.IOException

doTestOverwriteException

public void doTestOverwriteException(boolean useWorkspace,
                                     boolean useHandler)
                              throws java.lang.Exception
Tries to overwrite an existing node. This only works for nodes that do not allow same-name siblings.

Throws:
java.lang.Exception

testOverwriteExceptionWorkspaceWithHandler

public void testOverwriteExceptionWorkspaceWithHandler()
                                                throws java.lang.Exception
Throws:
java.lang.Exception

testOverwriteExceptionSessionWithHandler

public void testOverwriteExceptionSessionWithHandler()
                                              throws java.lang.Exception
Throws:
java.lang.Exception

testOverwriteExceptionWorkspace

public void testOverwriteExceptionWorkspace()
                                     throws java.lang.Exception
Throws:
java.lang.Exception

testOverwriteExceptionSession

public void testOverwriteExceptionSession()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

doTestNodeTypeConstraintViolation

public void doTestNodeTypeConstraintViolation(boolean useWorkspace,
                                              boolean useHandler)
                                       throws java.lang.Exception
Create a node named ntBase with node type nt:base and creates a tree in the repository which will be exported and reimported below the node ntBase.

Parameters:
useWorkspace -
useHandler -
Throws:
javax.jcr.RepositoryException
java.io.FileNotFoundException
java.io.IOException
java.lang.Exception

testNodeTypeConstraintViolationWorkspaceWithHandler

public void testNodeTypeConstraintViolationWorkspaceWithHandler()
                                                         throws java.lang.Exception
Throws:
java.lang.Exception

testNodeTypeConstraintViolationSessionWithHandler

public void testNodeTypeConstraintViolationSessionWithHandler()
                                                       throws java.lang.Exception
Throws:
java.lang.Exception

testNodeTypeConstraintViolationWorkspace

public void testNodeTypeConstraintViolationWorkspace()
                                              throws java.lang.Exception
Throws:
java.lang.Exception

testNodeTypeConstraintViolationSession

public void testNodeTypeConstraintViolationSession()
                                            throws java.lang.Exception
Throws:
java.lang.Exception

testSessionImportXml

public void testSessionImportXml()
                          throws javax.jcr.RepositoryException,
                                 java.io.IOException
Makes sure that importing into the session does not save anything if the session is closed.

Throws:
javax.jcr.RepositoryException
java.io.IOException

testSessionGetContentHandler

public void testSessionGetContentHandler()
                                  throws java.lang.Exception
Makes sure that importing into the session does not save anything if the session is closed.

Throws:
java.lang.Exception

doImport

public void doImport(java.lang.String absPath,
                     java.io.FileInputStream in,
                     boolean useWorkspace,
                     boolean useHandler)
              throws java.lang.Exception
Helper method which imports the given FileInputStream using Workspace or Session and via the methods importXML respective getImportContentHandler. Teh target node of the import is specified with its absolut path.

Parameters:
absPath -
in -
useWorkspace -
useHandler -
Throws:
javax.jcr.RepositoryException
java.io.IOException
java.lang.Exception

doImportNoSave

public void doImportNoSave(java.lang.String absPath,
                           java.io.FileInputStream in,
                           boolean useHandler)
                    throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_stream_workspace_skipBinary_noRecurse

public void testExportSysView_stream_workspace_skipBinary_noRecurse()
                                                             throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_stream_workspace_skipBinary_recurse

public void testExportSysView_stream_workspace_skipBinary_recurse()
                                                           throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_stream_workspace_saveBinary_noRecurse

public void testExportSysView_stream_workspace_saveBinary_noRecurse()
                                                             throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_stream_workspace_saveBinary_recurse

public void testExportSysView_stream_workspace_saveBinary_recurse()
                                                           throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_stream_session_skipBinary_noRecurse

public void testExportSysView_stream_session_skipBinary_noRecurse()
                                                           throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_stream_session_skipBinary_recurse

public void testExportSysView_stream_session_skipBinary_recurse()
                                                         throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_stream_session_saveBinary_noRecurse

public void testExportSysView_stream_session_saveBinary_noRecurse()
                                                           throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_stream_session_saveBinary_recurse

public void testExportSysView_stream_session_saveBinary_recurse()
                                                         throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_handler_workspace_skipBinary_noRecurse

public void testExportSysView_handler_workspace_skipBinary_noRecurse()
                                                              throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_handler_workspace_skipBinary_recurse

public void testExportSysView_handler_workspace_skipBinary_recurse()
                                                            throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_handler_workspace_saveBinary_noRecurse

public void testExportSysView_handler_workspace_saveBinary_noRecurse()
                                                              throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_handler_workspace_saveBinary_recurse

public void testExportSysView_handler_workspace_saveBinary_recurse()
                                                            throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_handler_session_skipBinary_noRecurse

public void testExportSysView_handler_session_skipBinary_noRecurse()
                                                            throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_handler_session_skipBinary_recurse

public void testExportSysView_handler_session_skipBinary_recurse()
                                                          throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_handler_session_saveBinary_noRecurse

public void testExportSysView_handler_session_saveBinary_noRecurse()
                                                            throws java.lang.Exception
Throws:
java.lang.Exception

testExportSysView_handler_session_saveBinary_recurse

public void testExportSysView_handler_session_saveBinary_recurse()
                                                          throws java.lang.Exception
Throws:
java.lang.Exception

importRepository

public void importRepository(boolean useHandler,
                             boolean workspace)
                      throws java.lang.Exception
Imports the repository

Parameters:
useHandler - True = use the import handler, false = use file input stream
workspace - True = import into workspace, false = import into session
Throws:
java.lang.Exception


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.