Search in sources :

Example 41 with TransferTarget

use of org.alfresco.service.cmr.transfer.TransferTarget in project alfresco-repository by Alfresco.

the class TransferServiceImplTest method testPeerAssocs.

// test replace node
// /**
// * Test the transfer method with regard to obscure paths.
// *
// * This is a unit test so it does some shenanigans to send to he same instance of alfresco.
// */
// public void testHorriblePaths() throws Exception
// {
// setDefaultRollback(false);
// 
// final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
// 
// final String CONTENT_TITLE = "ContentTitle";
// final String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
// final String CONTENT_NAME = "Demo Node 1";
// final Locale CONTENT_LOCALE = Locale.GERMAN;
// final String CONTENT_STRING = "The quick brown fox";
// final Set<NodeRef>nodes = new HashSet<NodeRef>();
// 
// final String targetName = "testManyNodes";
// 
// class TestContext
// {
// TransferTarget transferMe;
// NodeRef nodeA = null;
// NodeRef childNode = null;
// };
// 
// /**
// * Unit test kludge to transfer from guest home to company home
// */
// final UnitTestTransferManifestNodeFactory testNodeFactory = unitTestKludgeToTransferGuestHomeToCompanyHome();
// 
// TransferTarget transferMe;
// 
// final QName[] difficult = { QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeB"),
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"with.dot"),
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"8332"),
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"&#~@"),
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"_-+ )"),
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"with space"),
// // A, e with accent
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "\u0041\u00E9"),
// // Greek Alpha, Omega
// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "\u0391\u03A9")
// };
// 
// RetryingTransactionCallback<TestContext> setupCB = new RetryingTransactionCallback<TestContext>()
// {
// @Override
// public TestContext execute() throws Throwable
// {
// TestContext ctx = new TestContext();
// 
// /**
// * Get guest home
// */
// String guestHomeQuery = "/app:company_home/app:guest_home";
// ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
// assertEquals("", 1, guestHomeResult.length());
// NodeRef guestHome = guestHomeResult.getNodeRef(0);
// 
// /**
// * Create a test node that we will read and write
// */
// String guid = GUID.generate();
// 
// /**
// * Create a tree with "difficult" characters in the path
// * ManyNodesRoot
// * A (Folder)
// * ... childNode
// */
// ChildAssociationRef child;
// 
// child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(guid), ContentModel.TYPE_FOLDER);
// NodeRef testRootNode = child.getChildRef();
// nodeService.setProperty(testRootNode , ContentModel.PROP_TITLE, guid);
// nodeService.setProperty(testRootNode , ContentModel.PROP_NAME, guid);
// nodes.add(testRootNode);
// 
// child = nodeService.createNode(testRootNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeA"), ContentModel.TYPE_FOLDER);
// ctx.nodeA = child.getChildRef();
// nodeService.setProperty(ctx.nodeA , ContentModel.PROP_TITLE, "TestNodeA");
// nodeService.setProperty(ctx.nodeA , ContentModel.PROP_NAME, "TestNodeA");
// nodes.add(ctx.nodeA);
// 
// NodeRef current = ctx.nodeA;
// 
// for(QName name : difficult)
// {
// child = nodeService.createNode(current, ContentModel.ASSOC_CONTAINS, name, ContentModel.TYPE_FOLDER);
// current = child.getChildRef();
// nodeService.setProperty(current , ContentModel.PROP_TITLE, name);
// nodeService.setProperty(current , ContentModel.PROP_NAME, "testName");
// nodes.add(current);
// }
// 
// child = nodeService.createNode(current, ContentModel.ASSOC_CONTAINS, QName.createQName("testNodeAC"), ContentModel.TYPE_CONTENT);
// ctx.childNode = child.getChildRef();
// nodeService.setProperty(  ctx.childNode , ContentModel.PROP_TITLE, CONTENT_TITLE + "AC");
// nodeService.setProperty(  ctx.childNode , ContentModel.PROP_NAME, "DemoNodeAC");
// 
// {
// ContentWriter writer = contentService.getWriter(  ctx.childNode , ContentModel.PROP_CONTENT, true);
// writer.setLocale(CONTENT_LOCALE);
// writer.putContent(CONTENT_STRING);
// nodes.add(  ctx.childNode);
// }
// 
// 
// /**
// * Now go ahead and create our first transfer target
// */
// if(!transferService.targetExists(targetName))
// {
// ctx.transferMe = createTransferTarget(targetName);
// }
// else
// {
// ctx.transferMe = transferService.getTransferTarget(targetName);
// }
// 
// return ctx;
// }
// };
// 
// final TestContext testContext = tran.doInTransaction(setupCB);
// 
// RetryingTransactionCallback<Void> transferCB = new RetryingTransactionCallback<Void>() {
// 
// @Override
// public Void execute() throws Throwable
// {
// TransferDefinition definition = new TransferDefinition();
// definition.setNodes(nodes);
// transferService.transfer(targetName, definition);
// 
// return null;
// }
// };
// 
// tran.doInTransaction(transferCB);
// 
// RetryingTransactionCallback<Void> check1CB = new RetryingTransactionCallback<Void>() {
// 
// @Override
// public Void execute() throws Throwable
// {
// NodeRef destChildNode = testNodeFactory.getMappedNodeRef(testContext.childNode);
// assertTrue("dest node does not exist", nodeService.exists(destChildNode));
// 
// /**
// * Step through source and dest trees on nodes comparing the path as we go.
// */
// Path srcPath = nodeService.getPath(testContext.childNode);
// Path destPath = nodeService.getPath(destChildNode);
// 
// int srcSize = srcPath.size();
// int destSize = destPath.size();
// 
// Path dest = destPath.subPath(2, destSize-1);
// Path src = srcPath.subPath(3, srcSize-1);
// 
// //                System.out.println("src=" + src);
// //                System.out.println("dest=" + dest);
// assertEquals("paths are different", src.toString(), dest.toString());
// 
// return null;
// }
// };
// 
// tran.doInTransaction(check1CB);
// 
// RetryingTransactionCallback<Void> updateCB = new RetryingTransactionCallback<Void>() {
// 
// @Override
// public Void execute() throws Throwable
// {
// 
// return null;
// }
// };
// 
// tran.doInTransaction(updateCB);
// 
// tran.doInTransaction(transferCB);
// 
// RetryingTransactionCallback<Void> check2CB = new RetryingTransactionCallback<Void>() {
// 
// @Override
// public Void execute() throws Throwable
// {
// assertTrue("dest node does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(testContext.childNode)));
// 
// return null;
// }
// };
// tran.doInTransaction(check2CB);
// 
// } // horrible paths
/**
 * ALF-6174
 * Test transfer of peer associations
 *
 * Step 1 : Create 2 nodes
 * Add a peer assoc
 * Transfer
 *
 * Step 2: Add another peer assoc
 * Transfer
 *
 * Step 3: Remove a peer assoc
 * Transfer
 *
 * Step 4: Remove a peer assoc
 * Transfer
 *
 * @throws Exception
 */
