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 /* extends ComplexTestCase */ 41 { 42 private XMultiServiceFactory m_xMSF = null; 43 44 // public String[] getTestMethodNames() { 45 // return new String[] { 46 // "ExecuteTest01"}; 47 // } 48 // 49 // public String getTestObjectName() { 50 // return "OLESimpleStorageUnitTest"; 51 // } 52 before()53 @Before public void before () { 54 System.out.println("before()"); 55 try { 56 m_xMSF = getMSF(); 57 } catch ( Exception e ){ 58 fail( "Cannot create service factory!" ); 59 } 60 if ( m_xMSF == null ) { 61 fail( "Cannot create service factory!" ); 62 } 63 } 64 after()65 @After public void after () { 66 System.out.println("after()"); 67 m_xMSF = null; 68 } 69 ExecuteTest01()70 @Test public void ExecuteTest01() { 71 System.out.println("ExecuteTest01()"); 72 OLESimpleStorageTest aTest = new Test01( m_xMSF ); 73 assertTrue( "Test01 failed!", aTest.test() ); 74 } 75 76 77 getMSF()78 private XMultiServiceFactory getMSF() 79 { 80 final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); 81 return xMSF1; 82 } 83 84 // setup and close connections setUpConnection()85 @BeforeClass public static void setUpConnection() throws Exception { 86 System.out.println("setUpConnection()"); 87 connection.setUp(); 88 } 89 tearDownConnection()90 @AfterClass public static void tearDownConnection() 91 throws InterruptedException, com.sun.star.uno.Exception 92 { 93 // try 94 // { 95 // Thread.sleep(5000); 96 // } 97 // catch (java.lang.InterruptedException e) 98 // { 99 // } 100 System.out.println("tearDownConnection()"); 101 connection.tearDown(); 102 } 103 104 private static final OfficeConnection connection = new OfficeConnection(); 105 106 }