1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 package testtools
.servicetests
;
30 import com
.sun
.star
.uno
.UnoRuntime
;
31 import complexlib
.ComplexTestCase
;
32 import util
.WaitUnreachable
;
34 public abstract class TestBase
extends ComplexTestCase
{
35 public final String
[] getTestMethodNames() {
36 return new String
[] { "test" };
39 public final void test() throws Exception
{
40 TestServiceFactory factory
= getTestServiceFactory();
41 TestService2 t
= UnoRuntime
.queryInterface(
42 TestService2
.class, factory
.get());
44 assure(UnoRuntime
.queryInterface(TestService1
.class, t
) == t
);
45 assure(UnoRuntime
.queryInterface(XTestService1
.class, t
) == t
);
46 assure(UnoRuntime
.queryInterface(XTestService2
.class, t
) == t
);
48 assure(t
.getProp1() == 1);
50 assure(t
.getProp1() == 0);
51 assure(t
.getProp2() == 2);
55 } catch (VoidPropertyException e) {
57 assure(t
.getProp3Long() == 3);
61 } catch (OptionalPropertyException e) {
63 assure(t
.getProp4Long() == 4);
67 } catch (OptionalPropertyException e) {
72 } catch (VoidPropertyException e) {
74 assure(t
.getProp5Long() == 5);
75 assure(t
.getProp6() == 6);
80 } catch (VoidPropertyException e) {
83 assure(t
.getProp6() == 0);
87 } catch (OptionalPropertyException e) {
92 } catch (OptionalPropertyException e) {
97 } catch (OptionalPropertyException e) {
99 assure(t
.getProp7() == 7);
104 } catch (VoidPropertyException e) {
107 assure(t
.getProp7() == 0);
111 } catch (OptionalPropertyException e) {
116 } catch (OptionalPropertyException e) {
118 assure(t
.getProp8Long() == 8);
120 assure(t
.getProp8Long() == 0);
121 assure(t
.fn2() == 2);
122 XTestService3 t3
= UnoRuntime
.queryInterface(XTestService3
.class, t
);
124 assure(t3
.fn3() == 3);
125 XTestService4 t4
= UnoRuntime
.queryInterface(XTestService4
.class, t
);
127 WaitUnreachable u
= new WaitUnreachable(t
);
129 WaitUnreachable
.ensureFinalization(t3
);
131 WaitUnreachable
.ensureFinalization(t4
);
137 protected abstract TestServiceFactory
getTestServiceFactory()
140 protected interface TestServiceFactory
{
141 Object
get() throws Exception
;
143 void dispose() throws Exception
;