@Test
public void testPeerAssocs() throws Exception {
    final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
    final String CONTENT_TITLE = "ContentTitle";
    final Locale CONTENT_LOCALE = Locale.GERMAN;
    final String CONTENT_ENCODING = "UTF-8";
    /**
     *  For unit test
     *  - replace the HTTP transport with the in-process transport
     *  - replace the node factory with one that will map node refs, paths etc.
     *
     *  Fake Repository Id
     */
    final TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
    transferServiceImpl.setTransmitter(transmitter);
    final UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
    transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
    final List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
    // Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
    pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
    final String targetName = "testPeerAssocs";
    class TestContext {

        TransferTarget transferMe;

        NodeRef folderNodeRef;

        NodeRef sourceNodeRef;

        NodeRef targetNodeRef;

        NodeRef destSourceNodeRef;

        NodeRef destTargetNodeRef;
    }
    ;
    RetryingTransactionCallback<TestContext> setupCB = new RetryingTransactionCallback<TestContext>() {

        @Override
        public TestContext execute() throws Throwable {
            TestContext testContext = new TestContext();
            NodeRef guestHome = repositoryHelper.getGuestHome();
            /**
             * Create a test node that we will read and write
             */
            String name = GUID.generate();
            TransferDefinition def = new TransferDefinition();
            ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
            testContext.folderNodeRef = child.getChildRef();
            nodeService.setProperty(testContext.folderNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
            nodeService.setProperty(testContext.folderNodeRef, ContentModel.PROP_NAME, name);
            // Side effect - initialisee nodeid mapping
            testNodeFactory.createTransferManifestNode(testContext.folderNodeRef, def, new TransferContext());
            child = nodeService.createNode(testContext.folderNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("source"), ContentModel.TYPE_CONTENT);
            testContext.sourceNodeRef = child.getChildRef();
            nodeService.setProperty(testContext.sourceNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
            nodeService.setProperty(testContext.sourceNodeRef, ContentModel.PROP_NAME, "source");
            // Side effect - initialise nodeid mapping
            testNodeFactory.createTransferManifestNode(testContext.sourceNodeRef, def, new TransferContext());
            child = nodeService.createNode(testContext.folderNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("target"), ContentModel.TYPE_CONTENT);
            testContext.targetNodeRef = child.getChildRef();
            nodeService.setProperty(testContext.targetNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
            nodeService.setProperty(testContext.targetNodeRef, ContentModel.PROP_NAME, "target");
            testNodeFactory.createTransferManifestNode(testContext.folderNodeRef, def, new TransferContext());
            nodeService.createAssociation(testContext.sourceNodeRef, testContext.targetNodeRef, ContentModel.ASSOC_REFERENCES);
            // Side effect - initialise nodeid mapping
            testNodeFactory.createTransferManifestNode(testContext.targetNodeRef, def, new TransferContext());
            /**
             * Make sure the transfer target exists and is enabled.
             */
            if (!transferService.targetExists(targetName)) {
                testContext.transferMe = createTransferTarget(targetName);
            } else {
                testContext.transferMe = transferService.getTransferTarget(targetName);
            }
            transferService.enableTransferTarget(targetName, true);
            return testContext;
        }
    };
    final TestContext testContext = tran.doInTransaction(setupCB);
    RetryingTransactionCallback<Void> addPeerAssocCB = new RetryingTransactionCallback<Void>() {

        public QName assocQName = ContentModel.ASSOC_ATTACHMENTS;

        @Override
        public Void execute() throws Throwable {
            nodeService.createAssociation(testContext.sourceNodeRef, testContext.targetNodeRef, assocQName);
            return null;
        }
    };
    RetryingTransactionCallback<Void> removePeerAssocCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            List<AssociationRef> refs = nodeService.getTargetAssocs(testContext.sourceNodeRef, RegexQNamePattern.MATCH_ALL);
            if (refs.size() > 0) {
                AssociationRef ref = refs.get(0);
                nodeService.removeAssociation(ref.getSourceRef(), ref.getTargetRef(), ref.getTypeQName());
            }
            return null;
        }
    };
    RetryingTransactionCallback<Void> transferCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            TransferDefinition definition = new TransferDefinition();
            Set<NodeRef> nodes = new HashSet<NodeRef>();
            nodes.add(testContext.sourceNodeRef);
            nodes.add(testContext.targetNodeRef);
            nodes.add(testContext.folderNodeRef);
            definition.setNodes(nodes);
            transferService.transfer(targetName, definition);
            return null;
        }
    };
    RetryingTransactionCallback<List<AssociationRef>> readAssocsCB = new RetryingTransactionCallback<List<AssociationRef>>() {

        @Override
        public List<AssociationRef> execute() throws Throwable {
            List<AssociationRef> source = nodeService.getSourceAssocs(testContext.sourceNodeRef, RegexQNamePattern.MATCH_ALL);
            List<AssociationRef> target = nodeService.getTargetAssocs(testContext.sourceNodeRef, RegexQNamePattern.MATCH_ALL);
            NodeRef destNode = testNodeFactory.getMappedNodeRef(testContext.sourceNodeRef);
            List<AssociationRef> destSource = nodeService.getSourceAssocs(destNode, RegexQNamePattern.MATCH_ALL);
            List<AssociationRef> destTarget = nodeService.getTargetAssocs(destNode, RegexQNamePattern.MATCH_ALL);
            assertEquals("source peers different sizes", destSource.size(), source.size());
            assertEquals("target peers different sizes", destTarget.size(), target.size());
            if (destSource.size() == 1) {
                assertEquals(destSource.get(0).getTypeQName(), source.get(0).getTypeQName());
            }
            if (destTarget.size() == 1) {
                assertEquals(destTarget.get(0).getTypeQName(), target.get(0).getTypeQName());
            }
            return destTarget;
        }
    };
    /**
     * This is the test
     */
    tran.doInTransaction(transferCB);
    List<AssociationRef> assocs = tran.doInTransaction(readAssocsCB);
    assertEquals("assocs not one", 1, assocs.size());
    tran.doInTransaction(addPeerAssocCB);
    tran.doInTransaction(transferCB);
    assocs = tran.doInTransaction(readAssocsCB);
    assertEquals("assocs not two", 2, assocs.size());
    tran.doInTransaction(removePeerAssocCB);
    tran.doInTransaction(transferCB);
    tran.doInTransaction(removePeerAssocCB);
    tran.doInTransaction(transferCB);
}
Also used : Locale(java.util.Locale) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) TransferTarget(org.alfresco.service.cmr.transfer.TransferTarget) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef) TransferDefinition(org.alfresco.service.cmr.transfer.TransferDefinition) NodeRef(org.alfresco.service.cmr.repository.NodeRef) List(java.util.List) ArrayList(java.util.ArrayList) Pair(org.alfresco.util.Pair) HashSet(java.util.HashSet) Path(org.alfresco.service.cmr.repository.Path) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Example 42 with TransferTarget

