Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / document / _XStandaloneDocumentInfo.java
blobe14fb15510db3ae62eae78bc1be86a0e27849442
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XStandaloneDocumentInfo.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.document;
33 import lib.MultiMethodTest;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.beans.XPropertySet;
38 import com.sun.star.document.XStandaloneDocumentInfo;
39 import com.sun.star.io.IOException;
40 import com.sun.star.uno.UnoRuntime;
42 /**
43 * Testing <code>com.sun.star.document.XStandaloneDocumentInfo</code>
44 * interface methods. <p>
45 * This test needs the following object relations :
46 * <ul>
47 * <li> <code>'DOCURL'</code> (of type <code>String</code>):
48 * URL of document which info is loaded.</li>
49 * <ul> <p>
50 * Test is <b> NOT </b> multithread compilant. <p>
51 * @see com.sun.star.document.XStandaloneDocumentInfo
53 public class _XStandaloneDocumentInfo extends MultiMethodTest {
55 public XStandaloneDocumentInfo oObj = null;
56 String url = null;
58 protected void before() {
59 url = (String)tEnv.getObjRelation("DOCURL");
60 if (url == null) {
61 throw new StatusException
62 (Status.failed("Relation 'DOCURL' not found"));
66 String oldProp = null;
67 String newProp = null;
68 /**
69 * Sets new value of the property 'Author' and calls the method. <p>
70 * Has <b> OK </b> status if no exception occured.
72 public void _storeIntoURL() {
73 try {
74 oObj.loadFromURL(url);
75 XPropertySet propSet = (XPropertySet)
76 UnoRuntime.queryInterface(XPropertySet.class, oObj);
77 oldProp = (String)propSet.getPropertyValue("Author");
78 newProp = oldProp + "_";
79 propSet.setPropertyValue("Author", newProp);
81 oObj.storeIntoURL(url);
82 tRes.tested("storeIntoURL()", true);
83 } catch (IOException e) {
84 log.println("Couldn't store to " + url
85 + " : " + e.getMessage());
86 e.printStackTrace(log);
87 tRes.tested("storeIntoURL()", false);
88 } catch(com.sun.star.lang.WrappedTargetException e) {
89 log.println("Couldn't get/set property 'Author':" + e);
90 tRes.tested("storeIntoURL()", false);
91 } catch(com.sun.star.beans.UnknownPropertyException e) {
92 log.println("Couldn't get/set property 'Author':" + e);
93 tRes.tested("storeIntoURL()", false);
94 } catch(com.sun.star.lang.IllegalArgumentException e) {
95 log.println("Couldn't get/set property 'Author':" + e);
96 tRes.tested("storeIntoURL()", false);
97 } catch(com.sun.star.beans.PropertyVetoException e) {
98 log.println("Couldn't get/set property 'Author':" + e);
99 tRes.tested("storeIntoURL()", false);
104 * Calls the method and checks value of the property 'Author'. <p>
105 * Has <b> OK </b> status if no exception occured and value of the property
106 * 'Author' is equal to value that was set in the method
107 * <code>storeIntoURL</code>.
109 public void _loadFromURL() {
110 requiredMethod("storeIntoURL()");
111 try {
112 oObj.loadFromURL(url);
113 XPropertySet propSet = (XPropertySet)
114 UnoRuntime.queryInterface(XPropertySet.class, oObj);
115 String resProp = (String)propSet.getPropertyValue("Author");
116 log.println("Was: '" + oldProp + "',Set: '" + newProp +
117 "', New: " + resProp + "'");
118 tRes.tested("loadFromURL()", resProp.equals(newProp) );
119 } catch (IOException e) {
120 log.println("Couldn't load from " + url
121 + " : " + e.getMessage());
122 e.printStackTrace(log);
123 tRes.tested("loadFromURL()", false);
124 } catch(com.sun.star.lang.WrappedTargetException e) {
125 log.println("Couldn't get/set property 'Author':" + e);
126 tRes.tested("loadFromURL()", false);
127 } catch(com.sun.star.beans.UnknownPropertyException e) {
128 log.println("Couldn't get/set property 'Author':" + e);
129 tRes.tested("loadFromURL()", false);
133 } // finish class _XStandaloneDocumentInfo