1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 package complex.tempfile;
28 
29 // import complexlib.ComplexTestCase;
30 import com.sun.star.lang.XMultiServiceFactory;
31 import com.sun.star.ucb.XSimpleFileAccess;
32 import com.sun.star.uno.UnoRuntime;
33 
34 import org.junit.After;
35 import org.junit.AfterClass;
36 import org.junit.Before;
37 import org.junit.BeforeClass;
38 import org.junit.Test;
39 import org.openoffice.test.OfficeConnection;
40 import static org.junit.Assert.*;
41 
42 /* Document.
43  */
44 
45 public class TempFileUnitTest /* extends ComplexTestCase */ {
46     private XMultiServiceFactory m_xMSF = null;
47     private XSimpleFileAccess m_xSFA = null;
48 
49 //    public String[] getTestMethodNames() {
50 //        return new String[] {
51 //            "ExecuteTest01",
52 //            "ExecuteTest02"};
53 //    }
54 //
55 //    public String getTestObjectName() {
56 //        return "TempFileUnitTest";
57 //    }
58 
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 
115