use of org.alfresco.service.cmr.transfer.TransferTarget in project alfresco-repository by Alfresco.

the class TransferServiceImplTest method testGetTransferTargets.

/**
 * Test of Get TransferTargets
 *
 * @throws Exception
 */
@Test
public void testGetTransferTargets() throws Exception {
    String nameA = "Test Transfer Target " + GUID.generate();
    String nameB = "Test Transfer Target " + GUID.generate();
    String title = "title";
    String description = "description";
    String endpointProtocol = "http";
    String endpointHost = "localhost";
    int endpointPort = 8080;
    String endpointPath = "rhubarb";
    String username = "admin";
    char[] password = "password".toCharArray();
    /**
     * Now go ahead and create our first transfer target
     */
    TransferTarget targetA = transferService.createAndSaveTransferTarget(nameA, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
    TransferTarget targetB = transferService.createAndSaveTransferTarget(nameB, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
    Set<TransferTarget> targets = transferService.getTransferTargets();
    assertTrue("targets is empty", targets.size() > 0);
    assertTrue("didn't find target A", targets.contains(targetA));
    assertTrue("didn't find target B", targets.contains(targetB));
    for (TransferTarget target : targets) {
        System.out.println("found target: " + target.getName());
    }
}
Also used : TransferTarget(org.alfresco.service.cmr.transfer.TransferTarget) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Example 43 with TransferTarget

use of org.alfresco.service.cmr.transfer.TransferTarget in project alfresco-repository by Alfresco.

the class TransferServiceToBeRefactoredTest method testCopyTransferredNode.

/**
 * Test the behaviour with regard to copying transferred nodes.
 * <p>
 * Transfer node read only
 * <p>
 * Copy transferred node.
 * <p>
 * New node should not be locked and should not be transferred.
 * <p>
 * This is a unit test so it does some shenanigans to send to the same instance of alfresco.
 */
@Test
public void testCopyTransferredNode() throws Exception {
    final String CONTENT_TITLE = "ContentTitle";
    /**
     * Now go ahead and create our transfer target
     */
    final String targetName = "testCopyTransferredNode";
    class TestData {

        @SuppressWarnings("unused")
        TransferTarget transferMe;

        NodeRef S0NodeRef;

        NodeRef A1NodeRef;

        NodeRef A2NodeRef;

        NodeRef A3NodeRef;

        NodeRef B1NodeRef;

        NodeRef B2NodeRef;
    }
    final TestData testData = new TestData();
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            NodeRef guestHome = repositoryHelper.getGuestHome();
            /**
             * Node Source - located under guest home
             */
            {
                String name = GUID.generate();
                ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
                testData.S0NodeRef = child.getChildRef();
                nodeService.setProperty(testData.S0NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
                nodeService.setProperty(testData.S0NodeRef, ContentModel.PROP_NAME, name);
            }
            {
                // Node A1
                ChildAssociationRef child = nodeService.createNode(testData.S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A1"), ContentModel.TYPE_FOLDER);
                testData.A1NodeRef = child.getChildRef();
                nodeService.setProperty(testData.A1NodeRef, ContentModel.PROP_TITLE, "A1");
                nodeService.setProperty(testData.A1NodeRef, ContentModel.PROP_NAME, "A1");
            }
            {
                // Node A2
                ChildAssociationRef child = nodeService.createNode(testData.A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2"), ContentModel.TYPE_FOLDER);
                testData.A2NodeRef = child.getChildRef();
                nodeService.setProperty(testData.A2NodeRef, ContentModel.PROP_TITLE, "A2");
                nodeService.setProperty(testData.A2NodeRef, ContentModel.PROP_NAME, "A2");
            }
            {
                // Node A3
                ChildAssociationRef child = nodeService.createNode(testData.A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_FOLDER);
                testData.A3NodeRef = child.getChildRef();
                nodeService.setProperty(testData.A3NodeRef, ContentModel.PROP_TITLE, "A3");
                nodeService.setProperty(testData.A3NodeRef, ContentModel.PROP_NAME, "A3");
            }
            {
                // Node B1
                ChildAssociationRef child = nodeService.createNode(testData.S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B1"), ContentModel.TYPE_FOLDER);
                testData.B1NodeRef = child.getChildRef();
                nodeService.setProperty(testData.B1NodeRef, ContentModel.PROP_TITLE, "B1");
                nodeService.setProperty(testData.B1NodeRef, ContentModel.PROP_NAME, "B1");
            }
            {
                // Node B2
                ChildAssociationRef child = nodeService.createNode(testData.S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B2"), ContentModel.TYPE_FOLDER);
                testData.B2NodeRef = child.getChildRef();
                nodeService.setProperty(testData.B1NodeRef, ContentModel.PROP_TITLE, "B2");
                nodeService.setProperty(testData.B1NodeRef, ContentModel.PROP_NAME, "B2");
            }
            if (!transferService.targetExists(targetName)) {
                testData.transferMe = createTransferTarget(targetName);
            } else {
                testData.transferMe = transferService.getTransferTarget(targetName);
            }
            return null;
        }
    });
    /**
     *  For unit test
     *  - replace the HTTP transport with the in-process transport
     *  - Map path from A1 to B1 (So transfer will transfer by path)
     */
    TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
    transferServiceImpl.setTransmitter(transmitter);
    final UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
    transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
    final List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            // Map Project A to Project B
            pathMap.add(new Pair<Path, Path>(nodeService.getPath(testData.A1NodeRef), nodeService.getPath(testData.B1NodeRef)));
            return null;
        }
    });
    DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
    transferServiceImpl.setDescriptorService(mockedDescriptorService);
    /**
     * Step 1
     */
    logger.debug("First transfer - ");
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            /**
             * Transfer our transfer target node
             */
            {
                TransferDefinition definition = new TransferDefinition();
                Set<NodeRef> nodes = new HashSet<NodeRef>();
                nodes.add(testData.A2NodeRef);
                nodes.add(testData.A3NodeRef);
                definition.setNodes(nodes);
                definition.setReadOnly(true);
                transferService.transfer(targetName, definition);
            }
            return null;
        }
    });
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            // Now validate that the target node exists with the correct permissions
            NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(testData.A2NodeRef);
            assertTrue("dest node ref does not exist", nodeService.exists(A2destNodeRef));
            /**
             * Copy the node A2 Dest
             */
            NodeRef copiedNode = copyService.copy(A2destNodeRef, testData.B2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2Copy"));
            assertTrue("copied node does not exist", nodeService.exists(copiedNode));
            System.out.println("copied node is " + copiedNode);
            assertFalse("copied node still has transferred aspect", nodeService.hasAspect(copiedNode, TransferModel.ASPECT_TRANSFERRED));
            assertNull("copied node still has from repository id", nodeService.getProperty(copiedNode, TransferModel.PROP_FROM_REPOSITORY_ID));
            assertNull("copied node still has original repository id", nodeService.getProperty(copiedNode, TransferModel.PROP_REPOSITORY_ID));
            @SuppressWarnings("unused") Set<QName> aspects = nodeService.getAspects(copiedNode);
            /**
             * Copy a chain of transferred nodes - well A2dest and A3dest
             */
            copiedNode = copyService.copy(A2destNodeRef, testData.B2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2Copy2"), true);
            assertTrue("copied node does not exist", nodeService.exists(copiedNode));
            System.out.println("copied node is " + copiedNode);
            assertFalse("copied node still has transferred aspect", nodeService.hasAspect(copiedNode, TransferModel.ASPECT_TRANSFERRED));
            assertNull("copied node still has from repository id", nodeService.getProperty(copiedNode, TransferModel.PROP_FROM_REPOSITORY_ID));
            assertNull("copied node still has original repository id", nodeService.getProperty(copiedNode, TransferModel.PROP_REPOSITORY_ID));
            List<ChildAssociationRef> children = nodeService.getChildAssocs(copiedNode);
            for (ChildAssociationRef child : children) {
                assertFalse("copied node still has transferred aspect", nodeService.hasAspect(child.getChildRef(), TransferModel.ASPECT_TRANSFERRED));
                assertNull("copied node still has from repository id", nodeService.getProperty(child.getChildRef(), TransferModel.PROP_FROM_REPOSITORY_ID));
                assertNull("copied node still has original repository id", nodeService.getProperty(child.getChildRef(), TransferModel.PROP_REPOSITORY_ID));
            }
            return null;
        }
    });
}
Also used : ResultSet(org.alfresco.service.cmr.search.ResultSet) Set(java.util.Set) HashSet(java.util.HashSet) TransferTarget(org.alfresco.service.cmr.transfer.TransferTarget) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) TransferDefinition(org.alfresco.service.cmr.transfer.TransferDefinition) NodeRef(org.alfresco.service.cmr.repository.NodeRef) List(java.util.List) ArrayList(java.util.ArrayList) DescriptorService(org.alfresco.service.descriptor.DescriptorService) Pair(org.alfresco.util.Pair) HashSet(java.util.HashSet) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Example 44 with TransferTarget

