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