org.silverpeas.attachment.repository
Class JcrTest

java.lang.Object
  extended by org.silverpeas.attachment.repository.JcrTest
Direct Known Subclasses:
WebdavDocumentRepositoryTest.JcrWebdavRepositoryTest, WebdavServiceTest.JcrWebdavServiceTest

public abstract class JcrTest
extends Object

This class handle a JCR test with using a Spring context.


Constructor Summary
JcrTest()
           
 
Method Summary
 SimpleDocument assertContent(String uuId, String language, String expectedContent)
          Common method to assert the content for a language of a document.
 void assertDocumentDoesNotExist(String uuId)
          Common method to assert a document existence.
 void assertDocumentExists(String uuId)
          Common method to assert a document existence.
 SimpleDocument createAttachmentForTest(SimpleDocument document, SimpleAttachment attachment, String content)
          Creates an Image Master Node into the JCR
 SimpleAttachment defaultDEContent()
           
 SimpleDocument defaultDocument(String instanceId, String foreignId)
           
protected  SimpleDocument defaultDocument(String instanceId, String foreignId, SimpleAttachment file)
           
protected  SimpleAttachment defaultENContent()
           
 SimpleAttachment defaultFRContent()
           
 void execute()
          Execute the test with its context.
 org.springframework.context.support.ClassPathXmlApplicationContext getAppContext()
           
protected  byte[] getBinaryContent(javax.jcr.Property property)
          Gets the Binary content of a JCR node property.
protected  String getBinaryContentAsString(javax.jcr.Property property)
          Gets the Binary content of a JCR node property as a String.
protected  SimpleDocument getDocumentById(String uuId)
           
 SimpleDocument getDocumentById(String uuId, String language)
           
protected  javax.jcr.Node getRelativeNode(javax.jcr.Node parentNode, String jcrPath)
          Gets from the specified parent node the child node that satisfies the given jcrPath.
protected  javax.jcr.Node getSingleChildNode(javax.jcr.Node node)
          Gets the single child node of a node.
 Date getTestStartDate()
           
protected  List<String> listPathesFrom(javax.jcr.Node parentNode)
          Lists all entire pathes that exists from the specified node (recursive treatment).
protected  List<String> listPathesFrom(javax.jcr.Node parentNode, int deep)
          Lists all entire pathes that exists from the specified node (recursive treatment).
protected  Date randomDate()
           
abstract  void run()
           
 void setAppContext(org.springframework.context.support.ClassPathXmlApplicationContext appContext)
           
protected  void setBinaryContent(javax.jcr.Property property, byte[] content)
          Sets the Binary content of a JCR node property.
protected  SimpleDocument updateAttachmentForTest(SimpleDocument document)
          Creates an Image Master Node into the JCR
 SimpleDocument updateAttachmentForTest(SimpleDocument document, String language, String content)
          Creates an Image Master Node into the JCR
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JcrTest

public JcrTest()
Method Detail

getAppContext

public org.springframework.context.support.ClassPathXmlApplicationContext getAppContext()

setAppContext

public void setAppContext(org.springframework.context.support.ClassPathXmlApplicationContext appContext)

getTestStartDate

public Date getTestStartDate()

run

public abstract void run()
                  throws Exception
Throws:
Exception

execute

public void execute()
             throws Exception
Execute the test with its context.

Throws:
Exception

assertDocumentExists

public void assertDocumentExists(String uuId)
                          throws Exception
Common method to assert a document existence.

Parameters:
uuId - the uuId to retrieve the document.
Throws:
Exception

assertDocumentDoesNotExist

public void assertDocumentDoesNotExist(String uuId)
                                throws Exception
Common method to assert a document existence.

Parameters:
uuId - the uuId to retrieve the document.
Throws:
Exception

assertContent

public SimpleDocument assertContent(String uuId,
                                    String language,
                                    String expectedContent)
                             throws Exception
Common method to assert the content for a language of a document.

