diff options
Diffstat (limited to 'javaunohelper/test/com')
15 files changed, 0 insertions, 4774 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 deleted file mode 100644 index 3fe9bd53b..000000000 --- a/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java +++ /dev/null @@ -1,117 +0,0 @@ -/************************************************************************* - * - * 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 deleted file mode 100644 index f38ecf543..000000000 --- a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java +++ /dev/null @@ -1,99 +0,0 @@ -/************************************************************************* - * - * 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 deleted file mode 100644 index 18a0cac49..000000000 --- a/javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java +++ /dev/null @@ -1,100 +0,0 @@ -/************************************************************************* - * - * 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 deleted file mode 100644 index b417c2544..000000000 --- a/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java +++ /dev/null @@ -1,194 +0,0 @@ -/************************************************************************* - * - * 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 deleted file mode 100644 index 5f00fac98..000000000 --- a/javaunohelper/test/com/sun/star/comp/helper/makefile.mk +++ /dev/null @@ -1,52 +0,0 @@ -#************************************************************************* -# -# 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 - diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/AWeakBase.java b/javaunohelper/test/com/sun/star/lib/uno/helper/AWeakBase.java deleted file mode 100644 index 262c13dcf..000000000 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/AWeakBase.java +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************************************* - * - * 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.lib.uno.helper; -import com.sun.star.lang.XEventListener; - - -public class AWeakBase extends WeakBase implements XEventListener -{ - public int nDisposingCalled= 0; - - public AWeakBase(int i) - { - } - public AWeakBase() - { - } - - public void disposing(com.sun.star.lang.EventObject eventObject) - { -// System.out.println(getClass().getName() + " .disposing called"); - nDisposingCalled++; - } - -} - diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java deleted file mode 100644 index 012f98874..000000000 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java +++ /dev/null @@ -1,153 +0,0 @@ -/************************************************************************* - * - * 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.lib.uno.helper; -import com.sun.star.uno.XWeak; -import com.sun.star.lang.XTypeProvider; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.XEventListener; - -public class ComponentBase_Test -{ - AWeakBase obj1, obj2, obj3; - Object proxyObj1Weak1; - Object proxyObj3Weak1; - Object proxyObj3Weak2; - Object proxyObj3TypeProv; - Object proxyObj2TypeProv; - - /** Creates a new instance of ComponentBase_Test */ - public ComponentBase_Test() - { - obj1= new AWeakBase(); - obj2= new AWeakBase(); - obj3= new AWeakBase(); - proxyObj1Weak1= ProxyProvider.createProxy(obj1, XWeak.class); - proxyObj3Weak1= ProxyProvider.createProxy(obj3, XWeak.class); - proxyObj3Weak2= ProxyProvider.createProxy(obj3, XWeak.class); - proxyObj2TypeProv= ProxyProvider.createProxy(obj2, XTypeProvider.class); - proxyObj3TypeProv= ProxyProvider.createProxy(obj3, XTypeProvider.class); - } - - public boolean dispose() - { - System.out.println("Testing ComponentBase"); - ComponentBase comp= new ComponentBase(); - boolean r[]= new boolean[50]; - int i= 0; - // addEventListener - - comp.addEventListener(obj1); - comp.addEventListener(obj2); - comp.addEventListener(obj3); - comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj1Weak1)); - comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj3Weak2)); - comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj3TypeProv)); - obj1.nDisposingCalled = 0; - obj2.nDisposingCalled = 0; - obj3.nDisposingCalled = 0; - - comp.dispose(); - r[i++]= obj1.nDisposingCalled == 1; - r[i++]= obj2.nDisposingCalled == 1; - r[i++]= obj3.nDisposingCalled == 1; - // adding a listener after dispose, causes a immediate call to the listerner - obj1.nDisposingCalled= 0; - comp.addEventListener(obj1); - r[i++]= obj1.nDisposingCalled == 1; - //calling dispose again must not notify the listeners again - obj1.nDisposingCalled= 0; - obj2.nDisposingCalled= 0; - obj3.nDisposingCalled= 0; - comp.dispose(); // allready disposed; - r[i++]= obj1.nDisposingCalled == 0; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean test_finalize() - { - System.out.println("Testing ComponentBase"); - ComponentBase comp= new ComponentBase(); - boolean r[]= new boolean[50]; - int i= 0; - obj1.nDisposingCalled = 0; - comp.addEventListener(obj1); - - comp= null; - System.out.println("Waiting 10s"); - for(int c= 0; c < 100; c++) - { - try - { - Thread.currentThread().sleep(100); - System.gc(); - System.runFinalization(); - }catch (InterruptedException ie) - { - } - } - r[i++]= obj1.nDisposingCalled == 1; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public static void main(String[] args) - { - ComponentBase_Test test= new ComponentBase_Test(); - - boolean r[]= new boolean[50]; - int i= 0; - r[i++]= test.dispose(); - r[i++]= test.test_finalize(); - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Errors occurred!"); - else - System.out.println("No errors."); - - } - -} - diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java deleted file mode 100644 index b1268f7ed..000000000 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java +++ /dev/null @@ -1,207 +0,0 @@ -/************************************************************************* - * - * 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.lib.uno.helper; - -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.Type; -import com.sun.star.uno.AnyConverter; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.lang.XSingleComponentFactory; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XComponent; -import com.sun.star.beans.XPropertySet; -import com.sun.star.registry.XRegistryKey; -import com.sun.star.registry.XSimpleRegistry; -import com.sun.star.registry.XImplementationRegistration; -import com.sun.star.container.XSet; - -import com.sun.star.lib.uno.helper.Factory; -import com.sun.star.comp.helper.Bootstrap; -import com.sun.star.comp.helper.RegistryServiceFactory; -import com.sun.star.uno.UnoRuntime; - - -//================================================================================================== -public class Factory_Test - extends WeakBase - implements XServiceInfo -{ - static final String m_impl_name = Factory_Test.class.getName(); - static final String m_supported_services [] = { - "Factory_Test.Service0", "Factory_Test.Service1" }; - - //______________________________________________________________________________________________ - public Factory_Test() - { - } - //______________________________________________________________________________________________ - public Factory_Test( XComponentContext xContext ) - throws com.sun.star.uno.Exception - { - if (null == xContext.getValueByName( "/singletons/com.sun.star.lang.theServiceManager" )) - { - throw new com.sun.star.uno.RuntimeException( - "bad component context given!", this ); - } - } - //______________________________________________________________________________________________ - public static Object __create( XComponentContext xContext ) - throws com.sun.star.uno.Exception - { - return new Factory_Test( xContext ); - } - - // XServiceInfo impl - //______________________________________________________________________________________________ - public final String getImplementationName() - { - return m_impl_name; - } - //______________________________________________________________________________________________ - public final boolean supportsService( String service_name ) - { - for ( int nPos = 0; nPos < m_supported_services.length; ++nPos ) - { - if (m_supported_services[ nPos ].equals( service_name )) - return true; - } - return false; - } - //______________________________________________________________________________________________ - public final String [] getSupportedServiceNames() - { - return m_supported_services; - } - - //============================================================================================== - public static XSingleComponentFactory __getComponentFactory( String implName ) - { - if (implName.equals( m_impl_name )) - { - return Factory.createComponentFactory( - Factory_Test.class, Factory_Test.m_supported_services ); - } - return null; - } - //============================================================================================== - public static boolean __writeRegistryServiceInfo( XRegistryKey xKey ) - { - return Factory.writeRegistryServiceInfo( - m_impl_name, Factory_Test.m_supported_services, xKey ); - } - - //============================================================================================== - static void service_info_test( Object inst ) - { - XServiceInfo xInfo = UnoRuntime.queryInterface( XServiceInfo.class, inst ); - - if (! xInfo.getImplementationName().equals( m_impl_name )) - { - System.err.println( "Factory_Test: err -- 1" ); - System.exit( 1 ); - } - String supported_services [] = xInfo.getSupportedServiceNames(); - if (supported_services.length != m_supported_services.length) - { - System.err.println( "Factory_Test: err -- 2" ); - System.exit( 1 ); - } - for ( int nPos = 0; nPos < supported_services.length; ++nPos ) - { - if (! supported_services[ nPos ].equals( m_supported_services[ nPos ] )) - { - System.err.println( "Factory_Test: err -- 3" ); - System.exit( 1 ); - } - if (! xInfo.supportsService( m_supported_services[ nPos ] )) - { - System.err.println( "Factory_Test: err -- 4" ); - System.exit( 1 ); - } - } - } - //============================================================================================== - public static void main( String args [] ) - { - try - { - String jar = "file://" + new java.io.File( args[ 0 ] ).toURL().getPath(); - String rdb = "file://" + new java.io.File( args[ 1 ] ).toURL().getPath(); - System.out.println( "jar file = " + jar ); - System.out.println( "rdb file = " + rdb ); - - // bootstrap service manager - XMultiServiceFactory xMgr = RegistryServiceFactory.create( rdb ); - XPropertySet xProps = UnoRuntime.queryInterface( - XPropertySet.class, xMgr ); - XComponentContext xContext = (XComponentContext)AnyConverter.toObject( - new Type( XComponentContext.class ), xProps.getPropertyValue( "DefaultContext" ) ); - // insert java loader - XSet xSet = (XSet)AnyConverter.toObject( - new Type( XSet.class ), xContext.getServiceManager() ); - xSet.insert( new com.sun.star.comp.loader.JavaLoaderFactory( xMgr ) ); - // get rdb of smgr - XSimpleRegistry xRDB = (XSimpleRegistry)AnyConverter.toObject( - new Type( XSimpleRegistry.class ), xProps.getPropertyValue( "Registry" ) ); - // register impl - XImplementationRegistration xImpReg = - UnoRuntime.queryInterface( - XImplementationRegistration.class, - xContext.getServiceManager().createInstanceWithContext( - "com.sun.star.registry.ImplementationRegistration", xContext ) ); - xImpReg.registerImplementation( "com.sun.star.loader.Java2", jar, xRDB ); - - // tests - System.out.println( "testing instance" ); - service_info_test( new Factory_Test() ); - System.out.println( "testing instance" ); - service_info_test( new Factory_Test( xContext ) ); - System.out.println( "testing instance" ); - service_info_test( Factory_Test.__create( xContext ) ); - System.out.println( "testing factory __getComponentFactory()" ); - service_info_test( __getComponentFactory( m_impl_name ) ); - for ( int nPos = 0; nPos < m_supported_services.length; ++nPos ) - { - System.out.println( "testing factory " + m_supported_services[ nPos ] ); - service_info_test( - // create Service - xContext.getServiceManager().createInstanceWithContext( - m_supported_services[ nPos ], xContext ) ); - } - - XComponent xComp = UnoRuntime.queryInterface( XComponent.class, xContext ); - xComp.dispose(); - } - catch (Exception exc) - { - System.err.println( ">>>>>>>>>> exc occurred: " + exc.toString() ); - exc.printStackTrace(); - } - System.exit( 0 ); - } -} - diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java deleted file mode 100644 index cd83005cb..000000000 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java +++ /dev/null @@ -1,992 +0,0 @@ -/************************************************************************* - * - * 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.lib.uno.helper; - -import com.sun.star.uno.XInterface; -import java.util.Iterator; -import java.util.ListIterator; -import com.sun.star.uno.Type; -import com.sun.star.uno.XWeak; -import com.sun.star.lang.XTypeProvider; -import com.sun.star.lang.XEventListener; -import java.util.ArrayList; -import com.sun.star.lang.XMultiComponentFactory; -import com.sun.star.uno.XComponentContext; -import com.sun.star.comp.helper.Bootstrap; -import com.sun.star.bridge.XUnoUrlResolver; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.uno.IQueryInterface; -//import com.sun.star.lib.uno.environments.java.IRequester; -import com.sun.star.bridge.XBridge; -//import com.sun.star.lib.uno.environments.java.Proxy; -import com.sun.star.lib.uno.environments.java.java_environment; -import com.sun.star.lib.uno.typedesc.TypeDescription; -import java.util.HashMap; -import java.util.List; -import java.util.NoSuchElementException; - -public class InterfaceContainer_Test -{ - java_environment env= new java_environment(null); - /** Creates a new instance of InterfaceContainerTest */ - AWeakBase obj1,obj2,obj3,obj4; - Object proxyObj1Weak1; - Object proxyObj3Weak1; - Object proxyObj3Weak2; - Object proxyObj3TypeProv; - Object proxyObj2TypeProv; - //contains original objects - List list1; - //contains original objects + proxies - List list2; - //contains original object + proxies + null value - List list3; - - public InterfaceContainer_Test() - { - obj1= new AWeakBase(); - obj2= new AWeakBase(); - obj3= new AWeakBase(); - obj4= new AWeakBase(); - proxyObj1Weak1= ProxyProvider.createProxy(obj1, XWeak.class); - proxyObj3Weak1= ProxyProvider.createProxy(obj3, XWeak.class); - proxyObj3Weak2= ProxyProvider.createProxy(obj3, XWeak.class); - proxyObj2TypeProv= ProxyProvider.createProxy(obj2, XTypeProvider.class); - proxyObj3TypeProv= ProxyProvider.createProxy(obj3, XTypeProvider.class); - - list1= new ArrayList(); - list1.add(obj1); - list1.add(obj2); - list1.add(obj3); - list2= new ArrayList(); - list2.add(obj1); - list2.add(proxyObj2TypeProv); - list2.add(proxyObj3TypeProv); - list3= new ArrayList(); - list3.add(obj1); - list3.add(null); - list3.add(proxyObj2TypeProv); - list3.add(proxyObj3Weak1); - } - - /** Tests add(object), size(), clear(); - */ - public boolean add() - { - System.out.println("Testing List.add(Object), List.size(), List.clear(), List.isEmpty()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - r[i++]= cont.size() == 0; - r[i++]= cont.add(obj1); - r[i++]= cont.size() == 1; - r[i++]= cont.add(obj1); // add the same object again - r[i++]= cont.size() == 2; - r[i++]= cont.add(proxyObj3TypeProv); - r[i++]= cont.size() == 3; - r[i++]= cont.isEmpty() ? false: true; - cont.clear(); - r[i++]= cont.size() == 0; - r[i++]= cont.isEmpty(); - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - /**Tests list.addAll(Collection c), list.addAll(int index, Collection c) - */ - public boolean listConstructors() - { - System.out.println("Testing Constructors of InterfaceContainer"); - boolean r[]= new boolean[50]; - int i= 0; - InterfaceContainer cont= new InterfaceContainer(100); - - r[i++]= cont.elementData.length == 100; - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - public boolean trimToSize() - { - System.out.println("Testing InterfaceContainer.trimToSize"); - InterfaceContainer cont= new InterfaceContainer(100); - boolean r[]= new boolean[50]; - int i= 0; - cont.trimToSize(); - r[i++]= cont.isEmpty(); - cont= new InterfaceContainer(10); - cont.addAll(list1); - cont.trimToSize(); - r[i++]= cont.elementData.length == list1.size(); - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - public boolean ensureCapacity() - { - System.out.println("Testing InterfaceContainer.ensureCapacity"); - InterfaceContainer cont= new InterfaceContainer(10); - boolean r[]= new boolean[50]; - int i= 0; - - cont.ensureCapacity(9); - r[i++]= cont.elementData.length >= 9; - cont.ensureCapacity(11); - r[i++]= cont.elementData.length >= 11; - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean addAll() - { - System.out.println("Testing List.addAll(Collection c), List.addAll(int index, Collection c)"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - r[i++]= cont.addAll(list1); - r[i++]= cont.size() == list1.size(); - for (int c= 0; c < cont.size(); c++) - { - r[i++]= list1.get(c) == cont.get(c); - } - cont.add(obj1); - r[i++]= cont.addAll(1, list2); - r[i++]= cont.get(0) == list1.get(0); - r[i++]= cont.get(1) == list2.get(0); - r[i++]= cont.get(2) == list2.get(1); - r[i++]= cont.get(3) == list2.get(2); - r[i++]= cont.get(4) == list1.get(1); - r[i++]= cont.get(5) == list1.get(2); - r[i++]= cont.get(6) == obj1; - cont.clear(); - cont.addAll(list3); - // the null element in list3 at index 1 is not added to cont - r[i++]= cont.get(0) == list3.get(0); - r[i++]= cont.get(1) == list3.get(2); - r[i++]= cont.get(2) == list3.get(3); - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - /** Tests List.add(int index, Object element), List.get(int index) - */ - public boolean get() - { - System.out.println("Testing List.add(int index, Object element), List.get(int index)"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - cont.add(0, obj1); - cont.add(1, obj2); - cont.add(1, proxyObj3Weak1); - cont.add(3, obj3); - r[i++]= cont.get(0) == obj1; - r[i++]= cont.get(1) == proxyObj3Weak1; - r[i++]= cont.get(2) == obj2; - r[i++]= cont.get(3) == obj3; - try - { - cont.add(5, obj1); - }catch( java.lang.Exception e) - { - r[i++]= true; - } - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - /** Tests List.contains - */ - public boolean contains() - { - System.out.println("Testing List.contains()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - r[i++]= cont.contains(obj1) ? false : true; // nothing in the list - cont.add(obj1); - cont.add(proxyObj2TypeProv); - cont.add(proxyObj3TypeProv); - r[i++]= cont.contains(obj1); - r[i++]= cont.contains(obj2); - r[i++]= cont.contains(proxyObj3Weak1); - r[i++]= cont.contains(proxyObj3Weak2); - r[i++]= cont.contains(proxyObj1Weak1); - r[i++]= cont.contains(obj3); - r[i++]= cont.contains(null) ? false : true; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - /** Tests List.containsAll - */ - public boolean containsAll() - { - System.out.println("Testing List.containsAll"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - cont.addAll(list1); - r[i++]= cont.containsAll(list1); - cont.clear(); - cont.addAll(list2); - r[i++]= cont.containsAll(list2); - cont.clear(); - cont.addAll(list3); // the null element in list3 is not added to cont - r[i++]= cont.containsAll(list3) ? false : true; - cont.clear(); - for( int x= 0; x < 6; x++) - cont.add(obj4); - r[i++]= cont.contains(list1) ? false : true; - cont.add(1, list1.get(0)); - cont.add(3, list1.get(1)); - cont.add(5, list1.get(2)); - r[i++]= cont.contains(list1) ? false : true; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - /** Tests List.indexOf, List.lastIndexOf - */ - public boolean indexOf() - { - System.out.println("Testing List.indexOf(Object element), List.lastIndexOf(Object element)"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - cont.addAll(list1); - cont.addAll(list1); - r[i++]= cont.indexOf(obj3) == 2; - r[i++]= cont.lastIndexOf(obj3) == 5; - cont.clear(); - cont.addAll(list2); - cont.addAll(list2); - r[i++]= cont.indexOf(proxyObj3Weak1) == 2; - r[i++]= cont.lastIndexOf(proxyObj3Weak2) == 5; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - /** Tests List.remove(int index), List.remove(Object element), List.removeAll(Collection c) - */ - public boolean remove() - { - System.out.println("Testing List.remove(int index), List.remove(Object element), List.removeAll(Collection c)"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - cont.addAll(list2); - r[i++]= proxyObj2TypeProv.equals(cont.remove(1)); - r[i++]= cont.size() == 2; - cont.clear(); - cont.addAll(list2); - r[i++]= cont.remove(obj1); - r[i++]= cont.remove(proxyObj2TypeProv); - r[i++]= cont.remove(proxyObj3Weak2); - r[i++]= cont.isEmpty(); - cont.clear(); - cont.addAll(list3); - r[i++]= cont.removeAll(list3); - r[i++]= cont.isEmpty(); - cont.addAll(list2); - - List list= new ArrayList(); - list.add(list2.get(0)); - list.add(list2.get(1)); - list.add(proxyObj3Weak2); - r[i++]= cont.removeAll(list); - r[i++]= cont.isEmpty(); - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - /** Tests List.retainAll - */ - public boolean retainAll() - { - System.out.println("Testing List.retainAll(Collection c)"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - cont.addAll(list1); //obj1, obj2, obj3 - cont.addAll(list2); //obj1, proxyObj2TypeProv, proxyObj3TypeProv - List list = new ArrayList(); - list.add(obj1); - list.add(proxyObj3Weak1); - - r[i++]= cont.retainAll(list); - r[i++]= cont.get(0) == obj1; - r[i++]= cont.get(1) == obj3; - r[i++]= cont.get(2) == obj1; - r[i++]= cont.get(3) == proxyObj3TypeProv; - r[i++]= 4 == cont.size(); - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - /** Tests List.set(int index, Object element) - **/ - public boolean set() - { - System.out.println("Testing List.set(int index, Object element)"); - boolean r[]= new boolean[50]; - int i= 0; - InterfaceContainer cont= new InterfaceContainer(); - cont.addAll(list2); - Object o1= cont.set(0, obj3); - Object o2= cont.set(2, proxyObj3Weak1); - r[i++]= o1 == list2.get(0); - r[i++]= o2 == list2.get(2); - r[i++]= cont.get(0) == obj3; - r[i++]= cont.get(2) == proxyObj3Weak1; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - /** Tests List.toArray(), List.toArray(Object[] a) - */ - public boolean toArray() - { - System.out.println("Testing List.toArray(), List.toArray(Object[] a)"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - cont.addAll(list1); - Object[] ar= cont.toArray(); - Object[] arOrig= list1.toArray(); - r[i++]= ar.length == arOrig.length; - - r[i]= true; - for (int c= 0; c < ar.length; c++) - r[i]= r[i] && ar[c] == arOrig[c]; - - i++; - XWeak[] arWeak= new XWeak[3]; - XWeak[] arWeak2= (XWeak[])cont.toArray(arWeak); - r[i++]= ar.length == arWeak2.length; - r[i]= true; - for (int c= 0; c < ar.length; c++) - r[i]= r[i] && ar[c] == arWeak2[c]; - - i++; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean Iterator_next() - { - System.out.println("Testing InterfaceContainer.iterator, Iterator.next()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - cont.addAll(list1); - Iterator it= cont.iterator(); - r[i++]= it.next() == list1.get(0); - r[i++]= it.next() == list1.get(1); - r[i++]= it.next() == list1.get(2); - try - { - it.next(); - }catch(java.util.NoSuchElementException ne) - { - r[i++]= true; - }catch(Exception e) - { - r[i++]= false; - } - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean Iterator_hasNext() - { - System.out.println("Testing, Iterator.next()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - Iterator it= cont.iterator(); - r[i++]= ! it.hasNext(); - cont.addAll(list1); - it= cont.iterator(); - r[i++]= it.hasNext(); - it.next(); - r[i++]= it.hasNext(); - it.next(); - r[i++]= it.hasNext(); - it.next(); - r[i++]= ! it.hasNext(); - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean Iterator_remove() - { - System.out.println("Testing, Iterator.remove()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - Iterator it= cont.iterator(); - try - { - it.remove(); - } - catch( IllegalStateException ie) - { - r[i++]= true; - } - catch(java.lang.Exception e) - { - r[i++]= false; - } - cont.add(obj1); - it= cont.iterator(); - it.next(); - it.remove(); - r[i++]= cont.isEmpty(); - try - { - it.remove(); - } - catch (IllegalStateException ie) - { - r[i++]= true; - } - catch (Exception e) - { - r[i++]= false; - } - cont.clear(); - cont.addAll(list1); - it= cont.iterator(); - while (it.hasNext()) - { - it.next(); - it.remove(); - } - r[i++]= cont.isEmpty(); - - // 2 iterators, remove must not impair the other iterator - cont.clear(); - cont.addAll(list1); - int size= cont.size(); - it= cont.iterator(); - Iterator it2= cont.iterator(); - while (it.hasNext()) - { - it.next(); - it.remove(); - } - try - { - for( int c= 0; c < size; c++) - it2.next(); - r[i++]= true; - } - catch(Exception e) - { - r[i++]= false; - } - r[i++]= cont.size() == 0; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - public boolean ListIterator_next() - { - System.out.println("Testing InterfaceContainer.listIerator, ListIterator.next()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - cont.addAll(list1); - Iterator it= cont.listIterator(); - r[i++]= it.next() == list1.get(0); - r[i++]= it.next() == list1.get(1); - r[i++]= it.next() == list1.get(2); - try - { - it.next(); - }catch(java.util.NoSuchElementException ne) - { - r[i++]= true; - }catch(Exception e) - { - r[i++]= false; - } - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean ListIterator_hasNext() - { - System.out.println("Testing ListIterator.hasNext()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - Iterator it= cont.listIterator(); - r[i++]= ! it.hasNext(); - cont.addAll(list1); - it= cont.listIterator(); - r[i++]= it.hasNext(); - it.next(); - r[i++]= it.hasNext(); - it.next(); - r[i++]= it.hasNext(); - it.next(); - r[i++]= ! it.hasNext(); - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean ListIterator_remove() - { - System.out.println("Testing ListIterator.remove()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - ListIterator it= cont.listIterator(); - try - { - it.remove(); - } - catch( IllegalStateException ie) - { - r[i++]= true; - } - catch(java.lang.Exception e) - { - r[i++]= false; - } - cont.add(obj1); - it= cont.listIterator(); - it.next(); - it.remove(); - r[i++]= cont.isEmpty(); - try - { - it.remove(); - } - catch (IllegalStateException ie) - { - r[i++]= true; - } - catch (Exception e) - { - r[i++]= false; - } - cont.clear(); - cont.addAll(list1); - it= cont.listIterator(); - while (it.hasNext()) - { - it.next(); - it.remove(); - } - r[i++]= cont.isEmpty(); - - // 2 iterators, remove must not impair the other iterator - cont.clear(); - cont.addAll(list1); - int size= cont.size(); - it= cont.listIterator(); - Iterator it2= cont.listIterator(); - while (it.hasNext()) - { - it.next(); - it.remove(); - } - try - { - for( int c= 0; c < size; c++) - it2.next(); - r[i++]= true; - } - catch(Exception e) - { - r[i++]= false; - } - r[i++]= cont.size() == 0; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean ListIterator_hasPrevious() - { - System.out.println("Testing ListIterator.hasPrevious()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - ListIterator it= cont.listIterator(); - r[i++]= ! it.hasPrevious(); - cont.addAll(list1); - it= cont.listIterator(); - while (it.hasNext()) - { - it.next(); - r[i++]= it.hasPrevious(); - } - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean ListIterator_previous() - { - System.out.println("Testing ListIterator.previous()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - boolean bOk= true; - - cont.addAll(list1); - // go to the end of our list and list1 - ListIterator it= cont.listIterator(); - while (it.hasNext()) - it.next(); - ListIterator it_list1= list1.listIterator(); - while (it_list1.hasNext()) - it_list1.next(); - - while (it.hasPrevious()) - { - r[i++]= it.previous() == it_list1.previous(); - } - try - { - it.previous(); - r[i++]= false; - } - catch (java.util.NoSuchElementException e) - { - r[i++]=true; - } - - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean ListIterator_nextIndex() - { - System.out.println("Testing ListIterator.nextIndex()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - boolean bOk= true; - - ListIterator it= cont.listIterator(); - cont.addAll(list1); - it= cont.listIterator(); - r[i++]= it.nextIndex() == 0; - it.next(); - r[i++]= it.nextIndex() == 1; - it.next(); - r[i++]= it.nextIndex() == 2; - - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - public boolean ListIterator_previousIndex() - { - System.out.println("Testing ListIterator.previousIndex()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - boolean bOk= true; - - ListIterator it= cont.listIterator(); - cont.addAll(list1); - it= cont.listIterator(); - while (it.hasNext()) - it.next(); - - r[i++]= it.previousIndex() == 2; - it.previous(); - r[i++]= it.previousIndex() == 1; - it.previous(); - r[i++]= it.previousIndex() == 0; - it.previous(); - - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - public boolean ListIterator_add() - { - System.out.println("Testing ListIterator.add()"); - InterfaceContainer cont= new InterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - boolean bOk= true; - - ListIterator it= cont.listIterator(); - it.add(obj1); - r[i++]= cont.size() == 1; - it.add(obj2); - r[i++]= cont.size() == 2; - it.add(obj3); - r[i++]= it.previous() == obj3; - r[i++]= it.previous() == obj2; - r[i++]= it.previous() == obj1; - - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean disposeAndClear() - { - System.out.println("Testing InterfaceContainer.disposeAndClear"); - InterfaceContainer cont= new InterfaceContainer(10); - boolean r[]= new boolean[50]; - int i= 0; - - cont.add(obj1); - cont.add(obj2); - cont.add(obj3); - cont.add(proxyObj1Weak1); - cont.add(proxyObj3TypeProv); - System.out.println("Two proxies are called. Check the output:"); - cont.disposeAndClear(new com.sun.star.lang.EventObject()); - r[i++]= obj1.nDisposingCalled == 1; - r[i++]= obj2.nDisposingCalled == 1; - r[i++]= obj3.nDisposingCalled == 1; - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - - public static void main(String[] args) - { - InterfaceContainer_Test test= new InterfaceContainer_Test(); - boolean r[]= new boolean[50]; - int i= 0; - r[i++]= test.listConstructors(); - r[i++]= test.trimToSize(); - r[i++]= test.ensureCapacity(); - r[i++]= test.add(); - r[i++]= test.indexOf(); - r[i++]= test.contains(); - r[i++]= test.containsAll(); - r[i++]= test.get(); - r[i++]= test.addAll(); - r[i++]= test.remove(); - r[i++]= test.retainAll(); - r[i++]= test.set(); - r[i++]= test.toArray(); - r[i++]= test.Iterator_next(); - r[i++]= test.Iterator_hasNext(); - r[i++]= test.Iterator_remove(); - r[i++]= test.ListIterator_next(); - r[i++]= test.ListIterator_hasNext(); - r[i++]= test.ListIterator_remove(); - r[i++]= test.ListIterator_hasPrevious(); - r[i++]= test.ListIterator_previous(); - r[i++]= test.ListIterator_nextIndex(); - r[i++]= test.ListIterator_previousIndex(); - r[i++]= test.ListIterator_add(); - r[i++]= test.disposeAndClear(); - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Test finished.\nErrors occurred!!!"); - else - System.out.println("Test finished. \nNo errors."); - - } - -} diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer_Test.java deleted file mode 100644 index dee5b29eb..000000000 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer_Test.java +++ /dev/null @@ -1,372 +0,0 @@ -/************************************************************************* - * - * 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.lib.uno.helper; -import com.sun.star.lib.uno.environments.java.java_environment; -import java.util.List; -import com.sun.star.uno.XWeak; -import com.sun.star.lang.XTypeProvider; -import java.util.ArrayList; -import com.sun.star.uno.Type; -import com.sun.star.lib.uno.typedesc.TypeDescription; -import com.sun.star.uno.UnoRuntime; -//import com.sun.star.lib.uno.environments.java.Proxy; -import com.sun.star.uno.XInterface; -import com.sun.star.lang.XSingleComponentFactory; - -public class MultiTypeInterfaceContainer_Test -{ -// java_environment env= new java_environment(null); - /** Creates a new instance of InterfaceContainerTest */ - AWeakBase obj1,obj2,obj3,obj4; - Object proxyObj1Weak1; - Object proxyObj3Weak1; - Object proxyObj3Weak2; - Object proxyObj3TypeProv; - Object proxyObj2TypeProv; - //contains original objects - List list1; - //contains original objects + proxies - List list2; - //contains original object + proxies + null value - List list3; - - /** Creates a new instance of MultiTypeInterfaceContainer_Test */ - public MultiTypeInterfaceContainer_Test() - { - obj1= new AWeakBase(); - obj2= new AWeakBase(); - obj3= new AWeakBase(); - obj4= new AWeakBase(); - - proxyObj1Weak1= ProxyProvider.createProxy(obj1, XWeak.class); - proxyObj3Weak1= ProxyProvider.createProxy(obj3, XWeak.class); - proxyObj3Weak2= ProxyProvider.createProxy(obj3, XWeak.class); - proxyObj2TypeProv= ProxyProvider.createProxy(obj2, XTypeProvider.class); - proxyObj3TypeProv= ProxyProvider.createProxy(obj3, XTypeProvider.class); - - list1= new ArrayList(); - list1.add(obj1); - list1.add(obj2); - list1.add(obj3); - list2= new ArrayList(); - list2.add(obj1); - list2.add(proxyObj2TypeProv); - list2.add(proxyObj3TypeProv); - list3= new ArrayList(); - list3.add(obj1); - list3.add(null); - list3.add(proxyObj2TypeProv); - list3.add(proxyObj3Weak1); - } - /** returns Holder proxy objects for the specified interface. If the method is called - * several times with the same arguments then each time a new HolderProxy is returned. - * Then all HolderProxy s refer to the same Proxy object. - * The proxy can be queried for XEventListener. On the returned proxy disposing can be called - * - */ -// public Object getHolderProxy(Object obj, Class iface) -// { -// Object retVal= null; -// if (obj == null || iface == null || iface.isInstance(obj) == false ) -// return retVal; -// -// Type type= new Type(TypeDescription.getTypeDescription(iface)); -// Type evtType= new Type(TypeDescription.getTypeDescription(com.sun.star.lang.XEventListener.class)); -// // find the object identifier -// String sOid= UnoRuntime.generateOid(obj); -// retVal= env.getRegisteredInterface(sOid, type); -// // if retVal == null then probably not registered -// if (retVal == null) -// { -// // create the XEventListener proxy -// Requester eventRequester = new Requester(false, false, null); -// Object aProxyEvt = Proxy.create(eventRequester, sOid, evtType, false, false); -// String[] arOid= new String[]{sOid}; -// retVal= env.registerInterface(aProxyEvt, arOid, evtType); -// -// Requester requester = new Requester(false, false, aProxyEvt); -// Object aProxy = Proxy.create(requester, sOid, type, false, false); -// arOid= new String[] {sOid}; -// retVal= env.registerInterface(aProxy, arOid, type); -// } -// return retVal; -// } - - public boolean addInterface() - { - System.out.println("Testing MultiTypeInterfaceContainer.addInterface"); - MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer(); - boolean r[]= new boolean[200]; - int i= 0; - - int ci= 0; - ci= cont.addInterface(new Type(XInterface.class), obj1); - ci= cont.addInterface(new Type(XInterface.class), obj2); - ci= cont.addInterface(new Type(XInterface.class), obj3); - r[i++]= ci == 3; - ci= cont.addInterface(new Type(XWeak.class), obj1); - ci= cont.addInterface(new Type(XWeak.class), obj2); - r[i++]= ci ==2; - ci= cont.addInterface(null,obj1); - r[i++]= ci == 1; - ci= cont.addInterface(new Type(XTypeProvider.class), null); - r[i++]= ci == 0; - - cont= new MultiTypeInterfaceContainer(); - AWeakBase[] arObj= new AWeakBase[100]; - for (int c= 0; c < 100; c++) - { - arObj[c]= new AWeakBase(); - ci= cont.addInterface(new Type(XInterface.class), arObj[c]); - } - Type[] arT= cont.getContainedTypes(); - for (int c=0; c < 100; c++) - { - ci= cont.removeInterface(new Type(XInterface.class), arObj[c]); - r[i++]= ci == 100 -c -1; - - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean getContainedTypes() - { - System.out.println("Testing MultiTypeInterfaceContainer.getContainedTypes"); - MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - cont.addInterface(new Type(XInterface.class), obj1); - cont.addInterface(new Type(XWeak.class), obj1); - cont.addInterface(null, obj1); - cont.addInterface(new Type(XTypeProvider.class), null); - Object aObj= new Object(); - cont.addInterface(aObj, obj1); - cont.addInterface(XSingleComponentFactory.class, obj1); - Type[] types= cont.getContainedTypes(); - // 3 types and no XTypeProvider - r[i++]= types.length == 5; - for (int c= 0; c < types.length; c++) - { - if (types[c] == null) - r[i++]= true; - else if(types[c].equals( new Type(XTypeProvider.class))) - r[i++]= false; - else if(types[c].equals(new Type(XInterface.class))) - r[i++]= true; - else if (types[c].equals(new Type(XWeak.class))) - r[i++]= true; - else if (types[c].equals(new Type())) - r[i++]= true; - else if (types[c].equals(new Type( aObj.getClass()))) - r[i++]= true; - else if (types[c].equals(new Type(XSingleComponentFactory.class))) - r[i++]= true; - else - r[i++]= false; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean getContainer() - { - System.out.println("Testing MultiTypeInterfaceContainer.getContainedTypes"); - MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - int ci= 0; - ci= cont.addInterface(new Type(XInterface.class), obj1); - ci= cont.addInterface(new Type(XInterface.class), obj2); - ci= cont.addInterface(new Type(XInterface.class), obj3); - ci= cont.addInterface(new Type(XWeak.class), obj1); - ci= cont.addInterface(new Type(XWeak.class), obj2); - ci= cont.addInterface(null, obj1); - ci= cont.addInterface(new Type(XTypeProvider.class), null); - - InterfaceContainer icont= null; - icont= cont.getContainer( new Type(XTypeProvider.class)); - r[i++]= icont.size() == 0; - icont= cont.getContainer(new Type(XWeak.class)); - r[i++]= icont.size() == 2; - icont= cont.getContainer(null); - r[i++]= icont.size() == 1; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean removeInterface() - { - System.out.println("Testing MultiTypeInterfaceContainer.removeInterface"); - MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - int count= 0; - count= cont.removeInterface( new Type(XTypeProvider.class), obj1); - r[i++]= count == 0; - count= cont.removeInterface( new Type(XTypeProvider.class), null); - r[i++]= count == 0; - count= cont.removeInterface(null, obj2); - r[i++]= count == 0; - - cont.addInterface(new Type(XInterface.class), obj1); - cont.addInterface(null, obj1); - count= cont.removeInterface(null, obj2); - // count must still be 1 - r[i++]= count == 1; - count= cont.removeInterface(null, obj1); - r[i++]= count == 0; - count= cont.removeInterface(new Type(XInterface.class), obj1); - r[i++]= count == 0; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean clear() - { - System.out.println("Testing MultiTypeInterfaceContainer.clear"); - MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - - int count= 0; - cont.clear(); - Type[] types= cont.getContainedTypes(); - r[i++]= types.length == 0; - int ci; - ci= cont.addInterface(new Type(XInterface.class), obj1); - ci= cont.addInterface(new Type(XInterface.class), obj2); - ci= cont.addInterface(new Type(XInterface.class), obj3); - ci= cont.addInterface(new Type(XWeak.class), obj1); - ci= cont.addInterface(new Type(XWeak.class), obj2); - ci= cont.addInterface(null, obj1); - ci= cont.addInterface(new Type(XTypeProvider.class), null); - types= cont.getContainedTypes(); - r[i++]= types.length == 3; - cont.clear(); - types= cont.getContainedTypes(); - r[i++]= types.length == 0; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean disposeAndClear() - { - System.out.println("Testing MultiTypeInterfaceContainer.disposeAndClear"); - MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer(); - boolean r[]= new boolean[50]; - int i= 0; - obj1.nDisposingCalled= 0; - obj2.nDisposingCalled= 0; - obj3.nDisposingCalled= 0; - cont.addInterface(new Type(XInterface.class), null); - cont.addInterface(new Type(XInterface.class), obj1); - cont.addInterface(new Type(XInterface.class), obj2); - cont.addInterface(new Type(XInterface.class), obj3); - cont.addInterface(new Type(XWeak.class),obj1); - cont.addInterface(new Type(XWeak.class), obj2); - cont.addInterface(new Type(XTypeProvider.class), obj1); - cont.disposeAndClear(new com.sun.star.lang.EventObject("blabla")); - - r[i++]= obj1.nDisposingCalled == 3; - r[i++]= obj2.nDisposingCalled == 2; - r[i++]= obj3.nDisposingCalled == 1; - Type[] types= cont.getContainedTypes(); - r[i++]= types.length == 0; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - - public static void main(String[] args) - { - MultiTypeInterfaceContainer_Test test= new MultiTypeInterfaceContainer_Test(); - boolean r[]= new boolean[50]; - int i= 0; - r[i++]= test.addInterface(); - r[i++]= test.getContainedTypes(); - r[i++]= test.getContainer(); - r[i++]= test.removeInterface(); - r[i++]= test.clear(); - r[i++]= test.disposeAndClear(); - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if ( ! bOk ) - System.out.println("Test finished.\nErrors occurred!!!"); - else - System.out.println("Test finished. \nNo errors."); - - } -} - - - diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java deleted file mode 100644 index 7185bdc85..000000000 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java +++ /dev/null @@ -1,1693 +0,0 @@ -/************************************************************************* - * - * 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.lib.uno.helper; -import com.sun.star.lang.EventObject; -import com.sun.star.lang.DisposedException; -import com.sun.star.uno.Type; -import com.sun.star.uno.TypeClass; -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.Any; -import com.sun.star.uno.XWeak; -import com.sun.star.beans.XPropertySet; -import com.sun.star.beans.UnknownPropertyException; -import com.sun.star.beans.Property; -import com.sun.star.beans.PropertyAttribute; -import com.sun.star.beans.XPropertyChangeListener; -import com.sun.star.beans.PropertyVetoException; -import com.sun.star.beans.PropertyChangeEvent; -import com.sun.star.beans.XVetoableChangeListener; -import com.sun.star.beans.XPropertySetInfo; -import com.sun.star.beans.XPropertiesChangeListener; - -import java.util.Arrays; - -public class PropertySet_Test -{ - - /** Creates a new instance of PropertySet_Test */ - public PropertySet_Test() - { - } - - public boolean convertPropertyValue() - { - System.out.println("PropertySet.convertPropertyValue"); - boolean[] r= new boolean[50]; - int i= 0; - - TestClass cl= new TestClass(); - try { - r[i++]= cl.test_convertPropertyValue(); - }catch(java.lang.Exception e){ - i++; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean setPropertyValueNoBroadcast() - { - System.out.println("PropertySet.setValueNoBroadcast"); - boolean[] r= new boolean[50]; - int i= 0; - - TestClass cl= new TestClass(); - try { - r[i++]= cl.test_setPropertyValueNoBroadcast(); - }catch(java.lang.Exception e){ - i++; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean setPropertyValue() - { - System.out.println("PropertySet.setPropertyValue"); - boolean[] r= new boolean[150]; - int i= 0; - - TestClass cl= new TestClass(); - try { - cl.resetPropertyMembers(); - Object value; - Object ret; - value= new Boolean(true); - cl.setPropertyValue("PropBoolA", value); - ret= cl.getPropertyValue("PropBoolA"); - r[i++]= ((Boolean) ret).equals( (Boolean) value); - value= new Character('A'); - cl.setPropertyValue("PropCharA",value); - ret= cl.getPropertyValue("PropCharA"); - r[i++]= ((Character) ret).equals((Character) value); - value= new Byte((byte) 111); - cl.setPropertyValue("PropByteA",value); - ret= cl.getPropertyValue("PropByteA"); - r[i++]= ((Byte) ret).equals((Byte) value); - value= new Short((short)112); - cl.setPropertyValue("PropShortA", value); - ret= cl.getPropertyValue("PropShortA"); - r[i++]= ((Short) ret).equals((Short) value); - value= new Integer(113); - cl.setPropertyValue("PropIntA", value); - ret= cl.getPropertyValue("PropIntA"); - r[i++]= ((Integer) ret).equals((Integer) value); - value= new Long(115); - cl.setPropertyValue("PropLongA", value); - ret= cl.getPropertyValue("PropLongA"); - r[i++]= ((Long) ret).equals((Long) value); - value= new Float(3.14); - cl.setPropertyValue("PropFloatA", value); - ret= cl.getPropertyValue("PropFloatA"); - r[i++]= ((Float) ret).equals((Float) value); - value= new Double(3.145); - cl.setPropertyValue("PropDoubleA",value); - ret= cl.getPropertyValue("PropDoubleA"); - r[i++]= ((Double) ret).equals((Double) value); - value= new String("string"); - cl.setPropertyValue("PropStringA",value); - ret= cl.getPropertyValue("PropStringA"); - r[i++]= ((String) ret).equals((String) value); - value= new ComponentBase(); - cl.setPropertyValue("PropXInterfaceA",value); - ret= cl.getPropertyValue("PropXInterfaceA"); - r[i++]= ((XInterface) ret).equals((XInterface) value); - value= new ComponentBase(); - cl.setPropertyValue("PropXWeakA",value); - ret= cl.getPropertyValue("PropXWeakA"); - r[i++]= ((XWeak) ret).equals((XWeak) value); - value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE; - cl.setPropertyValue("PropEnum",value); - ret= cl.getPropertyValue("PropEnum"); - r[i++]= ret == value; - value= new byte[]{1,2,3}; - cl.setPropertyValue("PropArrayByteA", value); - ret= cl.getPropertyValue("PropArrayByteA"); - r[i++]= ((byte[]) ret).equals((byte[]) value); - value= new Type(String.class); - cl.setPropertyValue("PropTypeA", value); - ret= cl.getPropertyValue("PropTypeA"); - r[i++]= ((Type) ret).equals(value); - - // test protected,package,private members - value= new Boolean(true); - cl.setPropertyValue("PropBoolB", value); - ret= cl.getPropertyValue("PropBoolB"); - r[i++]= ((Boolean) ret).equals((Boolean) value); - cl.setPropertyValue("PropBoolC", value); - ret= cl.getPropertyValue("PropBoolC"); - r[i++]= ((Boolean) ret).equals((Boolean) value); - - try{ - cl.setPropertyValue("PropBoolD", value); - i++; - }catch (Exception e) - { - r[i++]= true; - } - cl.resetPropertyMembers(); - - value= new Boolean(true); - cl.setPropertyValue("PropObjectA", value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((Boolean) ret).equals((Boolean) value); - value= new Character('A'); - cl.setPropertyValue("PropObjectA",value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((Character) ret).equals((Character) value); - value= new Byte((byte) 111); - cl.setPropertyValue("PropObjectA",value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((Byte) ret).equals((Byte) value); - value= new Short((short)112); - cl.setPropertyValue("PropObjectA", value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((Short) ret).equals((Short) value); - value= new Integer(113); - cl.setPropertyValue("PropObjectA", value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((Integer) ret).equals((Integer) value); - value= new Long(115); - cl.setPropertyValue("PropObjectA", value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((Long) ret).equals((Long) value); - value= new Float(3.14); - cl.setPropertyValue("PropObjectA", value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((Float) ret).equals((Float) value); - value= new Double(3.145); - cl.setPropertyValue("PropObjectA",value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((Double) ret).equals((Double) value); - value= new String("string"); - cl.setPropertyValue("PropObjectA",value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((String) ret).equals((String) value); - value= new ComponentBase(); - cl.setPropertyValue("PropObjectA",value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((XInterface) ret).equals((XInterface) value); - value= new ComponentBase(); - cl.setPropertyValue("PropObjectA",value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((XWeak) ret).equals((XWeak) value); - value= new byte[]{1,2,3}; - cl.setPropertyValue("PropObjectA", value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((byte[]) ret).equals((byte[]) value); - value= new Type(String.class); - cl.setPropertyValue("PropObjectA", value); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((Type) ret).equals(value); - cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), new Byte((byte)1))); - ret= cl.getPropertyValue("PropObjectA"); - r[i++]= ((Byte) ret).byteValue() == 1; - - cl.resetPropertyMembers(); - value= new Boolean(true); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Character('A'); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Byte((byte) 111); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Short((short)112); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Integer(113); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Long(115); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Float(3.14); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Double(3.145); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new String("string"); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new ComponentBase(); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new ComponentBase(); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new byte[]{1,2,3}; - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Type(String.class); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - - cl.resetPropertyMembers(); - value= new Any(new Type(boolean.class), new Boolean(true)); - cl.setPropertyValue("PropBoolA", value); - ret= cl.getPropertyValue("PropBoolA"); - r[i++]= ret instanceof Boolean && util.anyEquals(value, ret); - value= new Any (new Type(char.class), new Character('A')); - cl.setPropertyValue("PropCharA",value); - ret= cl.getPropertyValue("PropCharA"); - r[i++]= ret instanceof Character && util.anyEquals(value, ret); - value= new Any(new Type(byte.class), new Byte((byte) 111)); - cl.setPropertyValue("PropByteA",value); - ret= cl.getPropertyValue("PropByteA"); - r[i++]= ret instanceof Byte && util.anyEquals(value, ret); - value= new Any(new Type(short.class), new Short((short)112)); - cl.setPropertyValue("PropShortA", value); - ret= cl.getPropertyValue("PropShortA"); - r[i++]= ret instanceof Short && util.anyEquals(value, ret); - value= new Any(new Type(int.class), new Integer(113)); - cl.setPropertyValue("PropIntA", value); - ret= cl.getPropertyValue("PropIntA"); - r[i++]= ret instanceof Integer && util.anyEquals(value, ret); - value= new Any(new Type(long.class), new Long(115)); - cl.setPropertyValue("PropLongA", value); - ret= cl.getPropertyValue("PropLongA"); - r[i++]= ret instanceof Long && util.anyEquals(value, ret); - value= new Any(new Type(float.class), new Float(3.14)); - cl.setPropertyValue("PropFloatA", value); - ret= cl.getPropertyValue("PropFloatA"); - r[i++]= ret instanceof Float && util.anyEquals(value, ret); - value= new Any(new Type(double.class),new Double(3.145)); - cl.setPropertyValue("PropDoubleA",value); - ret= cl.getPropertyValue("PropDoubleA"); - r[i++]= ret instanceof Double && util.anyEquals(value, ret); - value= new Any(new Type(String.class), new String("string")); - cl.setPropertyValue("PropStringA",value); - ret= cl.getPropertyValue("PropStringA"); - r[i++]= ret instanceof String && util.anyEquals(value, ret); - value= new Any(new Type(ComponentBase.class), new ComponentBase()); - cl.setPropertyValue("PropXInterfaceA",value); - ret= cl.getPropertyValue("PropXInterfaceA"); - r[i++]= ret instanceof ComponentBase && util.anyEquals(value, ret); - value= new Any( new Type(ComponentBase.class), new ComponentBase()); - cl.setPropertyValue("PropXWeakA",value); - ret= cl.getPropertyValue("PropXWeakA"); - r[i++]= ret instanceof ComponentBase && util.anyEquals(value, ret); - value= new Any(new Type(byte[].class), new byte[]{1,2,3}); - cl.setPropertyValue("PropArrayByteA", value); - ret= cl.getPropertyValue("PropArrayByteA"); - r[i++]= ret instanceof byte[] && util.anyEquals(value, ret); - value= new Any(new Type(Type.class), new Type(String.class)); - cl.setPropertyValue("PropTypeA", value); - ret= cl.getPropertyValue("PropTypeA"); - r[i++]= ret instanceof Type && util.anyEquals(value, ret); - - - cl.resetPropertyMembers(); - value= new Any(new Type(boolean.class), new Boolean(true)); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any (new Type(char.class), new Character('A')); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any(new Type(byte.class), new Byte((byte) 111)); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any(new Type(short.class), new Short((short)112)); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any(new Type(int.class), new Integer(113)); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any(new Type(long.class), new Long(115)); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any(new Type(float.class), new Float(3.14)); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any(new Type(double.class),new Double(3.145)); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any(new Type(String.class), new String("string")); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any(new Type(ComponentBase.class), new ComponentBase()); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any( new Type(ComponentBase.class), new ComponentBase()); - cl.setPropertyValue("PropAnyA",value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any(new Type(byte[].class), new byte[]{1,2,3}); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - value= new Any(new Type(Type.class), new Type(String.class)); - cl.setPropertyValue("PropAnyA", value); - ret= cl.getPropertyValue("PropAnyA"); - r[i++]= ret instanceof Any && util.anyEquals(value, ret); - - - // ------------------------------------------------------------------------------ - cl.resetPropertyMembers(); - value= new Boolean(true); - cl.setPropertyValue("PropBoolClass", value); - ret= cl.getPropertyValue("PropBoolClass"); - r[i++]= ((Boolean) ret).equals( (Boolean) value); - value= new Character('A'); - cl.setPropertyValue("PropCharClass",value); - ret= cl.getPropertyValue("PropCharClass"); - r[i++]= ((Character) ret).equals((Character) value); - value= new Byte((byte) 111); - cl.setPropertyValue("PropByteClass",value); - ret= cl.getPropertyValue("PropByteClass"); - r[i++]= ((Byte) ret).equals((Byte) value); - value= new Short((short)112); - cl.setPropertyValue("PropShortClass", value); - ret= cl.getPropertyValue("PropShortClass"); - r[i++]= ((Short) ret).equals((Short) value); - value= new Integer(113); - cl.setPropertyValue("PropIntClass", value); - ret= cl.getPropertyValue("PropIntClass"); - r[i++]= ((Integer) ret).equals((Integer) value); - value= new Long(115); - cl.setPropertyValue("PropLongClass", value); - ret= cl.getPropertyValue("PropLongClass"); - r[i++]= ((Long) ret).equals((Long) value); - value= new Float(3.14); - cl.setPropertyValue("PropFloatClass", value); - ret= cl.getPropertyValue("PropFloatClass"); - r[i++]= ((Float) ret).equals((Float) value); - value= new Double(3.145); - cl.setPropertyValue("PropDoubleClass",value); - ret= cl.getPropertyValue("PropDoubleClass"); - r[i++]= ((Double) ret).equals((Double) value); - - cl.resetPropertyMembers(); - - cl.resetPropertyMembers(); - value= new Any(new Type(boolean.class), new Boolean(true)); - cl.setPropertyValue("PropBoolClass", value); - ret= cl.getPropertyValue("PropBoolClass"); - r[i++]= ret instanceof Boolean && util.anyEquals(value, ret); - value= new Any (new Type(char.class), new Character('A')); - cl.setPropertyValue("PropCharClass",value); - ret= cl.getPropertyValue("PropCharClass"); - r[i++]= ret instanceof Character && util.anyEquals(value, ret); - value= new Any(new Type(byte.class), new Byte((byte) 111)); - cl.setPropertyValue("PropByteClass",value); - ret= cl.getPropertyValue("PropByteClass"); - r[i++]= ret instanceof Byte && util.anyEquals(value, ret); - value= new Any(new Type(short.class), new Short((short)112)); - cl.setPropertyValue("PropShortClass", value); - ret= cl.getPropertyValue("PropShortClass"); - r[i++]= ret instanceof Short && util.anyEquals(value, ret); - value= new Any(new Type(int.class), new Integer(113)); - cl.setPropertyValue("PropIntClass", value); - ret= cl.getPropertyValue("PropIntClass"); - r[i++]= ret instanceof Integer && util.anyEquals(value, ret); - value= new Any(new Type(long.class), new Long(115)); - cl.setPropertyValue("PropLongClass", value); - ret= cl.getPropertyValue("PropLongClass"); - r[i++]= ret instanceof Long && util.anyEquals(value, ret); - value= new Any(new Type(float.class), new Float(3.14)); - cl.setPropertyValue("PropFloatClass", value); - ret= cl.getPropertyValue("PropFloatClass"); - r[i++]= ret instanceof Float && util.anyEquals(value, ret); - value= new Any(new Type(double.class),new Double(3.145)); - cl.setPropertyValue("PropDoubleClass",value); - ret= cl.getPropertyValue("PropDoubleClass"); - r[i++]= ret instanceof Double && util.anyEquals(value, ret); - value= new Any(new Type(String.class), new String("string")); - - - - // PropertyAttribute.READONLY - cl.propBoolA.Attributes= PropertyAttribute.READONLY; - try{ - cl.setPropertyValue("PropBoolA", new Boolean(true)); - i++; - }catch (com.sun.star.beans.PropertyVetoException e) - { - r[i++]= true; - } - cl.propBoolA.Attributes= 0; - - // MAYBEVOID - cl.resetPropertyMembers(); - // first MAYBEVOID not set - - //primitive members: must not work - - cl.boolPropA= false; - try { - cl.setPropertyValue("PropBoolA", null); i++; - } catch (com.sun.star.lang.IllegalArgumentException e) { - r[i++]= true; - } - try { - cl.setPropertyValue("PropBoolA", new Any(new Type(boolean.class), null)); i++; - } catch (com.sun.star.lang.IllegalArgumentException e) { - r[i++]= true; - } - cl.propBoolA.Attributes= PropertyAttribute.MAYBEVOID; - try{ - cl.setPropertyValue("PropBoolA", null); i++; - } catch (com.sun.star.lang.IllegalArgumentException e) { - r[i++]= true; - } - cl.propBoolA.Attributes= 0; - - cl.propBoolClass.Attributes= PropertyAttribute.MAYBEVOID; - cl.boolClassProp= null; - cl.setPropertyValue("PropBoolClass", null); - r[i++]= cl.boolClassProp == null; - // the returned value must be a void any - Object objAny= cl.getPropertyValue("PropBoolClass"); - r[i++]= util.isVoidAny( objAny); - - cl.boolClassProp= new Boolean(true); - cl.setPropertyValue("PropBoolClass", null); - r[i++]= cl.boolClassProp == null; - cl.boolClassProp= new Boolean(false); - cl.setPropertyValue("PropBoolClass", new Any(new Type(boolean.class),null)); - r[i++]= cl.boolClassProp == null; - - cl.propXWeakA.Attributes= PropertyAttribute.MAYBEVOID; - cl.setPropertyValue("PropXWeakA", null); - r[i++]= util.isVoidAny(cl.getPropertyValue("PropXWeakA")); - cl.propXWeakA.Attributes= 0; - - cl.anyPropA= null; - try{ - cl.setPropertyValue("PropAnyA", null); i++; - }catch (com.sun.star.lang.IllegalArgumentException e) { - r[i++]= true; - } - cl.anyPropA= null; - cl.propAnyA.Attributes= PropertyAttribute.MAYBEVOID; - - Type _t= new Type(Object.class); - cl.setPropertyValue("PropAnyA", null); - r[i++]= cl.anyPropA.getType().equals(new Type(void.class)) && - cl.anyPropA.getObject() == null; - - cl.anyPropA= new Any(new Type(byte.class),new Byte((byte) 111)); - cl.setPropertyValue("PropAnyA", null); - r[i++]= cl.anyPropA.getType().equals(new Type(byte.class)) && - cl.anyPropA.getObject() == null; - - cl.anyPropA= null; - try{ - cl.setPropertyValue("PropAnyA", new Object()); i++; - }catch (com.sun.star.lang.IllegalArgumentException e) - { - r[i++]= true; - } - - cl.propObjectA.Attributes= 0; - try{ - cl.setPropertyValue("PropObjectA", null); i++; - }catch (com.sun.star.lang.IllegalArgumentException e) - { - r[i++]= true; - } - try{ - cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null)); i++; - } catch (com.sun.star.lang.IllegalArgumentException e) - { - r[i++]= true; - } - - cl.propObjectA.Attributes= PropertyAttribute.MAYBEVOID; - cl.propObjectA= null; - cl.setPropertyValue("PropObjectA", null); - r[i++]= cl.propObjectA == null; - - cl.propObjectA= null; - cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null)); - r[i++]= cl.propObjectA == null; - - - // - - }catch(java.lang.Exception e){ - i++; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean addPropertyChangeListener() - { - System.out.println("PropertySet.addPropertyChangeListener,\n" + - "PropertySet.removePropertChangeListener," + - "PropertySet.addVetoableChangeListener, \n" + - "PropertySet.removeVetoableChangeListener" + - "Notification of listeners"); - boolean[] r= new boolean[50]; - int i= 0; - try { - TestClass cl= new TestClass(); - Listener li= new Listener(); - cl.addPropertyChangeListener("PropByteA", li); - Byte val1= new Byte((byte)115); - cl.setPropertyValue("PropByteA", val1); - r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0; - cl.propByteA.Attributes = PropertyAttribute.BOUND; - cl.addPropertyChangeListener("PropByteA", li); - Byte val2= new Byte((byte)116); - cl.setPropertyValue("PropByteA", val2); - r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0; - r[i++]= li.evt.OldValue.equals(val1) && li.evt.NewValue.equals(val2) && li.evt.Source == cl; - - li.reset(); - Listener li2= new Listener(); - cl.addPropertyChangeListener("PropByteA", li2); - Byte val3= new Byte((byte) 117); - cl.setPropertyValue("PropByteA", val3); - r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0 - && li2.nChangeCalled == 1 && li2.nVetoCalled == 0; - r[i++]= li.evt.OldValue.equals(val2) && li.evt.NewValue.equals(val3) && li.evt.Source == cl - && li2.evt.OldValue.equals(val2) && li2.evt.NewValue.equals(val3) && li2.evt.Source == cl ; - - li.reset(); - li2.reset(); - Listener li3= new Listener(); - val1= new Byte((byte)118); - cl.addPropertyChangeListener("", li3); - cl.setPropertyValue("PropByteA", val1); - r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0 - && li2.nChangeCalled == 1 && li2.nVetoCalled == 0 - && li3.nChangeCalled == 1 && li3.nVetoCalled == 0; - r[i++]= li.evt.OldValue.equals(val3) && li.evt.NewValue.equals(val1) && li.evt.Source == cl; - r[i++]= li2.evt.OldValue.equals(val3) && li2.evt.NewValue.equals(val1) && li2.evt.Source == cl; - r[i++]= li3.evt.OldValue.equals(val3) && li3.evt.NewValue.equals(val1) && li3.evt.Source == cl ; - - li.reset(); - li2.reset(); - li3.reset(); - cl.removePropertyChangeListener("PropByteA",li); - cl.setPropertyValue("PropByteA", val1); - r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 - && li2.nChangeCalled == 1 && li2.nVetoCalled == 0 - && li3.nChangeCalled == 1 && li3.nVetoCalled == 0; - cl.removePropertyChangeListener("PropByteA", li2); - li.reset(); - li2.reset(); - li3.reset(); - cl.setPropertyValue("PropByteA", val1); - r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 - && li2.nChangeCalled == 0 && li2.nVetoCalled == 0 - && li3.nChangeCalled == 1 && li3.nVetoCalled == 0; - - cl.removePropertyChangeListener("", li3); - li.reset(); - li2.reset(); - li3.reset(); - cl.setPropertyValue("PropByteA", val2); - r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 - && li2.nChangeCalled == 0 && li2.nVetoCalled == 0 - && li3.nChangeCalled == 0 && li3.nVetoCalled == 0; - - cl.addPropertyChangeListener("PropByteA", li); - cl.addPropertyChangeListener("PropByteA", li2); - cl.addPropertyChangeListener("", li3); - cl.dispose(); - li.reset(); - li2.reset(); - li3.reset(); - try { - cl.setPropertyValue("PropByteA", val2); i++; - }catch (DisposedException e) - { - r[i++]= true; - } - - //Vetoable tests - cl= new TestClass(); - li.reset(); - li2.reset(); - li3.reset(); - cl.addVetoableChangeListener("PropByteA", li); - val1= new Byte((byte)115); - cl.setPropertyValue("PropByteA", val1); - r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0; - cl.propByteA.Attributes = PropertyAttribute.CONSTRAINED; - cl.addVetoableChangeListener("PropByteA", li); - val2= new Byte((byte)116); - li.reset(); - cl.setPropertyValue("PropByteA", val2); - r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1; - r[i++]= li.evt.OldValue.equals(val1) && li.evt.NewValue.equals(val2) && li.evt.Source == cl; - - li.reset(); - li2.reset(); - li3.reset(); - cl.addVetoableChangeListener("PropByteA", li2); - val3= new Byte((byte) 117); - cl.setPropertyValue("PropByteA", val3); - r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1 - && li2.nChangeCalled == 0 && li2.nVetoCalled == 1; - r[i++]= li.evt.OldValue.equals(val2) && li.evt.NewValue.equals(val3) && li.evt.Source == cl - && li2.evt.OldValue.equals(val2) && li2.evt.NewValue.equals(val3) && li2.evt.Source == cl ; - - li.reset(); - li2.reset(); - li3.reset(); - val1= new Byte((byte)118); - cl.addVetoableChangeListener("", li3); - cl.setPropertyValue("PropByteA", val1); - r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1 - && li2.nChangeCalled == 0 && li2.nVetoCalled == 1 - && li3.nChangeCalled == 0 && li3.nVetoCalled == 1; - r[i++]= li.evt.OldValue.equals(val3) && li.evt.NewValue.equals(val1) && li.evt.Source == cl; - r[i++]= li2.evt.OldValue.equals(val3) && li2.evt.NewValue.equals(val1) && li2.evt.Source == cl; - r[i++]= li3.evt.OldValue.equals(val3) && li3.evt.NewValue.equals(val1) && li3.evt.Source == cl ; - - li.reset(); - li2.reset(); - li3.reset(); - // Test Veto Exception - cl.setPropertyValue("PropByteA", val1); - li.bVeto= true; - try { - cl.setPropertyValue("PropByteA", val2);i++; - } catch (PropertyVetoException e) - { - r[i++]= true; - } - r[i++]= cl.bytePropA == val1.byteValue(); - li.bVeto= false; - - li.reset(); - li2.reset(); - li3.reset(); - cl.removeVetoableChangeListener("PropByteA",li); - cl.setPropertyValue("PropByteA", val1); - r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 - && li2.nChangeCalled == 0 && li2.nVetoCalled == 1 - && li3.nChangeCalled == 0 && li3.nVetoCalled == 1; - cl.removeVetoableChangeListener("PropByteA", li2); - li.reset(); - li2.reset(); - li3.reset(); - cl.setPropertyValue("PropByteA", val1); - r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 - && li2.nChangeCalled == 0 && li2.nVetoCalled == 0 - && li3.nChangeCalled == 0 && li3.nVetoCalled == 1; - - cl.removeVetoableChangeListener("", li3); - li.reset(); - li2.reset(); - li3.reset(); - cl.setPropertyValue("PropByteA", val2); - r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 - && li2.nChangeCalled == 0 && li2.nVetoCalled == 0 - && li3.nChangeCalled == 0 && li3.nVetoCalled == 0; - - cl.addVetoableChangeListener("PropByteA", li); - cl.addVetoableChangeListener("PropByteA", li2); - cl.addVetoableChangeListener("", li3); - cl.dispose(); - li.reset(); - li2.reset(); - li3.reset(); - try { - cl.setPropertyValue("PropByteA", val2); - }catch (DisposedException e) - { - r[i++]= true; - } - }catch (Exception e) - { - i++; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean getPropertySetInfo() - { - System.out.println("PropertySet.getPropertySetInfo"); - boolean[] r= new boolean[50]; - int i= 0; - - TestClass cl= new TestClass(); - try { - XPropertySetInfo info= cl.getPropertySetInfo(); - Property[] arProps= info.getProperties(); - Property[] arRegProps= cl.getRegisteredProperties(); - r[i++]= arProps.length == arRegProps.length; - for (int j= 0; j < arProps.length; j++) - { - boolean bFound= false; - for (int k= 0; k < arRegProps.length; k++) - { - if (arProps[j] == arRegProps[k]) - { - bFound= true; - break; - } - } - if ( !bFound) - r[i++]= false; - } - - for (int j= 0; j < arRegProps.length; j++) - { - Property prop= info.getPropertyByName(arRegProps[j].Name); - if (prop != arRegProps[j]) - r[i++]= false; - if (! info.hasPropertyByName(arRegProps[j].Name)) - r[i++]= false; - } - - - }catch(java.lang.Exception e){ - System.out.println(e.getMessage()); - i++; - } - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean setFastPropertyValue() - { - System.out.println("PropertySet.setFastPropertyValue"); - boolean[] r= new boolean[50]; - int i= 0; - - TestClass cl= new TestClass(); - try { - cl.setFastPropertyValue(5, new Integer(111)); - r[i++]= cl.intPropA == 111; - try { - cl.setFastPropertyValue(-1, new Integer(1)); i++; - } catch(UnknownPropertyException e) - { - r[i++]= true; - } - }catch(java.lang.Exception e){ - System.out.println(e.getMessage()); - i++; - } - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean getFastPropertyValue() - { - System.out.println("PropertySet.setFastPropertyValue"); - boolean[] r= new boolean[50]; - int i= 0; - - TestClass cl= new TestClass(); - try { - cl.setFastPropertyValue(5, new Integer(111)); - Integer aInt= (Integer) cl.getFastPropertyValue(5); - r[i++]= aInt.intValue() == 111; - }catch(java.lang.Exception e){ - System.out.println(e.getMessage()); - i++; - } - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean setPropertyValues() - { - System.out.println("PropertySet.setPropertyValues"); - boolean[] r= new boolean[50]; - int i= 0; - - TestClass cl= new TestClass(); - try { - cl.setPropertyValues(new String[0], new Object[0]); - String[] arNames= new String[] {"PropCharA","PropIntClass","PropObjectA"}; - Character aChar= new Character('A'); - Integer aInt= new Integer(111); - Byte aByte= new Byte((byte)11); - Object[] values= new Object[]{aChar, aInt, aByte}; - cl.setPropertyValues(arNames, values); - r[i++]= cl.charPropA == 'A' && cl.intClassProp.intValue() == 111 && ((Byte)cl.objectPropA).byteValue() == 11; - - arNames= new String[] {"blabla","PropIntClass","PropObjectA"}; - cl.resetPropertyMembers(); - cl.setPropertyValues(arNames, values); - r[i++]= cl.intClassProp.intValue() == 111 && ((Byte)cl.objectPropA).byteValue() == 11; - }catch(java.lang.Exception e){ - System.out.println(e.getMessage()); - i++; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean getPropertyValues() - { - System.out.println("PropertySet.getPropertyValues"); - boolean[] r= new boolean[50]; - int i= 0; - - TestClass cl= new TestClass(); - try { - cl.charPropA= 'A'; - cl.intClassProp= new Integer(111); - cl.objectPropA= new Byte((byte)11); - Object[] values= cl.getPropertyValues(new String[] {"PropCharA","PropIntClass","PropObjectA"}); - - r[i++]= ((Character) values[0]).charValue() == 'A' && ((Integer) values[1]).intValue() == 111 - && ((Byte) values[2]).byteValue() == 11; - }catch(java.lang.Exception e){ - System.out.println(e.getMessage()); - i++; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - // Currently the listeners are always notified if one of properties has changed. - // The property names in the first argument are ignored. - public boolean addPropertiesChangeListener() - { - System.out.println("PropertySet.addPropertiesChangeListener\n" + - "PropertySet.removePropertiesChangeListener\n" + - "notification of such listeners"); - boolean[] r= new boolean[50]; - int i= 0; - - TestClass cl= new TestClass(); - try { - Listener li1= new Listener(); - Listener li2= new Listener(); - cl.addPropertiesChangeListener(new String[]{"PropCharA"}, li1); - cl.setPropertyValue("PropCharA", new Character('B')); - r[i++]= li1.nPropertiesChange == 0; - cl.propCharA.Attributes= PropertyAttribute.BOUND; - cl.setPropertyValue("PropCharA", new Character('C')); - r[i++]= li1.nPropertiesChange == 1; - - PropertyChangeEvent evt= li1.arEvt[0]; - r[i++]= evt.PropertyName.equals("PropCharA") && ((Character)evt.OldValue).charValue() == 'B' - && ((Character) evt.NewValue).charValue() == 'C'; - li1.reset(); - cl.removePropertiesChangeListener(li1); - cl.setPropertyValue("PropCharA", new Character('F')); - r[i++]= li1.nPropertiesChange == 0; - }catch(java.lang.Exception e){ - System.out.println(e.getMessage()); - i++; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean firePropertiesChangeEvent() - { - System.out.println("PropertySet.firePropertiesChangeEvent"); - boolean[] r= new boolean[50]; - int i= 0; - - TestClass cl= new TestClass(); - try { - Listener li1= new Listener(); - cl.intClassProp= new Integer(111); - cl.charPropA= 'A'; - cl.firePropertiesChangeEvent(new String[]{"PropCharA","PropIntClass"}, li1); - r[i++]= li1.nPropertiesChange == 1; - PropertyChangeEvent[] arEvt= li1.arEvt; - r[i++]= arEvt[0].PropertyName.equals("PropCharA") - && ((Character) arEvt[0].OldValue).charValue() == 'A' - && ((Character) arEvt[0].NewValue).charValue() == 'A'; - r[i++]= arEvt[1].PropertyName.equals("PropIntClass") - && ((Integer) arEvt[1].OldValue).intValue() == 111 - && ((Integer) arEvt[1].NewValue).intValue() == 111; - }catch(java.lang.Exception e){ - System.out.println(e.getMessage()); - i++; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean registerProperty1() - { - TestClass2 cl= new TestClass2(); - return cl.test_registerProperty1(); - } - - public boolean registerProperty2() - { - TestClass2 cl= new TestClass2(); - return cl.test_registerProperty2(); - } - - public static boolean test() - { - PropertySet_Test test= new PropertySet_Test(); - boolean r[]= new boolean[50]; - int i= 0; - r[i++]= test.convertPropertyValue(); - r[i++]= test.setPropertyValueNoBroadcast(); - r[i++]= test.setPropertyValue(); - r[i++]= test.addPropertyChangeListener(); - r[i++]= test.getPropertySetInfo(); - r[i++]= test.setFastPropertyValue(); - r[i++]= test.getFastPropertyValue(); - r[i++]= test.setPropertyValues(); - r[i++]= test.getPropertyValues(); - r[i++]= test.addPropertiesChangeListener(); - r[i++]= test.firePropertiesChangeEvent(); - r[i++]= test.registerProperty1(); - r[i++]= test.registerProperty2(); - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Errors occurred!"); - else - System.out.println("No errors."); - return bOk; - } - public static void main(String[] args) - { - test(); - } -} - -class TestClass extends PropertySet -{ - public Property propBoolA= new Property("PropBoolA", 1, new Type(Boolean.TYPE), (short)0); - public boolean boolPropA; - public Property propCharA= new Property("PropCharA", 2, new Type(Character.TYPE), (short) 0); - public char charPropA; - public Property propByteA= new Property("PropByteA", 3, new Type(Byte.TYPE), (short) 0); - public byte bytePropA; - public Property propShortA= new Property("PropShortA", 4, new Type(Short.TYPE), (short) 0); - public short shortPropA; - public Property propIntA= new Property("PropIntA", 5, new Type(Integer.TYPE), (short) 0); - public int intPropA; - public Property propLongA= new Property("PropLongA", 6, new Type(Long.TYPE), (short) 0); - public long longPropA; - public Property propFloatA= new Property("PropFloatA", 7, new Type(Float.TYPE), (short) 0); - public float floatPropA; - public Property propDoubleA= new Property("PropDoubleA", 8, new Type(Double.TYPE), (short) 0); - public double doublePropA; - public Property propStringA= new Property("PropStringA", 9, new Type(String.class), (short) 0); - public String stringPropA; - public Property propArrayByteA= new Property("PropArrayByteA", 10, new Type(byte[].class), (short) 0); - public byte[] arBytePropA; - public Property propTypeA= new Property("PropTypeA", 11, new Type(Type.class), (short) 0); - public Type typePropA; - public Property propObjectA= new Property("PropObjectA",12, new Type(Object.class), (short) 0); - public Object objectPropA; - public Property propAnyA= new Property("PropAnyA", 13, new Type(Any.class), (short) 0); - public Any anyPropA; - public Property propXInterfaceA= new Property("PropXInterfaceA", 13, new Type(Any.class), (short) 0); - public XInterface xInterfacePropA; - public Property propXWeakA= new Property("PropXWeakA", 13, new Type(Any.class), (short) 0); - public XWeak xWeakPropA; - public Property propEnum = - new Property("PropEnum", 14, new Type("com.sun.star.beans.PropertyState", TypeClass.ENUM), (short)0); - public com.sun.star.beans.PropertyState enumPropertyState = com.sun.star.beans.PropertyState.DEFAULT_VALUE; - // Test private, protected, package access, Anys as arguments and members, members whith a value - - public Property propBoolB= new Property("PropBoolB", 101, new Type(Boolean.TYPE), (short) 0); - protected boolean boolPropB; - - public Property propBoolC= new Property("PropBoolC", 201, new Type(Boolean.TYPE), (short) 0); - boolean boolPropC; - - public Property propBoolD= new Property("PropBoolD", 301, new Type(Boolean.TYPE), (short) 0); - private boolean boolPropD; - - public Property propBoolClass= new Property("PropBoolClass", 1001, new Type(Boolean.class), (short) 0); - public Boolean boolClassProp; - public Property propCharClass= new Property("PropCharClass", 1002, new Type(Character.class), (short) 0); - public Character charClassProp; - public Property propByteClass= new Property("PropByteClass", 1003, new Type(Byte.class), (short) 0); - public Byte byteClassProp; - public Property propShortClass= new Property("PropShortClass", 1004, new Type(Short.class), (short) 0); - public Short shortClassProp; - public Property propIntClass= new Property("PropIntClass", 1005, new Type(Integer.class), (short) 0); - public Integer intClassProp; - public Property propLongClass= new Property("PropLongClass", 1006, new Type(Long.class), (short) 0); - public Long longClassProp; - public Property propFloatClass= new Property("PropFloatClass", 1007, new Type(Float.class), (short) 0); - public Float floatClassProp; - public Property propDoubleClass= new Property("PropDoubleClass", 1008, new Type(Double.class), (short) 0); - public Double doubleClassProp; - - - public TestClass() - { - - super(); -// When adding properties then modify the getRegisteredProperties method - //registerProperty(String name, int handle, Type type, short attributes, String memberName) - registerProperty(propBoolA, "boolPropA"); - registerProperty(propCharA, "charPropA"); - registerProperty(propByteA, "bytePropA"); - registerProperty(propShortA, "shortPropA"); - registerProperty(propIntA, "intPropA"); - registerProperty(propLongA, "longPropA"); - registerProperty(propFloatA, "floatPropA"); - registerProperty(propDoubleA, "doublePropA"); - registerProperty(propStringA, "stringPropA"); - registerProperty(propArrayByteA, "arBytePropA"); - registerProperty(propTypeA, "typePropA"); - registerProperty(propObjectA, "objectPropA"); - registerProperty(propAnyA, "anyPropA"); - registerProperty(propXInterfaceA, "xInterfacePropA"); - registerProperty(propXWeakA, "xWeakPropA"); - registerProperty(propEnum,"enumPropertyState"); - registerProperty(propBoolB, "boolPropB"); - registerProperty(propBoolC, "boolPropC"); - registerProperty(propBoolD, "boolPropD"); - registerProperty(propBoolClass, "boolClassProp"); - registerProperty(propCharClass, "charClassProp"); - registerProperty(propByteClass, "byteClassProp"); - registerProperty(propShortClass, "shortClassProp"); - registerProperty(propIntClass, "intClassProp"); - registerProperty(propLongClass, "longClassProp"); - registerProperty(propFloatClass, "floatClassProp"); - registerProperty(propDoubleClass, "doubleClassProp"); - } - - /** When adding properties then modify the getRegisteredProperties method - */ - public Property[] getRegisteredProperties() - { - return new Property[] { - propBoolA, propCharA, propByteA, propShortA, - propIntA, propLongA, propFloatA, propDoubleA, - propStringA, propArrayByteA, propTypeA, propObjectA, - propAnyA, propXInterfaceA, propXWeakA, propEnum, propBoolB, - propBoolC, propBoolD, propBoolClass, propCharClass, - propByteClass, propShortClass, propIntClass, propLongClass, - propFloatClass, propDoubleClass - }; - - } - public boolean test_convertPropertyValue() - { - boolean[] r= new boolean[150]; - int i= 0; - - resetPropertyMembers(); - Object[] outOldVal= new Object[1]; - Object[] outNewVal= new Object[1]; - - Object value= new Boolean(true); - try - { - r[i++]= convertPropertyValue(propBoolA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Boolean && outNewVal[0].equals(value) && outOldVal[0].equals(new Boolean(false)); - value= new Character('A'); - r[i++]= convertPropertyValue(propCharA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value) && outOldVal[0].equals(new Character((char)0)); - charPropA= 'B'; - r[i++]= convertPropertyValue(propCharA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value) && outOldVal[0].equals(new Character('B')); - value= new Byte((byte) 111); - r[i++]= convertPropertyValue(propByteA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Byte && outNewVal[0].equals(value); - value= new Short((short) 112); - r[i++]= convertPropertyValue(propShortA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Short && outNewVal[0].equals(value); - value= new Integer( 113); - r[i++]= convertPropertyValue(propIntA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value); - value= new Long(114); - r[i++]= convertPropertyValue(propLongA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Long && outNewVal[0].equals(value); - value= new Float(3.14); - r[i++]= convertPropertyValue(propFloatA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Float && outNewVal[0].equals(value); - value= new Double(3.145); - r[i++]= convertPropertyValue(propDoubleA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Double && outNewVal[0].equals(value); - value= "string"; - r[i++]= convertPropertyValue(propStringA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof String && outNewVal[0].equals(value); - value= new byte[]{1,2,3}; - arBytePropA= null; - r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof byte[] && outNewVal[0].equals(value) && outOldVal[0] == null; - r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value); - r[i++]= outOldVal[0] == null; - value= new Type(XInterface.class); - r[i++]= convertPropertyValue(propTypeA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Type && outNewVal[0].equals(value); - - value= new Object(); // TypeClass.VOID - r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Object && outNewVal[0].equals(value); - value= new Integer(111); - r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value); - value= new ComponentBase(); - r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Object && outNewVal[0].equals(value); - value= new Integer(111); - r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Any && ((Any)outNewVal[0]).getType().equals(new Type(Integer.class)) - && ((Any)outNewVal[0]).getObject().equals(value); - XWeak oWeak= new ComponentBase(); - value= oWeak; - // The returned Any must contain an XInterface - r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value); - r[i++]= ((Any) outNewVal[0]).getType().equals(new Type(XInterface.class)) - && ((Any) outNewVal[0]).getObject() == oWeak; - value= new ComponentBase(); - r[i++]= convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof XInterface && outNewVal[0].equals(value); - r[i++]= convertPropertyValue(propXWeakA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof XWeak && outNewVal[0].equals(value); - - value = com.sun.star.beans.PropertyState.DIRECT_VALUE; - r[i++]= convertPropertyValue(propEnum, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof com.sun.star.uno.Enum && outNewVal[0].equals(value); - - // Any arguments ------------------------------------------------------------------ - value= new Any( new Type(Integer.class),new Integer(111)); - r[i++]= convertPropertyValue(propIntA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Integer && ((Integer)outNewVal[0]).equals( ((Any)value).getObject()); - value= new Any(new Type(Boolean.class), new Boolean(true)); - r[i++]= convertPropertyValue(propBoolA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Boolean && ((Boolean)outNewVal[0]).equals(((Any) value).getObject()); - //Character, Byte, Short, Long - // must fail - value= new Any(new Type(Object.class), new Object()); - r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); - r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value); - value= new Any(new Type(Integer.class), new Integer(111)); - r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals( ((Any)value).getObject()); - r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Any && ((Any) outNewVal[0]).getType().equals( ((Any) value).getType()) - && ((Any) outNewVal[0]).getObject().equals( ((Any) value).getObject()); - value= new Any(new Type(XInterface.class), new ComponentBase()); - r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof XInterface && outNewVal[0] == ((Any) value).getObject(); - r[i++]= convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] == ((Any) value).getObject(); - value= new Any(new Type(byte[].class), new byte[]{1,2,3}); - r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof byte[]; - - - - // test private, protected, package fields - value= new Boolean(true); - r[i++]= convertPropertyValue(propBoolB, outNewVal, outOldVal, value); - r[i++]= ((Boolean)value).booleanValue() == ((Boolean) outNewVal[0]).booleanValue(); - r[i++]= convertPropertyValue(propBoolC, outNewVal, outOldVal, value); - r[i++]= ((Boolean)value).booleanValue() == ((Boolean) outNewVal[0]).booleanValue(); - // must fail because the the member boolPropD is private - try{ - convertPropertyValue(propBoolD, outNewVal, outOldVal, value); - i++; - }catch (Exception e) - { - r[i++]= true; - } - - // Properties member of type Byte,Short etc. - value= new Boolean(true); - r[i++]= convertPropertyValue(propBoolClass, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Boolean && outNewVal[0].equals(value); - value= new Character('A'); - r[i++]= convertPropertyValue(propCharClass, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value); - value= new Byte((byte) 111); - r[i++]= convertPropertyValue(propByteClass, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Byte && outNewVal[0].equals(value); - value= new Short((short) 112); - r[i++]= convertPropertyValue(propShortClass, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Short && outNewVal[0].equals(value); - value= new Integer( 113); - r[i++]= convertPropertyValue(propIntClass, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value); - value= new Long(114); - r[i++]= convertPropertyValue(propLongClass, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Long && outNewVal[0].equals(value); - value= new Float(3.14); - r[i++]= convertPropertyValue(propFloatClass, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Float && outNewVal[0].equals(value); - value= new Double(3.145); - r[i++]= convertPropertyValue(propDoubleA, outNewVal, outOldVal, value); - r[i++]= outNewVal[0] instanceof Double && outNewVal[0].equals(value); - }catch (com.sun.star.uno.Exception e) - { - i++; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - - return bOk; - } - - public boolean test_setPropertyValueNoBroadcast() - { - boolean[] r= new boolean[150]; - int i= 0; - resetPropertyMembers(); - try { - Object value= new Boolean(true); - setPropertyValueNoBroadcast(propBoolA, value); - r[i++]= boolPropA == ((Boolean) value).booleanValue(); - value= new Character('A'); - setPropertyValueNoBroadcast(propCharA, value); - r[i++]= charPropA == ((Character) value).charValue(); - value= new Byte((byte) 111); - setPropertyValueNoBroadcast(propByteA, value); - r[i++]= bytePropA == ((Byte)value).byteValue(); - value= new Short((short) 112); - setPropertyValueNoBroadcast(propShortA, value); - r[i++]= shortPropA == ((Short) value).shortValue(); - value= new Integer( 113); - setPropertyValueNoBroadcast(propIntA, value); - r[i++]= intPropA == ((Integer) value).intValue(); - value= new Long(114); - setPropertyValueNoBroadcast(propLongA, value); - r[i++]= longPropA == ((Long) value).longValue(); - value= new Float(3.14); - setPropertyValueNoBroadcast(propFloatA, value); - r[i++]= floatPropA == ((Float) value).floatValue(); - value= new Double(3.145); - setPropertyValueNoBroadcast(propDoubleA, value); - r[i++]= doublePropA == ((Double) value).doubleValue(); - value= "string"; - setPropertyValueNoBroadcast(propStringA, value); - r[i++]= stringPropA.equals(value); - value= new byte[]{1,2,3}; - setPropertyValueNoBroadcast(propArrayByteA, value); - r[i++]= arBytePropA.equals(value); - value= new Type(XInterface.class); - setPropertyValueNoBroadcast(propTypeA, value); - r[i++]= typePropA.equals(value); - value= new Integer(111); - setPropertyValueNoBroadcast(propObjectA, value); - r[i++]= objectPropA.equals(value); - value= (XInterface) new ComponentBase(); - setPropertyValueNoBroadcast(propObjectA, value); - r[i++]= objectPropA.equals(value); - value= new Any( new Type(Integer.TYPE), new Integer(111)); - setPropertyValueNoBroadcast(propAnyA, value); - r[i++]= util.anyEquals(anyPropA, value); - value= new ComponentBase(); - setPropertyValueNoBroadcast(propXInterfaceA, value); - r[i++]= xInterfacePropA instanceof XInterface && xInterfacePropA.equals(value); - setPropertyValueNoBroadcast(propXWeakA, value); - r[i++]= xInterfacePropA instanceof XWeak && xInterfacePropA.equals(value); - value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE; - setPropertyValueNoBroadcast(propEnum, value); - r[i++]= enumPropertyState == value; - value= new Boolean(true); - setPropertyValueNoBroadcast(propBoolB, value); - r[i++]= boolPropB == ((Boolean) value).booleanValue(); - setPropertyValueNoBroadcast(propBoolC, value); - r[i++]= boolPropC == ((Boolean) value).booleanValue(); - // must fail because the the member boolPropD is private - try{ - setPropertyValueNoBroadcast(propBoolD, value); - }catch(com.sun.star.lang.WrappedTargetException e) - { - r[i++]= true; - } - }catch (java.lang.Exception e) - { - i++; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - return bOk; - } - - void resetPropertyMembers() - { - boolPropA= false; - charPropA= (char) 0; - bytePropA= 0; - shortPropA= 0; - intPropA= 0; - longPropA= 0; - floatPropA= 0; - doublePropA= 0.; - stringPropA= null; - arBytePropA= null; - typePropA= null; - objectPropA= null; - anyPropA= null; - xInterfacePropA= null; - xWeakPropA= null; - enumPropertyState = com.sun.star.beans.PropertyState.DEFAULT_VALUE; - boolPropB= false; - boolPropC= false; - boolPropD= false; - boolClassProp= null; - charClassProp= null; - byteClassProp= null; - shortClassProp= null; - intClassProp= null; - longClassProp= null; - floatClassProp= null; - doubleClassProp= null; - } -} - -class TestClass2 extends PropertySet -{ - - public char charA; - protected char charB; - char charC; - - int intMemberA; - - public Character charClassA; - protected Character charClassB; - Character charClassC; - - boolean test_registerProperty1() - { - System.out.println("registerProperty Test 1"); - boolean r[]= new boolean[50]; - int i= 0; - - registerProperty("PropChar", new Type(char.class), (short) 0, "PropChar"); - registerProperty("PropInt", new Type(int.class), (short) 0, "PropInt"); - registerProperty("PropString", new Type(String.class), (short) 0, "PropString"); - - XPropertySetInfo info= getPropertySetInfo(); - Property[] props= info.getProperties(); - for (int j= 0; j < props.length; j++) - { - Property aProp= props[j]; - if (aProp.Name.equals("PropChar") && aProp.Type.equals(new Type(char.class)) && - aProp.Attributes == 0) - r[i++]= true; - else if (aProp.Name.equals("PropInt") && aProp.Type.equals(new Type(int.class)) && - aProp.Attributes == 0) - r[i++]= true; - else if (aProp.Name.equals("PropString") && aProp.Type.equals(new Type(String.class)) && - aProp.Attributes == 0) - r[i++]= true; - else - r[i++]= false; - } - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - boolean test_registerProperty2() - { - System.out.println("registerProperty Test 2"); - boolean r[]= new boolean[50]; - int i= 0; - - registerProperty("charA", "charA", (short) 0); - registerProperty("charB", "charB", (short) 0); - registerProperty("charC", "charC", (short) 0); - registerProperty("charClassB", "charClassB", PropertyAttribute.MAYBEVOID); - registerProperty("IntProp", "intMemberA", (short) 0); - - XPropertySetInfo info= getPropertySetInfo(); - Property[] props= info.getProperties(); - for (int j= 0; j < props.length; j++) - { - Property aProp= props[j]; - if (aProp.Name.equals("charA") && aProp.Type.equals(new Type(char.class)) && - aProp.Attributes == 0) - r[i++]= true; - else if (aProp.Name.equals("charB") && aProp.Type.equals(new Type(char.class)) && - aProp.Attributes == 0) - r[i++]= true; - else if (aProp.Name.equals("charC") && aProp.Type.equals(new Type(char.class)) && - aProp.Attributes == 0) - r[i++]= true; - else if (aProp.Name.equals("charClassB") && aProp.Type.equals(new Type(char.class)) && - aProp.Attributes == PropertyAttribute.MAYBEVOID) - r[i++]= true; - else if (aProp.Name.equals("IntProp") && aProp.Type.equals(new Type(int.class)) && - aProp.Attributes == 0) - r[i++]= true; - else - r[i++]= false; - } - Object ret; - Object val= new Character('A'); - try{ - setPropertyValue("charA", val); - ret= getPropertyValue("charA"); - r[i++]= val.equals(ret); - setPropertyValue("charClassB",val); - ret= getPropertyValue("charClassB"); - r[i++]= val.equals(ret); - val= new Integer(111); - setPropertyValue("IntProp",val); - ret= getPropertyValue("IntProp"); - r[i++]= val.equals(ret); - } - catch(Exception e) - { - r[i++]=false; - } - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - -} - -class util -{ - // An Object is considered an Any with TypeClass.VOID and no value. - static boolean anyEquals(Object val1, Object val2) - { - Object obj1= null; - Object obj2= null; - Type t1= null; - Type t2= null; - if (val1 instanceof Any) - { - obj1= ((Any) val1).getObject(); - t1= ((Any) val1).getType(); - } - else - obj1= val1; - - if (val2 instanceof Any) - { - obj2= ((Any) val2).getObject(); - t2= ((Any) val2).getType(); - } - else - obj2= val2; - - if (obj1 != null && obj1.equals(obj2)) - return true; - else if ((obj1 == null && obj2 == null) && t1 != null && t1.equals(t2)) - return true; - return false; - } - - // returns true if obj is an any that contains a void or interface type and the - // object is null - static boolean isVoidAny(Object obj) - { - boolean ret= false; - if( obj != null && obj instanceof Any) - { - Any a= (Any) obj; - if( a.getType().getTypeClass().equals( TypeClass.INTERFACE) - && a.getObject() == null) { - ret= true; - } - else if( a.getType().equals( new Type(void.class)) && a.getObject() == null) { - ret= true; - } - } - return ret; - } -} - -class Listener implements XPropertyChangeListener, XVetoableChangeListener, -XPropertiesChangeListener -{ - int nChangeCalled; - int nPropertiesChange; - int nVetoCalled; - int nDisposingCalled; - boolean bVeto= false; - PropertyChangeEvent evt; - PropertyChangeEvent[] arEvt; - // XPropertyChangeListener - public void propertyChange(PropertyChangeEvent evt ) - { - nChangeCalled++; - this.evt= evt; - } - - //VetoableChangeListener - public void vetoableChange(PropertyChangeEvent evt ) throws PropertyVetoException - { - nVetoCalled++; - this.evt= evt; - if (bVeto) - throw new PropertyVetoException(); - } - - public void disposing( /*IN*/EventObject Source ) - { - nDisposingCalled++; - } - - public void reset() - { - nChangeCalled= 0; - nPropertiesChange= 0; - nVetoCalled= 0; - nDisposingCalled= 0; - evt= null; - arEvt= null; - bVeto= false; - } - // XPropertiesChangeListener - public void propertiesChange(PropertyChangeEvent[] propertyChangeEvent) - { - nPropertiesChange++; - arEvt= propertyChangeEvent; - } - -} diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java b/javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java deleted file mode 100644 index ba25567fd..000000000 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java +++ /dev/null @@ -1,165 +0,0 @@ -/************************************************************************* - * - * 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.lib.uno.helper; -import com.sun.star.uno.Type; -import com.sun.star.lib.uno.typedesc.TypeDescription; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.XEventListener; -import com.sun.star.uno.IQueryInterface; -//import com.sun.star.lib.uno.environments.java.Proxy; -import com.sun.star.lib.uno.environments.java.java_environment; -//import com.sun.star.lib.uno.environments.java.IRequester; - - -public class ProxyProvider -{ - static java_environment env= new java_environment(null); - - /** Creates a new instance of ProxyProvider */ - public ProxyProvider() - { - } - /** returns Holder proxy objects for the specified interface. If the method is called - * several times with the same arguments then each time a new HolderProxy is returned. - * Then all HolderProxy s refer to the same Proxy object. - * The proxy can be queried for XEventListener. On the returned proxy disposing can be called - * - */ - public static Object createProxy(Object obj, Class iface) - { - - Object retVal= null; - if (obj == null || iface == null || iface.isInstance(obj) == false ) - return retVal; - - Type type= new Type(TypeDescription.getTypeDescription(iface)); - Type evtType= new Type(TypeDescription.getTypeDescription(com.sun.star.lang.XEventListener.class)); - // find the object identifier - String sOid= UnoRuntime.generateOid(obj); - retVal= env.getRegisteredInterface(sOid, type); - // if retVal == null then probably not registered - if (retVal == null) - { - Object aProxy = new Proxy(sOid, type); - String[] arOid = new String[] - {sOid}; - retVal= env.registerInterface(aProxy, arOid, type); - } - return retVal; - } -} - -class Proxy implements IQueryInterface, XEventListener -{ - String oid; - Type type; - Proxy(String oid, Type t) { - this.oid = oid; - this.type = t; - } - - public String getOid() { - return oid; - } - - public boolean isSame(Object object) { - if (object instanceof IQueryInterface) - { - IQueryInterface iquery = (IQueryInterface) object; - if (iquery != null) - { - if (iquery.getOid().equals(oid)) - return true; - else - return false; - } - } - - String oidObj = UnoRuntime.generateOid(object); - if (oidObj.equals(oid)) - return true; - else - return false; - } - - public Object queryInterface(Type type) { - return null; - } - - public void disposing(com.sun.star.lang.EventObject eventObject) { - } - -} - - -//class Requester //implements IRequester -//{ -// int _modus; -// boolean _virtual; -// boolean _forceSynchronous; -// boolean _passed = true; -// -// Object _xEventListenerProxy; -// int nDisposingCalled= 0; -// -// Requester(boolean virtual, boolean forceSynchronous, Object evtListener) -// { -// _virtual = virtual; -// _forceSynchronous = forceSynchronous; -// _xEventListenerProxy= evtListener; -// -// } -// -// public Object sendRequest(Object object, -// Type type, -// String operation, -// Object params[], -// Boolean synchron[], -// Boolean mustReply[]) throws Throwable -// { -// -// Object result = null; -// if (operation.equals("disposing")) -// { -// System.out.println("Disposing called on XEventListener proxy"); -// nDisposingCalled++; -// } -// else if (operation.equals("queryInterface")) -// { -// if (params[0] instanceof Type) -// { -// Type t= (Type) params[0]; -// if (t.equals( new Type("com.sun.star.lang.XEventListener"))) -// result= _xEventListenerProxy; -// } -// } -// return result; -// } -//} - - diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/UnoUrlTest.java b/javaunohelper/test/com/sun/star/lib/uno/helper/UnoUrlTest.java deleted file mode 100644 index 371e3d838..000000000 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/UnoUrlTest.java +++ /dev/null @@ -1,261 +0,0 @@ -/************************************************************************* - * - * 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.lib.uno.helper; -public class UnoUrlTest { - - private UnoUrlTest() { - } - - - private void fail(String msg) { - System.err.println(msg); - System.exit(1); - } - - private static void log(String msg) { - System.out.println(msg); - } - - private void assertTrue(boolean b) { - if (!b) - fail("boolean assertion failed"); - } - - private void assertEquals(String expected, String actual) { - if (!expected.equals(actual)) { - fail("Expected: '"+ expected + "' but was: '"+actual+"'"); - } - } - - private void assertEquals(int expected, int actual) { - if (expected != actual) { - fail("Expected: "+ expected + " but was: "+actual); - } - } - - public void testStart1() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno:x;y;z"); - assertTrue((url != null)); - assertEquals("x", url.getConnection()); - } catch (com.sun.star.lang.IllegalArgumentException e) { - fail("Caught exception:" + e.getMessage()); - } - } - - public void testStart2() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno1:x;y;z"); - fail("Should throw an exception"); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - public void testStart3() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("un:x;y;z"); - fail("Should throw an exception"); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - public void testStart4() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("x;y;z"); - assertTrue((url != null)); - assertEquals("y", url.getProtocol()); - } catch (com.sun.star.lang.IllegalArgumentException e) { - fail("Caught exception:" + e.getMessage()); - } - } - - public void testParam1() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno:"); - fail("Should throw an exception"); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - public void testParam2() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno:a;"); - fail("Should throw an exception"); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - public void testPartName1() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno:abc!abc;b;c"); - fail("Should throw an exception"); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - public void testOID1() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno:x;y;ABC<ABC"); - fail("Should throw an exception"); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - public void testOIDandParams1() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno:x,key9=val9;y;ABC"); - assertTrue((url != null)); - assertEquals("ABC", url.getRootOid()); - assertEquals(1, url.getConnectionParameters().size()); - assertEquals("val9", (String)url.getConnectionParameters().get("key9")); - } catch (com.sun.star.lang.IllegalArgumentException e) { - fail(e.getMessage()); - } - } - - public void testOIDandParams2() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno:x,key1=val1,k2=v2;y,k3=v3;ABC()!/"); - assertTrue((url != null)); - assertEquals("ABC()!/", url.getRootOid()); - assertEquals(2, url.getConnectionParameters().size()); - assertEquals(1, url.getProtocolParameters().size()); - } catch (com.sun.star.lang.IllegalArgumentException e) { - fail("Caught exception:" + e.getMessage()); - } - } - - public void testParams1() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno:x,abc!abc=val;y;ABC"); - fail("Should throw an exception"); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - public void testParams2() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno:x,abc=val<val;y;ABC"); - fail("Should throw an exception"); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - public void testParams3() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno:x,abc=val!()val;y;ABC"); - assertTrue((url != null)); - assertEquals(1, url.getConnectionParameters().size()); - } catch (com.sun.star.lang.IllegalArgumentException e) { - fail("Caught exception:" + e.getMessage()); - } - } - - public void testCommon() { - try { - UnoUrl url = - UnoUrl.parseUnoUrl( - "socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"); - assertTrue((url != null)); - assertEquals("StarOffice.ServiceManager", url.getRootOid()); - assertEquals("socket", url.getConnection()); - assertEquals("urp", url.getProtocol()); - assertEquals("2002", (String)url.getConnectionParameters().get("port")); - } catch (com.sun.star.lang.IllegalArgumentException e) { - fail("Caught exception:" + e.getMessage()); - } - } - - public void testUTF() { - try { - UnoUrl url = - UnoUrl.parseUnoUrl( - "socket,host=localhost,horst=abc%c3%9c%c3%a4ABC%41%2c%2C,port=2002;urp;StarOffice.ServiceManager"); - assertEquals("abcÜäABCA,,", (String)url.getConnectionParameters().get("horst")); - assertEquals( - "host=localhost,horst=abc%c3%9c%c3%a4ABC%41%2c%2C,port=2002", - url.getConnectionParametersAsString()); - } catch (com.sun.star.lang.IllegalArgumentException e) { - fail("Caught exception:" + e.getMessage()); - } - - } - - public void testUTF1() { - try { - UnoUrl url = UnoUrl.parseUnoUrl("uno:x,abc=val%4t;y;ABC"); - fail("Should throw an exception"); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - - public static void main(String args[]) { - UnoUrlTest t = new UnoUrlTest(); - - log("Running test case 1"); - t.testStart1(); - log("Running test case 2"); - t.testStart2(); - log("Running test case 3"); - t.testStart3(); - log("Running test case 4"); - t.testStart4(); - - log("Running test case 5"); - t.testParam1(); - log("Running test case 6"); - t.testParam2(); - - log("Running test case 7"); - t.testPartName1(); - - log("Running test case 8"); - t.testOID1(); - - log("Running test case 9"); - t.testOIDandParams1(); - log("Running test case 10"); - t.testOIDandParams2(); - - log("Running test case 11"); - t.testParams1(); - log("Running test case 12"); - t.testParams2(); - log("Running test case 13"); - t.testParams3(); - - log("Running test case 14"); - t.testCommon(); - - log("Running test case 15"); - t.testUTF(); - log("Running test case 16"); - t.testUTF1(); - } -} diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test.java deleted file mode 100644 index c51c5273b..000000000 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test.java +++ /dev/null @@ -1,251 +0,0 @@ -/************************************************************************* - * - * 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.lib.uno.helper; -import com.sun.star.uno.Type; -import com.sun.star.bridge.XBridgeSupplier2; -import com.sun.star.uno.XReference; -import com.sun.star.uno.XWeak; -import com.sun.star.lang.XTypeProvider; -import com.sun.star.uno.XAdapter; - -public class WeakBase_Test -{ - - /** Creates a new instance of WeakBase_Test */ - public WeakBase_Test() - { - } - - public boolean getTypes() - { - System.out.println("Testing WeakBase.getTypes"); - boolean[] r= new boolean[50]; - int i= 0; - - SomeClass comp= new SomeClass(); - Type[] types= comp.getTypes(); //XWeak,XTypeProvider,XReference,XBridgeSupplier2 - r[i++]= types.length == 4; - for (int c= 0; c < types.length; c++) - { - if (types[c].equals( new Type( XWeak.class))) - r[i++]= true; - else if (types[c].equals(new Type(XTypeProvider.class))) - r[i++]= true; - else if (types[c].equals(new Type(XReference.class))) - r[i++]= true; - else if (types[c].equals(new Type(XBridgeSupplier2.class))) - r[i++]= true; - else - r[i++]= false; - - } - - Foo1 f1= new Foo1(); - Foo1 f2= new Foo1(); - Type[] t1= f1.getTypes(); - Type[] t2= f2.getTypes(); - r[i++]= t1.equals(t2); - Foo2 f3= new Foo2(); - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean getImplementationId() - { - System.out.println("Testing WeakBase.getImplementationId"); - boolean[] r= new boolean[50]; - int i= 0; - - SomeClass comp= new SomeClass(); - // byte 0 - 3 contain hashcode and the remaining bytes represent the classname - byte [] ar= comp.getImplementationId(); - - StringBuffer buff= new StringBuffer(); - for (int c= 0; c < ar.length - 4; c++){ - buff.append((char) ar[4 + c]); -// buff.append(" "); - } - String retStr= buff.toString(); - r[i++]= retStr.equals("com.sun.star.lib.uno.helper.SomeClass"); -// System.out.println(buff.toString()); - - Foo1 f1= new Foo1(); - Foo1 f2= new Foo1(); - r[i++]= f1.getImplementationId().equals(f2.getImplementationId()); - Foo2 f3= new Foo2(); - r[i++]= ! f1.getImplementationId().equals(f3.getImplementationId()); - Foo3 f4= new Foo3(); - r[i++]= ! f1.getImplementationId().equals(f4.getImplementationId()); - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public boolean queryAdapter() - { - System.out.println("Testing WeakBase.queryAdapter, XAdapter tests"); - boolean[] r= new boolean[50]; - int i= 0; - - SomeClass comp= new SomeClass(); - XAdapter adapter= comp.queryAdapter(); - MyRef aRef1= new MyRef(); - MyRef aRef2= new MyRef(); - adapter.addReference(aRef1); - adapter.addReference(aRef2); - - r[i++]= adapter.queryAdapted() == comp; - comp= null; - System.out.println("Wait 5 sec"); - for(int c= 0; c < 50; c++) - { - try - { - Thread.currentThread().sleep(100); - System.gc(); - System.runFinalization(); - }catch (InterruptedException ie) - { - } - } - - r[i++]= aRef1.nDisposeCalled == 1; - r[i++]= aRef2.nDisposeCalled == 1; - r[i++]= adapter.queryAdapted() == null; - adapter.removeReference(aRef1); // should not do any harm - adapter.removeReference(aRef2); - - comp= new SomeClass(); - adapter= comp.queryAdapter(); - aRef1.nDisposeCalled= 0; - aRef2.nDisposeCalled= 0; - - adapter.addReference(aRef1); - adapter.addReference(aRef2); - - adapter.removeReference(aRef1); - System.out.println("Wait 5 sec"); - comp= null; - for(int c= 0; c < 50; c++) - { - try - { - Thread.currentThread().sleep(100); - System.gc(); - System.runFinalization(); - }catch (InterruptedException ie) - { - } - } - r[i++]= aRef1.nDisposeCalled == 0; - r[i++]= aRef2.nDisposeCalled == 1; - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Failed"); - else - System.out.println("Ok"); - return bOk; - } - - public static void main(String[] args) - { - WeakBase_Test test= new WeakBase_Test(); - boolean r[]= new boolean[50]; - int i= 0; - r[i++]= test.getTypes(); - r[i++]= test.getImplementationId(); - r[i++]= test.queryAdapter(); - - boolean bOk= true; - for (int c= 0; c < i; c++) - bOk= bOk && r[c]; - if (bOk == false) - System.out.println("Errors occurred!"); - else - System.out.println("No errors."); - - } - -} - -interface Aint -{ -} -class OtherClass extends WeakBase implements XBridgeSupplier2 -{ - - public Object createBridge(Object obj, byte[] values, short param, short param3) throws com.sun.star.lang.IllegalArgumentException - { - return null; - } -} - -class SomeClass extends OtherClass implements Aint,XReference -{ - - public void dispose() - { - } - -} - -class MyRef implements XReference -{ - int nDisposeCalled; - - public void dispose() - { - nDisposeCalled++; - } -} - -class Foo1 extends WeakBase -{ -} - -class Foo2 extends WeakBase -{ -} - -class Foo3 extends Foo1 -{ -} diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk b/javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk deleted file mode 100644 index d3de3df10..000000000 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk +++ /dev/null @@ -1,68 +0,0 @@ -#************************************************************************* -# -# 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$/lib$/uno$/helper -TARGET = com_sun_star_lib_uno_helper_test - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - -JARFILES = jurt.jar ridl.jar juh.jar - -JAVACLASSFILES= \ - $(CLASSDIR)$/$(PACKAGE)$/WeakBase_Test.class \ - $(CLASSDIR)$/$(PACKAGE)$/ComponentBase_Test.class \ - $(CLASSDIR)$/$(PACKAGE)$/InterfaceContainer_Test.class \ - $(CLASSDIR)$/$(PACKAGE)$/MultiTypeInterfaceContainer_Test.class \ - $(CLASSDIR)$/$(PACKAGE)$/ProxyProvider.class \ - $(CLASSDIR)$/$(PACKAGE)$/AWeakBase.class \ - $(CLASSDIR)$/$(PACKAGE)$/PropertySet_Test.class \ - $(CLASSDIR)$/$(PACKAGE)$/UnoUrlTest.class \ - $(CLASSDIR)$/$(PACKAGE)$/Factory_Test.class - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - -CPATH_JARS = java_uno.jar $(JARFILES) -CPATH_TMP1 = $(foreach,j,$(CPATH_JARS) $(SOLARBINDIR)$/$j) -CPATH_TMP2 = $(strip $(subst,!,$(PATH_SEPERATOR) $(CPATH_TMP1:s/ /!/))) -CPATH = $(CPATH_TMP2)$(PATH_SEPERATOR)$(OUT)$/bin$/factory_test.jar$(PATH_SEPERATOR)$(XCLASSPATH) - -$(OUT)$/bin$/factory_test.jar : $(CLASSDIR)$/$(PACKAGE)$/Factory_Test.class - -rm -f $@ - @echo RegistrationClassName: com.sun.star.lib.uno.helper.Factory_Test > $(OUT)$/bin$/manifest.mf - -jar cvfm $@ $(OUT)$/bin$/manifest.mf -C $(CLASSDIR) $(PACKAGE)$/Factory_Test.class - -run_factory_test : $(OUT)$/bin$/factory_test.jar - -$(GNUCOPY) $(SOLARBINDIR)$/udkapi.rdb $(OUT)$/bin$/factory_test.rdb - -java -classpath $(CPATH) com.sun.star.lib.uno.helper.Factory_Test $(OUT)$/bin$/factory_test.jar $(OUT)$/bin$/factory_test.rdb |