diff options
Diffstat (limited to 'ure/source/uretest')
-rw-r--r-- | ure/source/uretest/JavaClient.java | 58 | ||||
-rw-r--r-- | ure/source/uretest/JavaMain.java | 61 | ||||
-rw-r--r-- | ure/source/uretest/JavaNative.java | 30 | ||||
-rw-r--r-- | ure/source/uretest/JavaTest.java | 49 | ||||
-rw-r--r-- | ure/source/uretest/Makefile | 283 | ||||
-rw-r--r-- | ure/source/uretest/Makefile.pln | 276 | ||||
-rw-r--r-- | ure/source/uretest/README | 101 | ||||
-rw-r--r-- | ure/source/uretest/Runner.java | 32 | ||||
-rw-r--r-- | ure/source/uretest/Tester.java | 46 | ||||
-rw-r--r-- | ure/source/uretest/cppmain.cc | 240 | ||||
-rw-r--r-- | ure/source/uretest/cppserver.cc | 93 | ||||
-rw-r--r-- | ure/source/uretest/cpptest.cc | 89 | ||||
-rw-r--r-- | ure/source/uretest/javaclient.mf.template | 5 | ||||
-rw-r--r-- | ure/source/uretest/javamain.mf.template | 5 | ||||
-rw-r--r-- | ure/source/uretest/javanative.mf.template | 5 | ||||
-rw-r--r-- | ure/source/uretest/javatest.mf.template | 5 | ||||
-rw-r--r-- | ure/source/uretest/runner.mf.template | 5 | ||||
-rw-r--r-- | ure/source/uretest/services.rdb.in | 24 | ||||
-rw-r--r-- | ure/source/uretest/tester.mf.template | 5 | ||||
-rw-r--r-- | ure/source/uretest/types.idl | 43 | ||||
-rw-r--r-- | ure/source/uretest/types.mf.template | 4 |
21 files changed, 1459 insertions, 0 deletions
diff --git a/ure/source/uretest/JavaClient.java b/ure/source/uretest/JavaClient.java new file mode 100644 index 0000000000..f86d61af66 --- /dev/null +++ b/ure/source/uretest/JavaClient.java @@ -0,0 +1,58 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package test.java.javaclient; + +import com.sun.star.bridge.XBridge; +import com.sun.star.bridge.XBridgeFactory; +import com.sun.star.comp.helper.Bootstrap; +import com.sun.star.connection.Connector; +import com.sun.star.lang.XComponent; +import com.sun.star.lib.uno.helper.UnoUrl; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import test.types.Data; +import test.types.XServer; + +public final class JavaClient { + public static void main(String[] arguments) throws Exception { + XComponentContext context = Bootstrap.createInitialComponentContext( + null); + XBridgeFactory factory = UnoRuntime.queryInterface( + XBridgeFactory.class, + context.getServiceManager().createInstanceWithContext( + "com.sun.star.bridge.BridgeFactory", context)); + if (factory == null) { + throw new NullPointerException("no bridge factory"); + } + UnoUrl url = UnoUrl.parseUnoUrl(arguments[0]); + XBridge bridge = factory.createBridge( + "", url.getProtocolAndParametersAsString(), + Connector.create(context).connect( + url.getConnectionAndParametersAsString()), + null); + Data d = UnoRuntime.queryInterface( + XServer.class, bridge.getInstance(url.getRootOid())).getData(); + UnoRuntime.queryInterface(XComponent.class, bridge).dispose(); + if (!d.m1.equals("Hello") || d.m2 != 42) { + throw new RuntimeException("Data object contains bad values"); + } + } + + private JavaClient() {} +} diff --git a/ure/source/uretest/JavaMain.java b/ure/source/uretest/JavaMain.java new file mode 100644 index 0000000000..be0632293e --- /dev/null +++ b/ure/source/uretest/JavaMain.java @@ -0,0 +1,61 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package test.java.javamain; + +import com.sun.star.comp.loader.FactoryHelper; +import com.sun.star.lang.XMain; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.registry.XRegistryKey; +import com.sun.star.uno.XComponentContext; +import test.java.tester.Tester; + +public final class JavaMain implements XMain { + public JavaMain(XComponentContext context) { + this.context = context; + } + + public int run(String[] arguments) { + Tester.test(context); + return 0; + } + + public static boolean __writeRegistryServiceInfo(XRegistryKey key) { + return + FactoryHelper.writeRegistryServiceInfo( + IMPLEMENTATION_NAME, SERVICE_NAME, key); + } + + public static XSingleServiceFactory __getServiceFactory( + String name, XMultiServiceFactory factory, XRegistryKey key) + { + if (name.equals(IMPLEMENTATION_NAME)) { + return FactoryHelper.getServiceFactory( + JavaMain.class, SERVICE_NAME, factory, key); + } else { + return null; + } + } + + private static final String IMPLEMENTATION_NAME + = "test.java.javamain.Component"; + private static final String SERVICE_NAME = "test.dummy.JavaMain"; + + private final XComponentContext context; +} diff --git a/ure/source/uretest/JavaNative.java b/ure/source/uretest/JavaNative.java new file mode 100644 index 0000000000..289f00909d --- /dev/null +++ b/ure/source/uretest/JavaNative.java @@ -0,0 +1,30 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package test.java.javanative; + +import com.sun.star.comp.helper.Bootstrap; +import test.java.tester.Tester; + +public final class JavaNative { + public static void main(String[] arguments) throws Exception { + Tester.test(Bootstrap.defaultBootstrap_InitialComponentContext()); + } + + private JavaNative() {} +} diff --git a/ure/source/uretest/JavaTest.java b/ure/source/uretest/JavaTest.java new file mode 100644 index 0000000000..2bc1b0c720 --- /dev/null +++ b/ure/source/uretest/JavaTest.java @@ -0,0 +1,49 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package test.java.javatest; + +import com.sun.star.comp.loader.FactoryHelper; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.registry.XRegistryKey; +import test.types.TestException; +import test.types.XTest; + +public final class JavaTest implements XTest { + public JavaTest() {} + + public void throwException() throws TestException { + throw new TestException("test", this); + } + + public static XSingleServiceFactory __getServiceFactory( + String name, XMultiServiceFactory factory, XRegistryKey key) + { + if (name.equals(IMPLEMENTATION_NAME)) { + return FactoryHelper.getServiceFactory( + JavaTest.class, SERVICE_NAME, factory, key); + } else { + return null; + } + } + + private static final String IMPLEMENTATION_NAME + = "test.java.javatest.Component"; + private static final String SERVICE_NAME = "test.types.JavaTest"; +} diff --git a/ure/source/uretest/Makefile b/ure/source/uretest/Makefile new file mode 100644 index 0000000000..1ba97fd795 --- /dev/null +++ b/ure/source/uretest/Makefile @@ -0,0 +1,283 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +# The following variable can be set, if necessary (see README): +#GCCS_COMPAT := LD_PRELOAD=/lib/libgcc_s.so.1 + + +.DELETE_ON_ERROR: + + +PRJ = $(OO_SDK_HOME) + +include $(PRJ)/settings/settings.mk +include $(PRJ)/settings/std.mk + +ifeq "$(PLATFORM)" "windows" +qt = " +qt2 = +cwd = $(subst \,/,$(shell cd)) +link_output_switch = -out: +ure_java_url = $(subst $(subst .,., ),%%20,$(subst \,/,$(URLPREFIX)$(OO_SDK_URE_JAVA_DIR))) +else +qt = ' +qt2 = ' +cwd = $(PWD) +link_output_switch = $(subst .,.,-o ) +ure_java_url = $(URLPREFIX)$(OO_SDK_URE_JAVA_DIR) +endif + + +.PHONY: ALL +ALL: check + +include $(PRJ)/settings/stdtarget.mk + + +.PHONY: check +check: test-cpptest test-javatest test-javanative test-clientserver + +.PHONY: test-cpptest +test-cpptest: out.sdk/cppmain.uno.$(SHAREDLIB_EXT) out.sdk/types.rdb \ + out.sdk/services.rdb + $(GCCS_COMPAT) uno \ + -c test.cpp.cppmain.Component -l $(URLPREFIX)$(cwd)/$< \ + -env:URE_MORE_TYPES=$(URLPREFIX)$(cwd)/out.sdk/types.rdb \ + -env:URE_MORE_SERVICES=$(URLPREFIX)$(cwd)/out.sdk/services.rdb + +.PHONY: test-javatest +test-javatest: out.sdk/javamain.uno.jar out.sdk/types.rdb out.sdk/services.rdb + $(GCCS_COMPAT) uno \ + -c test.java.javamain.Component -l $(URLPREFIX)$(cwd)/$< \ + -env:URE_MORE_TYPES=$(URLPREFIX)$(cwd)/out.sdk/types.rdb \ + -env:URE_MORE_SERVICES=$(URLPREFIX)$(cwd)/out.sdk/services.rdb + +ifeq "$(PLATFORM)" "windows" +set_vars = set URE_MORE_TYPES=$(URLPREFIX)$(cwd)/out.sdk/types.rdb && \ + set URE_MORE_SERVICES=$(URLPREFIX)$(cwd)/out.sdk/services.rdb && +else +set_vars = URE_MORE_TYPES=$(URLPREFIX)$(cwd)/out.sdk/types.rdb \ + URE_MORE_SERVICES=$(URLPREFIX)$(cwd)/out.sdk/services.rdb +endif +.PHONY: test-javanative +test-javanative: out.sdk/runner.jar out.sdk/javanative.jar \ + out.sdk/services.rdb out.sdk/types.rdb + $(set_vars) $(GCCS_COMPAT) $(SDK_JAVA) -jar out.sdk/runner.jar \ + $(ure_java_url)/ $(URLPREFIX)$(cwd)/out.sdk/javanative.jar + +do_server = $(GCCS_COMPAT) uno -c test.cpp.cppserver.Component \ + -l $(URLPREFIX)$(cwd)/out.sdk/cppserver.uno.$(SHAREDLIB_EXT) \ + -env:URE_MORE_TYPES=$(URLPREFIX)$(cwd)/out.sdk/types.rdb \ + -env:URE_MORE_SERVICES=$(URLPREFIX)$(cwd)/out.sdk/services.rdb \ + -u "uno:pipe,name=ure_test;urp;server" --singleaccept +do_client = $(SDK_JAVA) -jar out.sdk/runner.jar $(ure_java_url)/ \ + $(URLPREFIX)$(cwd)/out.sdk/javaclient.jar \ + "uno:pipe,name=ure_test;urp;server" +.PHONY: test-clientserver +test-clientserver: out.sdk/cppserver.uno.$(SHAREDLIB_EXT) out.sdk/types.rdb \ + out.sdk/services.rdb out.sdk/runner.jar out.sdk/javaclient.jar +ifeq "$(PLATFORM)" "windows" + echo $(subst %,%%,$(do_server)) > out.sdk/server.bat + echo $(subst %,%%,$(do_client)) > out.sdk/client.bat + @ echo Execute test-clientserver manually: start out.sdk\server.bat + @ echo and then simultaneously start out.sdk\client.bat +else + $(do_server) & + sleep 5 && $(do_client) +endif + + +.PHONY: clean +clean: + $(DELRECURSIVE) $(subst /,$(PS),out.sdk) + + +out.sdk/cppmain.uno.$(SHAREDLIB_EXT): out.sdk/cppmain.$(OBJ_EXT) | out.sdk + $(LINK) $(COMP_LINK_FLAGS) $(link_output_switch)$@ $< $(LINK_LIBS) \ + $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB) $(SALHELPERLIB) \ + $(LIBO_SDK_LDFLAGS_STDLIBS) + +out.sdk/cppmain.$(OBJ_EXT): cppmain.cc out.sdk/cpputypes.cppumaker.flag \ + out.sdk/types.cppumaker.flag | out.sdk + $(CC) $(CC_FLAGS) $(CC_OUTPUT_SWITCH)$@ $(CC_INCLUDES) \ + -Iout.sdk/include/cpputypes -Iout.sdk/include/types $(CC_DEFINES) $< + + +out.sdk/cpptest.uno.$(SHAREDLIB_EXT): out.sdk/cpptest.$(OBJ_EXT) | out.sdk + $(LINK) $(COMP_LINK_FLAGS) $(link_output_switch)$@ $< $(LINK_LIBS) \ + $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB) $(LIBO_SDK_LDFLAGS_STDLIBS) + +out.sdk/cpptest.$(OBJ_EXT): cpptest.cc out.sdk/cpputypes.cppumaker.flag \ + out.sdk/types.cppumaker.flag | out.sdk + $(CC) $(CC_FLAGS) $(CC_OUTPUT_SWITCH)$@ $(CC_INCLUDES) \ + -Iout.sdk/include/cpputypes -Iout.sdk/include/types $(CC_DEFINES) $< + + +out.sdk/cppserver.uno.$(SHAREDLIB_EXT): out.sdk/cppserver.$(OBJ_EXT) | out.sdk + $(LINK) $(COMP_LINK_FLAGS) $(link_output_switch)$@ $< $(LINK_LIBS) \ + $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB) $(LIBO_SDK_LDFLAGS_STDLIBS) + +out.sdk/cppserver.$(OBJ_EXT): cppserver.cc out.sdk/cpputypes.cppumaker.flag \ + out.sdk/types.cppumaker.flag | out.sdk + $(CC) $(CC_FLAGS) $(CC_OUTPUT_SWITCH)$@ $(CC_INCLUDES) \ + -Iout.sdk/include/cpputypes -Iout.sdk/include/types $(CC_DEFINES) $< + + +out.sdk/cpputypes.cppumaker.flag: | out.sdk + $(CPPUMAKER) -O./out.sdk/include/cpputypes \ + "-Tcom.sun.star.beans.Introspection;com.sun.star.beans.theIntrospection;com.sun.star.bridge.BridgeFactory;com.sun.star.bridge.UnoUrlResolver;com.sun.star.connection.Acceptor;com.sun.star.connection.Connector;com.sun.star.io.Pipe;com.sun.star.io.TextInputStream;com.sun.star.io.TextOutputStream;com.sun.star.java.JavaVirtualMachine;com.sun.star.lang.DisposedException;com.sun.star.lang.EventObject;com.sun.star.lang.XMain;com.sun.star.lang.XMultiComponentFactory;com.sun.star.lang.XMultiServiceFactory;com.sun.star.lang.XSingleComponentFactory;com.sun.star.lang.XSingleServiceFactory;com.sun.star.lang.XTypeProvider;com.sun.star.loader.Java;com.sun.star.loader.SharedLibrary;com.sun.star.reflection.ProxyFactory;com.sun.star.registry.ImplementationRegistration;com.sun.star.registry.SimpleRegistry;com.sun.star.registry.XRegistryKey;com.sun.star.script.Converter;com.sun.star.script.Invocation;com.sun.star.security.AccessController;com.sun.star.security.Policy;com.sun.star.uno.DeploymentException;com.sun.star.uno.Exception;com.sun.star.uno.NamingService;com.sun.star.uno.RuntimeException;com.sun.star.uno.XAggregation;com.sun.star.uno.XComponentContext;com.sun.star.uno.XCurrentContext;com.sun.star.uno.XInterface;com.sun.star.uno.XWeak;com.sun.star.uri.ExternalUriReferenceTranslator;com.sun.star.uri.UriReferenceFactory;com.sun.star.uri.VndSunStarPkgUrlReferenceFactory;com.sun.star.util.theMacroExpander" \ + "$(URE_TYPES)" + touch $@ + +out.sdk/types.cppumaker.flag: out.sdk/types.rdb | out.sdk + $(CPPUMAKER) -O./out.sdk/include/types ./$< "-X$(URE_TYPES)" + touch $@ + + +out.sdk/javamain.uno.jar: \ + out.sdk/class/javamain/test/java/javamain/JavaMain.class \ + out.sdk/javamain.mf | out.sdk + $(SDK_JAR) cfm $@ out.sdk/javamain.mf -C out.sdk/class/javamain test + +out.sdk/javamain.mf: javamain.mf.template | out.sdk + sed -e $(qt)s~^Class-Path:$$~& tester.jar~$(qt) \ + -e $(qt)s~^UNO-Type-Path:$$~& types.jar~$(qt) $< > $@ + +out.sdk/class/javamain/test/java/javamain/JavaMain.class: JavaMain.java \ + out.sdk/tester.jar | out.sdk/class + - $(DELRECURSIVE) $(subst /,$(PS),out.sdk/class/javamain) + $(MKDIR) $(subst /,$(PS),out.sdk/class/javamain) + $(SDK_JAVAC) $(JAVAC_FLAGS) \ + -classpath "$(CLASSPATH)$(PATH_SEPARATOR)out.sdk/tester.jar" \ + -sourcepath . -d out.sdk/class/javamain $< + + +out.sdk/runner.jar: out.sdk/class/runner/test/java/runner/Runner.class \ + out.sdk/runner.mf | out.sdk + $(SDK_JAR) cfm $@ out.sdk/runner.mf -C out.sdk/class/runner test + +out.sdk/runner.mf: runner.mf.template | out.sdk + sed -e \ + $(qt)s~^Class-Path:$$~& $(ure_java_url)/unoloader.jar~$(qt) \ + -e $(qt)s~^UNO-Type-Path:$$~& ~$(qt) $< > $@ + +out.sdk/class/runner/test/java/runner/Runner.class: Runner.java | out.sdk/class + - $(DELRECURSIVE) $(subst /,$(PS),out.sdk/class/runner) + $(MKDIR) $(subst /,$(PS),out.sdk/class/runner) + $(SDK_JAVAC) $(JAVAC_FLAGS) -sourcepath . -d out.sdk/class/runner $< + + +out.sdk/tester.jar: out.sdk/class/tester/test/java/tester/Tester.class \ + out.sdk/tester.mf | out.sdk + $(SDK_JAR) cfm $@ out.sdk/tester.mf -C out.sdk/class/tester test + +out.sdk/tester.mf: tester.mf.template | out.sdk + sed -e $(qt)s~^Class-Path:$$~& types.jar~$(qt) \ + -e $(qt)s~^UNO-Type-Path:$$~& types.jar~$(qt) $< > $@ + +out.sdk/class/tester/test/java/tester/Tester.class: Tester.java \ + out.sdk/types.jar | out.sdk/class + - $(DELRECURSIVE) $(subst /,$(PS),out.sdk/class/tester) + $(MKDIR) $(subst /,$(PS),out.sdk/class/tester) + $(SDK_JAVAC) $(JAVAC_FLAGS) \ + -classpath "$(CLASSPATH)$(PATH_SEPARATOR)out.sdk/types.jar" \ + -sourcepath . -d out.sdk/class/tester $< + + +out.sdk/javatest.uno.jar: \ + out.sdk/class/javatest/test/java/javatest/JavaTest.class \ + out.sdk/javatest.mf | out.sdk + $(SDK_JAR) cfm $@ out.sdk/javatest.mf -C out.sdk/class/javatest test + +out.sdk/javatest.mf: javatest.mf.template | out.sdk + sed -e $(qt)s~^Class-Path:$$~& types.jar~$(qt) \ + -e $(qt)s~^UNO-Type-Path:$$~& types.jar~$(qt) $< > $@ + +out.sdk/class/javatest/test/java/javatest/JavaTest.class: JavaTest.java \ + out.sdk/types.jar | out.sdk/class + - $(DELRECURSIVE) $(subst /,$(PS),out.sdk/class/javatest) + $(MKDIR) $(subst /,$(PS),out.sdk/class/javatest) + $(SDK_JAVAC) $(JAVAC_FLAGS) \ + -classpath "$(CLASSPATH)$(PATH_SEPARATOR)out.sdk/types.jar" \ + -sourcepath . -d out.sdk/class/javatest $< + + +out.sdk/javanative.jar: \ + out.sdk/class/javanative/test/java/javanative/JavaNative.class \ + out.sdk/javanative.mf | out.sdk + $(SDK_JAR) cfm $@ out.sdk/javanative.mf -C out.sdk/class/javanative test + +out.sdk/javanative.mf: javanative.mf.template | out.sdk + sed -e $(qt)s~^Class-Path:$$~& tester.jar~$(qt) \ + -e $(qt)s~^UNO-Type-Path:$$~& types.jar~$(qt) $< > $@ + +out.sdk/class/javanative/test/java/javanative/JavaNative.class: \ + JavaNative.java out.sdk/tester.jar | out.sdk/class + - $(DELRECURSIVE) $(subst /,$(PS),out.sdk/class/javanative) + $(MKDIR) $(subst /,$(PS),out.sdk/class/javanative) + $(SDK_JAVAC) $(JAVAC_FLAGS) \ + -classpath "$(CLASSPATH)$(PATH_SEPARATOR)out.sdk/tester.jar" \ + -sourcepath . -d out.sdk/class/javanative $< + + +out.sdk/javaclient.jar: \ + out.sdk/class/javaclient/test/java/javaclient/JavaClient.class \ + out.sdk/javaclient.mf | out.sdk + $(SDK_JAR) cfm $@ out.sdk/javaclient.mf -C out.sdk/class/javaclient test + +out.sdk/javaclient.mf: javaclient.mf.template | out.sdk + sed -e $(qt)s~^Class-Path:$$~& types.jar~$(qt) \ + -e $(qt)s~^UNO-Type-Path:$$~& types.jar~$(qt) $< > $@ + +out.sdk/class/javaclient/test/java/javaclient/JavaClient.class: \ + JavaClient.java out.sdk/types.jar | out.sdk/class + - $(DELRECURSIVE) $(subst /,$(PS),out.sdk/class/javaclient) + $(MKDIR) $(subst /,$(PS),out.sdk/class/javaclient) + $(SDK_JAVAC) $(JAVAC_FLAGS) \ + -classpath "$(CLASSPATH)$(PATH_SEPARATOR)out.sdk/types.jar" \ + -sourcepath . -d out.sdk/class/javaclient $< + + +out.sdk/types.jar: out.sdk/types.javamaker.flag out.sdk/types.mf | out.sdk + $(SDK_JAR) cfm $@ out.sdk/types.mf -C out.sdk/class/types test + +out.sdk/types.mf: types.mf.template | out.sdk + sed -e $(qt)s~^Class-Path:$$~& ~$(qt) \ + -e $(qt)s~^UNO-Type-Path:$$~& \<\>~$(qt) $< > $@ + +out.sdk/types.javamaker.flag: out.sdk/types.rdb | out.sdk out.sdk/class + - $(DELRECURSIVE) $(subst /,$(PS),out.sdk/class/types) + $(JAVAMAKER) -O./out.sdk/class/types ./$< "-X$(URE_TYPES)" + touch $@ + + +out.sdk/types.rdb: types.idl | out.sdk + $(UNOIDLWRITE) $(URE_TYPES) $< $@ + + +out.sdk/services.rdb: services.rdb.in | out.sdk/cpptest.uno.$(SHAREDLIB_EXT) \ + out.sdk/javatest.uno.jar out.sdk + $(DEL) $(subst /,$(PS),$@) + sed -e s/@SHAREDLIB_EXT@/$(SHAREDLIB_EXT)/ < $^ > $@ + + +out.sdk: + $(MKDIR) $(subst /,$(PS),$@) + +out.sdk/class: | out.sdk + $(MKDIR) $(subst /,$(PS),$@) diff --git a/ure/source/uretest/Makefile.pln b/ure/source/uretest/Makefile.pln new file mode 100644 index 0000000000..37025d7acb --- /dev/null +++ b/ure/source/uretest/Makefile.pln @@ -0,0 +1,276 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +# The following variable must be set (see README): +#SDK_HOME := /opt/libreoffice/basis3.1/sdk + +# The following variables can be set, if necessary (see README): +#URE_HOME := /opt/libreoffice +#GCCS_COMPAT := LD_PRELOAD=/lib/libgcc_s.so.1 + + +URE_HOME ?= /opt/libreoffice + +.DELETE_ON_ERROR: + + +.PHONY: check +check: test-cpptest test-javatest test-javanative test-clientserver + +.PHONY: test-cpptest +test-cpptest: out.pln/cppmain.uno.so out.pln/types.rdb out.pln/services.rdb + $(GCCS_COMPAT) $(URE_HOME)/program/uno \ + -c test.cpp.cppmain.Component -l file://$(PWD)/$< \ + -env:URE_MORE_TYPES=file://$(PWD)/out.pln/types.rdb \ + -env:URE_MORE_SERVICES=file://$(PWD)/out.pln/services.rdb + +.PHONY: test-javatest +test-javatest: out.pln/javamain.uno.jar out.pln/types.rdb out.pln/services.rdb + $(GCCS_COMPAT) $(URE_HOME)/program/uno \ + -c test.java.javamain.Component -l file://$(PWD)/$< \ + -env:URE_MORE_TYPES=file://$(PWD)/out.pln/types.rdb \ + -env:URE_MORE_SERVICES=file://$(PWD)/out.pln/services.rdb + +.PHONY: test-javanative +test-javanative: out.pln/runner.jar out.pln/javanative.jar \ + out.pln/types.rdb out.pln/services.rdb + URE_MORE_TYPES=file://$(PWD)/out.pln/types.rdb \ + URE_MORE_SERVICES=file://$(PWD)/out.pln/services.rdb \ + $(GCCS_COMPAT) LD_LIBRARY_PATH=$(URE_HOME)/program java \ + -jar out.pln/runner.jar file://$(URE_HOME)/program/classes/ \ + file://$(PWD)/out.pln/javanative.jar + +.PHONY: test-clientserver +test-clientserver: out.pln/cppserver.uno.so out.pln/types.rdb \ + out.pln/services.rdb out.pln/runner.jar out.pln/javaclient.jar + $(GCCS_COMPAT) $(URE_HOME)/program/uno -c test.cpp.cppserver.Component \ + -l file://$(PWD)/out.pln/cppserver.uno.so \ + -env:URE_MORE_TYPES=file://$(PWD)/out.pln/types.rdb \ + -env:URE_MORE_SERVICES=file://$(PWD)/out.pln/services.rdb \ + -u 'uno:pipe,name=ure_test;urp;server' --singleaccept & + sleep 5 && \ + java -jar out.pln/runner.jar file://$(URE_HOME)/program/classes/ \ + file://$(PWD)/out.pln/javaclient.jar \ + 'uno:pipe,name=ure_test;urp;server' + + +.PHONY: clean +clean: + rm -rf out.pln + + +out.pln/cppmain.uno.so: out.pln/cppmain.o | out.pln out.pln/lib/libuno_cppu.so \ + out.pln/lib/libuno_cppuhelpergcc3.so out.pln/lib/libuno_sal.so \ + out.pln/lib/libuno_salhelpergcc3.so + g++ -shared -o $@ -Wl,-z,defs -Wl,--fatal-warnings $< -Lout.pln/lib \ + -luno_cppu -luno_cppuhelpergcc3 -luno_sal -luno_salhelpergcc3 + +out.pln/cppmain.o: cppmain.cc out.pln/cpputypes.cppumaker.flag \ + out.pln/types.cppumaker.flag | out.pln + g++ -c -o $@ -fpic -fvisibility=hidden -Wall -Wno-ctor-dtor-privacy \ + -I $(SDK_HOME)/include -I out.pln/include/cpputypes \ + -I out.pln/include/types -DCPPU_ENV=gcc3 -DLINUX -DUNX $< + + +out.pln/cpptest.uno.so: out.pln/cpptest.o | out.pln out.pln/lib/libuno_cppu.so \ + out.pln/lib/libuno_cppuhelpergcc3.so out.pln/lib/libuno_sal.so + g++ -shared -o $@ -Wl,-z,defs -Wl,--fatal-warnings $< -Lout.pln/lib \ + -luno_cppu -luno_cppuhelpergcc3 -luno_sal + +out.pln/cpptest.o: cpptest.cc out.pln/cpputypes.cppumaker.flag \ + out.pln/types.cppumaker.flag | out.pln + g++ -c -o $@ -fpic -fvisibility=hidden -Wall -Wno-ctor-dtor-privacy \ + -I $(SDK_HOME)/include -I out.pln/include/cpputypes \ + -I out.pln/include/types -DCPPU_ENV=gcc3 -DLINUX -DUNX $< + + +out.pln/cppserver.uno.so: out.pln/cppserver.o | out.pln \ + out.pln/lib/libuno_cppu.so out.pln/lib/libuno_cppuhelpergcc3.so \ + out.pln/lib/libuno_sal.so + g++ -shared -o $@ -Wl,-z,defs -Wl,--fatal-warnings $< -Lout.pln/lib \ + -luno_cppu -luno_cppuhelpergcc3 -luno_sal + +out.pln/cppserver.o: cppserver.cc out.pln/cpputypes.cppumaker.flag \ + out.pln/types.cppumaker.flag | out.pln + g++ -c -o $@ -fpic -fvisibility=hidden -Wall -Wno-ctor-dtor-privacy \ + -I $(SDK_HOME)/include -I out.pln/include/cpputypes \ + -I out.pln/include/types -DCPPU_ENV=gcc3 -DLINUX -DUNX $< + + +out.pln/cpputypes.cppumaker.flag: | out.pln + LD_LIBRARY_PATH=$(URE_HOME)/program $(SDK_HOME)/bin/cppumaker \ + -O./out.pln/include/cpputypes \ + '-Tcom.sun.star.beans.Introspection;com.sun.star.beans.theIntrospection;com.sun.star.bridge.BridgeFactory;com.sun.star.bridge.UnoUrlResolver;com.sun.star.connection.Acceptor;com.sun.star.connection.Connector;com.sun.star.io.Pipe;com.sun.star.io.TextInputStream;com.sun.star.io.TextOutputStream;com.sun.star.java.JavaVirtualMachine;com.sun.star.lang.DisposedException;com.sun.star.lang.EventObject;com.sun.star.lang.XMain;com.sun.star.lang.XMultiComponentFactory;com.sun.star.lang.XMultiServiceFactory;com.sun.star.lang.XSingleComponentFactory;com.sun.star.lang.XSingleServiceFactory;com.sun.star.lang.XTypeProvider;com.sun.star.loader.Java;com.sun.star.loader.SharedLibrary;com.sun.star.reflection.ProxyFactory;com.sun.star.registry.ImplementationRegistration;com.sun.star.registry.SimpleRegistry;com.sun.star.registry.XRegistryKey;com.sun.star.script.Converter;com.sun.star.script.Invocation;com.sun.star.security.AccessController;com.sun.star.security.Policy;com.sun.star.uno.DeploymentException;com.sun.star.uno.Exception;com.sun.star.uno.NamingService;com.sun.star.uno.RuntimeException;com.sun.star.uno.XAggregation;com.sun.star.uno.XComponentContext;com.sun.star.uno.XCurrentContext;com.sun.star.uno.XInterface;com.sun.star.uno.XWeak;com.sun.star.uri.ExternalUriReferenceTranslator;com.sun.star.uri.UriReferenceFactory;com.sun.star.uri.VndSunStarPkgUrlReferenceFactory;com.sun.star.util.theMacroExpander' \ + $(URE_HOME)/program/types.rdb + touch $@ + +out.pln/types.cppumaker.flag: out.pln/types.rdb | out.pln + LD_LIBRARY_PATH=$(URE_HOME)/program $(SDK_HOME)/bin/cppumaker \ + -O./out.pln/include/types ./$< -X$(URE_HOME)/program/types.rdb + touch $@ + + +out.pln/javamain.uno.jar: \ + out.pln/class/javamain/test/java/javamain/JavaMain.class \ + out.pln/javamain.mf | out.pln + jar cfm $@ out.pln/javamain.mf -C out.pln/class/javamain test + +out.pln/javamain.mf: javamain.mf.template | out.pln + sed -e 's~^Class-Path:$$~& tester.jar~' \ + -e 's~^UNO-Type-Path:$$~& types.jar~' $< > $@ + +out.pln/class/javamain/test/java/javamain/JavaMain.class: JavaMain.java \ + out.pln/tester.jar | out.pln/class + rm -rf out.pln/class/javamain + mkdir out.pln/class/javamain + javac -classpath \ + $(URE_HOME)/program/classes/libreoffice.jar:out.pln/tester.jar \ + -sourcepath . -d out.pln/class/javamain $< + + +out.pln/runner.jar: out.pln/class/runner/test/java/runner/Runner.class \ + out.pln/runner.mf | out.pln + jar cfm $@ out.pln/runner.mf -C out.pln/class/runner test + +out.pln/runner.mf: runner.mf.template | out.pln + sed -e \ + 's~^Class-Path:$$~& file://$(URE_HOME)/program/classes/unoloader.jar~' \ + -e 's~^UNO-Type-Path:$$~& ~' $< > $@ + +out.pln/class/runner/test/java/runner/Runner.class: Runner.java | out.pln/class + rm -rf out.pln/class/runner + mkdir out.pln/class/runner + javac -classpath $(URE_HOME)/program/classes/unoloader.jar \ + -sourcepath . -d out.pln/class/runner $< + + +out.pln/tester.jar: out.pln/class/tester/test/java/tester/Tester.class \ + out.pln/tester.mf | out.pln + jar cfm $@ out.pln/tester.mf -C out.pln/class/tester test + +out.pln/tester.mf: tester.mf.template | out.pln + sed -e 's~^Class-Path:$$~& types.jar~' \ + -e 's~^UNO-Type-Path:$$~& types.jar~' $< > $@ + +out.pln/class/tester/test/java/tester/Tester.class: Tester.java \ + out.pln/types.jar | out.pln/class + rm -rf out.pln/class/tester + mkdir out.pln/class/tester + javac -classpath \ + $(URE_HOME)/program/classes/libreoffice.jar:out.pln/types.jar \ + -sourcepath . -d out.pln/class/tester $< + + +out.pln/javatest.uno.jar: \ + out.pln/class/javatest/test/java/javatest/JavaTest.class \ + out.pln/javatest.mf | out.pln + jar cfm $@ out.pln/javatest.mf -C out.pln/class/javatest test + +out.pln/javatest.mf: javatest.mf.template | out.pln + sed -e 's~^Class-Path:$$~& types.jar~' \ + -e 's~^UNO-Type-Path:$$~& types.jar~' $< > $@ + +out.pln/class/javatest/test/java/javatest/JavaTest.class: JavaTest.java \ + out.pln/types.jar | out.pln/class + rm -rf out.pln/class/javatest + mkdir out.pln/class/javatest + javac -classpath \ + $(URE_HOME)/program/classes/libreoffice.jar:out.pln/types.jar \ + -sourcepath . -d out.pln/class/javatest $< + + +out.pln/javanative.jar: \ + out.pln/class/javanative/test/java/javanative/JavaNative.class \ + out.pln/javanative.mf | out.pln + jar cfm $@ out.pln/javanative.mf -C out.pln/class/javanative test + +out.pln/javanative.mf: javanative.mf.template | out.pln + sed -e 's~^Class-Path:$$~& tester.jar~' \ + -e 's~^UNO-Type-Path:$$~& types.jar~' $< > $@ + +out.pln/class/javanative/test/java/javanative/JavaNative.class: \ + JavaNative.java out.pln/tester.jar | out.pln/class + rm -rf out.pln/class/javanative + mkdir out.pln/class/javanative + javac -classpath \ + $(URE_HOME)/program/classes/libreoffice.jar:out.pln/tester.jar \ + -sourcepath . -d out.pln/class/javanative $< + + +out.pln/javaclient.jar: \ + out.pln/class/javaclient/test/java/javaclient/JavaClient.class \ + out.pln/javaclient.mf | out.pln + jar cfm $@ out.pln/javaclient.mf -C out.pln/class/javaclient test + +out.pln/javaclient.mf: javaclient.mf.template | out.pln + sed -e 's~^Class-Path:$$~& types.jar~' \ + -e 's~^UNO-Type-Path:$$~& types.jar~' $< > $@ + +out.pln/class/javaclient/test/java/javaclient/JavaClient.class: \ + JavaClient.java out.pln/types.jar | out.pln/class + rm -rf out.pln/class/javaclient + mkdir out.pln/class/javaclient + javac -classpath \ + $(URE_HOME)/program/classes/libreoffice.jar:out.pln/types.jar \ + -sourcepath . -d out.pln/class/javaclient $< + + +out.pln/types.jar: out.pln/types.javamaker.flag out.pln/types.mf | out.pln + jar cfm $@ out.pln/types.mf -C out.pln/class/types test + +out.pln/types.mf: types.mf.template | out.pln + sed -e 's~^Class-Path:$$~& ~' -e 's~^UNO-Type-Path:$$~& \<\>~' $< > $@ + +out.pln/types.javamaker.flag: out.pln/types.rdb | out.pln out.pln/class + rm -rf out.pln/class/types + LD_LIBRARY_PATH=$(URE_HOME)/program $(SDK_HOME)/bin/javamaker \ + -O./out.pln/class/types ./$< -X$(URE_HOME)/program/types.rdb + touch $@ + + +out.pln/types.rdb: types.idl | out.pln + LD_LIBRARY_PATH=$(URE_HOME)/program $(SDK_HOME)/bin/unoidl-write \ + $(URE_HOME)/program/types.rdb $< $@ + + +out.pln/services.rdb: services.rdb.in | out.pln/cpptest.uno.so \ + out.pln/javatest.uno.jar out.pln + sed -e s/@SHAREDLIB_EXT@/so/ < $^ > $@ + + +out.pln/lib/libuno_cppu.so: | out.pln/lib + ln -fs $(URE_HOME)/program/libuno_cppu.so.3 $@ + +out.pln/lib/libuno_cppuhelpergcc3.so: | out.pln/lib + ln -fs $(URE_HOME)/program/libuno_cppuhelpergcc3.so.3 $@ + +out.pln/lib/libuno_sal.so: | out.pln/lib + ln -fs $(URE_HOME)/program/libuno_sal.so.3 $@ + +out.pln/lib/libuno_salhelpergcc3.so: | out.pln/lib + ln -fs $(URE_HOME)/program/libuno_salhelpergcc3.so.3 $@ + + +out.pln: + mkdir $@ + +out.pln/class: | out.pln + mkdir $@ + +out.pln/lib: | out.pln + mkdir $@ diff --git a/ure/source/uretest/README b/ure/source/uretest/README new file mode 100644 index 0000000000..c4ef983327 --- /dev/null +++ b/ure/source/uretest/README @@ -0,0 +1,101 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +This directory contains test files for the UNO Runtime Environment (URE) as well +as the Makefile and Makefile.pln makefiles. To execute the makefiles, you need +GNU make 3.80 or later. + + +Makefile +-------- + +Before you execute Makefile, you need to configure the Software Development Kit +(SDK) environment to work with a URE installation, a C++ compiler, and a JDK. +For more information, read the .../docs/install.html file in the SDK +installation. + +NOTE: On Linux x86, if the Makefile accesses a GCC that is incompatible with the +GCC that was used to build the URE, use the GCCS_COMPAT environment variable as +a workaround. For more details, see the UDK README file. + + +Makefile.pln +------------ + +You can only run Makefile.pln on Linux x86. You do not need to configure your +SDK environment to use this makefile, however, you do need to set the following +environment variables: + +- SDK_HOME +Points to the base directory of an OpenOffice.org SDK so that you can access UNO +programming tools and files that are not part of the URE. For example, unoidl-write, +cppumaker, javamaker, and C++ headers. + +- PATH +Points to a GCC installation (including g++) as well as a JDK installation that +contains the java, javac, and jar executables. For the minimum version +requirements, see the SDK Installation Guide ($SDK_HOME/docs/install.html). + +- URE_HOME (optional) +Overwrites the default URE location, that is, /opt/libreoffice. + +- GCCS_COMPAT (optional) +Fixes incompatibility issues between the GCC that was used to build the URE and +the GCC that Makefile.pln accesses. For more details, see the UDK README file. + + +Tests +----- + +Makefile and Makefile.pln can execute the following tests: + +- test-cpptest +Builds a C++ UNO component, cppmain.uno, and runs the component with the uno +executable. The component first attempts to instantiate all the UNO services +and singletons that are part of the URE installation. The component then tries +to instantiate and to call another C++ UNO component (cpptest.uno) as well as a +Java UNO component (javatest.uno). The test completes when these components +throw a special exception that is caught by cppmain.uno. + +- test-javatest +Builds a Java UNO component, javamain.uno, and runs the component with the uno +executable. The component tries to instantiate and to call a C++ UNO component +(cpptest.uno) as well as a Java UNO component (javatest.uno). The test +completes when these components throw a special exception that is caught by +javamain.uno. + +- test-javanative +Builds a Java UNO application, javanative.jar, and runs the application with the +java executable. The application bootstraps a native UNO environment, and then +tries to instantiate and to call a C++ UNO component (cpptest.uno) as well as a +Java UNO component( javatest.uno). The test completes when these components +throw a special exception that is caught by javanative.jar. + +- test-clientserver +Builds a server C++ UNO component, cppserver.uno, and a Java UNO application, +javaclient.uno. The uno executable runs the cppserver.uno component which +listens on a pipe connection. The java executable runs the javaclient.uno +component which connects to the server after a five second pause so that the +server has enough time to start. + +- test-regview (Makefile.pln only) +Checks that the regview executable of the URE installation works reliably. + +NOTE: The files that are generated when Makefile and Makefile.pln execute are +saved to different local directories. Makefile outputs the generated files to +./out.sdk whereas Makefile.pln outputs the files to ./out.pln. diff --git a/ure/source/uretest/Runner.java b/ure/source/uretest/Runner.java new file mode 100644 index 0000000000..829ae33286 --- /dev/null +++ b/ure/source/uretest/Runner.java @@ -0,0 +1,32 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package test.java.runner; + +import java.net.URL; +import com.sun.star.lib.unoloader.UnoLoader; + +public final class Runner { + public static void main(String[] arguments) throws Exception { + String[] args = new String[arguments.length - 2]; + System.arraycopy(arguments, 2, args, 0, args.length); + UnoLoader.execute(new URL(arguments[0]), new URL(arguments[1]), args); + } + + private Runner() {} +} diff --git a/ure/source/uretest/Tester.java b/ure/source/uretest/Tester.java new file mode 100644 index 0000000000..547f89046a --- /dev/null +++ b/ure/source/uretest/Tester.java @@ -0,0 +1,46 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package test.java.tester; + +import com.sun.star.uno.XComponentContext; +import test.types.CppTest; +import test.types.JavaTest; +import test.types.TestException; +import test.types.XTest; + +public final class Tester { + public static void test(XComponentContext context) { + testService(CppTest.create(context), CppTest.class.getName()); + testService(JavaTest.create(context), JavaTest.class.getName()); + } + + private static void testService(XTest test, String name) { + boolean ok = false; + try { + test.throwException(); + } catch (TestException e) { + ok = true; + } + if (!ok) { + throw new RuntimeException(name + ".throwException failed"); + } + } + + private Tester() {} +} diff --git a/ure/source/uretest/cppmain.cc b/ure/source/uretest/cppmain.cc new file mode 100644 index 0000000000..fb957d9f22 --- /dev/null +++ b/ure/source/uretest/cppmain.cc @@ -0,0 +1,240 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "sal/config.h" +#include "sal/macros.h" + +#include <cstddef> +#include <memory> + +#include "com/sun/star/beans/Introspection.hpp" +#include "com/sun/star/beans/theIntrospection.hpp" +#include "com/sun/star/bridge/BridgeFactory.hpp" +#include "com/sun/star/bridge/UnoUrlResolver.hpp" +#include "com/sun/star/connection/Acceptor.hpp" +#include "com/sun/star/connection/Connector.hpp" +#include "com/sun/star/io/Pipe.hpp" +#include "com/sun/star/io/TextInputStream.hpp" +#include "com/sun/star/io/TextOutputStream.hpp" +#include "com/sun/star/java/JavaVirtualMachine.hpp" +#include "com/sun/star/lang/XMain.hpp" +#include "com/sun/star/loader/Java.hpp" +#include "com/sun/star/loader/SharedLibrary.hpp" +#include "com/sun/star/reflection/ProxyFactory.hpp" +#include "com/sun/star/registry/ImplementationRegistration.hpp" +#include "com/sun/star/registry/SimpleRegistry.hpp" +#include "com/sun/star/script/Converter.hpp" +#include "com/sun/star/script/Invocation.hpp" +#include "com/sun/star/security/AccessController.hpp" +#include "com/sun/star/security/Policy.hpp" +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/NamingService.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "com/sun/star/uri/ExternalUriReferenceTranslator.hpp" +#include "com/sun/star/uri/UriReferenceFactory.hpp" +#include "com/sun/star/uri/VndSunStarPkgUrlReferenceFactory.hpp" +#include "com/sun/star/util/theMacroExpander.hpp" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/implementationentry.hxx" +#include "cppuhelper/interfacecontainer.hxx" +#include "cppuhelper/unourl.hxx" +#include "cppuhelper/weak.hxx" +#include "osl/thread.h" +#include "rtl/malformeduriexception.hxx" +#include "rtl/string.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "salhelper/simplereferenceobject.hxx" +#include "uno/current_context.hxx" +#include "uno/environment.h" + +#include "test/types/CppTest.hpp" +#include "test/types/JavaTest.hpp" +#include "test/types/TestException.hpp" +#include "test/types/XTest.hpp" + +namespace { + +class Service: public ::cppu::WeakImplHelper1< css::lang::XMain > { +public: + explicit Service( + css::uno::Reference< css::uno::XComponentContext > const & context): + context_(context) {} + + virtual ::sal_Int32 SAL_CALL run( + css::uno::Sequence< ::rtl::OUString > const &); + +private: + Service(Service &); // not defined + void operator =(Service &); // not defined + + virtual ~Service() {} + + void test( + css::uno::Reference< test::types::XTest > const & test, + ::rtl::OUString const & name); + + css::uno::Reference< css::uno::XComponentContext > context_; +}; + +::sal_Int32 Service::run(css::uno::Sequence< ::rtl::OUString > const &) { + osl_getThreadIdentifier(0); // check for sal + (new salhelper::SimpleReferenceObject)->release(); // check for salhelper + css::uno::getCurrentContext(); // check for cppu + try { // check for cppuhelper + std::auto_ptr< cppu::UnoUrl > dummy(new cppu::UnoUrl(rtl::OUString())); + } catch (rtl::MalformedUriException &) {} + static char const * const services[] = { + "com.sun.star.io.DataInputStream", + "com.sun.star.io.DataOutputStream", + "com.sun.star.io.MarkableInputStream", + "com.sun.star.io.MarkableOutputStream", + "com.sun.star.io.ObjectInputStream", + "com.sun.star.io.ObjectOutputStream", + "com.sun.star.io.Pump", + "com.sun.star.lang.RegistryServiceManager", + "com.sun.star.lang.ServiceManager", + "com.sun.star.reflection.CoreReflection", + "com.sun.star.registry.NestedRegistry", + "com.sun.star.script.InvocationAdapterFactory", + "com.sun.star.uri.UriSchemeParser_vndDOTsunDOTstarDOTscript" + }; + for (::std::size_t i = 0; i < SAL_N_ELEMENTS(services); ++i) { + ::rtl::OUString name(::rtl::OUString::createFromAscii(services[i])); + css::uno::Reference< css::uno::XInterface > instance; + try { + instance = context_->getServiceManager()->createInstanceWithContext( + name, context_); + } catch (css::uno::RuntimeException &) { + throw; + } catch (css::uno::Exception &) { + throw css::uno::RuntimeException( + ::rtl::OUString("error creating instance"), + static_cast< ::cppu::OWeakObject * >(this)); + } + if (!instance.is()) { + throw css::uno::RuntimeException( + "no instance: " + name, + static_cast< ::cppu::OWeakObject * >(this)); + } + } + css::beans::Introspection::create(context_); + css::beans::theIntrospection::get(context_); + css::bridge::BridgeFactory::create(context_); + css::bridge::UnoUrlResolver::create(context_); + css::connection::Acceptor::create(context_); + css::connection::Connector::create(context_); + css::io::Pipe::create(context_); + css::io::TextInputStream::create(context_); + css::io::TextOutputStream::create(context_); + css::java::JavaVirtualMachine::create(context_); + css::loader::Java::create(context_); + css::loader::SharedLibrary::create(context_); + css::reflection::ProxyFactory::create(context_); + css::registry::ImplementationRegistration::create(context_); + css::registry::SimpleRegistry::create(context_); + css::script::Converter::create(context_); + css::script::Invocation::create(context_); + css::security::AccessController::create(context_); + css::security::Policy::create(context_); + css::uno::NamingService::create(context_); + css::uri::ExternalUriReferenceTranslator::create(context_); + css::uri::UriReferenceFactory::create(context_); + css::uri::VndSunStarPkgUrlReferenceFactory::create(context_); + static char const * const singletons[] = { + "com.sun.star.reflection.theTypeDescriptionManager" + }; + for (std::size_t i = 0; i != SAL_N_ELEMENTS(singletons); ++i) { + css::uno::Reference< css::uno::XInterface > instance( + context_->getValueByName( + "/singletons/" + rtl::OUString::createFromAscii(singletons[i])), + css::uno::UNO_QUERY_THROW); + } + css::util::theMacroExpander::get(context_); + test( + ::test::types::CppTest::create(context_), + ::rtl::OUString("test.types.CppTest")); + test( + ::test::types::JavaTest::create(context_), + ::rtl::OUString("test.types.JavaTest")); + return 0; +} + +void Service::test( + css::uno::Reference< test::types::XTest > const & test, + ::rtl::OUString const & name) +{ + bool ok = false; + try { + test->throwException(); + } catch (::test::types::TestException &) { + ok = true; + } + if (!ok) { + throw css::uno::RuntimeException( + (name + + ::rtl::OUString(".throwException failed")), + static_cast< ::cppu::OWeakObject * >(this)); + } +} + +namespace CppMain { + +css::uno::Reference< css::uno::XInterface > create( + css::uno::Reference< css::uno::XComponentContext > const & context) +{ + return static_cast< ::cppu::OWeakObject * >(new Service(context)); +} + +rtl::OUString getImplementationName() { + return rtl::OUString("test.cpp.cppmain.Component"); +} + +css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames() { + return css::uno::Sequence< ::rtl::OUString >(); +} + +} + +::cppu::ImplementationEntry entries[] = { + { CppMain::create, CppMain::getImplementationName, + CppMain::getSupportedServiceNames, ::cppu::createSingleComponentFactory, + 0, 0 }, + { 0, 0, 0, 0, 0, 0 } }; + +} + +extern "C" SAL_DLLPUBLIC_EXPORT ::sal_Bool SAL_CALL component_writeInfo( + void * serviceManager, void * registryKey) +{ + return ::cppu::component_writeInfoHelper( + serviceManager, registryKey, entries); +} + +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + char const * implName, void * serviceManager, void * registryKey) +{ + return ::cppu::component_getFactoryHelper( + implName, serviceManager, registryKey, entries); +} diff --git a/ure/source/uretest/cppserver.cc b/ure/source/uretest/cppserver.cc new file mode 100644 index 0000000000..db42c9fb3f --- /dev/null +++ b/ure/source/uretest/cppserver.cc @@ -0,0 +1,93 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "sal/config.h" + +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/implementationentry.hxx" +#include "cppuhelper/weak.hxx" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "uno/environment.h" + +#include "test/types/Data.hpp" +#include "test/types/XServer.hpp" + +namespace { + +class Service: public ::cppu::WeakImplHelper1< ::test::types::XServer > { +public: + Service() {} + + virtual ::test::types::Data SAL_CALL getData() { + return ::test::types::Data(rtl::OUString("Hello"), 42); + } + +private: + Service(Service &); // not defined + void operator =(Service &); // not defined + + virtual ~Service() {} +}; + +namespace CppServer { + +css::uno::Reference< css::uno::XInterface > create( + css::uno::Reference< css::uno::XComponentContext > const &) +{ + return static_cast< ::cppu::OWeakObject * >(new Service); +} + +rtl::OUString getImplementationName() { + return rtl::OUString("test.cpp.cppserver.Component"); +} + +css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { + return css::uno::Sequence< rtl::OUString >(); +} + +} + +::cppu::ImplementationEntry entries[] = { + { CppServer::create, CppServer::getImplementationName, + CppServer::getSupportedServiceNames, ::cppu::createSingleComponentFactory, + 0, 0 }, + { 0, 0, 0, 0, 0, 0 } }; + +} + +extern "C" SAL_DLLPUBLIC_EXPORT ::sal_Bool SAL_CALL component_writeInfo( + void * serviceManager, void * registryKey) +{ + return ::cppu::component_writeInfoHelper( + serviceManager, registryKey, entries); +} + +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + char const * implName, void * serviceManager, void * registryKey) +{ + return ::cppu::component_getFactoryHelper( + implName, serviceManager, registryKey, entries); +} diff --git a/ure/source/uretest/cpptest.cc b/ure/source/uretest/cpptest.cc new file mode 100644 index 0000000000..b037fdceeb --- /dev/null +++ b/ure/source/uretest/cpptest.cc @@ -0,0 +1,89 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "sal/config.h" + +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/implementationentry.hxx" +#include "cppuhelper/weak.hxx" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "uno/environment.h" + +#include "test/types/TestException.hpp" +#include "test/types/XTest.hpp" + +namespace { + +class Service: public cppu::WeakImplHelper1< test::types::XTest > { +public: + Service() {} + + virtual void SAL_CALL throwException() { + throw test::types::TestException( + rtl::OUString("test"), + static_cast< cppu::OWeakObject * >(this)); + } + +private: + Service(Service &); // not defined + void operator =(Service &); // not defined + + virtual ~Service() {} +}; + +namespace CppTest { + +css::uno::Reference< css::uno::XInterface > create( + css::uno::Reference< css::uno::XComponentContext > const &) +{ + return static_cast< cppu::OWeakObject * >(new Service); +} + +rtl::OUString getImplementationName() { + return rtl::OUString("test.cpp.cpptest.Component"); +} + +css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { + rtl::OUString s("test.types.CppTest"); + return css::uno::Sequence< rtl::OUString >(&s, 1); +} + +} + +cppu::ImplementationEntry entries[] = { + { CppTest::create, CppTest::getImplementationName, + CppTest::getSupportedServiceNames, cppu::createSingleComponentFactory, 0, + 0 }, + { 0, 0, 0, 0, 0, 0 } }; + +} + +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + char const * implName, void * serviceManager, void * registryKey) +{ + return cppu::component_getFactoryHelper( + implName, serviceManager, registryKey, entries); +} diff --git a/ure/source/uretest/javaclient.mf.template b/ure/source/uretest/javaclient.mf.template new file mode 100644 index 0000000000..745d23afbc --- /dev/null +++ b/ure/source/uretest/javaclient.mf.template @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Class-Path: +Main-Class: test/java/javaclient/JavaClient +Sealed: true +UNO-Type-Path: diff --git a/ure/source/uretest/javamain.mf.template b/ure/source/uretest/javamain.mf.template new file mode 100644 index 0000000000..8ef4aa210c --- /dev/null +++ b/ure/source/uretest/javamain.mf.template @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Class-Path: +Sealed: true +UNO-Type-Path: +RegistrationClassName: test.java.javamain.JavaMain diff --git a/ure/source/uretest/javanative.mf.template b/ure/source/uretest/javanative.mf.template new file mode 100644 index 0000000000..bb1103e025 --- /dev/null +++ b/ure/source/uretest/javanative.mf.template @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Class-Path: +Main-Class: test/java/javanative/JavaNative +Sealed: true +UNO-Type-Path: diff --git a/ure/source/uretest/javatest.mf.template b/ure/source/uretest/javatest.mf.template new file mode 100644 index 0000000000..8fc858aece --- /dev/null +++ b/ure/source/uretest/javatest.mf.template @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Class-Path: +Sealed: true +UNO-Type-Path: +RegistrationClassName: test.java.javatest.JavaTest diff --git a/ure/source/uretest/runner.mf.template b/ure/source/uretest/runner.mf.template new file mode 100644 index 0000000000..dc9c266135 --- /dev/null +++ b/ure/source/uretest/runner.mf.template @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Class-Path: +Main-Class: test/java/runner/Runner +Sealed: true +UNO-Type-Path: diff --git a/ure/source/uretest/services.rdb.in b/ure/source/uretest/services.rdb.in new file mode 100644 index 0000000000..0bec749e8e --- /dev/null +++ b/ure/source/uretest/services.rdb.in @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * +--> + +<components xmlns="http://openoffice.org/2010/uno-components"> + <component + loader="com.sun.star.loader.SharedLibrary" + uri="./cpptest.uno.@SHAREDLIB_EXT@"> + <implementation name="test.cpp.cpptest.Component"> + <service name="test.types.CppTest"/> + </implementation> + </component> + <component loader="com.sun.star.loader.Java2" uri="./javatest.uno.jar"> + <implementation name="test.java.javatest.Component"> + <service name="test.types.JavaTest"/> + </implementation> + </component> +</components> diff --git a/ure/source/uretest/tester.mf.template b/ure/source/uretest/tester.mf.template new file mode 100644 index 0000000000..fc483bc7da --- /dev/null +++ b/ure/source/uretest/tester.mf.template @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Class-Path: +Main-Class: test/java/tester/Tester +Sealed: true +UNO-Type-Path: diff --git a/ure/source/uretest/types.idl b/ure/source/uretest/types.idl new file mode 100644 index 0000000000..97d580d4c9 --- /dev/null +++ b/ure/source/uretest/types.idl @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +module test { module types { + +exception TestException: com::sun::star::uno::Exception {}; + +interface XTest { + void throwException() raises (TestException); +}; + +service CppTest: XTest; + +service JavaTest: XTest; + +struct Data { + string m1; + long m2; +}; + +interface XServer { + Data getData(); +}; + +}; }; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ure/source/uretest/types.mf.template b/ure/source/uretest/types.mf.template new file mode 100644 index 0000000000..c8fcee4b16 --- /dev/null +++ b/ure/source/uretest/types.mf.template @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Class-Path: +Sealed: true +UNO-Type-Path: |