2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.lang
.XMultiServiceFactory
;
24 import com
.sun
.star
.ucb
.XDataContainer
;
27 * Testing <code>com.sun.star.ucb.XDataContainer</code>
30 * <li><code> getContentType()</code></li>
31 * <li><code> setContentType()</code></li>
32 * <li><code> getData()</code></li>
33 * <li><code> setData()</code></li>
34 * <li><code> getDataURL()</code></li>
35 * <li><code> setDataURL()</code></li>
37 * Test is <b> NOT </b> multithread compilant. <p>
38 * @see com.sun.star.ucb.XDataContainer
40 public class _XDataContainer
extends MultiMethodTest
{
42 public static XDataContainer oObj
= null; // oObj filled by MultiMethodTest
43 private byte[] data
= new byte[] {34, 35, 36} ;
44 private String dataURL
= null;
47 * Sets the content type to some value. <p>
48 * Has <b>OK</b> status if no runtime exseptions occurred.
50 public void _setContentType() {
51 oObj
.setContentType("image/jpeg") ;
52 tRes
.tested("setContentType()", true) ;
56 * Check if values 'set' and 'get' are equal. <p>
57 * Has <b>OK</b> status if they are equal. <p>
58 * The following method tests are to be completed successfully before :
60 * <li> <code> setContentType() </code> </li>
63 public void _getContentType() {
64 requiredMethod("setContentType()") ;
66 String type
= oObj
.getContentType() ;
67 tRes
.tested("getContentType()", "image/jpeg".equals(type
)) ;
71 * Sets the data to some byte array. <p>
72 * Has <b>OK</b> status if no runtime exseptions occurred.
74 public void _setData() {
76 tRes
.tested("setData()", true) ;
80 * Check if arrays 'set' and 'get' are equal. <p>
81 * Has <b>OK</b> status if they are equal. <p>
82 * The following method tests are to be completed successfully before :
84 * <li> <code> setData() </code> </li>
87 public void _getData() {
88 requiredMethod("setData()") ;
90 byte[] gData
= oObj
.getData() ;
92 if (res
= (gData
!= null && gData
.length
== data
.length
)) {
93 for (int i
= 0; i
< data
.length
; i
++) {
94 res
&= data
[i
] == gData
[i
] ;
98 tRes
.tested("getData()", res
) ;
102 * Sets the data URL to some URL. <p>
103 * Has <b>OK</b> status if no runtime exseptions occurred.
105 public void _setDataURL() {
106 dataURL
= util
.utils
.getOfficeTemp((XMultiServiceFactory
)tParam
.getMSF()) ;
107 oObj
.setDataURL(dataURL
) ;
108 tRes
.tested("setDataURL()", true) ;
112 * Check if URLs 'set' and 'get' are equal. <p>
113 * Has <b>OK</b> status if they are equal. <p>
114 * The following method tests are to be completed successfully before :
116 * <li> <code> setDataURL() </code> </li>
119 public void _getDataURL() {
120 requiredMethod("setDataURL()") ;
122 String gURL
= oObj
.getDataURL() ;
123 tRes
.tested("getDataURL()", dataURL
.equals(gURL
)) ;