org.alfresco.repo.transfer
Class TransferServiceToBeRefactoredTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.springframework.test.ConditionalTestCase
              extended by org.springframework.test.AbstractSpringContextTests
                  extended by org.springframework.test.AbstractSingleSpringContextTests
                      extended by org.springframework.test.AbstractDependencyInjectionSpringContextTests
                          extended by org.springframework.test.AbstractTransactionalSpringContextTests
                              extended by org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
                                  extended by org.alfresco.util.BaseSpringTest
                                      extended by org.alfresco.util.BaseAlfrescoSpringTest
                                          extended by org.alfresco.repo.transfer.TransferServiceToBeRefactoredTest
All Implemented Interfaces:
junit.framework.Test

public class TransferServiceToBeRefactoredTest
extends BaseAlfrescoSpringTest

Unit test for TransferServiceImpl Contains some integration tests for the transfer service These tests need their transaction management to be re-factored then they can be re-instated into TransferServiceImplTest


Field Summary
 
Fields inherited from class org.alfresco.util.BaseAlfrescoSpringTest
actionService, authenticationComponent, authenticationService, nodeService, rootNodeRef, storeRef
 
Fields inherited from class org.alfresco.util.BaseSpringTest
sessionFactory
 
Fields inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
jdbcTemplate
 
Fields inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
transactionDefinition, transactionManager, transactionStatus
 
Fields inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_NO
 
Fields inherited from class org.springframework.test.AbstractSingleSpringContextTests
applicationContext
 
Fields inherited from class org.springframework.test.ConditionalTestCase
logger
 
Constructor Summary
TransferServiceToBeRefactoredTest()
           
 
Method Summary
protected  void onSetUp()
          Called during the transaction setup
 void runBare()
           
 void testCopyAlien()
          Test the behaviour with respect to copy of alien nodes.
 void testCopyTransferredNode()
          Test the behaviour with regard to copying transferred nodes.
 void testLocalAlienRestore()
          Test restore of a local node.
 void testMultiRepoTransfer()
          Transfer sync from multiple repos.
 void testMultiRepoTransferMove()
          Test the transfer method behaviour with respect to move and alien nodes.
 void testReadOnlyFlag()
          Transfer with read only flag Node tree for this test
 void testTransferInvadedByLocalAlienNodes()
          Test the transfer method behaviour with respect to sync with (local) alien nodes.
 void testTransferReport()
          Test the transfer report.
 void testTransferSyncNodes()
          Test the transfer method behaviour with respect to sync folders - sending a complete set of nodes and implying delete from the absence of an association.
 void testTransferWithPermissions()
          Test the transfer method with regard to permissions on a node.
 void testTwoRepoSync()
          Transfer sync from multiple repos.
 
Methods inherited from class org.alfresco.util.BaseAlfrescoSpringTest
createNode, onSetUpInTransaction, onTearDownInTransaction
 
Methods inherited from class org.alfresco.util.BaseSpringTest
flushAndClear, getConfigLocations, getSession, loadContext, setSessionFactory
 
Methods inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
countRowsInTable, deleteFromTables, executeSqlScript, getJdbcTemplate, setComplete, setDataSource, setSqlScriptEncoding
 
Methods inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
endTransaction, isDefaultRollback, isRollback, onSetUpBeforeTransaction, onTearDown, onTearDownAfterTransaction, preventTransaction, setDefaultRollback, setTransactionDefinition, setTransactionManager, startNewTransaction
 
Methods inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
getAutowireMode, injectDependencies, isDependencyCheck, isPopulateProtectedVariables, prepareTestInstance, setAutowireMode, setDependencyCheck, setPopulateProtectedVariables
 
Methods inherited from class org.springframework.test.AbstractSingleSpringContextTests
contextKey, createApplicationContext, createBeanDefinitionReader, customizeBeanFactory, getApplicationContext, getConfigPath, getConfigPaths, getLoadCount, loadContextLocations, prepareApplicationContext, setDirty, setUp, tearDown
 
Methods inherited from class org.springframework.test.AbstractSpringContextTests
addContext, contextKeyString, getContext, hasCachedContext, isContextKeyEmpty, setDirty
 
Methods inherited from class org.springframework.test.ConditionalTestCase
getDisabledTestCount, isDisabledInThisEnvironment, recordDisabled
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, 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
 

Constructor Detail

TransferServiceToBeRefactoredTest

public TransferServiceToBeRefactoredTest()
Method Detail

runBare

public void runBare()
             throws java.lang.Throwable
Overrides:
runBare in class org.springframework.test.ConditionalTestCase
Throws:
java.lang.Throwable

