1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 package complex.storages;
24 
25 import com.sun.star.lang.XMultiServiceFactory;
26 import com.sun.star.lang.XMultiComponentFactory;
27 import com.sun.star.connection.XConnector;
28 import com.sun.star.connection.XConnection;
29 
30 import com.sun.star.bridge.XUnoUrlResolver;
31 import com.sun.star.uno.UnoRuntime;
32 import com.sun.star.uno.XInterface;
33 import com.sun.star.uno.XNamingService;
34 import com.sun.star.uno.XComponentContext;
35 
36 import com.sun.star.container.*;
37 import com.sun.star.beans.*;
38 import com.sun.star.lang.*;
39 
40 import complex.storages.*;
41 import share.LogWriter;
42 import stats.SimpleLogWriter;
43 
44 import java.util.*;
45 import java.io.*;
46 
47 import org.junit.AfterClass;
48 import org.junit.Before;
49 import org.junit.BeforeClass;
50 import org.junit.Test;
51 import org.openoffice.test.OfficeConnection;
52 import static org.junit.Assert.*;
53 
54 /* This unit test for storage objects is designed to
55  * test most important statements from storage service
56  * specification.
57  *
58  * Regression tests are added to extend the tested
59  * functionalities.
60  */
61 public class StorageUnitTest
62 {
63     private static final OfficeConnection connection = new OfficeConnection();
64     private static final LogWriter log = new SimpleLogWriter();
65 	private XMultiServiceFactory m_xMSF = null;
66 	private XSingleServiceFactory m_xStorageFactory = null;
67 
68     @BeforeClass
setUpConnection()69     public static void setUpConnection()
70         throws Exception
71     {
72         connection.setUp();
73         log.initialize(null, true);
74     }
75 
76     @AfterClass
tearDownConnection()77     public static void tearDownConnection()
78         throws InterruptedException, com.sun.star.uno.Exception
79     {
80         connection.tearDown();
81     }
82 
83     @Before
before()84     public void before()
85 	{
86         m_xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
87 		if ( m_xMSF == null )
88 		{
89 			fail( "Can't create service factory!" );
90 			return;
91 		}
92 
93 		try {
94 			Object oStorageFactory = m_xMSF.createInstance( "com.sun.star.embed.StorageFactory" );
95 			m_xStorageFactory = (XSingleServiceFactory)UnoRuntime.queryInterface( XSingleServiceFactory.class,
96 																				oStorageFactory );
97 		}
98 		catch( Exception e )
99 		{
100 			fail( "Can't create storage factory!" );
101 			return;
102 		}
103 
104 		if ( m_xStorageFactory == null )
105 		{
106 			fail( "Can't create service factory!" );
107 			return;
108 		}
109     }
110 
111     @Test
ExecuteTest01()112 	public void ExecuteTest01()
113 	{
114 		StorageTest aTest = new Test01( m_xMSF, m_xStorageFactory, log );
115 		assertTrue( "Test01 failed!", aTest.test() );
116 	}
117 
118     @Test
ExecuteTest02()119 	public void ExecuteTest02()
120 	{
121 		StorageTest aTest = new Test02( m_xMSF, m_xStorageFactory, log );
122 		assertTrue( "Test02 failed!", aTest.test() );
123 	}
124 
125     @Test
ExecuteTest03()126 	public void ExecuteTest03()
127 	{
128 		StorageTest aTest = new Test03( m_xMSF, m_xStorageFactory, log );
129 		assertTrue( "Test03 failed!", aTest.test() );
130 	}
131 
132     @Test
ExecuteTest04()133 	public void ExecuteTest04()
134 	{
135 		StorageTest aTest = new Test04( m_xMSF, m_xStorageFactory, log );
136 		assertTrue( "Test04 failed!", aTest.test() );
137 	}
138 
139     @Test
ExecuteTest05()140 	public void ExecuteTest05()
141 	{
142 		StorageTest aTest = new Test05( m_xMSF, m_xStorageFactory, log );
143 		assertTrue( "Test05 failed!", aTest.test() );
144 	}
145 
146     @Test
ExecuteTest06()147 	public void ExecuteTest06()
148 	{
149 		StorageTest aTest = new Test06( m_xMSF, m_xStorageFactory, log );
150 		assertTrue( "Test06 failed!", aTest.test() );
151 	}
152 
153     @Test
ExecuteTest07()154 	public void ExecuteTest07()
155 	{
156 		StorageTest aTest = new Test07( m_xMSF, m_xStorageFactory, log );
157 		assertTrue( "Test07 failed!", aTest.test() );
158 	}
159 
160     @Test
ExecuteTest08()161 	public void ExecuteTest08()
162 	{
163 		StorageTest aTest = new Test08( m_xMSF, m_xStorageFactory, log );
164 		assertTrue( "Test08 failed!", aTest.test() );
165 	}
166 
167     @Test
ExecuteTest09()168 	public void ExecuteTest09()
169 	{
170 		StorageTest aTest = new Test09( m_xMSF, m_xStorageFactory, log );
171 		assertTrue( "Test09 failed!", aTest.test() );
172 	}
173 
174     @Test
ExecuteTest10()175 	public void ExecuteTest10()
176 	{
177 		StorageTest aTest = new Test10( m_xMSF, m_xStorageFactory, log );
178 		assertTrue( "Test10 failed!", aTest.test() );
179 	}
180 
181     @Test
ExecuteTest11()182 	public void ExecuteTest11()
183 	{
184 		StorageTest aTest = new Test11( m_xMSF, m_xStorageFactory, log );
185 		assertTrue( "Test11 failed!", aTest.test() );
186 	}
187 
188     @Test
ExecuteTest12()189 	public void ExecuteTest12()
190 	{
191 		StorageTest aTest = new Test12( m_xMSF, m_xStorageFactory, log );
192 		assertTrue( "Test12 failed!", aTest.test() );
193 	}
194 
195     @Test
ExecuteTest13()196 	public void ExecuteTest13()
197 	{
198 		StorageTest aTest = new Test13( m_xMSF, m_xStorageFactory, log );
199 		assertTrue( "Test13 failed!", aTest.test() );
200 	}
201 
202     @Test
ExecuteTest14()203 	public void ExecuteTest14()
204 	{
205 		StorageTest aTest = new Test14( m_xMSF, m_xStorageFactory, log );
206 		assertTrue( "Test14 failed!", aTest.test() );
207 	}
208 
209     @Test
ExecuteTest15()210 	public void ExecuteTest15()
211 	{
212 		StorageTest aTest = new Test15( m_xMSF, m_xStorageFactory, log );
213 		assertTrue( "Test15 failed!", aTest.test() );
214 	}
215 
216     @Test
ExecuteTest16()217 	public void ExecuteTest16()
218 	{
219 		StorageTest aTest = new Test16( m_xMSF, m_xStorageFactory, log );
220 		assertTrue( "Test16 failed!", aTest.test() );
221 	}
222 
223     @Test
ExecuteTest17()224 	public void ExecuteTest17()
225 	{
226 		StorageTest aTest = new Test17( m_xMSF, m_xStorageFactory, log );
227 		assertTrue( "Test17 failed!", aTest.test() );
228 	}
229 
230     @Test
ExecuteTest18()231 	public void ExecuteTest18()
232 	{
233 		StorageTest aTest = new Test18( m_xMSF, m_xStorageFactory, log );
234 		assertTrue( "Test18 failed!", aTest.test() );
235 	}
236 
237     @Test
ExecuteRegressionTest_114358()238 	public void ExecuteRegressionTest_114358()
239 	{
240 		StorageTest aTest = new RegressionTest_114358( m_xMSF, m_xStorageFactory, log );
241 		assertTrue( "RegressionTest_114358 failed!", aTest.test() );
242 	}
243 
244     @Test
ExecuteRegressionTest_i29169()245 	public void ExecuteRegressionTest_i29169()
246 	{
247 		StorageTest aTest = new RegressionTest_i29169( m_xMSF, m_xStorageFactory, log );
248 		assertTrue( "RegressionTest_i29169 failed!", aTest.test() );
249 	}
250 
251     @Test
ExecuteRegressionTest_i30400()252 	public void ExecuteRegressionTest_i30400()
253 	{
254 		StorageTest aTest = new RegressionTest_i30400( m_xMSF, m_xStorageFactory, log );
255 		assertTrue( "RegressionTest_i30400 failed!", aTest.test() );
256 	}
257 
258     @Test
ExecuteRegressionTest_i29321()259 	public void ExecuteRegressionTest_i29321()
260 	{
261 		StorageTest aTest = new RegressionTest_i29321( m_xMSF, m_xStorageFactory, log );
262 		assertTrue( "RegressionTest_i29321 failed!", aTest.test() );
263 	}
264 
265     @Test
ExecuteRegressionTest_i30677()266 	public void ExecuteRegressionTest_i30677()
267 	{
268 		StorageTest aTest = new RegressionTest_i30677( m_xMSF, m_xStorageFactory, log );
269 		assertTrue( "RegressionTest_i30677 failed!", aTest.test() );
270 	}
271 
272     @Test
ExecuteRegressionTest_i27773()273 	public void ExecuteRegressionTest_i27773()
274 	{
275 		StorageTest aTest = new RegressionTest_i27773( m_xMSF, m_xStorageFactory, log );
276 		assertTrue( "RegressionTest_i27773 failed!", aTest.test() );
277 	}
278 
279     @Test
ExecuteRegressionTest_i46848()280 	public void ExecuteRegressionTest_i46848()
281 	{
282 		StorageTest aTest = new RegressionTest_i46848( m_xMSF, m_xStorageFactory, log );
283 		assertTrue( "RegressionTest_i46848 failed!", aTest.test() );
284 	}
285 
286     @Test
ExecuteRegressionTest_i55821()287 	public void ExecuteRegressionTest_i55821()
288 	{
289 		StorageTest aTest = new RegressionTest_i55821( m_xMSF, m_xStorageFactory, log );
290 		assertTrue( "RegressionTest_i55821 failed!", aTest.test() );
291 	}
292 
293     @Test
ExecuteRegressionTest_i35095()294 	public void ExecuteRegressionTest_i35095()
295 	{
296 		StorageTest aTest = new RegressionTest_i35095( m_xMSF, m_xStorageFactory, log );
297 		assertTrue( "RegressionTest_i35095 failed!", aTest.test() );
298 	}
299 
300     @Test
ExecuteRegressionTest_i49755()301 	public void ExecuteRegressionTest_i49755()
302 	{
303 		StorageTest aTest = new RegressionTest_i49755( m_xMSF, m_xStorageFactory, log );
304 		assertTrue( "RegressionTest_i49755 failed!", aTest.test() );
305 	}
306 
307     @Test
ExecuteRegressionTest_i59886()308 	public void ExecuteRegressionTest_i59886()
309 	{
310 		StorageTest aTest = new RegressionTest_i59886( m_xMSF, m_xStorageFactory, log );
311 		assertTrue( "RegressionTest_i59886 failed!", aTest.test() );
312 	}
313 
314     @Test
ExecuteRegressionTest_i61909()315 	public void ExecuteRegressionTest_i61909()
316 	{
317 		StorageTest aTest = new RegressionTest_i61909( m_xMSF, m_xStorageFactory, log );
318 		assertTrue( "RegressionTest_i61909 failed!", aTest.test() );
319 	}
320 
321     @Test
ExecuteRegressionTest_i84234()322 	public void ExecuteRegressionTest_i84234()
323 	{
324 		StorageTest aTest = new RegressionTest_i84234( m_xMSF, m_xStorageFactory, log );
325 		assertTrue( "RegressionTest_i84234 failed!", aTest.test() );
326 	}
327 
328     @Test
ExecuteRegressionTest_125919()329 	public void ExecuteRegressionTest_125919()
330 	{
331 		StorageTest aTest = new RegressionTest_125919( m_xMSF, m_xStorageFactory, log );
332 		assertTrue( "RegressionTest_125919 failed!", aTest.test() );
333 	}
334 }
335 
336