summaryrefslogtreecommitdiff
path: root/javaunohelper/test/com/sun
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/test/com/sun
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/test/com/sun')
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java86
1 files changed, 33 insertions, 53 deletions
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