summaryrefslogtreecommitdiff
path: root/framework/qa/complex/api_internal/CheckAPI.java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/qa/complex/api_internal/CheckAPI.java')
-rwxr-xr-xframework/qa/complex/api_internal/CheckAPI.java103
1 files changed, 76 insertions, 27 deletions
diff --git a/framework/qa/complex/api_internal/CheckAPI.java b/framework/qa/complex/api_internal/CheckAPI.java
index 432182222eeb..be979e9234ac 100755
--- a/framework/qa/complex/api_internal/CheckAPI.java
+++ b/framework/qa/complex/api_internal/CheckAPI.java
@@ -28,7 +28,6 @@
package complex.api_internal;
// imports
-import complexlib.ComplexTestCase;
import helper.OfficeProvider;
import helper.ProcessHandler;
import com.sun.star.task.XJob;
@@ -38,16 +37,27 @@ import com.sun.star.beans.PropertyValue;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.beans.NamedValue;
-import java.io.PrintWriter;
import java.util.Vector;
import java.util.StringTokenizer;
+
+// ---------- junit imports -----------------
+import lib.TestParameters;
+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.*;
+// ------------------------------------------
+
/**
* This test executes the API tests internally in StarOffice. Prerequiste is
* that a OOoRunner.jar is registered inseide of StarOffice. Adjust the joblist
* inside of the ChekAPI.props to determine which tetss will be executed.
*/
-public class CheckAPI extends ComplexTestCase {
+public class CheckAPI {
// The name of the tested service
private final String testName = "StarOfficeAPI";
@@ -56,40 +66,52 @@ public class CheckAPI extends ComplexTestCase {
* Return all test methods.
* @return The test methods.
*/
- public String[] getTestMethodNames() {
- return new String[]{"checkAPI"};
- }
+// public String[] getTestMethodNames() {
+// return new String[]{"checkAPI"};
+// }
+
+ /**
+ * The test parameters
+ */
+ private static TestParameters param = null;
/**
+ *
+ */
+ @Before public void before()
+ {
+ param = new TestParameters();
+ }
+ /**
* Execute the API tests inside of the Office. If the Office crashes, it
* will be restarted and the job will continue after the one that caused the crash.
*/
- public void checkAPI() {
- log.println("Start with test");
+ @Test public void checkAPI() {
+ System.out.println("Start with test");
// if test is idle for 5 minutes, assume that it hangs and kill it.
- param.put("TimeOut", new Integer("300000"));
+ // param.put("TimeOut", new Integer("300000"));
/* AppProvider office = (AppProvider)dcl.getInstance("helper.OfficeProvider");
Object msf = office.getManager(param);
if (msf == null) {
failed("Could not connect an Office.");
}
param.put("ServiceFactory",msf); */
- XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF();
+ XMultiServiceFactory xMSF = getMSF();
Object oObj = null;
try {
oObj = xMSF.createInstance("org.openoffice.RunnerService");
}
catch(com.sun.star.uno.Exception e) {
- failed("Could not create Instance of 'org.openoffice.RunnerService'");
- }
- if ( oObj == null ) {
- failed("Cannot create 'org.openoffice.RunnerService'");
+ fail("Could not create Instance of 'org.openoffice.RunnerService'");
}
+ assertNotNull("Cannot create 'org.openoffice.RunnerService'", oObj);
+
// get the parameters for the internal test
String paramList = (String)param.get("ParamList");
Vector p = new Vector();
StringTokenizer paramTokens = new StringTokenizer(paramList, " ");
- while(paramTokens.hasMoreTokens()) {
+ while(paramTokens.hasMoreTokens())
+ {
p.add(paramTokens.nextToken());
}
int length = p.size()/2+1;
@@ -98,15 +120,17 @@ public class CheckAPI extends ComplexTestCase {
internalParams[i] = new NamedValue();
internalParams[i].Name = (String)p.get(i*2);
internalParams[i].Value = p.get(i*2+1);
- log.println("Name: "+internalParams[i].Name);
- log.println("Value: "+(String)internalParams[i].Value);
+ System.out.println("Name: "+internalParams[i].Name);
+ System.out.println("Value: "+(String)internalParams[i].Value);
}
// do we have test jobs?
String testJob = (String)param.get("job");
PropertyValue[]props;
- if (testJob==null) {
- if ( param.get("job1")==null ) {
+ if (testJob==null)
+ {
+ if ( param.get("job1")==null )
+ {
// get all test jobs from runner service
XPropertyAccess xPropAcc = (XPropertyAccess)UnoRuntime.queryInterface(XPropertyAccess.class, oObj);
props = xPropAcc.getPropertyValues();
@@ -131,13 +155,13 @@ public class CheckAPI extends ComplexTestCase {
props[0].Value = testJob;
}
- log.println("Props length: "+ props.length);
+ System.out.println("Props length: "+ props.length);
for (int i=0; i<props.length; i++) {
- XJob xJob = (XJob)UnoRuntime.queryInterface(XJob.class, oObj);
+ XJob xJob = UnoRuntime.queryInterface(XJob.class, oObj);
internalParams[length-1] = new NamedValue();
internalParams[length-1].Name = "-o";
internalParams[length-1].Value = props[i].Value;
- log.println("Executing: " + (String)props[i].Value);
+ System.out.println("Executing: " + (String)props[i].Value);
String erg = null;
@@ -146,8 +170,8 @@ public class CheckAPI extends ComplexTestCase {
}
catch(Throwable t) {
// restart and go on with test!!
- t.printStackTrace((PrintWriter)log);
- failed("Test run '" + (String)props[i].Value +"' could not be executed: Office crashed and is killed!", true);
+ t.printStackTrace();
+ fail("Test run '" + (String)props[i].Value +"' could not be executed: Office crashed and is killed!");
xMSF = null;
ProcessHandler handler = (ProcessHandler)param.get("AppProvider");
handler.kill();
@@ -163,12 +187,12 @@ public class CheckAPI extends ComplexTestCase {
oObj = xMSF.createInstance("org.openoffice.RunnerService");
}
catch(com.sun.star.uno.Exception e) {
- failed("Could not create Instance of 'org.openoffice.RunnerService'");
+ fail("Could not create Instance of 'org.openoffice.RunnerService'");
}
}
- log.println(erg);
+ System.out.println(erg);
String processedErg = parseResult(erg);
- assure("Run '" + (String)props[i].Value + "' has result '" + processedErg + "'", processedErg == null, true);
+ assertTrue("Run '" + (String)props[i].Value + "' has result '" + processedErg + "'", processedErg == null);
}
}
@@ -195,6 +219,31 @@ public class CheckAPI extends ComplexTestCase {
}
return processedErg;
}
+
+
+
+
+ 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();
+
}