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: _XDataContainer.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
.lang
.XMultiServiceFactory
;
36 import com
.sun
.star
.ucb
.XDataContainer
;
39 * Testing <code>com.sun.star.ucb.XDataContainer</code>
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>
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;
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) ;
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 :
72 * <li> <code> setContentType() </code> </li>
75 public void _getContentType() {
76 requiredMethod("setContentType()") ;
78 String type
= oObj
.getContentType() ;
79 tRes
.tested("getContentType()", "image/jpeg".equals(type
)) ;
83 * Sets the data to some byte array. <p>
84 * Has <b>OK</b> status if no runtime exseptions occured.
86 public void _setData() {
88 tRes
.tested("setData()", true) ;
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 :
96 * <li> <code> setData() </code> </li>
99 public void _getData() {
100 requiredMethod("setData()") ;
102 byte[] gData
= oObj
.getData() ;
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 :
128 * <li> <code> setDataURL() </code> </li>
131 public void _getDataURL() {
132 requiredMethod("setDataURL()") ;
134 String gURL
= oObj
.getDataURL() ;
135 tRes
.tested("getDataURL()", dataURL
.equals(gURL
)) ;