summaryrefslogtreecommitdiff
path: root/scripting/workben/mod/_scripting
diff options
context:
space:
mode:
Diffstat (limited to 'scripting/workben/mod/_scripting')
-rw-r--r--scripting/workben/mod/_scripting/Dispatch.java35
-rw-r--r--scripting/workben/mod/_scripting/Function.java27
-rw-r--r--scripting/workben/mod/_scripting/FunctionProvider.java21
-rw-r--r--scripting/workben/mod/_scripting/ScriptInfo.java56
-rw-r--r--scripting/workben/mod/_scripting/ScriptRuntimeManager.java12
-rw-r--r--scripting/workben/mod/_scripting/ScriptStorage.java50
-rw-r--r--scripting/workben/mod/_scripting/ScriptStorageManager.java26
-rw-r--r--scripting/workben/mod/_scripting/TestDataLoader.java11
8 files changed, 136 insertions, 102 deletions
diff --git a/scripting/workben/mod/_scripting/Dispatch.java b/scripting/workben/mod/_scripting/Dispatch.java
index 00b4ee5900bf..20542cf02d10 100644
--- a/scripting/workben/mod/_scripting/Dispatch.java
+++ b/scripting/workben/mod/_scripting/Dispatch.java
@@ -43,30 +43,34 @@ import com.sun.star.util.XURLTransformer;
public class Dispatch extends TestCase {
private String scriptURL = "script://HighlightText.showForm";
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters tParam, PrintWriter log ) throws StatusException {
- log.println("creating test environment");
+ TestParameters tParam, PrintWriter log) throws StatusException {
+ log.println("creating test environment");
XInterface oObj = null;
URL dispatchURL = null;
+
try {
XMultiServiceFactory xMSF = tParam.getMSF();
SOfficeFactory SOF = null;
- SOF = SOfficeFactory.getFactory( xMSF );
- String docPath = util.utils.getFullTestURL( "ExampleSpreadSheetLatest.sxc" );
- XComponent doc = SOF.loadDocument( docPath );
- XModel model = UnoRuntime.queryInterface( XModel.class,
- doc );
+ SOF = SOfficeFactory.getFactory(xMSF);
+ String docPath = util.utils.getFullTestURL("ExampleSpreadSheetLatest.sxc");
+ XComponent doc = SOF.loadDocument(docPath);
+ XModel model = UnoRuntime.queryInterface(XModel.class,
+ doc);
XFrame frame = model.getCurrentController().getFrame();
- oObj = ( XInterface )xMSF.createInstanceWithArguments( "com.sun.star.comp.ScriptProtocolHandler", new Object[] { frame } );
+ oObj = (XInterface)
+ xMSF.createInstanceWithArguments("com.sun.star.comp.ScriptProtocolHandler",
+ new Object[] { frame });
- XURLTransformer xParser=UnoRuntime.queryInterface(XURLTransformer.class,
- tParam.getMSF().createInstance
- ("com.sun.star.util.URLTransformer"));
+ XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class,
+ tParam.getMSF().createInstance
+ ("com.sun.star.util.URLTransformer"));
// Because it's an in/out parameter we must use an array of
// URL objects.
URL[] aParseURL = new URL[1];
@@ -81,13 +85,14 @@ public class Dispatch extends TestCase {
}
TestEnvironment tEnv = new TestEnvironment(oObj) ;
- tEnv.addObjRelation( "XDispatchProvider.URL", scriptURL );
- tEnv.addObjRelation( "XDispatch.URL", dispatchURL );
+ tEnv.addObjRelation("XDispatchProvider.URL", scriptURL);
+ tEnv.addObjRelation("XDispatch.URL", dispatchURL);
return tEnv ;
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/Function.java b/scripting/workben/mod/_scripting/Function.java
index 97c90771a25e..9a2d8b273144 100644
--- a/scripting/workben/mod/_scripting/Function.java
+++ b/scripting/workben/mod/_scripting/Function.java
@@ -38,29 +38,33 @@ public class Function extends TestCase {
private String doc = "doc_with_beanshell_scripts.sxw";
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters tParam, PrintWriter log ) throws StatusException {
+ TestParameters tParam, PrintWriter log) throws StatusException {
XInterface oObj = null;
- XFunctionProvider provider = null;
+ XFunctionProvider provider = null;
log.println("creating test environment");
+
try {
XMultiServiceFactory xMSF = tParam.getMSF();
SOfficeFactory SOF = null;
- SOF = SOfficeFactory.getFactory( xMSF );
+ SOF = SOfficeFactory.getFactory(xMSF);
String docPath = util.utils.getFullTestURL(doc);
- XComponent doc = SOF.loadDocument( docPath );
- XModel model = UnoRuntime.queryInterface( XModel.class,
- doc );
+ XComponent doc = SOF.loadDocument(docPath);
+ XModel model = UnoRuntime.queryInterface(XModel.class,
+ doc);
oObj =
- (XInterface)xMSF.createInstanceWithArguments( "drafts.com.sun.star.script.framework.provider.FunctionProvider", new Object[]{ model } );
- provider = UnoRuntime.queryInterface( XFunctionProvider.class, oObj );
- oObj = provider.getFunction( script );
+ (XInterface)
+ xMSF.createInstanceWithArguments("drafts.com.sun.star.script.framework.provider.FunctionProvider",
+ new Object[] { model });
+ provider = UnoRuntime.queryInterface(XFunctionProvider.class, oObj);
+ oObj = provider.getFunction(script);
} catch (com.sun.star.uno.Exception e) {
e.printStackTrace();
@@ -75,7 +79,8 @@ public class Function extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/FunctionProvider.java b/scripting/workben/mod/_scripting/FunctionProvider.java
index beb5d6c9f714..8cbedee9935e 100644
--- a/scripting/workben/mod/_scripting/FunctionProvider.java
+++ b/scripting/workben/mod/_scripting/FunctionProvider.java
@@ -34,25 +34,29 @@ public class FunctionProvider extends TestCase {
String docPath = null;
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters tParam, PrintWriter log ) throws StatusException {
+ TestParameters tParam, PrintWriter log) throws StatusException {
XInterface oObj = null;
- log.println("creating test environment");
+ log.println("creating test environment");
+
try {
XMultiServiceFactory xMSF = tParam.getMSF();
- Object xInterface = xMSF.createInstance( "com.sun.star.frame.Desktop" );
- XDesktop dtop = UnoRuntime.queryInterface( XDesktop.class,
- xInterface );
+ Object xInterface = xMSF.createInstance("com.sun.star.frame.Desktop");
+ XDesktop dtop = UnoRuntime.queryInterface(XDesktop.class,
+ xInterface);
XModel model = dtop.getCurrentFrame().getController().getModel();
oObj =
- (XInterface)xMSF.createInstanceWithArguments( "drafts.com.sun.star.script.framework.provider.FunctionProvider", new Object[]{ model } );
+ (XInterface)
+ xMSF.createInstanceWithArguments("drafts.com.sun.star.script.framework.provider.FunctionProvider",
+ new Object[] { model });
} catch (com.sun.star.uno.Exception e) {
@@ -66,7 +70,8 @@ public class FunctionProvider extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/ScriptInfo.java b/scripting/workben/mod/_scripting/ScriptInfo.java
index 8001ca99d5c7..05b7b3d0c80e 100644
--- a/scripting/workben/mod/_scripting/ScriptInfo.java
+++ b/scripting/workben/mod/_scripting/ScriptInfo.java
@@ -36,51 +36,58 @@ public class ScriptInfo extends TestCase {
String docPath = null;
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
// Get path to test documents
- String rootDocPath = ( String )tParam.get( "TEST_DOCUMENT_PATH" );
- System.out.println( "TEST_DOCUMENT_PATH is " + rootDocPath );
- rootDocPath = util.utils.getFullTestURL( "ExampleSpreadSheetLatest.sxc" );
- if ( rootDocPath != null && rootDocPath.length() > 1 ){
+ String rootDocPath = (String)tParam.get("TEST_DOCUMENT_PATH");
+ System.out.println("TEST_DOCUMENT_PATH is " + rootDocPath);
+ rootDocPath = util.utils.getFullTestURL("ExampleSpreadSheetLatest.sxc");
+
+ if (rootDocPath != null && rootDocPath.length() > 1) {
// convert all "\\" to "/", necessary for UCB
- if ( rootDocPath.indexOf( "\\" ) > 0 ){
- rootDocPath = rootDocPath.replace( '\\','/' );
- }
+ if (rootDocPath.indexOf("\\") > 0) {
+ rootDocPath = rootDocPath.replace('\\', '/');
+ }
+
System.out.println("After processing the path is " + rootDocPath);
- // encode the ulr (for UCB)
- String encodedPath = URLEncoder.encode( rootDocPath );
- System.out.println("The encoded path is " + encodedPath );
+ // encode the ulr (for UCB)
+ String encodedPath = URLEncoder.encode(rootDocPath);
+ System.out.println("The encoded path is " + encodedPath);
docPath = "vnd.sun.star.pkg://" + encodedPath;
- System.out.println( "docPath path is " + docPath );
+ System.out.println("docPath path is " + docPath);
}
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters tParam, PrintWriter log ) throws StatusException {
+ TestParameters tParam, PrintWriter log) throws StatusException {
- log.println("creating test environment");
- if ( docPath == null ){
+ log.println("creating test environment");
+
+ if (docPath == null) {
log.println("Testdata not set up, docPath is null");
throw new StatusException(
"Can't create object environment, no test document available",
- new Exception() ) ;
+ new Exception()) ;
}
XInterface oObj = null;
XSimpleFileAccess access = null;
+
try {
XMultiServiceFactory xMSF = tParam.getMSF();
Object xInterface =
- xMSF.createInstance( "com.sun.star.ucb.SimpleFileAccess" );
- access = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface );
+ xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ access = UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface);
Object storageObj = xMSF.createInstanceWithArguments(
- "drafts.com.sun.star.script.framework.storage.ScriptStorage",
- new Object[]{ access, Integer.valueOf(99), docPath } );
- XScriptInfoAccess infoAccess = UnoRuntime.queryInterface(XScriptInfoAccess.class, storageObj);
- XScriptInfo[] infos = infoAccess.getImplementations("script://MemoryUtils.MemUsage?location=document");
- oObj = infos[0];
+ "drafts.com.sun.star.script.framework.storage.ScriptStorage",
+ new Object[] { access, Integer.valueOf(99), docPath });
+ XScriptInfoAccess infoAccess = UnoRuntime.queryInterface(
+ XScriptInfoAccess.class, storageObj);
+ XScriptInfo[] infos =
+ infoAccess.getImplementations("script://MemoryUtils.MemUsage?location=document");
+ oObj = infos[0];
} catch (com.sun.star.uno.Exception e) {
throw new StatusException("Can't create object environment", e) ;
}
@@ -92,7 +99,8 @@ public class ScriptInfo extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/ScriptRuntimeManager.java b/scripting/workben/mod/_scripting/ScriptRuntimeManager.java
index 79f84ac109ec..6051adb1ae70 100644
--- a/scripting/workben/mod/_scripting/ScriptRuntimeManager.java
+++ b/scripting/workben/mod/_scripting/ScriptRuntimeManager.java
@@ -28,20 +28,21 @@ import lib.TestParameters;
public class ScriptRuntimeManager extends TestCase {
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters Param, PrintWriter log ) throws StatusException {
+ TestParameters Param, PrintWriter log) throws StatusException {
- log.println("creating test environment");
+ log.println("creating test environment");
XInterface oObj = null;
try {
oObj = (XInterface) Param.getMSF().createInstance
- ("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeManager");
+ ("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeManager");
} catch (com.sun.star.uno.Exception e) {
throw new StatusException("Can't create object environment", e) ;
}
@@ -53,7 +54,8 @@ public class ScriptRuntimeManager extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/ScriptStorage.java b/scripting/workben/mod/_scripting/ScriptStorage.java
index dc8749bf103f..c09f24c083fd 100644
--- a/scripting/workben/mod/_scripting/ScriptStorage.java
+++ b/scripting/workben/mod/_scripting/ScriptStorage.java
@@ -33,48 +33,53 @@ public class ScriptStorage extends TestCase {
String docPath = null;
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
// Get path to test documents
- String rootDocPath = ( String )tParam.get( "TEST_DOCUMENT_PATH" );
- System.out.println( "TEST_DOCUMENT_PATH is " + rootDocPath );
- rootDocPath = util.utils.getFullTestURL( "ExampleSpreadSheetLatest.sxc" );
- if ( rootDocPath != null && rootDocPath.length() > 1 ){
+ String rootDocPath = (String)tParam.get("TEST_DOCUMENT_PATH");
+ System.out.println("TEST_DOCUMENT_PATH is " + rootDocPath);
+ rootDocPath = util.utils.getFullTestURL("ExampleSpreadSheetLatest.sxc");
+
+ if (rootDocPath != null && rootDocPath.length() > 1) {
// convert all "\\" to "/", necessary for UCB
- if ( rootDocPath.indexOf( "\\" ) > 0 ){
- rootDocPath = rootDocPath.replace( '\\','/' );
- }
+ if (rootDocPath.indexOf("\\") > 0) {
+ rootDocPath = rootDocPath.replace('\\', '/');
+ }
+
System.out.println("After processing the path is " + rootDocPath);
- // encode the ulr (for UCB)
- String encodedPath = URLEncoder.encode( rootDocPath );
- System.out.println("The encoded path is " + encodedPath );
+ // encode the ulr (for UCB)
+ String encodedPath = URLEncoder.encode(rootDocPath);
+ System.out.println("The encoded path is " + encodedPath);
docPath = "vnd.sun.star.pkg://" + encodedPath;
- System.out.println( "docPath path is " + docPath );
+ System.out.println("docPath path is " + docPath);
}
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters tParam, PrintWriter log ) throws StatusException {
+ TestParameters tParam, PrintWriter log) throws StatusException {
- log.println("creating test environment");
- if ( docPath == null ){
+ log.println("creating test environment");
+
+ if (docPath == null) {
log.println("Testdata not set up, docPath is null");
throw new StatusException(
"Can't create object environment, no test document available",
- new Exception() ) ;
+ new Exception()) ;
}
XInterface oObj = null;
XSimpleFileAccess access = null;
+
try {
XMultiServiceFactory xMSF = tParam.getMSF();
Object xInterface =
- xMSF.createInstance( "com.sun.star.ucb.SimpleFileAccess" );
- access = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface );
- oObj = ( XInterface )xMSF.createInstanceWithArguments(
- "drafts.com.sun.star.script.framework.storage.ScriptStorage",
- new Object[]{ access, Integer.valueOf(99), docPath } );
+ xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ access = UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface);
+ oObj = (XInterface)xMSF.createInstanceWithArguments(
+ "drafts.com.sun.star.script.framework.storage.ScriptStorage",
+ new Object[] { access, Integer.valueOf(99), docPath });
} catch (com.sun.star.uno.Exception e) {
throw new StatusException("Can't create object environment", e) ;
@@ -87,7 +92,8 @@ public class ScriptStorage extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/ScriptStorageManager.java b/scripting/workben/mod/_scripting/ScriptStorageManager.java
index 64d993edfdc4..b18c613f59e8 100644
--- a/scripting/workben/mod/_scripting/ScriptStorageManager.java
+++ b/scripting/workben/mod/_scripting/ScriptStorageManager.java
@@ -32,31 +32,32 @@ import lib.TestParameters;
public class ScriptStorageManager extends TestCase {
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters Param, PrintWriter log ) throws StatusException {
+ TestParameters Param, PrintWriter log) throws StatusException {
XInterface oObj = null;
- Object oInterface = null;
+ Object oInterface = null;
- try {
+ try {
XMultiServiceFactory xMSF = Param.getMSF();
XPropertySet xProp = UnoRuntime.queryInterface(
- XPropertySet.class, xMSF);
+ XPropertySet.class, xMSF);
// get context
XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class,
- xProp.getPropertyValue("DefaultContext"));
+ xProp.getPropertyValue("DefaultContext"));
// get the script storage manager from context
oInterface = xContext.getValueByName("/singletons/" +
- "drafts.com.sun.star.script.framework.storage.theScriptStorageManager");
- }
- catch( Exception e ) {
- log.println("ScriptStorageManager singleton service not available" );
- e.printStackTrace();
+ "drafts.com.sun.star.script.framework.storage.theScriptStorageManager");
+ } catch (Exception e) {
+ log.println("ScriptStorageManager singleton service not available");
+ e.printStackTrace();
}
+
oObj = (XInterface) oInterface;
TestEnvironment tEnv = new TestEnvironment(oObj) ;
@@ -66,7 +67,8 @@ public class ScriptStorageManager extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/TestDataLoader.java b/scripting/workben/mod/_scripting/TestDataLoader.java
index 63d360e6a678..6f8078656058 100644
--- a/scripting/workben/mod/_scripting/TestDataLoader.java
+++ b/scripting/workben/mod/_scripting/TestDataLoader.java
@@ -56,8 +56,7 @@ public class TestDataLoader {
current = previous = st.nextToken();
list.add(getParameters(st));
- }
- else {
+ } else {
in.close();
return;
}
@@ -78,14 +77,13 @@ public class TestDataLoader {
tEnv.addObjRelation(previous, list);
in.close();
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
}
}
private static Parameters getParameters(StringTokenizer st) {
String separator = "=";
- HashMap<String,Object> map = new HashMap<String,Object>(5);
+ HashMap<String, Object> map = new HashMap<String, Object>(5);
while (st.hasMoreTokens()) {
String pair = st.nextToken();
@@ -98,12 +96,15 @@ public class TestDataLoader {
continue;
name = tokens.nextToken();
+
if (tokens.countTokens() == 1)
value = tokens.nextToken();
else {
StringBuffer buf = new StringBuffer(tokens.nextToken());
+
while (tokens.hasMoreTokens())
buf.append(separator).append(tokens.nextToken());
+
value = buf.toString();
}