KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > engine > csv > CsvBootstrapImplTest


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: CsvBootstrapImplTest.java 1089 2006-09-14 19:57:55Z dutoo $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.engine.csv;
23
24 import static org.easymock.EasyMock.expect;
25 import static org.easymock.classextension.EasyMock.createMock;
26 import static org.easymock.classextension.EasyMock.replay;
27 import static org.easymock.classextension.EasyMock.verify;
28
29 import java.io.File JavaDoc;
30
31 import javax.jbi.JBIException;
32 import javax.jbi.component.InstallationContext;
33
34 import org.objectweb.petals.engine.csv.CsvBootstrapImpl;
35
36 import junit.framework.TestCase;
37
38
39 /**
40  * Tests CsvBootstrapImpl
41  * @version $Rev: 1069 $Date: ${date}
42  * @since Petals 1.0
43  * @author Marc Dutoo - Open Wide
44  *
45  */

46 public class CsvBootstrapImplTest extends TestCase {
47
48     File JavaDoc installationRoot = null;
49
50     private String JavaDoc baseDir;
51
52     
53     public void testCleanUp() {
54         CsvBootstrapImpl csvBootstrap = new CsvBootstrapImpl();
55
56         // Run the Test
57
try {
58             csvBootstrap.cleanUp();
59         } catch (JBIException e) {
60             e.printStackTrace();
61             fail("Error in CsvBootstrap clean up");
62         }
63     }
64
65     
66     public void testGetExtensionMBeanName() {
67         // Create objects
68
CsvBootstrapImpl csvBootstrap = new CsvBootstrapImpl();
69
70         // Run the Test
71
Object JavaDoc result = null;
72         result = csvBootstrap.getExtensionMBeanName();
73         assertNull("Result of invocation should be null", result);
74     }
75
76     
77     public void testInit() {
78         // Create Mock Objects
79
InstallationContext installationContext = createMock(InstallationContext.class);
80         // Init mocks
81
expect(installationContext.getInstallRoot()).andReturn(
82             installationRoot.getAbsolutePath());
83         replay(installationContext);
84
85         CsvBootstrapImpl csvBootstrap = new CsvBootstrapImpl();
86         // Run the Test
87
try {
88             csvBootstrap.init(installationContext);
89         } catch (JBIException e) {
90             e.printStackTrace();
91             fail("Error in CsvBootstrap init method");
92         }
93
94         assertEquals(csvBootstrap.installContext , installationContext);
95     }
96
97     
98     public void testOnInstall() {
99         // Create Mock Objects
100
InstallationContext installationContext = createMock(InstallationContext.class);
101         // Init mocks
102
CsvBootstrapImpl csvBootstrap = new CsvBootstrapImpl();
103         // Run the Test
104
try {
105             csvBootstrap.init(installationContext);
106         } catch (JBIException e) {
107             e.printStackTrace();
108             fail("Error in CsvBootstrap onInstall method");
109         }
110     }
111
112     
113     public void testOnUninstall() {
114         // Create Mock Objects
115
InstallationContext installationContext = createMock(InstallationContext.class);
116         // Init mocks
117
expect(installationContext.getInstallRoot()).andReturn(
118             installationRoot.getAbsolutePath()).anyTimes();
119         expect(installationContext.getInstallationDescriptorExtension()).andReturn(
120                 null);
121         replay(installationContext);
122
123         CsvBootstrapImpl csvBootstrap = new CsvBootstrapImpl();
124         // Run the Test
125
try {
126             csvBootstrap.init(installationContext);
127             csvBootstrap.onInstall();
128         } catch (JBIException e) {
129             e.printStackTrace();
130             fail("Error in CsvBootstrap init or onUninstall method");
131         }
132
133         // Run the Test
134
try {
135             csvBootstrap.onUninstall();
136         } catch (JBIException e) {
137             e.printStackTrace();
138             fail("Error in CsvBootstrap onuninstall method");
139         }
140         verify(installationContext);
141     }
142
143     
144     @Override JavaDoc
145     protected void setUp() throws Exception JavaDoc {
146         baseDir = this.getClass().getResource(".").toString();
147         baseDir = baseDir.substring(0, baseDir.indexOf("target"));
148         baseDir = baseDir.substring(baseDir.indexOf(":") + 1);
149         installationRoot = new File JavaDoc(baseDir + File.separator + "src"
150             + File.separator + "test-data" + File.separator + "bootstrap");
151     }
152
153 }
154
155
156
Popular Tags