1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import lib
.StatusException
;
34 import com
.sun
.star
.beans
.XPropertySet
;
35 import com
.sun
.star
.document
.XStandaloneDocumentInfo
;
36 import com
.sun
.star
.io
.IOException
;
37 import com
.sun
.star
.uno
.UnoRuntime
;
40 * Testing <code>com.sun.star.document.XStandaloneDocumentInfo</code>
41 * interface methods. <p>
42 * This test needs the following object relations :
44 * <li> <code>'DOCURL'</code> (of type <code>String</code>):
45 * URL of document which info is loaded.</li>
47 * Test is <b> NOT </b> multithread compilant. <p>
48 * @see com.sun.star.document.XStandaloneDocumentInfo
50 public class _XStandaloneDocumentInfo
extends MultiMethodTest
{
52 public XStandaloneDocumentInfo oObj
= null;
55 protected void before() {
56 url
= (String
)tEnv
.getObjRelation("DOCURL");
58 throw new StatusException
59 (Status
.failed("Relation 'DOCURL' not found"));
63 String oldProp
= null;
64 String newProp
= null;
66 * Sets new value of the property 'Author' and calls the method. <p>
67 * Has <b> OK </b> status if no exception occurred.
69 public void _storeIntoURL() {
71 oObj
.loadFromURL(url
);
72 XPropertySet propSet
= (XPropertySet
)
73 UnoRuntime
.queryInterface(XPropertySet
.class, oObj
);
74 oldProp
= (String
)propSet
.getPropertyValue("Author");
75 newProp
= oldProp
+ "_";
76 propSet
.setPropertyValue("Author", newProp
);
78 oObj
.storeIntoURL(url
);
79 tRes
.tested("storeIntoURL()", true);
80 } catch (IOException e
) {
81 log
.println("Couldn't store to " + url
82 + " : " + e
.getMessage());
83 e
.printStackTrace(log
);
84 tRes
.tested("storeIntoURL()", false);
85 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
86 log
.println("Couldn't get/set property 'Author':" + e
);
87 tRes
.tested("storeIntoURL()", false);
88 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
89 log
.println("Couldn't get/set property 'Author':" + e
);
90 tRes
.tested("storeIntoURL()", false);
91 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
92 log
.println("Couldn't get/set property 'Author':" + e
);
93 tRes
.tested("storeIntoURL()", false);
94 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
95 log
.println("Couldn't get/set property 'Author':" + e
);
96 tRes
.tested("storeIntoURL()", false);
101 * Calls the method and checks value of the property 'Author'. <p>
102 * Has <b> OK </b> status if no exception occurred and value of the property
103 * 'Author' is equal to value that was set in the method
104 * <code>storeIntoURL</code>.
106 public void _loadFromURL() {
107 requiredMethod("storeIntoURL()");
109 oObj
.loadFromURL(url
);
110 XPropertySet propSet
= (XPropertySet
)
111 UnoRuntime
.queryInterface(XPropertySet
.class, oObj
);
112 String resProp
= (String
)propSet
.getPropertyValue("Author");
113 log
.println("Was: '" + oldProp
+ "',Set: '" + newProp
+
114 "', New: " + resProp
+ "'");
115 tRes
.tested("loadFromURL()", resProp
.equals(newProp
) );
116 } catch (IOException e
) {
117 log
.println("Couldn't load from " + url
118 + " : " + e
.getMessage());
119 e
.printStackTrace(log
);
120 tRes
.tested("loadFromURL()", false);
121 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
122 log
.println("Couldn't get/set property 'Author':" + e
);
123 tRes
.tested("loadFromURL()", false);
124 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
125 log
.println("Couldn't get/set property 'Author':" + e
);
126 tRes
.tested("loadFromURL()", false);
130 } // finish class _XStandaloneDocumentInfo