KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > jcr > importer > ImportTest


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

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 JavaDoc
33     protected void setUp() throws Exception JavaDoc
34     {
35         super.setUp();
36         
37         SimpleCredentials superuser = new SimpleCredentials("superuser", "".toCharArray());
38         superuserSession = repository.login(superuser, getWorkspace());
39     }
40     
41     @Override JavaDoc
42     protected void tearDown() throws Exception JavaDoc
43     {
44         super.tearDown();
45         superuserSession.logout();
46     }
47     
48     public void testSysImport()
49         throws Exception JavaDoc
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 JavaDoc
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 JavaDoc
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