2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import com
.sun
.star
.uno
.UnoRuntime
;
22 import complexlib
.ComplexTestCase
;
23 import util
.WaitUnreachable
;
25 public abstract class TestBase
extends ComplexTestCase
{
27 public final String
[] getTestMethodNames() {
28 return new String
[] { "test" };
31 public final void test() throws Exception
{
32 TestServiceFactory factory
= getTestServiceFactory();
33 TestService2 t
= UnoRuntime
.queryInterface(
34 TestService2
.class, factory
.get());
36 assure(UnoRuntime
.queryInterface(TestService1
.class, t
) == t
);
37 assure(UnoRuntime
.queryInterface(XTestService1
.class, t
) == t
);
38 assure(UnoRuntime
.queryInterface(XTestService2
.class, t
) == t
);
40 assure(t
.getProp1() == 1);
42 assure(t
.getProp1() == 0);
43 assure(t
.getProp2() == 2);
44 assure(t
.getProp3Long() == 3);
45 assure(t
.getProp4Long() == 4);
46 assure(t
.getProp5Long() == 5);
47 assure(t
.getProp6() == 6);
49 assure(t
.getProp6() == 0);
50 assure(t
.getProp7() == 7);
52 assure(t
.getProp7() == 0);
53 assure(t
.getProp8Long() == 8);
55 assure(t
.getProp8Long() == 0);
57 XTestService3 t3
= UnoRuntime
.queryInterface(XTestService3
.class, t
);
59 assure(t3
.fn3() == 3);
60 XTestService4 t4
= UnoRuntime
.queryInterface(XTestService4
.class, t
);
62 WaitUnreachable u
= new WaitUnreachable(t
);
64 WaitUnreachable
.ensureFinalization(t3
);
66 WaitUnreachable
.ensureFinalization(t4
);
72 protected abstract TestServiceFactory
getTestServiceFactory()
75 protected interface TestServiceFactory
{
76 Object
get() throws Exception
;
78 void dispose() throws Exception
;