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  File file
           
protected  boolean NORECURSE
           
protected  boolean RECURSE
           
protected  boolean SAVEBINARY
           
protected  Session session
           
protected  boolean SESSION
           
protected  boolean SKIPBINARY
           
protected  boolean STREAM
           
protected  org.apache.jackrabbit.test.api.TreeComparator treeComparator
           
protected  Workspace workspace
           
protected  boolean WORKSPACE
           
 
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
SerializationTest()
           
 
Method Summary
 void doImport(String absPath, 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(String absPath, 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  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
cleanUp, cleanUpTestRoot, createRandomString, ensureCanSetProperty, ensureCanSetProperty, ensureCanSetProperty, ensureMultipleWorkspacesSupported, getNonExistingWorkspaceName, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

workspace

protected Workspace workspace

file

protected 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 Session session
Constructor Detail

SerializationTest

public SerializationTest()
Method Detail

setUp

public void setUp()
           throws RepositoryException,
                  Exception
Overrides:
setUp in class AbstractJCRTest
Throws:
RepositoryException
Exception

tearDown

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

initVersioningException

protected Node initVersioningException(boolean returnParent)
                                throws RepositoryException,
                                       NotExecutableException,
                                       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:
RepositoryException
NotExecutableException
IOException

doTestVersioningExceptionFileParent

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

doTestVersioningExceptionFileChild

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

testVersioningExceptionFileParentWorkspaceContentHandler

public void testVersioningExceptionFileParentWorkspaceContentHandler()
                                                              throws Exception
Throws:
Exception

testVersioningExceptionFileParentSessionContentHandler

public void testVersioningExceptionFileParentSessionContentHandler()
                                                            throws Exception
Throws:
Exception

testVersioningExceptionFileParentWorkspace

public void testVersioningExceptionFileParentWorkspace()
                                                throws Exception
Throws:
Exception

testVersioningExceptionFileParentSession

public void testVersioningExceptionFileParentSession()
                                              throws Exception
Throws:
Exception

testVersioningExceptionFileChildWorkspaceContentHandler

public void testVersioningExceptionFileChildWorkspaceContentHandler()
                                                             throws Exception
Throws:
Exception

testVersioningExceptionFileChildSessionContentHandler

public void testVersioningExceptionFileChildSessionContentHandler()
                                                           throws Exception
Throws:
Exception

testVersioningExceptionFileChildWorkspace

public void testVersioningExceptionFileChildWorkspace()
                                               throws Exception
Throws:
Exception

testVersioningExceptionFileChildSession

public void testVersioningExceptionFileChildSession()
                                             throws Exception
Throws:
Exception

doTestLockException

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

Throws:
Exception

testLockExceptionWorkspaceWithHandler

public void testLockExceptionWorkspaceWithHandler()
                                           throws Exception
Throws:
Exception

testLockExceptionSessionWithHandler

public void testLockExceptionSessionWithHandler()
                                         throws Exception
Throws:
Exception

testLockExceptionWorkspace

public void testLockExceptionWorkspace()
                                throws Exception
Throws:
Exception

testLockExceptionSession

public void testLockExceptionSession()
                              throws Exception
Throws:
Exception

testInvalidXmlThrowsSaxException

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

Throws:
IOException
ParserConfigurationException

testInvalidXmlThrowsInvalidSerializedDataException

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

Throws:
RepositoryException
IOException

testWorkspaceGetImportContentHandlerExceptions

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

Throws:
RepositoryException

testSessionGetImportContentHandlerExceptions

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

Throws:
RepositoryException

testSessionImportXmlExceptions

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

Throws:
RepositoryException
IOException

testWorkspaceImportXmlExceptions

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

Throws:
RepositoryException
IOException

doTestOverwriteException

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

Throws:
Exception

testOverwriteExceptionWorkspaceWithHandler

public void testOverwriteExceptionWorkspaceWithHandler()
                                                throws Exception
Throws:
Exception

testOverwriteExceptionSessionWithHandler

public void testOverwriteExceptionSessionWithHandler()
                                              throws Exception
Throws:
Exception

testOverwriteExceptionWorkspace

public void testOverwriteExceptionWorkspace()
                                     throws Exception
Throws:
Exception

testOverwriteExceptionSession

public void testOverwriteExceptionSession()
                                   throws Exception
Throws:
Exception

doTestNodeTypeConstraintViolation

public void doTestNodeTypeConstraintViolation(boolean useWorkspace,
                                              boolean useHandler)
                                       throws 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:
RepositoryException
FileNotFoundException
IOException
Exception

testNodeTypeConstraintViolationWorkspaceWithHandler

public void testNodeTypeConstraintViolationWorkspaceWithHandler()
                                                         throws Exception
Throws:
Exception

testNodeTypeConstraintViolationSessionWithHandler

public void testNodeTypeConstraintViolationSessionWithHandler()
                                                       throws Exception
Throws:
Exception

testNodeTypeConstraintViolationWorkspace

public void testNodeTypeConstraintViolationWorkspace()
                                              throws Exception
Throws:
Exception

testNodeTypeConstraintViolationSession

public void testNodeTypeConstraintViolationSession()
                                            throws Exception
Throws:
Exception

testSessionImportXml

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

Throws:
RepositoryException
IOException

testSessionGetContentHandler

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

Throws:
Exception

doImport

public void doImport(String absPath,
                     FileInputStream in,
                     boolean useWorkspace,
                     boolean useHandler)
              throws 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:
RepositoryException
IOException
Exception

doImportNoSave

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

testExportSysView_stream_workspace_skipBinary_noRecurse

public void testExportSysView_stream_workspace_skipBinary_noRecurse()
                                                             throws Exception
Throws:
Exception

testExportSysView_stream_workspace_skipBinary_recurse

public void testExportSysView_stream_workspace_skipBinary_recurse()
                                                           throws Exception
Throws:
Exception

testExportSysView_stream_workspace_saveBinary_noRecurse

public void testExportSysView_stream_workspace_saveBinary_noRecurse()
                                                             throws Exception
Throws:
Exception

testExportSysView_stream_workspace_saveBinary_recurse

public void testExportSysView_stream_workspace_saveBinary_recurse()
                                                           throws Exception
Throws:
Exception

testExportSysView_stream_session_skipBinary_noRecurse

public void testExportSysView_stream_session_skipBinary_noRecurse()
                                                           throws Exception
Throws:
Exception

testExportSysView_stream_session_skipBinary_recurse

public void testExportSysView_stream_session_skipBinary_recurse()
                                                         throws Exception
Throws:
Exception

testExportSysView_stream_session_saveBinary_noRecurse

public void testExportSysView_stream_session_saveBinary_noRecurse()
                                                           throws Exception
Throws:
Exception

testExportSysView_stream_session_saveBinary_recurse

public void testExportSysView_stream_session_saveBinary_recurse()
                                                         throws Exception
Throws:
Exception

testExportSysView_handler_workspace_skipBinary_noRecurse

public void testExportSysView_handler_workspace_skipBinary_noRecurse()
                                                              throws Exception
Throws:
Exception

testExportSysView_handler_workspace_skipBinary_recurse

public void testExportSysView_handler_workspace_skipBinary_recurse()
                                                            throws Exception
Throws:
Exception

testExportSysView_handler_workspace_saveBinary_noRecurse

public void testExportSysView_handler_workspace_saveBinary_noRecurse()
                                                              throws Exception
Throws:
Exception

testExportSysView_handler_workspace_saveBinary_recurse

public void testExportSysView_handler_workspace_saveBinary_recurse()
                                                            throws Exception
Throws:
Exception

testExportSysView_handler_session_skipBinary_noRecurse

public void testExportSysView_handler_session_skipBinary_noRecurse()
                                                            throws Exception
Throws:
Exception

testExportSysView_handler_session_skipBinary_recurse

public void testExportSysView_handler_session_skipBinary_recurse()
                                                          throws Exception
Throws:
Exception

testExportSysView_handler_session_saveBinary_noRecurse

public void testExportSysView_handler_session_saveBinary_noRecurse()
                                                            throws Exception
Throws:
Exception

testExportSysView_handler_session_saveBinary_recurse

public void testExportSysView_handler_session_saveBinary_recurse()
                                                          throws Exception
Throws:
Exception

importRepository

public void importRepository(boolean useHandler,
                             boolean workspace)
                      throws 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:
Exception


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