/************************************************************************* * * 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 * * 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