|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
fri.util.database.jpa.commons.AbstractJpaTest
fri.util.database.jpa.tree.AbstractTreeTest<D,N>
public abstract class AbstractTreeTest<D extends TreeDao<N>,N extends TreeNode>
Tests all public methods of TreeDao with following sample tree:
ROOT - A - A1 - B - B1 - B2 - C - C1 - C11TODO: add a concurrent test, e.g. reading nodes while adding, moving and copying.
Field Summary | |
---|---|
protected static java.lang.String |
COPIED_NAME_PREFIX
Constant prefix for testing node renames. |
protected static java.lang.String[][] |
UNIQUE_PROPERTY_NAMES
Unique constraint property names to test. |
Fields inherited from class fri.util.database.jpa.commons.AbstractJpaTest |
---|
ECLIPSELINK_PERSISTENCE_UNIT_NAME, HIBERNATE_PERSISTENCE_UNIT_NAME |
Constructor Summary | |
---|---|
AbstractTreeTest()
|
Method Summary | |
---|---|
protected void |
assertTreeCacheable(java.util.List<N> treeList)
Check depth-first order. |
protected DbSession |
beginDbTransaction(java.lang.String message)
|
protected abstract void |
checkTreeIntegrity(DbSession session,
N root)
|
protected void |
commitDbTransaction(java.lang.String message)
|
protected java.io.Serializable |
createTree()
|
protected java.io.Serializable |
createTree(java.lang.String rootName)
|
protected java.io.Serializable |
createTree(java.lang.String rootName,
boolean useLowerCaseNames)
|
protected N |
findByName(N root,
java.lang.String name)
|
protected D |
getDao()
|
protected java.util.List<N> |
getFullTreeForIntegrityCheck(N root)
|
protected abstract java.lang.String |
getName(N node)
For a concrete POJO we must return properties from it. |
protected boolean |
isTestCopy()
|
protected abstract D |
newDao(DbSession session)
|
protected DbSession |
newDbSession(java.lang.String message)
|
protected abstract N |
newTreePojo(java.lang.String name)
Factory method for new NestedSetsTreePojos. |
protected abstract UniqueTreeConstraint<N> |
newUniqueChildrenTreeConstraintImpl()
|
protected abstract UniqueTreeConstraint<N> |
newUniqueChildrenTreeConstraintImplWithoutRoots()
|
protected abstract UniqueTreeConstraint<N> |
newUniqueWholeTreeConstraintImpl()
|
protected abstract UniqueTreeConstraint<N> |
newUniqueWholeTreeConstraintImplWithoutRoots()
|
static void |
outputTree(java.util.List<? extends TreeNode> nodes)
|
static void |
outputTree(TreeNode root,
TreeDao dao)
Utility method. |
protected abstract void |
renameBeforeCopy(N node)
|
protected void |
rollbackDbTransaction(java.lang.String message)
|
protected void |
setName(N entity,
N root,
java.lang.String name)
Name is unique, so a check is done here explicitly before calling entity.setName() . |
protected abstract void |
setNameNotConstraintChecking(N entity,
java.lang.String name)
|
protected void |
setValid(N entity)
To be overridden by temporal test. |
protected void |
tearDown()
Overridden to clean-up test table(s). |
void |
testAddToTree()
Tests adding tree nodes. |
void |
testBigTree()
Create a big tree. |
void |
testCopiedNodeRenamer()
Test renaming nodes while copying. |
void |
testCopyRootToBeRoot()
Test copying root to be another root. |
void |
testCopyToOtherRoot()
Test copy a sub-tree to another root. |
void |
testCopyToSelf()
Test copy a sub-tree to itself, which is cloning a tree. |
void |
testCopyTree()
Test copy a sub-tree without unique constraint on database level. |
void |
testCopyTreeBelowItselfFails()
Test copy a sub-tree below itself. |
void |
testCopyTreeFailsWithUniqueConstraint()
Test copy a sub-tree. |
void |
testCopyTreeToAlteredName()
Test copy a sub-tree to another name. |
void |
testCopyTreeToAlteredNameWithUniqueConstraint()
Test copy a sub-tree to another name with unique constraint turned on. |
void |
testCopyTreeToBeRoot()
Test copying trees to be roots. |
void |
testCopyTreeWithPrecedingDelete()
Test copy a sub-tree without unique constraint on database level. |
void |
testCreateAndRemoveRoot()
|
void |
testCreateTree()
Tests creation of a tree, including addChild(). |
void |
testDatabaseToBeCaseSensitive()
Especially for MySql, check that string-compares are case-sensitive! |
void |
testFindChildrenInCachedTree()
Demonstrates how to retrieve the tree structure from a list of all nodes under a root. |
void |
testGetRoots()
Tests reading all roots. |
void |
testIsBelow()
Tests reading parent of all tree nodes. |
void |
testIsRoot()
|
void |
testLevel()
Tests level of all tree nodes. |
void |
testMoveRootToOtherTree()
Test moving sub-trees to other roots. |
void |
testMoveToOtherTree()
Test moving sub-trees to other roots. |
void |
testMoveTree()
Tests moving subtrees in a tree. |
void |
testMoveTreeBelowItselfFails()
Test move a sub-tree below itself. |
void |
testMoveTreeToBeRoot()
Test moving tree to be roots. |
void |
testNonUniqueRootsButUniqueChildren()
|
void |
testNonUniqueRootsButWholeTreeUniqueNodes()
|
void |
testParent()
Tests reading parent of all tree nodes. |
void |
testPath()
Tests reading parents of tree nodes. |
void |
testRemoveAllTrees()
Tests removing all tree roots. |
void |
testRemoveFromTree()
Tests removing tree nodes. |
void |
testRemoveTree()
Tests removing tree roots. |
void |
testUniqueChildrenConstraint()
Test unique constraint for children. |
void |
testUniqueness()
Test unique constraint for root and sub-node. |
void |
testUniquenessWithDeletion()
Test unique constraint together with deletion, special for temporal extension. |
void |
testUniqueWholeTreeConstraintOnMove()
Test unique constraint for children. |
void |
testUpdateNode()
|
void |
testUpdateRootWithWholeTreeUniqueConstraint()
|
void |
testUpdateToSameNameWithUniqueConstraint()
|
Methods inherited from class fri.util.database.jpa.commons.AbstractJpaTest |
---|
beginTransaction, commitTransaction, getPersistenceUnitName, log, logAfterEnd, logBeforeEnd, logStart, rollbackTransaction, setUp |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, 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 |
---|
protected static final java.lang.String[][] UNIQUE_PROPERTY_NAMES
protected static final java.lang.String COPIED_NAME_PREFIX
Constructor Detail |
---|
public AbstractTreeTest()
Method Detail |
---|
public static final void outputTree(TreeNode root, TreeDao dao)
public static final void outputTree(java.util.List<? extends TreeNode> nodes)
public void testDatabaseToBeCaseSensitive() throws java.lang.Exception
java.lang.Exception
public void testCreateTree() throws java.lang.Exception
java.lang.Exception
protected void assertTreeCacheable(java.util.List<N> treeList)
public void testIsRoot() throws java.lang.Exception
java.lang.Exception
public void testCreateAndRemoveRoot() throws java.lang.Exception
java.lang.Exception
public void testUpdateNode() throws java.lang.Exception
java.lang.Exception
public void testUpdateToSameNameWithUniqueConstraint() throws java.lang.Exception
java.lang.Exception
public void testUpdateRootWithWholeTreeUniqueConstraint() throws java.lang.Exception
java.lang.Exception
public void testNonUniqueRootsButWholeTreeUniqueNodes() throws java.lang.Exception
java.lang.Exception
public void testNonUniqueRootsButUniqueChildren() throws java.lang.Exception
java.lang.Exception
public void testGetRoots() throws java.lang.Exception
java.lang.Exception
public void testLevel() throws java.lang.Exception
java.lang.Exception
public void testParent() throws java.lang.Exception
java.lang.Exception
public void testPath() throws java.lang.Exception
java.lang.Exception
public void testIsBelow() throws java.lang.Exception
java.lang.Exception
public void testAddToTree() throws java.lang.Exception
java.lang.Exception
public void testRemoveFromTree() throws java.lang.Exception
java.lang.Exception
public void testRemoveTree() throws java.lang.Exception
java.lang.Exception
public void testRemoveAllTrees() throws java.lang.Exception
java.lang.Exception
public void testMoveTree() throws java.lang.Exception
java.lang.Exception
public void testUniqueness() throws java.lang.Exception
java.lang.Exception
public void testUniquenessWithDeletion() throws java.lang.Exception
java.lang.Exception
public void testMoveTreeBelowItselfFails() throws java.lang.Exception
java.lang.Exception
public void testMoveToOtherTree() throws java.lang.Exception
java.lang.Exception
public void testMoveRootToOtherTree() throws java.lang.Exception
java.lang.Exception
public void testMoveTreeToBeRoot() throws java.lang.Exception
java.lang.Exception
public void testCopyTreeFailsWithUniqueConstraint() throws java.lang.Exception
java.lang.Exception
public void testCopyTree() throws java.lang.Exception
java.lang.Exception
public void testCopyTreeWithPrecedingDelete() throws java.lang.Exception
java.lang.Exception
public void testCopyTreeToAlteredName() throws java.lang.Exception
java.lang.Exception
public void testCopyTreeToAlteredNameWithUniqueConstraint() throws java.lang.Exception
java.lang.Exception
public void testCopyTreeBelowItselfFails() throws java.lang.Exception
java.lang.Exception
public void testCopyToSelf() throws java.lang.Exception
java.lang.Exception
public void testCopyToOtherRoot() throws java.lang.Exception
java.lang.Exception
public void testCopyTreeToBeRoot() throws java.lang.Exception
java.lang.Exception
public void testCopyRootToBeRoot() throws java.lang.Exception
java.lang.Exception
public void testCopiedNodeRenamer() throws java.lang.Exception
java.lang.Exception
public void testFindChildrenInCachedTree() throws java.lang.Exception
java.lang.Exception
public void testUniqueWholeTreeConstraintOnMove() throws java.lang.Exception
java.lang.Exception
public void testUniqueChildrenConstraint() throws java.lang.Exception
java.lang.Exception
public void testBigTree() throws UniqueConstraintViolationException
UniqueConstraintViolationException
protected abstract UniqueTreeConstraint<N> newUniqueWholeTreeConstraintImpl()
protected abstract UniqueTreeConstraint<N> newUniqueWholeTreeConstraintImplWithoutRoots()
protected abstract UniqueTreeConstraint<N> newUniqueChildrenTreeConstraintImpl()
protected abstract UniqueTreeConstraint<N> newUniqueChildrenTreeConstraintImplWithoutRoots()
protected void tearDown() throws java.lang.Exception
tearDown
in class AbstractJpaTest
java.lang.Exception
protected abstract D newDao(DbSession session)
protected final D getDao()
protected abstract N newTreePojo(java.lang.String name)
protected abstract java.lang.String getName(N node)
protected final void setName(N entity, N root, java.lang.String name) throws UniqueConstraintViolationException
entity.setName()
.
UniqueConstraintViolationException
protected abstract void setNameNotConstraintChecking(N entity, java.lang.String name)
protected abstract void checkTreeIntegrity(DbSession session, N root)
protected java.util.List<N> getFullTreeForIntegrityCheck(N root)
protected final boolean isTestCopy()
protected abstract void renameBeforeCopy(N node)
protected final DbSession beginDbTransaction(java.lang.String message)
protected DbSession newDbSession(java.lang.String message)
protected void commitDbTransaction(java.lang.String message)
protected void rollbackDbTransaction(java.lang.String message)
protected final N findByName(N root, java.lang.String name)
protected final java.io.Serializable createTree() throws UniqueConstraintViolationException
UniqueConstraintViolationException
protected final java.io.Serializable createTree(java.lang.String rootName) throws UniqueConstraintViolationException
UniqueConstraintViolationException
protected final java.io.Serializable createTree(java.lang.String rootName, boolean useLowerCaseNames) throws UniqueConstraintViolationException
UniqueConstraintViolationException
protected void setValid(N entity)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |