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