1 5 6 package org.exoplatform.services.jcr.api.moving.fs; 7 8 9 import javax.jcr.ItemExistsException; 10 import javax.jcr.Node; 11 import javax.jcr.Repository; 12 import javax.jcr.RepositoryException; 13 import javax.jcr.StringValue; 14 15 import org.exoplatform.services.jcr.api.moving.CopyNodeTest; 16 17 22 public class TestCopyNode extends CopyNodeTest{ 23 24 public void setUp() throws Exception { 25 super.setUp(); 26 repository = (Repository) repositoryService.getRepository("fs1"); 27 ticket = repository.login(credentials, "ws"); 28 workspace = ticket.getWorkspace(); 29 } 30 31 public void testCopy() throws RepositoryException { 32 try { 33 workspace.copy("/dummyNode", "/test", false); 34 fail("exception should have been thrown"); 35 } catch (RepositoryException e) { 36 } 37 38 Node root = ticket.getRootNode(); 39 Node file = root.addNode("childNode", "nt:folder").addNode("childNode2", "nt:file"); 40 Node contentNode = file.getNode("jcr:content"); 41 contentNode.setProperty("exo:content", new StringValue("this is the content")); 42 root.addNode("existNode", "nt:folder"); 43 ticket.save(); 44 45 try { 46 workspace.copy("/childNode", "/existNode", false); 47 fail("exception should have been throwned"); 48 } catch (ItemExistsException e) { 49 } 50 51 workspace.copy("/childNode", "/test", false); 52 ticket = repository.login(credentials, WORKSPACE); 53 assertNotNull(ticket.getNodeByAbsPath("/test")); 54 assertNotNull(ticket.getNodeByAbsPath("/childNode")); 55 assertNotNull(ticket.getNodeByAbsPath("/test/childNode2")); 56 assertNotNull(ticket.getNodeByAbsPath("/test/childNode2").getNode("jcr:content"). 57 getProperty("exo:content")); 58 59 workspace.copy("/childNode", "/test2", true); 60 ticket = repository.login(credentials, WORKSPACE); 61 assertNotNull(ticket.getNodeByAbsPath("/test2")); 62 assertNotNull(ticket.getNodeByAbsPath("/childNode")); 63 try { 64 ticket.getNodeByAbsPath("/test2/childNode2"); 65 fail("exception should have been thrown"); 66 } catch (RepositoryException e) { 67 } 68 77 } 78 79 public void testClone() { 80 81 } 82 83 public void testMove() throws RepositoryException { 84 Node root; 85 try { 86 workspace.move("/dummyNode", "/test"); 87 fail("exception should have been thrown"); 88 } catch (RepositoryException e) { 89 } 90 91 root = ticket.getRootNode(); 92 Node file = root.addNode("childNode", "nt:folder").addNode("childNode2", "nt:file"); 93 Node contentNode = file.getNode("jcr:content"); 94 contentNode.setProperty("exo:content", new StringValue("this is the content")); 95 root.addNode("existNode", "nt:folder"); 96 ticket.save(); 97 98 try { 99 workspace.move("/childNode", "/existNode"); 100 fail("exception should have been thrown"); 101 } catch (ItemExistsException e) { 102 } 103 assertNotNull(ticket.getNodeByAbsPath("/childNode/childNode2").getNode("jcr:content").getProperty("exo:content")); 104 workspace.move("/childNode", "/test"); 105 ticket = repository.login(credentials, WORKSPACE); 106 assertNotNull(ticket.getNodeByAbsPath("/test")); 107 assertNotNull(ticket.getNodeByAbsPath("/test/childNode2").getNode("jcr:content").getProperty("exo:content")); 108 109 try { 110 ticket.getNodeByAbsPath("/childNode"); 111 fail("exception should have been thrown"); 112 } catch (RepositoryException e) { 113 } 114 130 131 } 132 133 134 } 135 | Popular Tags |