summaryrefslogtreecommitdiff
path: root/sfx2/qa/complex/sfx2/JUnitBasedTest.java
blob: a43493712c314bc38a7fec981bc64c4950e94d52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package complex.sfx2;

import org.openoffice.test.OfficeConnection;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.XComponentContext;
import org.junit.AfterClass;
import org.junit.BeforeClass;

/**
 *
 * @author Frank
 */
public class JUnitBasedTest
{
    // -----------------------------------------------------------------------------------------------------------------
    protected XComponentContext getContext()
    {
        return m_connection.getComponentContext();
    }

    // -----------------------------------------------------------------------------------------------------------------
    protected XMultiServiceFactory getORB()
    {
        final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(
            XMultiServiceFactory.class, getContext().getServiceManager() );
        return xMSF1;
    }

    // -----------------------------------------------------------------------------------------------------------------
    @BeforeClass
    public static void setUpConnection() throws Exception
    {
        System.out.println( "--------------------------------------------------------------------------------" );
        System.out.println( "connecting ..." );
        m_connection.setUp();
    }

    // -----------------------------------------------------------------------------------------------------------------
    @AfterClass
    public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
    {
        System.out.println();
        System.out.println( "tearing down connection" );
        m_connection.tearDown();
        System.out.println( "--------------------------------------------------------------------------------" );
    }

    private static final OfficeConnection   m_connection = new OfficeConnection();
}