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: _XComponentLoader.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 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.beans
.PropertyState
;
36 import com
.sun
.star
.beans
.PropertyValue
;
37 import com
.sun
.star
.frame
.XComponentLoader
;
38 import com
.sun
.star
.lang
.XComponent
;
42 * Testing <code>com.sun.star.frame.XComponentLoader</code>
45 * <li><code> loadComponentFromURL() </code></li>
47 * Test is <b> NOT </b> multithread compilant. <p>
48 * @see com.sun.star.frame.XComponentLoader
50 public class _XComponentLoader
extends MultiMethodTest
{
51 public XComponentLoader oObj
= null; // oObj filled by MultiMethodTest
54 * Method which tests the objects ability to load a
55 * component from URL. All available components are loaded by turns. <p>
56 * Has <b> OK </b> status if the method successfully returns
57 * and no exceptions were thrown. <p>
60 public void _loadComponentFromURL() {
61 boolean result
= true;
63 log
.println("testing loadComponentFromURL() ... ");
65 PropertyValue
[] szEmptyArgs
= new PropertyValue
[0];
66 String frameName
= "_blank";
67 XComponent oDoc
= null;
69 log
.println("load writer doc that contains links");
70 PropertyValue
[] szArgs
= new PropertyValue
[1];
71 PropertyValue Arg
= new PropertyValue();
72 Arg
.Name
= "UpdateDocMode";
73 Arg
.Value
= new Short(com
.sun
.star
.document
.UpdateDocMode
.NO_UPDATE
);
75 String url
= util
.utils
.getFullTestURL("Writer_link.sxw");
76 log
.println("try to load '" + url
+ "'");
77 oDoc
= oObj
.loadComponentFromURL(
78 url
, frameName
, 0, szArgs
);
83 catch (InterruptedException ex
) {
88 url
= util
.utils
.getFullTestURL("Calc_Link.sxc");
89 log
.println("try to load '" + url
+ "'");
90 oDoc
= oObj
.loadComponentFromURL(
91 url
, frameName
, 0, szArgs
);
96 catch (InterruptedException ex
) {
103 log
.println("load a blank impress doc");
104 Arg
.Name
= "OpenFlags";
107 Arg
.State
= PropertyState
.DEFAULT_VALUE
;
109 oDoc
= oObj
.loadComponentFromURL(
110 "private:factory/simpress", frameName
, 0, szArgs
);
112 log
.println("disposing impress doc");
115 log
.println("load a blank writer doc");
116 oDoc
= oObj
.loadComponentFromURL(
117 "private:factory/swriter", frameName
, 0, szEmptyArgs
);
119 log
.println("disposing writer doc");
122 log
.println("load a blank calc doc");
123 oDoc
= oObj
.loadComponentFromURL(
124 "private:factory/scalc", frameName
, 0, szEmptyArgs
);
126 log
.println("disposing calc doc");
129 log
.println("load a blank draw doc");
130 oDoc
= oObj
.loadComponentFromURL(
131 "private:factory/sdraw", frameName
, 0, szEmptyArgs
);
133 log
.println("disposing draw doc");
136 log
.println("load a blank math doc");
137 oDoc
= oObj
.loadComponentFromURL(
138 "private:factory/smath", frameName
, 0, szEmptyArgs
);
140 log
.println("disposing math doc");
144 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
145 log
.println("Exception occured while loading");
146 e
.printStackTrace(log
);
149 catch (com
.sun
.star
.io
.IOException e
) {
150 log
.println("Exception occured while loading");
151 e
.printStackTrace(log
);
155 tRes
.tested("loadComponentFromURL()", result
);