Kaydet (Commit) 69309ccb authored tarafından Lars Langhans's avatar Lars Langhans

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

üst 7a058994
to sot : tools ucbhelper unotools NULL to sot : tools ucbhelper unotools NULL
to sot usr1 - all sot_mkout NULL to sot usr1 - all sot_mkout NULL
to sot\inc nmake - all sot_inc NULL to sot\inc nmake - all sot_inc NULL
to sot\prj get - all sot_prj NULL to sot\prj get - all sot_prj NULL
to sot\source\base nmake - all sot_base sot_inc NULL to sot\source\base nmake - all sot_base sot_inc NULL
to sot\source\sdstor nmake - all sot_sdst sot_inc NULL to sot\source\sdstor nmake - all sot_sdst sot_inc NULL
to sot\source\unoolestorage nmake - all sot_unoolestor sot_inc NULL to sot\source\unoolestorage nmake - all sot_unoolestor sot_inc NULL
to sot\util nmake - all sot_ut sot_base sot_sdst sot_unoolestor NULL to sot\util nmake - all sot_ut sot_base sot_sdst sot_unoolestor NULL
to sot\qa\complex\olesimplestorage nmake - all sot_complex sot_ut NULL
...@@ -26,42 +26,85 @@ ...@@ -26,42 +26,85 @@
************************************************************************/ ************************************************************************/
package complex.olesimplestorage; package complex.olesimplestorage;
import complexlib.ComplexTestCase;
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime; 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. /* Document.
*/ */
public class OLESimpleStorageUnitTest extends ComplexTestCase { public class OLESimpleStorageUnitTest /* extends ComplexTestCase */
{
private XMultiServiceFactory m_xMSF = null; private XMultiServiceFactory m_xMSF = null;
public String[] getTestMethodNames() { // public String[] getTestMethodNames() {
return new String[] { // return new String[] {
"ExecuteTest01"}; // "ExecuteTest01"};
} // }
//
public String getTestObjectName() { // public String getTestObjectName() {
return "OLESimpleStorageUnitTest"; // return "OLESimpleStorageUnitTest";
} // }
public void before () { @Before public void before () {
System.out.println("before()");
try { try {
m_xMSF = (XMultiServiceFactory)param.getMSF(); m_xMSF = getMSF();
} catch ( Exception e ){ } catch ( Exception e ){
failed ( "Cannot create service factory!" ); fail( "Cannot create service factory!" );
} }
if ( m_xMSF == null ) { if ( m_xMSF == null ) {
failed ( "Cannot create service factory!" ); fail( "Cannot create service factory!" );
} }
} }
public void after () { @After public void after () {
System.out.println("after()");
m_xMSF = null; m_xMSF = null;
} }
public void ExecuteTest01() { @Test public void ExecuteTest01() {
OLESimpleStorageTest aTest = new Test01( m_xMSF, log ); System.out.println("ExecuteTest01()");
assure( "Test01 failed!", aTest.test() ); OLESimpleStorageTest aTest = new Test01( m_xMSF );
assertTrue( "Test01 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
{
// try
// {
// Thread.sleep(5000);
// }
// catch (java.lang.InterruptedException e)
// {
// }
System.out.println("tearDownConnection()");
connection.tearDown();
}
private static final OfficeConnection connection = new OfficeConnection();
} }
\ No newline at end of file
package complex.olesimplestorage; package complex.olesimplestorage;
import complexlib.ComplexTestCase;
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.io.XInputStream; import com.sun.star.io.XInputStream;
...@@ -10,7 +10,7 @@ import com.sun.star.embed.XOLESimpleStorage; ...@@ -10,7 +10,7 @@ import com.sun.star.embed.XOLESimpleStorage;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import java.util.Random; import java.util.Random;
import share.LogWriter;
public class Test01 implements OLESimpleStorageTest public class Test01 implements OLESimpleStorageTest
{ {
...@@ -19,10 +19,10 @@ public class Test01 implements OLESimpleStorageTest ...@@ -19,10 +19,10 @@ public class Test01 implements OLESimpleStorageTest
final int pStreamCnt = 5; final int pStreamCnt = 5;
final int pBytesCnt = 10; final int pBytesCnt = 10;
public Test01 ( XMultiServiceFactory xMSF, LogWriter aLogWriter ) public Test01 ( XMultiServiceFactory xMSF )
{ {
m_xMSF = xMSF; m_xMSF = xMSF;
m_aTestHelper = new TestHelper (aLogWriter, "Test01: "); m_aTestHelper = new TestHelper ("Test01: ");
} }
public boolean test () public boolean test ()
...@@ -31,7 +31,7 @@ public class Test01 implements OLESimpleStorageTest ...@@ -31,7 +31,7 @@ public class Test01 implements OLESimpleStorageTest
{ {
//create a new temporary stream //create a new temporary stream
Object oTempFile = m_xMSF.createInstance ( "com.sun.star.io.TempFile" ); Object oTempFile = m_xMSF.createInstance ( "com.sun.star.io.TempFile" );
XTempFile xTempFile = (XTempFile) UnoRuntime.queryInterface ( XTempFile.class, oTempFile ); XTempFile xTempFile = UnoRuntime.queryInterface(XTempFile.class, oTempFile);
m_aTestHelper.Message ( "A new temporary stream created." ); m_aTestHelper.Message ( "A new temporary stream created." );
//create OLESimpleStorage based on it //create OLESimpleStorage based on it
...@@ -39,7 +39,7 @@ public class Test01 implements OLESimpleStorageTest ...@@ -39,7 +39,7 @@ public class Test01 implements OLESimpleStorageTest
pArgs[0] = (Object) xTempFile; pArgs[0] = (Object) xTempFile;
pArgs[1] = new Boolean( true ); pArgs[1] = new Boolean( true );
Object oOLESimpleStorage = m_xMSF.createInstanceWithArguments ( "com.sun.star.embed.OLESimpleStorage", pArgs ); Object oOLESimpleStorage = m_xMSF.createInstanceWithArguments ( "com.sun.star.embed.OLESimpleStorage", pArgs );
XOLESimpleStorage xOLESimpleStorage = (XOLESimpleStorage) UnoRuntime.queryInterface ( XOLESimpleStorage.class, oOLESimpleStorage ); XOLESimpleStorage xOLESimpleStorage = UnoRuntime.queryInterface(XOLESimpleStorage.class, oOLESimpleStorage);
m_aTestHelper.Message ( "OLESimpleStorage based on XStream created." ); m_aTestHelper.Message ( "OLESimpleStorage based on XStream created." );
//fill it with some streams //fill it with some streams
...@@ -53,7 +53,7 @@ public class Test01 implements OLESimpleStorageTest ...@@ -53,7 +53,7 @@ public class Test01 implements OLESimpleStorageTest
{ {
oRandom.nextBytes (pBytesOut[i]); oRandom.nextBytes (pBytesOut[i]);
oStream[i] = m_xMSF.createInstance ( "com.sun.star.io.TempFile" ); oStream[i] = m_xMSF.createInstance ( "com.sun.star.io.TempFile" );
xTempStream[i] = (XTempFile) UnoRuntime.queryInterface ( XTempFile.class, oStream[i] ); xTempStream[i] = UnoRuntime.queryInterface(XTempFile.class, oStream[i]);
xTempStream[i].getOutputStream ().writeBytes (pBytesOut[i]); xTempStream[i].getOutputStream ().writeBytes (pBytesOut[i]);
xTempStream[i].seek (0); xTempStream[i].seek (0);
m_aTestHelper.Message ( "Substream " + i + " initialized." ); m_aTestHelper.Message ( "Substream " + i + " initialized." );
...@@ -83,7 +83,7 @@ public class Test01 implements OLESimpleStorageTest ...@@ -83,7 +83,7 @@ public class Test01 implements OLESimpleStorageTest
//open the same stream with the constructor for inputstream //open the same stream with the constructor for inputstream
pArgs[0] = (Object)xTempFile.getInputStream (); pArgs[0] = (Object)xTempFile.getInputStream ();
oOLESimpleStorage = m_xMSF.createInstanceWithArguments ( "com.sun.star.embed.OLESimpleStorage", pArgs ); oOLESimpleStorage = m_xMSF.createInstanceWithArguments ( "com.sun.star.embed.OLESimpleStorage", pArgs );
xOLESimpleStorage = (XOLESimpleStorage)UnoRuntime.queryInterface ( XOLESimpleStorage.class, oOLESimpleStorage ); xOLESimpleStorage = UnoRuntime.queryInterface(XOLESimpleStorage.class, oOLESimpleStorage);
m_aTestHelper.Message ( "Storage reopened, based on XInputStream." ); m_aTestHelper.Message ( "Storage reopened, based on XInputStream." );
//check that all the streams contain correct information //check that all the streams contain correct information
...@@ -92,8 +92,7 @@ public class Test01 implements OLESimpleStorageTest ...@@ -92,8 +92,7 @@ public class Test01 implements OLESimpleStorageTest
{ {
if ( xOLESimpleStorage.hasByName (sSubStreamPrefix + i) ) if ( xOLESimpleStorage.hasByName (sSubStreamPrefix + i) )
{ {
xTempStream[i] = (XTempFile)UnoRuntime.queryInterface ( xTempStream[i] = UnoRuntime.queryInterface(XTempFile.class, xOLESimpleStorage.getByName(sSubStreamPrefix + i));
XTempFile.class, xOLESimpleStorage.getByName (sSubStreamPrefix + i) );
xTempStream[i].seek (0); xTempStream[i].seek (0);
xTempStream[i].getInputStream ().readBytes (pBytesIn[i], pBytesIn[i][0].length + 1 ); xTempStream[i].getInputStream ().readBytes (pBytesIn[i], pBytesIn[i][0].length + 1 );
for ( int j = 0; j < pBytesCnt; ++j ) for ( int j = 0; j < pBytesCnt; ++j )
...@@ -120,6 +119,7 @@ public class Test01 implements OLESimpleStorageTest ...@@ -120,6 +119,7 @@ public class Test01 implements OLESimpleStorageTest
catch ( Exception e ) catch ( Exception e )
{ {
m_aTestHelper.Error ( "Exception: " + e ); m_aTestHelper.Error ( "Exception: " + e );
return false;
} }
return true; return true;
} }
......
package complex.olesimplestorage; package complex.olesimplestorage;
import share.LogWriter;
public class TestHelper public class TestHelper
{ {
LogWriter m_aLogWriter;
String m_sTestPrefix; String m_sTestPrefix;
/** Creates a new instance of TestHelper */ /** Creates a new instance of TestHelper
public TestHelper ( LogWriter aLogWriter, String sTestPrefix ) * @param sTestPrefix
*/
public TestHelper ( String sTestPrefix )
{ {
m_aLogWriter = aLogWriter;
m_sTestPrefix = sTestPrefix; m_sTestPrefix = sTestPrefix;
} }
public void Error ( String sError ) public void Error ( String sError )
{ {
m_aLogWriter.println ( m_sTestPrefix + "Error: " + sError ); System.out.println ( m_sTestPrefix + "Error: " + sError );
} }
public void Message ( String sMessage ) public void Message ( String sMessage )
{ {
m_aLogWriter.println ( m_sTestPrefix + sMessage ); System.out.println ( m_sTestPrefix + sMessage );
} }
} }
...@@ -25,60 +25,38 @@ ...@@ -25,60 +25,38 @@
# #
#************************************************************************* #*************************************************************************
PRJ = ..$/..$/.. .IF "$(OOO_SUBSEQUENT_TESTS)" == ""
TARGET = OLESimpleStorageUnitTest nothing .PHONY:
PRJNAME = sot .ELSE
PACKAGE = complex$/olesimplestorage
# --- Settings -----------------------------------------------------
.INCLUDE: settings.mk
#----- compile .java files -----------------------------------------
JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
JAVAFILES =\
OLESimpleStorageUnitTest.java\
OLESimpleStorageTest.java\
TestHelper.java\
Test01.java
JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
#----- make a jar from compiled files ------------------------------
MAXLINELENGTH = 100000 PRJ = ../../..
PRJNAME = sot
TARGET = qa_complex_olesimplestorage
JARCLASSDIRS = $(PACKAGE) .IF "$(OOO_JUNIT_JAR)" != ""
JARTARGET = $(TARGET).jar PACKAGE = complex/olesimplestorage
JARCOMPRESS = TRUE JAVATESTFILES = \
OLESimpleStorageUnitTest.java
# --- Parameters for the test -------------------------------------- JAVAFILES = $(JAVATESTFILES) \
OLESimpleStorageTest.java \
Test01.java \
TestHelper.java
# start an office if the parameter is set for the makefile JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar jurt.jar
.IF "$(OFFICE)" == "" EXTRAJARFILES = $(OOO_JUNIT_JAR)
CT_APPEXECCOMMAND = .END
.ELSE
CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
.ENDIF
# test base is java complex .INCLUDE: settings.mk
CT_TESTBASE = -TestBase java_complex .INCLUDE: target.mk
.INCLUDE: installationtest.mk
# test looks something like the.full.package.TestName ALLTAR : javatest
CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
# start the runner application .END
CT_APP = org.openoffice.Runner
# --- Targets ------------------------------------------------------
.INCLUDE: target.mk
RUN: run
run:
+java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment