merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / ucb / _XDataContainer.java
blobc4111089e0cdfae5c19e2696168ee50988954fe9
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: _XDataContainer.java,v $
10 * $Revision: 1.5 $
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.ucb;
33 import lib.MultiMethodTest;
35 import com.sun.star.lang.XMultiServiceFactory;
36 import com.sun.star.ucb.XDataContainer;
38 /**
39 * Testing <code>com.sun.star.ucb.XDataContainer</code>
40 * interface methods :
41 * <ul>
42 * <li><code> getContentType()</code></li>
43 * <li><code> setContentType()</code></li>
44 * <li><code> getData()</code></li>
45 * <li><code> setData()</code></li>
46 * <li><code> getDataURL()</code></li>
47 * <li><code> setDataURL()</code></li>
48 * </ul> <p>
49 * Test is <b> NOT </b> multithread compilant. <p>
50 * @see com.sun.star.ucb.XDataContainer
52 public class _XDataContainer extends MultiMethodTest {
54 public static XDataContainer oObj = null; // oObj filled by MultiMethodTest
55 private byte[] data = new byte[] {34, 35, 36} ;
56 private String dataURL = null;
58 /**
59 * Sets the content type to some value. <p>
60 * Has <b>OK</b> status if no runtime exseptions occured.
62 public void _setContentType() {
63 oObj.setContentType("image/jpeg") ;
64 tRes.tested("setContentType()", true) ;
67 /**
68 * Check if values 'set' and 'get' are equal. <p>
69 * Has <b>OK</b> status if they are equal. <p>
70 * The following method tests are to be completed successfully before :
71 * <ul>
72 * <li> <code> setContentType() </code> </li>
73 * </ul>
75 public void _getContentType() {
76 requiredMethod("setContentType()") ;
78 String type = oObj.getContentType() ;
79 tRes.tested("getContentType()", "image/jpeg".equals(type)) ;
82 /**
83 * Sets the data to some byte array. <p>
84 * Has <b>OK</b> status if no runtime exseptions occured.
86 public void _setData() {
87 oObj.setData(data) ;
88 tRes.tested("setData()", true) ;
91 /**
92 * Check if arrays 'set' and 'get' are equal. <p>
93 * Has <b>OK</b> status if they are equal. <p>
94 * The following method tests are to be completed successfully before :
95 * <ul>
96 * <li> <code> setData() </code> </li>
97 * </ul>
99 public void _getData() {
100 requiredMethod("setData()") ;
102 byte[] gData = oObj.getData() ;
103 boolean res = true ;
104 if (res = (gData != null && gData.length == data.length)) {
105 for (int i = 0; i < data.length; i++) {
106 res &= data[i] == gData[i] ;
110 tRes.tested("getData()", res) ;
114 * Sets the data URL to some URL. <p>
115 * Has <b>OK</b> status if no runtime exseptions occured.
117 public void _setDataURL() {
118 dataURL = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF()) ;
119 oObj.setDataURL(dataURL) ;
120 tRes.tested("setDataURL()", true) ;
124 * Check if URLs 'set' and 'get' are equal. <p>
125 * Has <b>OK</b> status if they are equal. <p>
126 * The following method tests are to be completed successfully before :
127 * <ul>
128 * <li> <code> setDataURL() </code> </li>
129 * </ul>
131 public void _getDataURL() {
132 requiredMethod("setDataURL()") ;
134 String gURL = oObj.getDataURL() ;
135 tRes.tested("getDataURL()", dataURL.equals(gURL)) ;