use of org.alfresco.service.cmr.transfer.TransferTarget in project alfresco-repository by Alfresco.

the class TransferServiceToBeRefactoredTest method testTwoRepoSync.

// end test read only flag
/**
 * 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
 */
@Test
public void testTwoRepoSync() throws Exception {
    /**
     * Step 1
     * create Tree A1...A6
     * transfer (sync)
     * check the transfered aspect
     * create node B6.  Fake its transfered aspect to be from Repo B, Non Alien.
     * transfer (sync)
     */
    final String CONTENT_TITLE = "ContentTitle";
    final Locale CONTENT_LOCALE = Locale.GERMAN;
    final String CONTENT_STRING = "Hello";
    /**
     *  For unit test
     *  - replace the HTTP transport with the in-process transport
     *  - replace the node factory with one that will map node refs, paths etc.
     */
    TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
    transferServiceImpl.setTransmitter(transmitter);
    final UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
    transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
    List<Pair<Path, Path>> pathMap = testNodeFactory.getPathMap();
    // Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
    pathMap.add(new Pair<Path, Path>(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
    DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
    transferServiceImpl.setDescriptorService(mockedDescriptorService);
    final String repositoryId = REPO_ID_A;
    /**
     * Now go ahead and create our first transfer target
     */
    final String targetName = "testTransferSyncNodes";
    class TestData {

        @SuppressWarnings("unused")
        TransferTarget transferMe;

        NodeRef A1NodeRef;

        NodeRef A2NodeRef;

        NodeRef A3NodeRef;

        NodeRef A4NodeRef;

        NodeRef A5NodeRef;

        NodeRef B6NodeRef;

        NodeRef A7NodeRef;
    }
    final TestData testData = new TestData();
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            NodeRef guestHome = repositoryHelper.getGuestHome();
            /**
             * Create a test nodes A1 through A5 that we will read and write
             */
            {
                // Node A1
                String name = GUID.generate();
                ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
                testData.A1NodeRef = child.getChildRef();
                nodeService.setProperty(testData.A1NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
                nodeService.setProperty(testData.A1NodeRef, ContentModel.PROP_NAME, name);
            }
            {
                // Node A2
                ChildAssociationRef child = nodeService.createNode(testData.A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2"), ContentModel.TYPE_FOLDER);
                testData.A2NodeRef = child.getChildRef();
                nodeService.setProperty(testData.A2NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
                nodeService.setProperty(testData.A2NodeRef, ContentModel.PROP_NAME, "A2");
            }
            {
                // Node A3
                ChildAssociationRef child = nodeService.createNode(testData.A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_CONTENT);
                testData.A3NodeRef = child.getChildRef();
                nodeService.setProperty(testData.A3NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
                nodeService.setProperty(testData.A3NodeRef, ContentModel.PROP_NAME, "A3");
                ContentWriter writer = contentService.getWriter(testData.A3NodeRef, ContentModel.PROP_CONTENT, true);
                writer.setLocale(CONTENT_LOCALE);
                writer.putContent(CONTENT_STRING);
            }
            {
                // Node A4
                ChildAssociationRef child = nodeService.createNode(testData.A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A4"), ContentModel.TYPE_CONTENT);
                testData.A4NodeRef = child.getChildRef();
                nodeService.setProperty(testData.A4NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
                nodeService.setProperty(testData.A4NodeRef, ContentModel.PROP_NAME, "A4");
                ContentWriter writer = contentService.getWriter(testData.A4NodeRef, ContentModel.PROP_CONTENT, true);
                writer.setLocale(CONTENT_LOCALE);
                writer.putContent(CONTENT_STRING);
            }
            {
                // Node A5
                ChildAssociationRef child = nodeService.createNode(testData.A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A5"), ContentModel.TYPE_CONTENT);
                testData.A5NodeRef = child.getChildRef();
                nodeService.setProperty(testData.A5NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
                nodeService.setProperty(testData.A5NodeRef, ContentModel.PROP_NAME, "A5");
                ContentWriter writer = contentService.getWriter(testData.A5NodeRef, ContentModel.PROP_CONTENT, true);
                writer.setLocale(CONTENT_LOCALE);
                writer.putContent(CONTENT_STRING);
            }
            // Create the transfer target if it does not already exist
            if (!transferService.targetExists(targetName)) {
                testData.transferMe = createTransferTarget(targetName);
            } else {
                testData.transferMe = transferService.getTransferTarget(targetName);
            }
            return null;
        }
    });
    final Set<NodeRef> nodes = new HashSet<NodeRef>();
    nodes.add(testData.A1NodeRef);
    nodes.add(testData.A2NodeRef);
    nodes.add(testData.A3NodeRef);
    nodes.add(testData.A4NodeRef);
    nodes.add(testData.A5NodeRef);
    /**
     * transfer (sync)
     * check the transfered aspect
     * create node B6.  Fake its transfered aspect to be from Repo B, Non Alien.
     * transfer (sync)
     */
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            TransferDefinition definition = new TransferDefinition();
            definition.setNodes(nodes);
            definition.setSync(true);
            transferService.transfer(targetName, definition);
            return null;
        }
    });
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            // Node B6 - faked transfer from repository B. Child of Destination node A1
            NodeRef a1Dest = testNodeFactory.getMappedNodeRef(testData.A1NodeRef);
            assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(testData.A1NodeRef)));
            assertEquals("dest node A1 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A1NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
            assertEquals("dest node A1 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A1NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
            assertEquals("dest node A2 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
            assertEquals("dest node A2 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A2NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
            assertEquals("dest node A3 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
            assertEquals("dest node A3 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A3NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
            assertEquals("dest node A4 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A4NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
            assertEquals("dest node A4 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A4NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
            assertEquals("dest node A5 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A5NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
            assertEquals("dest node A5 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A5NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
            ChildAssociationRef child = nodeService.createNode(a1Dest, ContentModel.ASSOC_CONTAINS, QName.createQName("B6"), ContentModel.TYPE_CONTENT);
            testData.B6NodeRef = child.getChildRef();
            nodeService.setProperty(testData.B6NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
            nodeService.setProperty(testData.B6NodeRef, ContentModel.PROP_NAME, "B6");
            /**
             * The first tranfer was mocked to repository A - this is repository B.
             */
            // This is repository B so there's no need to fake it
            // nodeService.setProperty(testData.B6NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
            // nodeService.setProperty(testData.B6NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
            ContentWriter writer = contentService.getWriter(testData.B6NodeRef, ContentModel.PROP_CONTENT, true);
            writer.setLocale(CONTENT_LOCALE);
            writer.putContent(CONTENT_STRING);
            return null;
        }
    });
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            TransferDefinition definition = new TransferDefinition();
            definition.setNodes(nodes);
            definition.setSync(true);
            transferService.transfer(targetName, definition);
            return null;
        }
    });
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            // Does node B6 still exist ?
            assertTrue("dest node B6 does not exist", nodeService.exists(testData.B6NodeRef));
            assertTrue("B6 not alien", nodeService.hasAspect(testData.B6NodeRef, TransferModel.ASPECT_ALIEN));
            return null;
        }
    });
    /**
     * Step 2
     * Chain Sync
     * Change Nodes A1 ... A5 source to be received "from repo B"
     * Create Node A7 - Fake it to be received "from repo B"
     * transfer
     */
    final String NEW_TITLE = "Chain sync";
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            nodeService.setProperty(testData.A1NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
            nodeService.setProperty(testData.A1NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
            nodeService.setProperty(testData.A1NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
            nodeService.setProperty(testData.A2NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
            nodeService.setProperty(testData.A2NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
            nodeService.setProperty(testData.A2NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
            nodeService.setProperty(testData.A3NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
            nodeService.setProperty(testData.A3NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
            nodeService.setProperty(testData.A3NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
            /**
             * The repository was mocked to repoistory A. This is repository B
             */
            ChildAssociationRef child = nodeService.createNode(testData.A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A7"), ContentModel.TYPE_CONTENT);
            testData.A7NodeRef = child.getChildRef();
            nodeService.setProperty(testData.A7NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
            nodeService.setProperty(testData.A7NodeRef, ContentModel.PROP_NAME, "A7");
            nodeService.setProperty(testData.A7NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
            nodeService.setProperty(testData.A7NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
            nodeService.setProperty(testData.A7NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
            ContentWriter writer = contentService.getWriter(testData.A3NodeRef, ContentModel.PROP_CONTENT, true);
            writer.setLocale(CONTENT_LOCALE);
            writer.putContent(CONTENT_STRING);
            return null;
        }
    });
    nodes.add(testData.A7NodeRef);
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            TransferDefinition definition = new TransferDefinition();
            definition.setNodes(nodes);
            definition.setSync(true);
            transferService.transfer(targetName, definition);
            return null;
        }
    });
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            assertTrue("dest node A7 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(testData.A7NodeRef)));
            assertEquals("dest node A1 Title", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A1NodeRef), ContentModel.PROP_TITLE), NEW_TITLE);
            assertEquals("dest node A1 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A1NodeRef), TransferModel.PROP_REPOSITORY_ID), REPO_ID_B);
            assertEquals("dest node A1 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A1NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
            assertEquals("dest node A2 Title", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A2NodeRef), ContentModel.PROP_TITLE), NEW_TITLE);
            assertEquals("dest node A2 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A2NodeRef), TransferModel.PROP_REPOSITORY_ID), REPO_ID_B);
            assertEquals("dest node A2 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
            assertEquals("dest node A3 Title", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A3NodeRef), ContentModel.PROP_TITLE), NEW_TITLE);
            assertEquals("dest node A3 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A3NodeRef), TransferModel.PROP_REPOSITORY_ID), REPO_ID_B);
            assertEquals("dest node A3 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(testData.A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
            return null;
        }
    });
}
Also used : Locale(java.util.Locale) Path(org.alfresco.service.cmr.repository.Path) TransferTarget(org.alfresco.service.cmr.transfer.TransferTarget) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) TransferDefinition(org.alfresco.service.cmr.transfer.TransferDefinition) NodeRef(org.alfresco.service.cmr.repository.NodeRef) ContentWriter(org.alfresco.service.cmr.repository.ContentWriter) DescriptorService(org.alfresco.service.descriptor.DescriptorService) Pair(org.alfresco.util.Pair) HashSet(java.util.HashSet) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Example 45 with TransferTarget

use of org.alfresco.service.cmr.transfer.TransferTarget in project alfresco-repository by Alfresco.

the class TransferServiceImplTest method testUpdateTransferTarget.

/**
 */
@Test
public void testUpdateTransferTarget() throws Exception {
    String updateMe = "Test Transfer Target " + GUID.generate();
    String title = "title";
    String description = "description";
    String endpointProtocol = "http";
    String endpointHost = "localhost";
    int endpointPort = 8080;
    String endpointPath = "rhubarb";
    String username = "admin";
    char[] password = "password".toCharArray();
    /**
     * Create our transfer target
     */
    TransferTarget target = transferService.createAndSaveTransferTarget(updateMe, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
    /*
         * Now update with exactly the same values.
         */
    TransferTarget update1 = transferService.saveTransferTarget(target);
    assertNotNull("return value is null", update1);
    assertNotNull("node ref is null", update1.getNodeRef());
    // titled aspect
    assertEquals("name not equal", update1.getName(), updateMe);
    assertEquals("title not equal", update1.getTitle(), title);
    assertEquals("description not equal", update1.getDescription(), description);
    // endpoint
    assertEquals("endpointProtocol not equal", update1.getEndpointProtocol(), endpointProtocol);
    assertEquals("endpointHost not equal", update1.getEndpointHost(), endpointHost);
    assertEquals("endpointPort not equal", update1.getEndpointPort(), endpointPort);
    assertEquals("endpointPath not equal", update1.getEndpointPath(), endpointPath);
    // authentication
    assertEquals("username not equal", update1.getUsername(), username);
    char[] pass = update1.getPassword();
    assertEquals(password.length, pass.length);
    for (int i = 0; i < password.length; i++) {
        if (password[i] != pass[i]) {
            fail("password not equal:" + new String(password) + new String(pass));
        }
    }
    /**
     * Now update with different values
     */
    String title2 = "Two";
    String description2 = "descriptionTwo";
    String endpointProtocol2 = "https";
    String endpointHost2 = "1.0.0.127";
    int endpointPort2 = 4040;
    String endpointPath2 = "custard";
    String username2 = "admin_two";
    char[] password2 = "two".toCharArray();
    target.setDescription(description2);
    target.setTitle(title2);
    target.setEndpointHost(endpointHost2);
    target.setEndpointPath(endpointPath2);
    target.setEndpointPort(endpointPort2);
    target.setEndpointProtocol(endpointProtocol2);
    target.setPassword(password2);
    target.setUsername(username2);
    TransferTarget update2 = transferService.saveTransferTarget(target);
    assertNotNull("return value is null", update2);
    assertNotNull("node ref is null", update2.getNodeRef());
    // titled aspect
    assertEquals("name not equal", update2.getName(), updateMe);
    assertEquals("title not equal", update2.getTitle(), title2);
    assertEquals("description not equal", update2.getDescription(), description2);
    // endpoint
    assertEquals("endpointProtocol not equal", update2.getEndpointProtocol(), endpointProtocol2);
    assertEquals("endpointHost not equal", update2.getEndpointHost(), endpointHost2);
    assertEquals("endpointPort not equal", update2.getEndpointPort(), endpointPort2);
    assertEquals("endpointPath not equal", update2.getEndpointPath(), endpointPath2);
    // authentication
    assertEquals("username not equal", update2.getUsername(), username2);
    pass = update2.getPassword();
    assertEquals(password2.length, pass.length);
    for (int i = 0; i < pass.length; i++) {
        if (pass[i] != password2[i]) {
            fail("password not equal:" + new String(pass) + new String(password2));
        }
    }
}
Also used : TransferTarget(org.alfresco.service.cmr.transfer.TransferTarget) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Aggregations

TransferTarget (org.alfresco.service.cmr.transfer.TransferTarget)48 BaseAlfrescoSpringTest (org.alfresco.util.BaseAlfrescoSpringTest)30 Test (org.junit.Test)30 NodeRef (org.alfresco.service.cmr.repository.NodeRef)29 TransferDefinition (org.alfresco.service.cmr.transfer.TransferDefinition)26 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)25 HashSet (java.util.HashSet)22 Locale (java.util.Locale)18 DescriptorService (org.alfresco.service.descriptor.DescriptorService)16 Pair (org.alfresco.util.Pair)14 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)13 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)12 TransferException (org.alfresco.service.cmr.transfer.TransferException)12 ArrayList (java.util.ArrayList)10 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)10 IOException (java.io.IOException)8 Path (org.alfresco.service.cmr.repository.Path)8 List (java.util.List)7 QName (org.alfresco.service.namespace.QName)7 HostConfiguration (org.apache.commons.httpclient.HostConfiguration)7