1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package testtools.servicetests; 29 30 import com.sun.star.uno.UnoRuntime; 31 import complexlib.ComplexTestCase; 32 import util.WaitUnreachable; 33 34 public abstract class TestBase extends ComplexTestCase { 35 public final String[] getTestMethodNames() { 36 return new String[] { "test" }; 37 } 38 39 public final void test() throws Exception { 40 TestServiceFactory factory = getTestServiceFactory(); 41 TestService2 t = UnoRuntime.queryInterface( 42 TestService2.class, factory.get()); 43 assure(t != null); 44 assure(UnoRuntime.queryInterface(TestService1.class, t) == t); 45 assure(UnoRuntime.queryInterface(XTestService1.class, t) == t); 46 assure(UnoRuntime.queryInterface(XTestService2.class, t) == t); 47 assure(t.fn1() == 1); 48 assure(t.getProp1() == 1); 49 t.setProp1(0); 50 assure(t.getProp1() == 0); 51 assure(t.getProp2() == 2); 52 /*try { 53 t.getProp3Void(); 54 failed(); 55 } catch (VoidPropertyException e) { 56 }*/ 57 assure(t.getProp3Long() == 3); 58 /*try { 59 t.getProp4None(); 60 failed(); 61 } catch (OptionalPropertyException e) { 62 }*/ 63 assure(t.getProp4Long() == 4); 64 /*try { 65 t.getProp5None(); 66 failed(); 67 } catch (OptionalPropertyException e) { 68 } 69 try { 70 t.getProp5Void(); 71 failed(); 72 } catch (VoidPropertyException e) { 73 }*/ 74 assure(t.getProp5Long() == 5); 75 assure(t.getProp6() == 6); 76 /*t.clearProp6(); 77 try { 78 t.getProp6(); 79 failed(); 80 } catch (VoidPropertyException e) { 81 }*/ 82 t.setProp6(0); 83 assure(t.getProp6() == 0); 84 /*try { 85 t.getProp7None(); 86 failed(); 87 } catch (OptionalPropertyException e) { 88 } 89 try { 90 t.setProp7None(0); 91 failed(); 92 } catch (OptionalPropertyException e) { 93 } 94 try { 95 t.clearProp7None(); 96 failed(); 97 } catch (OptionalPropertyException e) { 98 }*/ 99 assure(t.getProp7() == 7); 100 /*t.clearProp7(); 101 try { 102 t.getProp7(); 103 failed(); 104 } catch (VoidPropertyException e) { 105 }*/ 106 t.setProp7(0); 107 assure(t.getProp7() == 0); 108 /*try { 109 t.getProp8None(); 110 failed(); 111 } catch (OptionalPropertyException e) { 112 } 113 try { 114 t.setProp8None(0); 115 failed(); 116 } catch (OptionalPropertyException e) { 117 }*/ 118 assure(t.getProp8Long() == 8); 119 t.setProp8Long(0); 120 assure(t.getProp8Long() == 0); 121 assure(t.fn2() == 2); 122 XTestService3 t3 = UnoRuntime.queryInterface(XTestService3.class, t); 123 assure(t3 != null); 124 assure(t3.fn3() == 3); 125 XTestService4 t4 = UnoRuntime.queryInterface(XTestService4.class, t); 126 assure(t4 == null); 127 WaitUnreachable u = new WaitUnreachable(t); 128 t = null; 129 WaitUnreachable.ensureFinalization(t3); 130 t3 = null; 131 WaitUnreachable.ensureFinalization(t4); 132 t4 = null; 133 u.waitUnreachable(); 134 factory.dispose(); 135 } 136 137 protected abstract TestServiceFactory getTestServiceFactory() 138 throws Exception; 139 140 protected interface TestServiceFactory { 141 Object get() throws Exception; 142 143 void dispose() throws Exception; 144 } 145 } 146