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
{
26 public final String
[] getTestMethodNames() {
27 return new String
[] { "test" };
30 public final void test() throws Exception
{
31 TestServiceFactory factory
= getTestServiceFactory();
32 TestService2 t
= UnoRuntime
.queryInterface(
33 TestService2
.class, factory
.get());
35 assure(UnoRuntime
.queryInterface(TestService1
.class, t
) == t
);
36 assure(UnoRuntime
.queryInterface(XTestService1
.class, t
) == t
);
37 assure(UnoRuntime
.queryInterface(XTestService2
.class, t
) == t
);
39 assure(t
.getProp1() == 1);
41 assure(t
.getProp1() == 0);
42 assure(t
.getProp2() == 2);
46 } catch (VoidPropertyException e) {
48 assure(t
.getProp3Long() == 3);
52 } catch (OptionalPropertyException e) {
54 assure(t
.getProp4Long() == 4);
58 } catch (OptionalPropertyException e) {
63 } catch (VoidPropertyException e) {
65 assure(t
.getProp5Long() == 5);
66 assure(t
.getProp6() == 6);
71 } catch (VoidPropertyException e) {
74 assure(t
.getProp6() == 0);
78 } catch (OptionalPropertyException e) {
83 } catch (OptionalPropertyException e) {
88 } catch (OptionalPropertyException e) {
90 assure(t
.getProp7() == 7);
95 } catch (VoidPropertyException e) {
98 assure(t
.getProp7() == 0);
102 } catch (OptionalPropertyException e) {
107 } catch (OptionalPropertyException e) {
109 assure(t
.getProp8Long() == 8);
111 assure(t
.getProp8Long() == 0);
112 assure(t
.fn2() == 2);
113 XTestService3 t3
= UnoRuntime
.queryInterface(XTestService3
.class, t
);
115 assure(t3
.fn3() == 3);
116 XTestService4 t4
= UnoRuntime
.queryInterface(XTestService4
.class, t
);
118 WaitUnreachable u
= new WaitUnreachable(t
);
120 WaitUnreachable
.ensureFinalization(t3
);
122 WaitUnreachable
.ensureFinalization(t4
);
128 protected abstract TestServiceFactory
getTestServiceFactory()
131 protected interface TestServiceFactory
{
132 Object
get() throws Exception
;
134 void dispose() throws Exception
;