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