KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > exporter > test > TestExportService


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.services.exporter.test;
6
7 import java.util.ArrayList JavaDoc;
8 import org.exoplatform.container.PortalContainer;
9 import org.exoplatform.services.backup.BackupService;
10 import org.exoplatform.services.database.HibernateService;
11 import org.exoplatform.services.organization.Group;
12 import org.exoplatform.services.organization.OrganizationService;
13 import org.exoplatform.services.organization.User;
14 import org.exoplatform.services.portal.PortalConfigService;
15 import org.exoplatform.test.BasicTestCase;
16
17
18 /**
19  * Thu, May 15, 2004
20  * @author: Tuan Nguyen
21  * @version: $Id: TestExportService.java,v 1.7 2004/07/24 16:38:59 tuan08 Exp $
22  * @since: 0.0
23  * @email: tuan08@yahoo.com
24  */

25 public class TestExportService extends BasicTestCase {
26     private static BackupService service_ ;
27     private static OrganizationService orgService_ ;
28     
29   public TestExportService(String JavaDoc name) {
30     super(name);
31   }
32
33   public void setUp() throws Exception JavaDoc {
34     if (service_ == null) {
35       PortalContainer manager = PortalContainer.getInstance();
36       manager.getComponentInstanceOfType(PortalConfigService.class) ;
37       service_ = (BackupService) manager.getComponentInstanceOfType(BackupService.class) ;
38       orgService_ = (OrganizationService) manager.getComponentInstanceOfType(OrganizationService.class);
39     }
40   }
41
42   public void tearDown() throws Exception JavaDoc {
43     PortalContainer manager = PortalContainer.getInstance();
44     HibernateService hservice =
45         (HibernateService) manager.getComponentInstanceOfType(HibernateService.class) ;
46     hservice.closeSession();
47   }
48   
49   public void testExportUserData() throws Exception JavaDoc {
50     service_.exportUserData() ;
51     System.err.println(service_.getExportLogger().getTextSummary()) ;
52   }
53
54   public void testImportUserData() throws Exception JavaDoc {
55     orgService_.removeUser("exo") ;
56     service_.importUserData("exo") ;
57     User user = orgService_.findUserByName("exo") ;
58     assertTrue("user is not null" , user != null) ;
59     System.err.println(service_.getImportLogger().getTextSummary()) ;
60     
61     service_.importUserData("exo") ;
62     user = orgService_.findUserByName("exo") ;
63     assertTrue("user is not null" , user != null) ;
64     System.err.println(service_.getImportLogger().getTextSummary()) ;
65   }
66   
67   public void testExportServiceData() throws Exception JavaDoc {
68     service_.exportServiceData() ;
69     System.err.println(service_.getExportLogger().getTextSummary()) ;
70   }
71   
72   public void testImportServiceData() throws Exception JavaDoc {
73     service_.importServiceData() ;
74     System.err.println(service_.getImportLogger().getTextSummary()) ;
75   }
76   
77   protected String JavaDoc getDescription() {
78     return "Test Export Service" ;
79   }
80 }
81
Popular Tags