summaryrefslogtreecommitdiff
path: root/javaunohelper/test/com/sun/star/comp
diff options
context:
space:
mode:
Diffstat (limited to 'javaunohelper/test/com/sun/star/comp')
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java117
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java99
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java100
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java194
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/makefile.mk52
5 files changed, 562 insertions, 0 deletions
diff --git a/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java b/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java
new file mode 100644
index 000000000000..3fe9bd53beb6
--- /dev/null
+++ b/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.helper;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+
+
+public class Bootstrap_Test {
+
+ static public boolean test( String ini_file, java.util.Hashtable bootstrap_parameters )
+ throws java.lang.Exception
+ {
+ boolean passed = false;
+ System.err.println();
+ System.out.println("*******************************************************************");
+ System.err.println("Bootstrap - doing tests...");
+ System.err.println();
+
+ try {
+ XComponentContext xContext =
+ com.sun.star.comp.helper.Bootstrap.defaultBootstrap_InitialComponentContext(
+ ini_file, bootstrap_parameters );
+
+ if (AnyConverter.isVoid(
+ xContext.getValueByName(
+ "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) ))
+ {
+ throw new Exception(
+ "no /singletons/com.sun.star.reflection.theTypeDescriptionManager!" );
+ }
+
+ XMultiServiceFactory msf = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xContext.getServiceManager() );
+ String services[] = msf.getAvailableServiceNames();
+ System.out.println("Available services are:");
+ System.err.println();
+ if (services.length == 0)
+ System.out.println("No services avialable!");
+
+ else
+ for ( int i=0; i<services.length; i++ )
+ System.out.println(services[i]);
+
+ XComponent xComp = UnoRuntime.queryInterface(
+ XComponent.class, xContext );
+ xComp.dispose();
+
+ passed = true;
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.err.println();
+ System.err.println("Bootstrap test passed? " + passed);
+ System.out.println("*******************************************************************");
+ System.err.println();
+ return passed;
+ }
+
+ private static void usage() {
+ System.out.println();
+ System.out.println("usage:");
+ System.out.println("java com.sun.star.comp.helper.Bootstrap_Test ini-file name=value ...");
+ System.out.println("example:");
+ System.out.println("java com.sun.star.comp.helper.Bootstrap_Test file:///c:/ooo10/program/uno.ini SYSBINDIR=file:///c:/ooo10/program");
+ System.exit( -1 );
+ }
+
+ static public void main(String args[]) throws java.lang.Exception {
+ if ( args.length == 0 )
+ usage();
+
+ java.util.Hashtable bootstrap_parameters = new java.util.Hashtable();
+ for ( int nPos = 1; nPos < args.length; ++nPos )
+ {
+ String arg = args[ nPos ];
+ int n = arg.indexOf( '=' );
+ if (n > 0)
+ {
+ bootstrap_parameters.put( arg.substring( 0, n ), arg.substring( n +1 ) );
+ }
+ }
+
+ System.exit( test(args[0], bootstrap_parameters) == true ? 0: -1 );
+ }
+}
+
diff --git a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java b/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java
new file mode 100644
index 000000000000..f38ecf543249
--- /dev/null
+++ b/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.comp.helper;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+
+import com.sun.star.comp.helper.ComponentContext;
+import com.sun.star.comp.helper.ComponentContextEntry;
+import com.sun.star.uno.UnoRuntime;
+
+import java.util.Hashtable;
+
+
+public class ComponentContext_Test {
+ public static void main(String args[]) {
+ try {
+ Hashtable table = new Hashtable();
+ table.put( "bla1", new ComponentContextEntry( null, new Integer( 1 ) ) );
+ XComponentContext xInitialContext = Bootstrap.createInitialComponentContext( table );
+
+ table = new Hashtable();
+ table.put( "bla2", new ComponentContextEntry( new Integer( 2 ) ) );
+ table.put( "bla3", new Integer( 3 ) );
+ XComponentContext xContext = new ComponentContext( table, xInitialContext );
+
+ XMultiComponentFactory xSMgr = xContext.getServiceManager();
+ Object o = xSMgr.createInstanceWithContext( "com.sun.star.loader.Java", xContext );
+ if (o == null)
+ System.err.println( "### failed raising service: 1!" );
+ o = xSMgr.createInstanceWithContext( "com.sun.star.bridge.BridgeFactory", xContext );
+ if (o == null)
+ System.err.println( "### failed raising service: 2!" );
+ o = xSMgr.createInstanceWithContext( "com.sun.star.bridge.UnoUrlResolver", xContext );
+ if (o == null)
+ System.err.println( "### failed raising service: 3!" );
+ o = xSMgr.createInstanceWithContext( "com.sun.star.connection.Connector", xContext );
+ if (o == null)
+ System.err.println( "### failed raising service: 4!" );
+ o = xSMgr.createInstanceWithContext( "com.sun.star.connection.Acceptor", xContext );
+ if (o == null)
+ System.err.println( "### failed raising service: 5!" );
+ o = xSMgr.createInstanceWithContext( "com.sun.star.lang.ServiceManager", xContext );
+ if (o == null)
+ System.err.println( "### failed raising service: 6!" );
+
+ if (xContext.getValueByName( "bla1" ) == null ||
+ xContext.getValueByName( "bla2" ) == null ||
+ xContext.getValueByName( "bla3" ) == null ||
+ xInitialContext.getValueByName( "bla2" ) != null ||
+ xInitialContext.getValueByName( "bla3" ) != null)
+ {
+ System.err.println( "### bootstrap context test failed: 1!" );
+ }
+ if (((Integer)xContext.getValueByName( "bla1" )).intValue() != 1 ||
+ ((Integer)xContext.getValueByName( "bla2" )).intValue() != 2 ||
+ ((Integer)xContext.getValueByName( "bla3" )).intValue() != 3 ||
+ ((Integer)xInitialContext.getValueByName( "bla1" )).intValue() != 1)
+ {
+ System.err.println( "### bootstrap context test failed: 2!" );
+ }
+
+ XComponent xComp = UnoRuntime.queryInterface(
+ XComponent.class, xInitialContext );
+ xComp.dispose();
+ }
+ catch(Exception exception) {
+ System.err.println("exception occurred:" + exception);
+ exception.printStackTrace();
+ }
+ }
+}
+
+
diff --git a/javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java b/javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java
new file mode 100644
index 000000000000..18a0cac49fa4
--- /dev/null
+++ b/javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.helper;
+
+import com.sun.star.comp.loader.JavaLoader;
+
+import com.sun.star.comp.servicemanager.ServiceManager;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.container.XSet;
+import com.sun.star.container.XContentEnumerationAccess;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.container.XElementAccess;
+
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XInitialization;
+
+import com.sun.star.loader.XImplementationLoader;
+
+import com.sun.star.registry.XSimpleRegistry;
+
+public class RegistryServiceFactory_Test {
+
+ static public boolean test(String applicat) throws java.lang.Exception {
+ boolean passed = false;
+ System.err.println();
+ System.out.println("*******************************************************************");
+ System.err.println("RegistryServiceFactory - doing tests...");
+ System.err.println();
+
+ try {
+ XMultiServiceFactory msf = RegistryServiceFactory.create( applicat );
+ String services[] = msf.getAvailableServiceNames();
+ System.out.println("Available services are:");
+ System.err.println();
+ if (services.length == 0)
+ System.out.println("No services avialable!");
+
+ else
+ for ( int i=0; i<services.length; i++ )
+ System.out.println(services[i]);
+
+ passed = true;
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.err.println();
+ System.err.println("RegistryServiceFactory test passed? " + passed);
+ System.out.println("*******************************************************************");
+ System.err.println();
+ return passed;
+ }
+
+ private static void usage() {
+ System.out.println();
+ System.out.println("usage:");
+ System.out.println("java com.sun.star.comp.helper.RegistryServiceFactory [rdb-file]");
+ System.out.println("example:");
+ System.out.println("java com.sun.star.comp.helper.RegistryServiceFactory c:\\applicat.rdb");
+ System.exit( -1 );
+ }
+
+ static public void main(String args[]) throws java.lang.Exception {
+ if ( args.length != 1 )
+ usage();
+ System.exit( test(args[0]) == true ? 0: -1 );
+ }
+}
+
diff --git a/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java b/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java
new file mode 100644
index 000000000000..b417c2544060
--- /dev/null
+++ b/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.helper;
+
+import com.sun.star.comp.loader.JavaLoader;
+
+import com.sun.star.comp.servicemanager.ServiceManager;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.container.XSet;
+import com.sun.star.container.XContentEnumerationAccess;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.container.XElementAccess;
+
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XInitialization;
+
+import com.sun.star.loader.XImplementationLoader;
+
+import com.sun.star.registry.XSimpleRegistry;
+
+
+public class SharedLibraryLoader_Test {
+
+ private static final String NATIVE_SERVICE_MANAGER_IMP_NAME = "com.sun.star.comp.stoc.OServiceManager";
+ private static final String NATIVE_SERVICE_MANAGER_LIB_NAME = "servicemgr.uno";
+ private static final String NATIVE_REGISTRY_IMP_NAME = "com.sun.star.comp.stoc.SimpleRegistry";
+ private static final String NATIVE_REGISTRY_LIB_NAME = "simplereg.uno";
+
+ private static XMultiServiceFactory nativeServiceManager = null;
+ private static XSingleServiceFactory sharedLibraryLoaderFactory = null;
+ private static XImplementationLoader sharedLibraryLoader = null;
+ private static XSimpleRegistry simpleRegistry = null;
+
+ static public boolean test_getSharedLibraryLoaderFactory()
+ throws java.lang.Exception
+ {
+ sharedLibraryLoaderFactory = null;
+ System.out.println("*******************************************************************");
+ System.out.println("Test: <<< get SharedLibraryLoader factory >>>");
+ sharedLibraryLoaderFactory = SharedLibraryLoader.getServiceFactory(null, null);
+
+ System.out.print("Test - ");
+ System.out.println(sharedLibraryLoaderFactory == null? "failed" : "successfull");
+ System.out.println("*******************************************************************");
+ System.out.println();
+
+ return sharedLibraryLoaderFactory != null;
+ }
+
+ static public boolean test_instantiateSharedLibraryLoader()
+ throws java.lang.Exception
+ {
+ sharedLibraryLoader = null;
+ System.out.println("*******************************************************************");
+ System.out.println("Test: <<< instantiate SharedLibraryLoader >>>");
+ if ( sharedLibraryLoaderFactory == null )
+ if ( ! test_getSharedLibraryLoaderFactory() )
+ return false;
+
+ sharedLibraryLoader = UnoRuntime.queryInterface(
+ XImplementationLoader.class, sharedLibraryLoaderFactory.createInstance() );
+
+ System.out.print("Test - ");
+ System.out.println(sharedLibraryLoader == null? "failed" : "successfull");
+ System.out.println("*******************************************************************");
+ System.out.println();
+
+ return sharedLibraryLoader != null;
+ }
+
+ static public boolean test_loadNativeServiceManager()
+ throws java.lang.Exception
+ {
+ nativeServiceManager = null;
+
+ System.out.println("*******************************************************************");
+ System.out.println("Test: <<< load native ServiceManager >>>");
+ if ( sharedLibraryLoader == null )
+ if ( ! test_instantiateSharedLibraryLoader() )
+ return false;
+
+ System.err.println("- get the native ServiceManger factory");
+ XSingleServiceFactory aSMgrFac =
+ UnoRuntime.queryInterface( XSingleServiceFactory.class,
+ sharedLibraryLoader.activate(NATIVE_SERVICE_MANAGER_IMP_NAME, null, NATIVE_SERVICE_MANAGER_LIB_NAME, null));
+
+ System.err.println("- instantiate the native ServiceManger");
+ nativeServiceManager = UnoRuntime.queryInterface( XMultiServiceFactory.class, aSMgrFac.createInstance() );
+
+ System.out.print("Test - ");
+ System.out.println(nativeServiceManager == null? "failed" : "successfull");
+
+ System.out.println("*******************************************************************");
+ System.out.println();
+ return nativeServiceManager != null;
+ }
+
+ static public boolean test_loadNativeSimpleRegistry()
+ throws java.lang.Exception
+ {
+ boolean result = false;
+ System.out.println("*******************************************************************");
+ System.out.println("Test: <<< load native SimpleRegistry >>>");
+ if ( sharedLibraryLoader == null )
+ if ( ! test_instantiateSharedLibraryLoader() )
+ return false;
+
+ System.err.println("- get factory of the Registry");
+ XSingleServiceFactory aRegFac =
+ UnoRuntime.queryInterface( XSingleServiceFactory.class,
+ sharedLibraryLoader.activate(NATIVE_REGISTRY_IMP_NAME, null, NATIVE_REGISTRY_LIB_NAME, null)
+ );
+ System.err.println("- instantiate the Registry");
+ simpleRegistry =
+ UnoRuntime.queryInterface( XSimpleRegistry.class, aRegFac.createInstance() );
+ System.out.print("Test - ");
+ System.out.println(simpleRegistry == null? "failed" : "successfull");
+ System.out.println("*******************************************************************");
+ System.err.println();
+ return true;
+ }
+
+ static public boolean test_registerSharedLibraryLoader()
+ throws java.lang.Exception
+ {
+ boolean result = true;
+ System.out.println("*******************************************************************");
+ System.out.println("Test: <<< register SharedLibraryLoader at the Registry >>>");
+
+ if ( simpleRegistry == null )
+ if ( ! test_loadNativeSimpleRegistry() )
+ return false;
+
+ com.sun.star.registry.XRegistryKey regKey = simpleRegistry.getRootKey();
+ result = SharedLibraryLoader.writeRegistryServiceInfo( null, regKey );
+
+ System.out.print("Test - ");
+ System.out.println( result==false ? "failed" : "successfull");
+ System.out.println("*******************************************************************");
+ System.out.println();
+ return result;
+ }
+
+ static public boolean test() throws java.lang.Exception {
+ boolean passed = true;
+
+ System.err.println("SharedLibraryLoader - doing tests...");
+ passed = test_getSharedLibraryLoaderFactory() && passed;
+ passed = test_instantiateSharedLibraryLoader() && passed;
+ passed = test_loadNativeServiceManager() && passed;
+ passed = test_loadNativeSimpleRegistry() && passed;
+ //passed = test_registerSharedLibraryLoader() && passed;
+
+ System.err.println("SharedLibraryLoader test passed? " + passed);
+
+ return passed;
+ }
+
+ static public void main(String args[]) throws java.lang.Exception {
+ System.exit( test() == true ? 0: -1 );
+ }
+}
+
diff --git a/javaunohelper/test/com/sun/star/comp/helper/makefile.mk b/javaunohelper/test/com/sun/star/comp/helper/makefile.mk
new file mode 100644
index 000000000000..5f00fac9870f
--- /dev/null
+++ b/javaunohelper/test/com/sun/star/comp/helper/makefile.mk
@@ -0,0 +1,52 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ =..$/..$/..$/..$/..$/..
+PRJNAME = juhelper
+PACKAGE = com$/sun$/star$/comp$/helper
+TARGET = com_sun_star_comp_helper_test
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = jurt.jar ridl.jar
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/ComponentContext_Test.class \
+ $(CLASSDIR)$/$(PACKAGE)$/SharedLibraryLoader_Test.class \
+ $(CLASSDIR)$/$(PACKAGE)$/RegistryServiceFactory_Test.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Bootstrap_Test.class
+
+JAVAFILES= $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES)))
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+