1 17 package org.alfresco.jcr.importer; 18 19 import javax.jcr.ImportUUIDBehavior; 20 import javax.jcr.RepositoryException; 21 import javax.jcr.Session; 22 import javax.jcr.SimpleCredentials; 23 24 import org.alfresco.jcr.test.BaseJCRTest; 25 import org.springframework.core.io.ClassPathResource; 26 27 28 public class ImportTest extends BaseJCRTest 29 { 30 protected Session superuserSession; 31 32 @Override  33 protected void setUp() throws Exception  34 { 35 super.setUp(); 36 37 SimpleCredentials superuser = new SimpleCredentials("superuser", "".toCharArray()); 38 superuserSession = repository.login(superuser, getWorkspace()); 39 } 40 41 @Override  42 protected void tearDown() throws Exception  43 { 44 super.tearDown(); 45 superuserSession.logout(); 46 } 47 48 public void testSysImport() 49 throws Exception  50 { 51 ClassPathResource sysview = new ClassPathResource("org/alfresco/jcr/test/sysview.xml"); 52 superuserSession.importXML("/testroot", sysview.getInputStream(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); 53 } 54 55 public void testDocImport() 56 throws Exception  57 { 58 ClassPathResource sysview = new ClassPathResource("org/alfresco/jcr/test/docview.xml"); 59 superuserSession.importXML("/testroot", sysview.getInputStream(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); 60 } 61 62 public void testThrowCollision() 63 throws Exception  64 { 65 ClassPathResource sysview = new ClassPathResource("org/alfresco/jcr/test/docview.xml"); 66 superuserSession.importXML("/testroot", sysview.getInputStream(), ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING); 67 68 try 69 { 70 superuserSession.importXML("/testroot", sysview.getInputStream(), ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW); 71 fail("Failed to catch UUID collision"); 72 } 73 catch(RepositoryException e) 74 { 75 } 76 } 77 78 } 79 | Popular Tags |