sb123:#i111449# cleanups in unotools qa/complex tests

This commit is contained in:
Lars Langhans 2010-06-07 12:21:37 +02:00
parent 25dc0b273b
commit 7a058994a9
6 changed files with 97 additions and 102 deletions

View file

@ -10,3 +10,5 @@ ut unotools\source\i18n nmake - all ut_i18n ut_inc NULL
ut unotools\source\property nmake - all ut_property ut_inc NULL
ut unotools\source\accessibility nmake - all ut_accessibility ut_inc NULL
ut unotools\util nmake - all ut_util ut_config ut_i18n ut_misc ut_procfact ut_streaming ut_ucbhelper ut_property ut_accessibility NULL
ut unotools\qa\complex\tempfile nmake - all ut_qa_complex ut_util NULL

View file

@ -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[] getTestMethodNames() {
// return new String[] {
// "ExecuteTest01",
// "ExecuteTest02"};
// }
//
// public String getTestObjectName() {
// return "TempFileUnitTest";
// }
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() );
}
public void ExecuteTest02() {
TempFileTest aTest = new Test02( m_xMSF, m_xSFA, log );
assure( "Test02 failed!", aTest.test() );
@Test public void ExecuteTest02() {
TempFileTest aTest = new Test02( m_xMSF, m_xSFA );
assertTrue( "Test02 failed!", aTest.test() );
}
};
private XMultiServiceFactory getMSF()
{
final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
return xMSF1;
}
// 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();
};

View file

@ -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;

View file

@ -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;

View file

@ -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 );
}
}

View file

@ -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