/* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ // package name: as default, start with complex package complex.api_internal; // imports import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import helper.OfficeProvider; import helper.ProcessHandler; import java.util.ArrayList; import java.util.StringTokenizer; import java.util.Vector; import lib.TestParameters; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.openoffice.test.OfficeConnection; import com.sun.star.beans.NamedValue; import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertyAccess; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.task.XJob; import com.sun.star.uno.UnoRuntime; /** * 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 { // The name of the tested service private final String testName = "StarOfficeAPI"; /** * Return all test methods. * @return The test methods. */ // 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. */ @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")); XMultiServiceFactory xMSF = getMSF(); Object oObj = null; try { oObj = xMSF.createInstance("org.openoffice.RunnerService"); } catch(com.sun.star.uno.Exception e) { 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"); ArrayList p = new ArrayList(); StringTokenizer paramTokens = new StringTokenizer(paramList, " "); while(paramTokens.hasMoreTokens()) { p.add(paramTokens.nextToken()); } int length = p.size()/2+1; NamedValue[] internalParams = new NamedValue[length]; for (int i=0; i