summaryrefslogtreecommitdiff
path: root/javaunohelper/test/com/sun/star/lib
diff options
context:
space:
mode:
authorJörg Budischewski <jbu@openoffice.org>2002-06-13 08:06:11 +0000
committerJörg Budischewski <jbu@openoffice.org>2002-06-13 08:06:11 +0000
commite068bbe6ff10fa85df35dcf7fd6a329dc2026986 (patch)
treef694df5215741212f32876650397e17ee6678c19 /javaunohelper/test/com/sun/star/lib
parent78ed5e2ed4e8b73a64235f1e56c3a977b4e2d841 (diff)
#99853# Joerg Brunsmann: testclass for new UnoUrl helper class
Diffstat (limited to 'javaunohelper/test/com/sun/star/lib')
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/UnoUrlTest.java234
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk7
2 files changed, 238 insertions, 3 deletions
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/UnoUrlTest.java b/javaunohelper/test/com/sun/star/lib/uno/helper/UnoUrlTest.java
new file mode 100644
index 000000000000..0a0dbc004971
--- /dev/null
+++ b/javaunohelper/test/com/sun/star/lib/uno/helper/UnoUrlTest.java
@@ -0,0 +1,234 @@
+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();
+ }
+} \ No newline at end of file
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk b/javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk
index b9edcac3fb43..7072e8704825 100644
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk
+++ b/javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: jl $ $Date: 2002-04-25 11:37:30 $
+# last change: $Author: jbu $ $Date: 2002-06-13 09:06:11 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -80,7 +80,8 @@ JAVACLASSFILES= \
$(CLASSDIR)$/$(PACKAGE)$/MultiTypeInterfaceContainer_Test.class \
$(CLASSDIR)$/$(PACKAGE)$/ProxyProvider.class \
$(CLASSDIR)$/$(PACKAGE)$/AWeakBase.class \
- $(CLASSDIR)$/$(PACKAGE)$/PropertySet_Test.class
+ $(CLASSDIR)$/$(PACKAGE)$/PropertySet_Test.class \
+ $(CLASSDIR)$/$(PACKAGE)$/UnoUrlTest.class
#JAVAFILES= $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES)))