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.olesimplestorage; 24 25 import com.sun.star.lang.XMultiServiceFactory; 26 import com.sun.star.uno.UnoRuntime; 27 28 29 import org.junit.After; 30 import org.junit.AfterClass; 31 import org.junit.Before; 32 import org.junit.BeforeClass; 33 import org.junit.Test; 34 import org.openoffice.test.OfficeConnection; 35 import static org.junit.Assert.*; 36 37 /* Document. 38 */ 39 40 public class OLESimpleStorageUnitTest 41 { 42 private XMultiServiceFactory m_xMSF = null; 43 before()44 @Before public void before () { 45 System.out.println("before()"); 46 try { 47 m_xMSF = getMSF(); 48 } catch ( Exception e ){ 49 fail( "Cannot create service factory!" ); 50 } 51 if ( m_xMSF == null ) { 52 fail( "Cannot create service factory!" ); 53 } 54 } 55 after()56 @After public void after () { 57 System.out.println("after()"); 58 m_xMSF = null; 59 } 60 ExecuteTest01()61 @Test public void ExecuteTest01() { 62 System.out.println("ExecuteTest01()"); 63 OLESimpleStorageTest aTest = new Test01( m_xMSF ); 64 assertTrue( "Test01 failed!", aTest.test() ); 65 } 66 67 68 getMSF()69 private XMultiServiceFactory getMSF() 70 { 71 final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); 72 return xMSF1; 73 } 74 75 // setup and close connections setUpConnection()76 @BeforeClass public static void setUpConnection() throws Exception { 77 System.out.println("setUpConnection()"); 78 connection.setUp(); 79 } 80 tearDownConnection()81 @AfterClass public static void tearDownConnection() 82 throws InterruptedException, com.sun.star.uno.Exception 83 { 84 // try 85 // { 86 // Thread.sleep(5000); 87 // } 88 // catch (java.lang.InterruptedException e) 89 // { 90 // } 91 System.out.println("tearDownConnection()"); 92 connection.tearDown(); 93 } 94 95 private static final OfficeConnection connection = new OfficeConnection(); 96 97 } 98