onSetUp

protected void onSetUp()
                throws java.lang.Exception
Called during the transaction setup

Overrides:
onSetUp in class org.springframework.test.AbstractTransactionalSpringContextTests
Throws:
java.lang.Exception

testTransferReport

public void testTransferReport()
                        throws java.lang.Exception
Test the transfer report. This is a unit test so it does some shenanigans to send to the same instance of alfresco.

Throws:
java.lang.Exception

testTransferSyncNodes

public void testTransferSyncNodes()
                           throws java.lang.Exception
Test the transfer method behaviour with respect to sync folders - sending a complete set of nodes and implying delete from the absence of an association. This is a unit test so it does some shenanigans to send to the same instance of alfresco. Tree of nodes A1 | | A2 A3 (Content Node) | A4 A5 (Content Node) Test steps - 1 add A1 transfer(sync) 2 add A2, A3, A4, A5 transfer(sync) 3 remove A2 transfer(sync) A4 and A5 should cascade delete on source 4 remove A3 transfer(sync) 5 add back A3 - new node ref transfer(sync) 6 add A2, A4, A5 transfer(sync) 7 test delete and restore of a single node remove A3 . transfer restore node A3 transfer 8 test delete and restore of a tree of nodes remove A2 (A4 and A5 should cascade delete on source as well) transfer restore node A2 (and A4 and A5 cascade restore) transfer

Throws:
java.lang.Exception

testTransferInvadedByLocalAlienNodes

public void testTransferInvadedByLocalAlienNodes()
                                          throws java.lang.Exception
Test the transfer method behaviour with respect to sync with (local) alien nodes. So we have Repository A transferring content and Repository B is the local repo that we add and delete alien nodes. In general an alien node will prevent deletion of the parent folders
 Tree of nodes
 
      A1
      |      |                      | 
      A2     A3 (Content Node)      B9 (Alien Content Node)
      |
   A4 A5 B10 (Alien Content Node)   A6
   |                                |
   A7 B11 (Alien Content Node)      A8 B12 B13 (Alien Content Node)
                                        |
                                       B14
 
Test steps -
  1. add A1, A2, A3, A4, A5, A6, A7, A8 transfer(sync)
  2. add Alien node B9. A1 becomes Alien.
  3. remove alien node B9. A1 becomes non Alien.
  4. add Alien node B10. A1 and A2 become Alien
  5. remove Alien node B10. A1 and A2 become non Alien
  6. add B12 and B14 A6, A2, A1 becomes Alien
  7. remove B14, B12, A6, A2, A1 remain Alien
  8. add B13 A6, A2, A1 remains Alien
  9. remove B13 A6, A2, A1 remains Alien
  10. remove B12 A6, A2, A1 becomes non Alien.
  11. add B9 and B10 A1 and A2 become Alien
  12. remove B10 A2 becomes non alien A1 remains alien.
  13. Add B11, delete A2 transfer sync
  14. (A5, A6, A7 and A8 should be deleted A2 and A4 remain since they contain alien content.)

Throws:
java.lang.Exception

testLocalAlienRestore

public void testLocalAlienRestore()
                           throws java.lang.Exception
Test restore of a local node.
 Tree of nodes
     A1   B1
     |
     B2
     |
     B3
 
 
  1. Add B2. A1 is alien.
  2. Delete B2. A1 not alien
  3. Restore B2. A1 is alien
  4. Add B3. A1 is alien
  5. Delete B2. A1 not alien
  6. Restore to B1. B2 and B3 not alien.

Throws:
java.lang.Exception

testTransferWithPermissions

public void testTransferWithPermissions()
                                 throws java.lang.Exception
Test the transfer method with regard to permissions on a node.

Step 1: Create a node with a single permission Inherit:false Read, Admin, Allow Transfer

Step 2: Update it to have several permissions Inherit:false Read, Everyone, DENY Read, Admin, Allow

Step 3: Remove a permission Inherit:false Read, Admin, Allow

Step 4: Revert to inherit all permissions Inherit:true

This is a unit test so it does some shenanigans to send to the same instance of alfresco.

Throws:
java.lang.Exception

testReadOnlyFlag

public void testReadOnlyFlag()
                      throws java.lang.Exception
Transfer with read only flag Node tree for this test
 
           A (Folder)
   |                 | 
   B (Content)   C (Folder)
                     |
                     D (Content)
 
Step 1 transfer Nodes ABCD with read only flag set - content should all be locked on destination

Step 2 lock B (Content node) as user fred transfer (read only) - destination lock should change to Admin

