1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TestBase.java,v $
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());
47 assure(UnoRuntime
.queryInterface(TestService1
.class, t
) == t
);
48 assure(UnoRuntime
.queryInterface(XTestService1
.class, t
) == t
);
49 assure(UnoRuntime
.queryInterface(XTestService2
.class, t
) == t
);
51 assure(t
.getProp1() == 1);
53 assure(t
.getProp1() == 0);
54 assure(t
.getProp2() == 2);
58 } catch (VoidPropertyException e) {
60 assure(t
.getProp3Long() == 3);
64 } catch (OptionalPropertyException e) {
66 assure(t
.getProp4Long() == 4);
70 } catch (OptionalPropertyException e) {
75 } catch (VoidPropertyException e) {
77 assure(t
.getProp5Long() == 5);
78 assure(t
.getProp6() == 6);
83 } catch (VoidPropertyException e) {
86 assure(t
.getProp6() == 0);
90 } catch (OptionalPropertyException e) {
95 } catch (OptionalPropertyException e) {
100 } catch (OptionalPropertyException e) {
102 assure(t
.getProp7() == 7);
107 } catch (VoidPropertyException e) {
110 assure(t
.getProp7() == 0);
114 } catch (OptionalPropertyException e) {
119 } catch (OptionalPropertyException e) {
121 assure(t
.getProp8Long() == 8);
123 assure(t
.getProp8Long() == 0);
124 assure(t
.fn2() == 2);
125 XTestService3 t3
= UnoRuntime
.queryInterface(XTestService3
.class, t
);
127 assure(t3
.fn3() == 3);
128 XTestService4 t4
= UnoRuntime
.queryInterface(XTestService4
.class, t
);
130 WaitUnreachable u
= new WaitUnreachable(t
);
132 WaitUnreachable
.ensureFinalization(t3
);
134 WaitUnreachable
.ensureFinalization(t4
);
140 protected abstract TestServiceFactory
getTestServiceFactory()
143 protected interface TestServiceFactory
{
144 Object
get() throws Exception
;
146 void dispose() throws Exception
;