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 .
19 package test
.java_remote
;
21 import com
.sun
.star
.bridge
.XInstanceProvider
;
22 import com
.sun
.star
.lang
.DisposedException
;
23 import com
.sun
.star
.lib
.uno
.typeinfo
.MethodTypeInfo
;
24 import com
.sun
.star
.lib
.uno
.typeinfo
.TypeInfo
;
25 import com
.sun
.star
.uno
.UnoRuntime
;
26 import com
.sun
.star
.uno
.XComponentContext
;
27 import com
.sun
.star
.uno
.XInterface
;
28 import complexlib
.ComplexTestCase
;
29 import test
.lib
.TestBed
;
32 * Test case for bug #97697#.
34 * <p>Bug #97697# "GPF in java-uno bridge in bugdoc scenario" shows that sending
35 * a plain <code>Object</code> as an <code>Any</code> over the URP bridge lead
36 * to a <code>StackOverflowError</code> on the writer thread, which was silently
37 * discarded (and the bridge was not disposed).</p>
39 * <p>This test has to detect whether the spawned client process indeed hangs,
40 * which can not be done reliably. As an approximation, it waits for 10 sec and
41 * considers the process hanging if it has not completed by then.</p>
43 public final class Bug97697_Test
extends ComplexTestCase
{
44 public String
getTestObjectName() {
45 return getClass().getName();
48 public String
[] getTestMethodNames() {
49 return new String
[] { "test" };
52 public void test() throws Exception
{
53 TestBed t
= new TestBed();
54 assure("test", t
.execute(new Provider(t
), true, Client
.class, 10000));
57 public static final class Client
extends TestBed
.Client
{
58 public static void main(String
[] args
) {
59 new Client().execute();
62 protected boolean run(XComponentContext context
) throws Throwable
{
63 XTransport transport
= UnoRuntime
.queryInterface(
64 XTransport
.class, getBridge(context
).getInstance("Transport"));
67 } catch (DisposedException e
) {
74 private static final class Provider
implements XInstanceProvider
{
75 public Provider(TestBed testBed
) {
76 this.testBed
= testBed
;
79 public Object
getInstance(String instanceName
) {
80 return new XTransport() {
81 public Object
getAny() {
82 testBed
.serverDone(true);
88 private final TestBed testBed
;
91 public interface XTransport
extends XInterface
{
94 TypeInfo
[] UNOTYPEINFO
= { new MethodTypeInfo("getAny", 0, 0) };