diff options
author | Lars Langhans <lla@openoffice.org> | 2010-06-07 12:21:37 +0200 |
---|---|---|
committer | Lars Langhans <lla@openoffice.org> | 2010-06-07 12:21:37 +0200 |
commit | 7a058994a9a89a397d5824a03a4c654feed829a3 (patch) | |
tree | 85ec510d80455dd027cc8480e653ce32cd9154d9 /unotools/qa | |
parent | 25dc0b273b730d5ac4630dbc618d70ca87229ca9 (diff) |
sb123:#i111449# cleanups in unotools qa/complex tests
Diffstat (limited to 'unotools/qa')
-rw-r--r-- | unotools/qa/complex/tempfile/TempFileUnitTest.java | 81 | ||||
-rw-r--r-- | unotools/qa/complex/tempfile/Test01.java | 12 | ||||
-rw-r--r-- | unotools/qa/complex/tempfile/Test02.java | 14 | ||||
-rw-r--r-- | unotools/qa/complex/tempfile/TestHelper.java | 20 | ||||
-rw-r--r-- | unotools/qa/complex/tempfile/makefile.mk | 70 |
5 files changed, 95 insertions, 102 deletions
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(); +}; + diff --git a/unotools/qa/complex/tempfile/Test01.java b/unotools/qa/complex/tempfile/Test01.java index dbf3d6c15de2..3eac1c2ecf44 100644 --- a/unotools/qa/complex/tempfile/Test01.java +++ b/unotools/qa/complex/tempfile/Test01.java @@ -26,7 +26,7 @@ ************************************************************************/ package complex.tempfile; -import complexlib.ComplexTestCase; +// import complexlib.ComplexTestCase; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.ucb.XSimpleFileAccess; @@ -42,10 +42,10 @@ public class Test01 implements TempFileTest { XSimpleFileAccess m_xSFA = null; TestHelper m_aTestHelper = null; - public Test01(XMultiServiceFactory xMSF, XSimpleFileAccess xSFA, LogWriter aLogWriter) { + public Test01(XMultiServiceFactory xMSF, XSimpleFileAccess xSFA) { m_xMSF = xMSF; m_xSFA = xSFA; - m_aTestHelper = new TestHelper(aLogWriter, "Test01: "); + m_aTestHelper = new TestHelper( "Test01: "); } public boolean test() { @@ -56,11 +56,9 @@ public class Test01 implements TempFileTest { //create a temporary file. try { Object oTempFile = m_xMSF.createInstance( "com.sun.star.io.TempFile" ); - xTempFile = (XTempFile) UnoRuntime.queryInterface( XTempFile.class, - oTempFile ); + xTempFile = UnoRuntime.queryInterface(XTempFile.class, oTempFile); m_aTestHelper.Message( "Tempfile created." ); - xTruncate = (XTruncate)UnoRuntime.queryInterface( XTruncate.class, - oTempFile ); + xTruncate = UnoRuntime.queryInterface(XTruncate.class, oTempFile); } catch( Exception e ) { m_aTestHelper.Error( "Cannot create TempFile. exception: " + e ); return false; diff --git a/unotools/qa/complex/tempfile/Test02.java b/unotools/qa/complex/tempfile/Test02.java index 18ca4de2e04b..79e27720b31e 100644 --- a/unotools/qa/complex/tempfile/Test02.java +++ b/unotools/qa/complex/tempfile/Test02.java @@ -26,15 +26,13 @@ ************************************************************************/ package complex.tempfile; -import complexlib.ComplexTestCase; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.ucb.XSimpleFileAccess; import com.sun.star.io.*; -import com.sun.star.lang.XServiceInfo; + import com.sun.star.uno.UnoRuntime; import java.util.Random; -import share.LogWriter; public class Test02 implements TempFileTest { @@ -42,10 +40,10 @@ public class Test02 implements TempFileTest { XSimpleFileAccess m_xSFA; TestHelper m_aTestHelper; - public Test02(XMultiServiceFactory xMSF, XSimpleFileAccess xSFA, LogWriter aLogWriter) { + public Test02(XMultiServiceFactory xMSF, XSimpleFileAccess xSFA) { m_xMSF = xMSF; m_xSFA = xSFA; - m_aTestHelper = new TestHelper(aLogWriter, "Test02: "); + m_aTestHelper = new TestHelper( "Test02: "); } public boolean test() { @@ -57,11 +55,9 @@ public class Test02 implements TempFileTest { //create a temporary file. try { oTempFile = m_xMSF.createInstance( "com.sun.star.io.TempFile" ); - xTempFile = (XTempFile) UnoRuntime.queryInterface( XTempFile.class, - oTempFile ); + xTempFile = UnoRuntime.queryInterface(XTempFile.class, oTempFile); m_aTestHelper.Message( "Tempfile created." ); - xTruncate = (XTruncate)UnoRuntime.queryInterface( XTruncate.class, - oTempFile ); + xTruncate = UnoRuntime.queryInterface(XTruncate.class, oTempFile); } catch(Exception e) { m_aTestHelper.Error( "Cannot create TempFile. exception: " + e ); return false; diff --git a/unotools/qa/complex/tempfile/TestHelper.java b/unotools/qa/complex/tempfile/TestHelper.java index 6edc2c362fa8..cf93828624f5 100644 --- a/unotools/qa/complex/tempfile/TestHelper.java +++ b/unotools/qa/complex/tempfile/TestHelper.java @@ -26,22 +26,20 @@ ************************************************************************/ package complex.tempfile; -import complexlib.ComplexTestCase; -import com.sun.star.lang.XMultiServiceFactory; + import com.sun.star.io.*; import com.sun.star.uno.AnyConverter; import com.sun.star.ucb.XSimpleFileAccess; -import com.sun.star.uno.UnoRuntime; -import share.LogWriter; + public class TestHelper { - LogWriter m_aLogWriter; + String m_sTestPrefix; - public TestHelper( LogWriter aLogWriter, String sTestPrefix ) { - m_aLogWriter = aLogWriter; + public TestHelper( String sTestPrefix ) { + m_sTestPrefix = sTestPrefix; } public void SetTempFileRemove( XTempFile xTempFile, boolean b ) { @@ -69,7 +67,7 @@ public class TestHelper { } catch (Exception e) { Error ( "Cannot get TempFileURL. exception: " + e ); } - if ( sTempFileURL == null || sTempFileURL == "" ) { + if ( sTempFileURL == null || sTempFileURL.equals("") ) { Error ( "Temporary file not valid." ); } return sTempFileURL; @@ -82,7 +80,7 @@ public class TestHelper { } catch ( Exception e ) { Error( "Cannot get TempFileName. exception: " + e ); } - if ( sTempFileName == null || sTempFileName == "") { + if ( sTempFileName == null || sTempFileName.equals("") ) { Error( "Temporary file not valid." ); } return sTempFileName; @@ -216,10 +214,10 @@ public class TestHelper { } public void Error( String sError ) { - m_aLogWriter.println( m_sTestPrefix + "Error: " + sError ); + System.out.println( m_sTestPrefix + "Error: " + sError ); } public void Message( String sMessage ) { - m_aLogWriter.println( m_sTestPrefix + sMessage ); + System.out.println( m_sTestPrefix + sMessage ); } } diff --git a/unotools/qa/complex/tempfile/makefile.mk b/unotools/qa/complex/tempfile/makefile.mk index 13d66ca3edd1..30a5eb7261ec 100644 --- a/unotools/qa/complex/tempfile/makefile.mk +++ b/unotools/qa/complex/tempfile/makefile.mk @@ -25,61 +25,33 @@ # #************************************************************************* -PRJ = ..$/..$/.. -TARGET = TempFileUnitTest -PRJNAME = unotools -PACKAGE = complex$/tempfile - -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - - -#----- compile .java files ----------------------------------------- - -JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar - -JAVAFILES =\ - TempFileUnitTest.java\ - TempFileTest.java\ - TestHelper.java\ - Test01.java\ - Test02.java - -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -#----- make a jar from compiled files ------------------------------ - -MAXLINELENGTH = 100000 - -JARCLASSDIRS = $(PACKAGE) -JARTARGET = $(TARGET).jar -JARCOMPRESS = TRUE - -# --- Parameters for the test -------------------------------------- - -# start an office if the parameter is set for the makefile -.IF "$(OFFICE)" == "" -CT_APPEXECCOMMAND = +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: .ELSE -CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;" -.ENDIF -# test base is java complex -CT_TESTBASE = -TestBase java_complex +PRJ = ../../.. +PRJNAME = unotools +TARGET = qa_complex_tempfile -# test looks something like the.full.package.TestName -CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b) +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/tempfile +JAVATESTFILES = \ + TempFileUnitTest.java -# start the runner application -CT_APP = org.openoffice.Runner +JAVAFILES = $(JAVATESTFILES) \ + TempFileTest.java \ + Test01.java \ + Test02.java \ + TestHelper.java -# --- Targets ------------------------------------------------------ +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar jurt.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END +.INCLUDE: settings.mk .INCLUDE: target.mk +.INCLUDE: installationtest.mk -RUN: run - -run: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST) - +ALLTAR : javatest +.END |