public class DocumentViewImportTest extends AbstractJCRTest
DocumentViewImportTest
Tests importXML and
getImportContentHandler methods of the Workspace and Session class. Also
tests the UuidBehaviour flag.Modifier and Type | Field and Description |
---|---|
protected static String |
attributeName |
protected static String |
attributeValue |
protected static String |
childElem |
protected boolean |
CONTENTHANDLER |
protected static String |
decodedAttributeName |
protected static String |
decodedAttributeValue |
protected static String |
decodedElemName |
protected DocumentBuilder |
dom |
protected static String |
encodedAttributeName |
protected static String |
encodedAttributeValue |
protected static String |
encodedElemName |
protected DocumentBuilderFactory |
factory |
protected File |
file |
protected static String |
grandChildElem |
protected javax.jcr.NamespaceRegistry |
nsp |
protected javax.jcr.nodetype.NodeTypeManager |
ntManager |
protected String |
ntUnstructured |
protected String |
referenced |
protected String |
referencing |
protected static String |
refNodeElem |
protected String |
refTarget |
protected javax.jcr.Node |
refTargetNode |
protected boolean |
respectMixRef |
protected static String |
rootElem |
protected javax.jcr.Session |
session |
protected boolean |
SESSION |
protected boolean |
STREAM |
protected String |
target |
protected javax.jcr.Node |
targetNode |
protected String |
TEST_PREFIX |
protected String |
TEST_URI |
protected String |
unusedPrefix |
protected String |
unusedURI |
protected int |
uuidBehaviour |
protected javax.jcr.Workspace |
workspace |
protected boolean |
WORKSPACE |
protected String |
XML_NS |
protected String |
xmltext |
protected static String |
xmltextElem |
isReadOnly, jcrBaseVersion, jcrCopiedFrom, jcrCreated, jcrFrozenNode, jcrFrozenUuid, jcrIsCheckedOut, jcrlockIsDeep, jcrLockOwner, jcrMergeFailed, jcrMixinTypes, jcrPredecessors, jcrPrimaryType, jcrRootVersion, jcrSuccessors, jcrSystem, jcrUUID, jcrVersionHistory, mixLockable, mixReferenceable, mixShareable, mixSimpleVersionable, mixTitle, 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, testNodeTypeTestRoot, testPath, testRoot, testRootNode, vf, workspaceName
Constructor and Description |
---|
DocumentViewImportTest() |
Modifier and Type | Method and Description |
---|---|
void |
checkImportDocumentView_IMPORT_UUID_COLLISION_REMOVE_EXISTING()
Checks ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING i.e that
the existing node is removed in case of uuid collision.
|
void |
checkImportDocumentView_IMPORT_UUID_COLLISION_REPLACE_EXISTING()
Checks ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING i.e that
the existing node is replaced by the imported one node when uuid
collision occurs.
|
void |
checkImportDocumentView_IMPORT_UUID_COLLISION_THROW()
Checks ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW i.e that a
ItemExistsException is thrown in case of importing with an input stream
or a SAXException is thrown in case of importing with a ContentHandler.
|
void |
checkImportDocumentView_IMPORT_UUID_CREATE_NEW()
Checks
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW i.e. |
void |
checkImportSimpleXMLTree()
Tests if the simple xml document defined in createSimpleDocument() is
imported correctly according the specification rules given in 7.3.2
|
void |
checkNamespaceAdded()
Checks if a namespace not yet existing in the repository is registered
after an according document import.
|
void |
checkXmlTextNode(javax.jcr.Node node)
Tests if xmltext in a body of a xml element is correctly imported to a
node with name jcr:xmltext and that the value of the text is stored in
the singlevalued jcr:xmlcharacters property of String type.
|
protected javax.jcr.Node |
createAncestors(String absPath) |
String |
createReferenceableNode(String name)
Creates a node with given name below the testRootNode which will be
referenced by the node nodeName2 and returns the UUID assigned to the
created node.
|
Document |
createSimpleDocument()
Creates a document with some nodes and props for Namespace adding test
and for correct tree structure tests after having imported.
|
void |
doTestGetImportContentHandler()
Tests getImportContentHandler method with uuidBehaviour
IMPORT_UUID_CREATE_NEW.
|
void |
doTestImportXML()
Tests importXML method with uuidBehaviour IMPORT_UUID_CREATE_NEW.
|
void |
doTestSameUUIDAtAncestor(boolean withWorkspace,
boolean withHandler)
Tests correct failure of importing a element wit the same UUID as the target node or
an ancestor of it in case of uuidBehavior IMPORT_UUID_COLLISION_REMOVE_EXISTING.
|
protected String |
getUnusedPrefix()
Returns a namespace prefix that currently not used in the namespace
registry.
|
protected String |
getUnusedURI()
Returns a namespace URI that currently not used in the namespace
registry.
|
void |
importRefNodeDocument(String absPath,
String uuid,
int uuidBehaviour,
boolean withWorkspace,
boolean withHandler)
Creates a document with a element rootElem containing a jcr:uuid
attribute with the given uuid as value.
|
void |
importWithHandler(String absPath,
Document document,
int uuidBehaviour,
boolean withWorkspace)
Imports a given document using the ContentHandler received either with
Workspace.getImportContentHandler or Session.getImportContentHandler.
|
protected void |
importXML(String absPath,
Document document,
int uuidBehaviour,
boolean withWorkspace)
Imports a given document using either Workspace.importXML or
Session.importXML method.
|
boolean |
isMixRefRespected()
Tests if jcr:uuid property of mix:referenceable nodetype is respected.
|
void |
serialize(Document document) |
void |
setUp()
Sets up the fixture for the test cases.
|
boolean |
supportsNodeType(String ntName) |
void |
tearDown() |
void |
testSameUUIDAtAncestorSession() |
void |
testSameUUIDAtAncestorSessionHandler() |
void |
testSameUUIDAtAncestorWorkspace() |
void |
testSameUUIDAtAncestorWorkspaceHandler() |
void |
testSessionGetImportContentHandler() |
void |
testSessionImportXml() |
void |
testWorkspaceGetImportContentHandler() |
void |
testWorkspaceImportXml() |
checkSupportedOption, cleanUp, cleanUpTestRoot, createRandomString, ensureCanSetProperty, ensureCanSetProperty, ensureCanSetProperty, ensureKnowsNodeType, ensureLockingSupported, ensureMixinType, ensureMultipleWorkspacesSupported, getHelper, getJcrValue, getLocalName, getNonExistingWorkspaceName, getPrefix, getProperty, getProperty, getQualifiedName, getSize, isSupported, needsMixin, run
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, runBare, runTest, setName, toString
protected final boolean WORKSPACE
protected final boolean SESSION
protected boolean CONTENTHANDLER
protected boolean STREAM
protected String target
protected String refTarget
protected javax.jcr.Session session
protected javax.jcr.Workspace workspace
protected javax.jcr.nodetype.NodeTypeManager ntManager
protected javax.jcr.NamespaceRegistry nsp
protected String ntUnstructured
protected File file
protected String referenced
protected String referencing
protected javax.jcr.Node targetNode
protected javax.jcr.Node refTargetNode
protected String unusedPrefix
protected String unusedURI
protected final String TEST_PREFIX
protected final String TEST_URI
protected final String XML_NS
protected static final String rootElem
protected static final String refNodeElem
protected static final String xmltextElem
protected static final String childElem
protected static final String grandChildElem
protected static final String encodedElemName
protected static final String decodedElemName
protected static final String attributeName
protected static final String attributeValue
protected static final String encodedAttributeName
protected static final String decodedAttributeName
protected static final String encodedAttributeValue
protected static final String decodedAttributeValue
protected String xmltext
protected boolean respectMixRef
protected int uuidBehaviour
protected DocumentBuilderFactory factory
protected DocumentBuilder dom
public void setUp() throws Exception
Exception
public void testWorkspaceGetImportContentHandler() throws Exception
Exception
public void testSessionGetImportContentHandler() throws Exception
Exception
public void doTestImportXML() throws Exception
Additionally it checks the uuidBehaviour flag if the jcr:uuid property is respected during import.
javax.jcr.RepositoryException
IOException
SAXException
NotExecutableException
Exception
public void doTestGetImportContentHandler() throws Exception
Additionally it checks the uuidBehaviour flag if the jcr:uuid property is respected during import.
javax.jcr.RepositoryException
SAXException
IOException
NotExecutableException
Exception
public void checkImportSimpleXMLTree() throws javax.jcr.RepositoryException, IOException
javax.jcr.RepositoryException
IOException
public void checkXmlTextNode(javax.jcr.Node node) throws javax.jcr.RepositoryException, IOException
javax.jcr.RepositoryException
IOException
public void checkNamespaceAdded() throws javax.jcr.RepositoryException, IOException
javax.jcr.RepositoryException
IOException
public void checkImportDocumentView_IMPORT_UUID_CREATE_NEW() throws Exception
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW
i.e. that a node
receives a new uuid when imported in any case.Exception
public void checkImportDocumentView_IMPORT_UUID_COLLISION_REMOVE_EXISTING() throws Exception
Exception
public void checkImportDocumentView_IMPORT_UUID_COLLISION_REPLACE_EXISTING() throws Exception
Exception
public void checkImportDocumentView_IMPORT_UUID_COLLISION_THROW() throws Exception
javax.jcr.RepositoryException
IOException
Exception
public void doTestSameUUIDAtAncestor(boolean withWorkspace, boolean withHandler) throws Exception
Exception
public void testSameUUIDAtAncestorWorkspaceHandler() throws Exception
Exception
public void testSameUUIDAtAncestorWorkspace() throws Exception
Exception
public void testSameUUIDAtAncestorSessionHandler() throws Exception
Exception
public void testSameUUIDAtAncestorSession() throws Exception
Exception
public Document createSimpleDocument()
protected void importXML(String absPath, Document document, int uuidBehaviour, boolean withWorkspace) throws javax.jcr.RepositoryException, IOException
absPath
- the absPath to the parent node where to import the
documentdocument
- the document to importuuidBehaviour
- how the uuid collisions should be handledwithWorkspace
- if workspace or session interface should be usedjavax.jcr.RepositoryException
IOException
public void importWithHandler(String absPath, Document document, int uuidBehaviour, boolean withWorkspace) throws Exception
absPath
- the absPath to the parent node where to import the
documentdocument
- the document to importuuidBehaviour
- how the uuid collisions should be handledwithWorkspace
- if workspace or session interface should be usedjavax.jcr.RepositoryException
SAXException
IOException
Exception
public boolean isMixRefRespected() throws javax.jcr.RepositoryException, IOException
javax.jcr.RepositoryException
IOException
public String createReferenceableNode(String name) throws javax.jcr.RepositoryException, NotExecutableException
name
- javax.jcr.RepositoryException
NotExecutableException
- if the created node is not referenceable
and cannot be made referenceable by adding mix:referenceable.public void importRefNodeDocument(String absPath, String uuid, int uuidBehaviour, boolean withWorkspace, boolean withHandler) throws Exception
uuid
- uuidBehaviour
- withWorkspace
- withHandler
- javax.jcr.RepositoryException
IOException
Exception
protected javax.jcr.Node createAncestors(String absPath) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public void serialize(Document document) throws IOException
IOException
public boolean supportsNodeType(String ntName) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
protected String getUnusedPrefix() throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
protected String getUnusedURI() throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
Copyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.