xref: /AOO42X/main/unotools/qa/complex/tempfile/TempFileUnitTest.java (revision b0efeae40e43e6d4ccd561d22ec612d42773857b)
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.tempfile;
24 
25 // import complexlib.ComplexTestCase;
26 import com.sun.star.lang.XMultiServiceFactory;
27 import com.sun.star.ucb.XSimpleFileAccess;
28 import com.sun.star.uno.UnoRuntime;
29 
30 import org.junit.After;
31 import org.junit.AfterClass;
32 import org.junit.Before;
33 import org.junit.BeforeClass;
34 import org.junit.Test;
35 import org.openoffice.test.OfficeConnection;
36 import static org.junit.Assert.*;
37 
38 /* Document.
39  */
40 
41 public class TempFileUnitTest /* extends ComplexTestCase */ {
42     private XMultiServiceFactory m_xMSF = null;
43     private XSimpleFileAccess m_xSFA = null;
44 <<<<<<< HEAD
45 
46 //    public String[] getTestMethodNames() {
47 //        return new String[] {
48 //            "ExecuteTest01",
49 //            "ExecuteTest02"};
50 //    }
51 //
52 //    public String getTestObjectName() {
53 //        return "TempFileUnitTest";
54 //    }
55 
56 =======
57 
58 >>>>>>> 3309286857 (pre-commit auto remove trailing whitespace from java files (#382))
59     @Before public void before() {
60         m_xMSF = getMSF();
61         if ( m_xMSF == null ) {
62             fail ( "Cannot create service factory!" );
63         }
64         try
65         {
66             Object oSFA = m_xMSF.createInstance( "com.sun.star.ucb.SimpleFileAccess" );
67             m_xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class, oSFA );
68         }
69         catch ( Exception e )
70         {
71             fail ( "Cannot get simple file access! Exception: " + e);
72         }
73         if ( m_xSFA == null ) {
74             fail ( "Cannot get simple file access!" );
75         }
76     }
77 
78     @After public void after() {
79         m_xMSF = null;
80         m_xSFA = null;
81     }
82 
83     @Test public void ExecuteTest01() {
84         TempFileTest aTest = new Test01( m_xMSF, m_xSFA );
85         assertTrue( "Test01 failed!", aTest.test() );
86     }
87 
88     @Test public void ExecuteTest02() {
89         TempFileTest aTest = new Test02( m_xMSF, m_xSFA );
90         assertTrue( "Test02 failed!", aTest.test() );
91     }
92 
93     private XMultiServiceFactory getMSF()
94     {
95         final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
96         return xMSF1;
97     }
98 
99     // setup and close connections
100     @BeforeClass public static void setUpConnection() throws Exception {
101         System.out.println("setUpConnection()");
102         connection.setUp();
103     }
104 
105     @AfterClass public static void tearDownConnection()
106         throws InterruptedException, com.sun.star.uno.Exception
107     {
108         System.out.println("tearDownConnection()");
109         connection.tearDown();
110     }
111 
112     private static final OfficeConnection connection = new OfficeConnection();
113 };
114