Step 3 lock C (Folder) as user fred transfer (read only) - destination lock should change to Admin

Step 4 transfer without read only flag - locks should revert from Admin to Fred.

Step 5 remove locks on A and B - transfer without read only flag - content should all be unlocked.

Throws:
java.lang.Exception

testTwoRepoSync

public void testTwoRepoSync()
                     throws java.lang.Exception
Transfer sync from multiple repos. This is a unit test so does lots of shenanigans to fake transfer from three repositories on a single repo. Multi-repo sync depends upon the following pieces of functionality a) transferred nodes are tagged with a trx:transferred aspect containing the originating repository id and the from repository id b) to support hub and spoke - when syncing don't imply delete nodes that are not "from" the transferring system * Tree of nodes A1 | | A2 A3 (Content Node) B6 (Content Node) | A4 A5 B7 Step 1 Hub and Spoke Sync create Tree A1...A5 transfer (sync) check the transfered aspects on destination create node B6. Fake its transfered aspect to be from Repo B. transfer (sync) Step 2 Chain Sync Create Node A7 "from repo B". Change Nodes A1 ... A5 source to be received "from repo B" transfer

Throws:
java.lang.Exception

testMultiRepoTransfer

public void testMultiRepoTransfer()
                           throws java.lang.Exception
Transfer sync from multiple repos. This is a unit test so does lots of shenanigans to fake transfer from three repositories on a single repo. Trees of nodes
      A1              B1               C1
      |                                 |    
    A2/images                       A2 Dummy/images
      |                              |
      A3                            C3 
                                          
 Destination   
      B1
      |
    A2/images
      |     |
      C3    A3 
            | 
            C4         
 
Step 1. Transfer from A to B. Step 2. Transfer from C to B (crossing over on A2Dest) Step 3. Invade A3Dest via C4 Step 4. Delete C4. Sync from C Step 5. Delete C3 - A2 dest images folder uninvaded.

Throws:
java.lang.Exception

testMultiRepoTransferMove

public void testMultiRepoTransferMove()
                               throws java.lang.Exception
Test the transfer method behaviour with respect to move and alien nodes. So we have Repository A transferring content and Repository B is the local repo that we move alien nodes in and out. Tree
         B1
    |          |         |
    C2(p1)    C3(p2)     A4
    |          
    A5        
    |
    B6
 
Step 1: Tansfer in C's nodes to Repo B Step 2. Transfer in A's nodes to Repo B Setup tree above. Validat that A2 is child of C2 dest. A4 is a child of B1 Step 3. Move A5 from C2 to C3 via transfer. C2Dest should stop being invaded by A5, C3Dest should be invaded by A5. Step 4. Invade A5 by B6. Move from C3 to C2 via transfer. C2Dest should be invaded by A and B. C3Dest should not be invaded. Step 5. Move A5 to A4. A4 should be invaded by B due to B6 but not by A. C2Dest should not be invaded.

Throws:
java.lang.Exception

testCopyTransferredNode

public void testCopyTransferredNode()
                             throws java.lang.Exception
Test the behaviour with regard to copying transferred nodes.

Transfer node read only

Copy transferred node.

New node should not be locked and should not be transferred.

This is a unit test so it does some shenanigans to send to the same instance of alfresco.

Throws:
java.lang.Exception

testCopyAlien

public void testCopyAlien()
                   throws java.lang.Exception
Test the behaviour with respect to copy of alien nodes. So we have Repository A transferring content and Repository B is the local repo that we copy alien nodes in and out. Copied nodes are not "transferred" so they change from being "from repository A" to "from the local repository". Tree
         B1
    |          |         |
    C2(p1)    C3(p2)     A4
    |          
    A5        
    |
    B6
 
Step 1: Tansfer in C's nodes to Repo B Step 2. Transfer in A's nodes to Repo B Setup tree above. Validat that A2 is child of C2 dest. A4 is a child of B1 Step 3. Copy A5 from C2 to C3. C2Dest should still be invaded by A5 C3Dest should be invaded by A5(copy 1) which is now a "B" invader. Step 4. Copy A5 from C2 to A4. C2Dest should still be invaded by A5 A4Dest should be invaded by A5(copy 2) which is now a "B" invader. Step 5. Invade A5 dest with B6. Copy A5(Dest) to B1 (A5 Copy 3) B1 should not be invaded. A5 Copy 3 not invaded. B6 Copy not invaded. Step 6. Invade A5 dest with B6. Copy A5(Dest) to B1 (A5 Copy 3) with children B1 should not be invaded. A5 Copy 4 not invaded. B6 Copy not invaded.

Throws:
java.lang.Exception


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.