Parameters:
uuId - the uuId to retrieve the document.
language - the language in which the content must be verified.
expectedContent - if null, the content for the language does not exist.
Returns:
the document loaded for assertions.
Throws:
Exception

getDocumentById

public SimpleDocument getDocumentById(String uuId,
                                      String language)
                               throws Exception
Throws:
Exception

getDocumentById

protected SimpleDocument getDocumentById(String uuId)
                                  throws Exception
Throws:
Exception

defaultDocument

protected SimpleDocument defaultDocument(String instanceId,
                                         String foreignId,
                                         SimpleAttachment file)

defaultDocument

public SimpleDocument defaultDocument(String instanceId,
                                      String foreignId)

defaultENContent

protected SimpleAttachment defaultENContent()

defaultFRContent

public SimpleAttachment defaultFRContent()

defaultDEContent

public SimpleAttachment defaultDEContent()

randomDate

protected Date randomDate()

createAttachmentForTest

public SimpleDocument createAttachmentForTest(SimpleDocument document,
                                              SimpleAttachment attachment,
                                              String content)
                                       throws Exception
Creates an Image Master Node into the JCR

Parameters:
document -
attachment -
content -
Returns:
Throws:
Exception

updateAttachmentForTest

public SimpleDocument updateAttachmentForTest(SimpleDocument document,
                                              String language,
                                              String content)
                                       throws Exception
Creates an Image Master Node into the JCR

Parameters:
document -
language -
content -
Returns:
Throws:
Exception

updateAttachmentForTest

protected SimpleDocument updateAttachmentForTest(SimpleDocument document)
                                          throws Exception
Creates an Image Master Node into the JCR

Parameters:
document -
Returns:
Throws:
Exception

getSingleChildNode

protected javax.jcr.Node getSingleChildNode(javax.jcr.Node node)
                                     throws Exception
Gets the single child node of a node. If no node exists or sevreal node exists, a failed assertion is performed.

Parameters:
node - the parent node.
Returns:
the single child node.
Throws:
Exception

getBinaryContentAsString

protected String getBinaryContentAsString(javax.jcr.Property property)
                                   throws Exception
Gets the Binary content of a JCR node property as a String.

Parameters:
property - the JCR property that must contains a binary content.
Returns:
the binary content as a String.
Throws:
Exception

getBinaryContent

protected byte[] getBinaryContent(javax.jcr.Property property)
                           throws Exception
Gets the Binary content of a JCR node property.

Parameters:
property - the JCR property that must contains a binary content.
Returns:
the binary content.
Throws:
Exception

setBinaryContent

protected void setBinaryContent(javax.jcr.Property property,
                                byte[] content)
                         throws Exception
Sets the Binary content of a JCR node property.

Parameters:
property - the JCR property that must contains a binary content.
Throws:
Exception

getRelativeNode

protected javax.jcr.Node getRelativeNode(javax.jcr.Node parentNode,
                                         String jcrPath)
Gets from the specified parent node the child node that satisfies the given jcrPath.

Parameters:
parentNode - the parent node from which the JCR path is guessed.
jcrPath - the JCR path to find.
Returns:
the JCR node instance if it exists, null otherwise.

listPathesFrom

protected List<String> listPathesFrom(javax.jcr.Node parentNode)
                               throws javax.jcr.RepositoryException
Lists all entire pathes that exists from the specified node (recursive treatment).

Parameters:
parentNode - the parent node.
Returns:
the list of entire pathes, null if the specified node does not exist anymore.
Throws:
javax.jcr.RepositoryException

listPathesFrom

protected List<String> listPathesFrom(javax.jcr.Node parentNode,
                                      int deep)
                               throws javax.jcr.RepositoryException
Lists all entire pathes that exists from the specified node (recursive treatment).

Parameters:
parentNode - the parent node.
deep - the maximum number sub-nodes to reach.
Returns:
the list of entire pathes, null if the specified node does not exist anymore.
Throws:
javax.jcr.RepositoryException


Copyright © 2016 Silverpeas. All Rights Reserved.