xref: /trunk/main/sot/qa/complex/olesimplestorage/OLESimpleStorageUnitTest.java (revision 3309286857f19787ae62bd793a98b5af4edd2ad3)
1b191c303SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b191c303SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b191c303SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b191c303SAndrew Rist  * distributed with this work for additional information
6b191c303SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b191c303SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b191c303SAndrew Rist  * "License"); you may not use this file except in compliance
9b191c303SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11b191c303SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13b191c303SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b191c303SAndrew Rist  * software distributed under the License is distributed on an
15b191c303SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b191c303SAndrew Rist  * KIND, either express or implied.  See the License for the
17b191c303SAndrew Rist  * specific language governing permissions and limitations
18b191c303SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20b191c303SAndrew Rist  *************************************************************/
21b191c303SAndrew Rist 
22b191c303SAndrew Rist 
23cdf0e10cSrcweir package complex.olesimplestorage;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
26cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir import org.junit.After;
30cdf0e10cSrcweir import org.junit.AfterClass;
31cdf0e10cSrcweir import org.junit.Before;
32cdf0e10cSrcweir import org.junit.BeforeClass;
33cdf0e10cSrcweir import org.junit.Test;
34cdf0e10cSrcweir import org.openoffice.test.OfficeConnection;
35cdf0e10cSrcweir import static org.junit.Assert.*;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir /* Document.
38cdf0e10cSrcweir  */
39cdf0e10cSrcweir 
40*c944caccSDamjan Jovanovic public class OLESimpleStorageUnitTest
41cdf0e10cSrcweir {
42cdf0e10cSrcweir     private XMultiServiceFactory m_xMSF = null;
43cdf0e10cSrcweir 
before()44cdf0e10cSrcweir     @Before public void before () {
45cdf0e10cSrcweir         System.out.println("before()");
46cdf0e10cSrcweir         try {
47cdf0e10cSrcweir             m_xMSF = getMSF();
48cdf0e10cSrcweir         } catch ( Exception e ){
49cdf0e10cSrcweir             fail( "Cannot create service factory!" );
50cdf0e10cSrcweir         }
51cdf0e10cSrcweir         if ( m_xMSF == null ) {
52cdf0e10cSrcweir             fail( "Cannot create service factory!" );
53cdf0e10cSrcweir         }
54cdf0e10cSrcweir     }
55cdf0e10cSrcweir 
after()56cdf0e10cSrcweir     @After public void after () {
57cdf0e10cSrcweir         System.out.println("after()");
58cdf0e10cSrcweir         m_xMSF = null;
59cdf0e10cSrcweir     }
60cdf0e10cSrcweir 
ExecuteTest01()61cdf0e10cSrcweir     @Test public void ExecuteTest01() {
62cdf0e10cSrcweir         System.out.println("ExecuteTest01()");
63cdf0e10cSrcweir         OLESimpleStorageTest aTest = new Test01( m_xMSF );
64cdf0e10cSrcweir         assertTrue( "Test01 failed!", aTest.test() );
65cdf0e10cSrcweir     }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 
getMSF()69cdf0e10cSrcweir     private XMultiServiceFactory getMSF()
70cdf0e10cSrcweir     {
71cdf0e10cSrcweir         final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
72cdf0e10cSrcweir         return xMSF1;
73cdf0e10cSrcweir     }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     // setup and close connections
setUpConnection()76cdf0e10cSrcweir     @BeforeClass public static void setUpConnection() throws Exception {
77cdf0e10cSrcweir         System.out.println("setUpConnection()");
78cdf0e10cSrcweir         connection.setUp();
79cdf0e10cSrcweir     }
80cdf0e10cSrcweir 
tearDownConnection()81cdf0e10cSrcweir     @AfterClass public static void tearDownConnection()
82cdf0e10cSrcweir         throws InterruptedException, com.sun.star.uno.Exception
83cdf0e10cSrcweir     {
84cdf0e10cSrcweir //        try
85cdf0e10cSrcweir //        {
86cdf0e10cSrcweir //            Thread.sleep(5000);
87cdf0e10cSrcweir //        }
88cdf0e10cSrcweir //        catch (java.lang.InterruptedException e)
89cdf0e10cSrcweir //        {
90cdf0e10cSrcweir //        }
91cdf0e10cSrcweir         System.out.println("tearDownConnection()");
92cdf0e10cSrcweir         connection.tearDown();
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     private static final OfficeConnection connection = new OfficeConnection();
96cdf0e10cSrcweir 
97cdf0e10cSrcweir }
98