Debian Codegraph @

framework/qa/complex/disposing/GetServiceWhileDisposingOffice.java

raw
1 /*
2 * This file is part of the LibreOffice project.
3 *
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/.
7 *
8 * This file incorporates work covered by the following license notice:
9 *
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 .
17 */
18 package complex.disposing;
19
20 import com.sun.star.lang.XMultiServiceFactory;
21 import com.sun.star.uno.UnoRuntime;
22 import com.sun.star.frame.XDesktop;
23
24 import org.junit.AfterClass;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27 import org.openoffice.test.OfficeConnection;
28
29
30 /**
31 * This test is for bug110698. The Office is closed and is continually connected
32 * while it closes. This did let the Office freeze. Now when the Office is
33 * closed, the connection is refused.
34 */
35 public class GetServiceWhileDisposingOffice
36 {
37
38 @Test public void checkServiceWhileDisposing() throws Exception
39 {
40 XMultiServiceFactory xMSF = getMSF();
41 XDesktop xDesktop = null;
42
43 xDesktop = UnoRuntime.queryInterface(XDesktop.class, xMSF.createInstance("com.sun.star.frame.Desktop"));
44 int step = 0;
45 try
46 {
47 System.out.println("Start the termination of the Office.");
48 xDesktop.terminate();
49 for (; step < 10000; step++)
50 {
51 xMSF.createInstance("com.sun.star.frame.Desktop");
52 }
53 }
54 catch (com.sun.star.lang.DisposedException e)
55 {
56 System.out.println("DisposedException in step: " + step);
57 }
58 }
59
60
61 private XMultiServiceFactory getMSF()
62 {
63 return UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
64 }
65
66 // setup and close connections
67 @BeforeClass
68 public static void setUpConnection() throws Exception
69 {
70 System.out.println("setUpConnection()");
71 connection.setUp();
72 }
73
74 @AfterClass
75 public static void tearDownConnection()
76 {
77 System.out.println("tearDownConnection()");
78 // Office is already terminated.
79 }
80 private static final OfficeConnection connection = new OfficeConnection();
81
82 }