1*bc3375a3SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*bc3375a3SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*bc3375a3SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*bc3375a3SAndrew Rist  * distributed with this work for additional information
6*bc3375a3SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*bc3375a3SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*bc3375a3SAndrew Rist  * "License"); you may not use this file except in compliance
9*bc3375a3SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*bc3375a3SAndrew Rist  *
11*bc3375a3SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*bc3375a3SAndrew Rist  *
13*bc3375a3SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*bc3375a3SAndrew Rist  * software distributed under the License is distributed on an
15*bc3375a3SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*bc3375a3SAndrew Rist  * KIND, either express or implied.  See the License for the
17*bc3375a3SAndrew Rist  * specific language governing permissions and limitations
18*bc3375a3SAndrew Rist  * under the License.
19*bc3375a3SAndrew Rist  *
20*bc3375a3SAndrew Rist  *************************************************************/
21*bc3375a3SAndrew Rist 
22*bc3375a3SAndrew Rist 
23cdf0e10cSrcweir package complex.tempfile;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir // import complexlib.ComplexTestCase;
26cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
27cdf0e10cSrcweir import com.sun.star.ucb.XSimpleFileAccess;
28cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
29cdf0e10cSrcweir 
30cdf0e10cSrcweir import org.junit.After;
31cdf0e10cSrcweir import org.junit.AfterClass;
32cdf0e10cSrcweir import org.junit.Before;
33cdf0e10cSrcweir import org.junit.BeforeClass;
34cdf0e10cSrcweir import org.junit.Test;
35cdf0e10cSrcweir import org.openoffice.test.OfficeConnection;
36cdf0e10cSrcweir import static org.junit.Assert.*;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir /* Document.
39cdf0e10cSrcweir  */
40cdf0e10cSrcweir 
41cdf0e10cSrcweir public class TempFileUnitTest /* extends ComplexTestCase */ {
42cdf0e10cSrcweir     private XMultiServiceFactory m_xMSF = null;
43cdf0e10cSrcweir     private XSimpleFileAccess m_xSFA = null;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir //    public String[] getTestMethodNames() {
46cdf0e10cSrcweir //        return new String[] {
47cdf0e10cSrcweir //            "ExecuteTest01",
48cdf0e10cSrcweir //            "ExecuteTest02"};
49cdf0e10cSrcweir //    }
50cdf0e10cSrcweir //
51cdf0e10cSrcweir //    public String getTestObjectName() {
52cdf0e10cSrcweir //        return "TempFileUnitTest";
53cdf0e10cSrcweir //    }
54cdf0e10cSrcweir 
before()55cdf0e10cSrcweir     @Before public void before() {
56cdf0e10cSrcweir         m_xMSF = getMSF();
57cdf0e10cSrcweir         if ( m_xMSF == null ) {
58cdf0e10cSrcweir             fail ( "Cannot create service factory!" );
59cdf0e10cSrcweir         }
60cdf0e10cSrcweir         try
61cdf0e10cSrcweir         {
62cdf0e10cSrcweir             Object oSFA = m_xMSF.createInstance( "com.sun.star.ucb.SimpleFileAccess" );
63cdf0e10cSrcweir             m_xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class, oSFA );
64cdf0e10cSrcweir         }
65cdf0e10cSrcweir         catch ( Exception e )
66cdf0e10cSrcweir         {
67cdf0e10cSrcweir             fail ( "Cannot get simple file access! Exception: " + e);
68cdf0e10cSrcweir         }
69cdf0e10cSrcweir         if ( m_xSFA == null ) {
70cdf0e10cSrcweir             fail ( "Cannot get simple file access!" );
71cdf0e10cSrcweir         }
72cdf0e10cSrcweir     }
73cdf0e10cSrcweir 
after()74cdf0e10cSrcweir     @After public void after() {
75cdf0e10cSrcweir         m_xMSF = null;
76cdf0e10cSrcweir         m_xSFA = null;
77cdf0e10cSrcweir     }
78cdf0e10cSrcweir 
ExecuteTest01()79cdf0e10cSrcweir     @Test public void ExecuteTest01() {
80cdf0e10cSrcweir         TempFileTest aTest = new Test01( m_xMSF, m_xSFA );
81cdf0e10cSrcweir         assertTrue( "Test01 failed!", aTest.test() );
82cdf0e10cSrcweir     }
83cdf0e10cSrcweir 
ExecuteTest02()84cdf0e10cSrcweir     @Test public void ExecuteTest02() {
85cdf0e10cSrcweir         TempFileTest aTest = new Test02( m_xMSF, m_xSFA );
86cdf0e10cSrcweir         assertTrue( "Test02 failed!", aTest.test() );
87cdf0e10cSrcweir     }
88cdf0e10cSrcweir 
getMSF()89cdf0e10cSrcweir     private XMultiServiceFactory getMSF()
90cdf0e10cSrcweir     {
91cdf0e10cSrcweir         final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
92cdf0e10cSrcweir         return xMSF1;
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     // setup and close connections
setUpConnection()96cdf0e10cSrcweir     @BeforeClass public static void setUpConnection() throws Exception {
97cdf0e10cSrcweir         System.out.println("setUpConnection()");
98cdf0e10cSrcweir         connection.setUp();
99cdf0e10cSrcweir     }
100cdf0e10cSrcweir 
tearDownConnection()101cdf0e10cSrcweir     @AfterClass public static void tearDownConnection()
102cdf0e10cSrcweir         throws InterruptedException, com.sun.star.uno.Exception
103cdf0e10cSrcweir     {
104cdf0e10cSrcweir         System.out.println("tearDownConnection()");
105cdf0e10cSrcweir         connection.tearDown();
106cdf0e10cSrcweir     }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     private static final OfficeConnection connection = new OfficeConnection();
109cdf0e10cSrcweir };
110cdf0e10cSrcweir 
111