From 7a058994a9a89a397d5824a03a4c654feed829a3 Mon Sep 17 00:00:00 2001 From: Lars Langhans Date: Mon, 7 Jun 2010 12:21:37 +0200 Subject: sb123:#i111449# cleanups in unotools qa/complex tests --- unotools/qa/complex/tempfile/TempFileUnitTest.java | 81 +++++++++++++++------- 1 file changed, 55 insertions(+), 26 deletions(-) (limited to 'unotools/qa/complex/tempfile/TempFileUnitTest.java') diff --git a/unotools/qa/complex/tempfile/TempFileUnitTest.java b/unotools/qa/complex/tempfile/TempFileUnitTest.java index 5cd0b7292105..e5f1f2d6d6b2 100644 --- a/unotools/qa/complex/tempfile/TempFileUnitTest.java +++ b/unotools/qa/complex/tempfile/TempFileUnitTest.java @@ -26,60 +26,89 @@ ************************************************************************/ package complex.tempfile; -import complexlib.ComplexTestCase; +// import complexlib.ComplexTestCase; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.ucb.XSimpleFileAccess; import com.sun.star.uno.UnoRuntime; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + /* Document. */ -public class TempFileUnitTest extends ComplexTestCase { +public class TempFileUnitTest /* extends ComplexTestCase */ { private XMultiServiceFactory m_xMSF = null; private XSimpleFileAccess m_xSFA = null; - public String[] getTestMethodNames() { - return new String[] { - "ExecuteTest01", - "ExecuteTest02"}; - } - - public String getTestObjectName() { - return "TempFileUnitTest"; - } +// public String[] getTestMethodNames() { +// return new String[] { +// "ExecuteTest01", +// "ExecuteTest02"}; +// } +// +// public String getTestObjectName() { +// return "TempFileUnitTest"; +// } - public void before() { - m_xMSF = (XMultiServiceFactory)param.getMSF(); + @Before public void before() { + m_xMSF = getMSF(); if ( m_xMSF == null ) { - failed ( "Cannot create service factory!" ); + fail ( "Cannot create service factory!" ); } try { Object oSFA = m_xMSF.createInstance( "com.sun.star.ucb.SimpleFileAccess" ); - m_xSFA = ( XSimpleFileAccess )UnoRuntime.queryInterface( XSimpleFileAccess.class, - oSFA ); + m_xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class, oSFA ); } catch ( Exception e ) { - failed ( "Cannot get simple file access! Exception: " + e); + fail ( "Cannot get simple file access! Exception: " + e); } if ( m_xSFA == null ) { - failed ( "Cannot get simple file access!" ); + fail ( "Cannot get simple file access!" ); } } - public void after() { + @After public void after() { m_xMSF = null; m_xSFA = null; } - public void ExecuteTest01() { - TempFileTest aTest = new Test01( m_xMSF, m_xSFA, log ); - assure( "Test01 failed!", aTest.test() ); + @Test public void ExecuteTest01() { + TempFileTest aTest = new Test01( m_xMSF, m_xSFA ); + assertTrue( "Test01 failed!", aTest.test() ); + } + + @Test public void ExecuteTest02() { + TempFileTest aTest = new Test02( m_xMSF, m_xSFA ); + assertTrue( "Test02 failed!", aTest.test() ); } - public void ExecuteTest02() { - TempFileTest aTest = new Test02( m_xMSF, m_xSFA, log ); - assure( "Test02 failed!", aTest.test() ); + private XMultiServiceFactory getMSF() + { + final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + return xMSF1; } -}; \ No newline at end of file + + // setup and close connections + @BeforeClass public static void setUpConnection() throws Exception { + System.out.println("setUpConnection()"); + connection.setUp(); + } + + @AfterClass public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println("tearDownConnection()"); + connection.tearDown(); + } + + private static final OfficeConnection connection = new OfficeConnection(); +}; + -- cgit