1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 package ifc.ucb; 29 30 import lib.MultiMethodTest; 31 32 import com.sun.star.lang.XMultiServiceFactory; 33 import com.sun.star.ucb.XDataContainer; 34 35 /** 36 * Testing <code>com.sun.star.ucb.XDataContainer</code> 37 * interface methods : 38 * <ul> 39 * <li><code> getContentType()</code></li> 40 * <li><code> setContentType()</code></li> 41 * <li><code> getData()</code></li> 42 * <li><code> setData()</code></li> 43 * <li><code> getDataURL()</code></li> 44 * <li><code> setDataURL()</code></li> 45 * </ul> <p> 46 * Test is <b> NOT </b> multithread compilant. <p> 47 * @see com.sun.star.ucb.XDataContainer 48 */ 49 public class _XDataContainer extends MultiMethodTest { 50 51 public static XDataContainer oObj = null; // oObj filled by MultiMethodTest 52 private byte[] data = new byte[] {34, 35, 36} ; 53 private String dataURL = null; 54 55 /** 56 * Sets the content type to some value. <p> 57 * Has <b>OK</b> status if no runtime exseptions occured. 58 */ 59 public void _setContentType() { 60 oObj.setContentType("image/jpeg") ; 61 tRes.tested("setContentType()", true) ; 62 } 63 64 /** 65 * Check if values 'set' and 'get' are equal. <p> 66 * Has <b>OK</b> status if they are equal. <p> 67 * The following method tests are to be completed successfully before : 68 * <ul> 69 * <li> <code> setContentType() </code> </li> 70 * </ul> 71 */ 72 public void _getContentType() { 73 requiredMethod("setContentType()") ; 74 75 String type = oObj.getContentType() ; 76 tRes.tested("getContentType()", "image/jpeg".equals(type)) ; 77 } 78 79 /** 80 * Sets the data to some byte array. <p> 81 * Has <b>OK</b> status if no runtime exseptions occured. 82 */ 83 public void _setData() { 84 oObj.setData(data) ; 85 tRes.tested("setData()", true) ; 86 } 87 88 /** 89 * Check if arrays 'set' and 'get' are equal. <p> 90 * Has <b>OK</b> status if they are equal. <p> 91 * The following method tests are to be completed successfully before : 92 * <ul> 93 * <li> <code> setData() </code> </li> 94 * </ul> 95 */ 96 public void _getData() { 97 requiredMethod("setData()") ; 98 99 byte[] gData = oObj.getData() ; 100 boolean res = true ; 101 if (res = (gData != null && gData.length == data.length)) { 102 for (int i = 0; i < data.length; i++) { 103 res &= data[i] == gData[i] ; 104 } 105 } 106 107 tRes.tested("getData()", res) ; 108 } 109 110 /** 111 * Sets the data URL to some URL. <p> 112 * Has <b>OK</b> status if no runtime exseptions occured. 113 */ 114 public void _setDataURL() { 115 dataURL = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF()) ; 116 oObj.setDataURL(dataURL) ; 117 tRes.tested("setDataURL()", true) ; 118 } 119 120 /** 121 * Check if URLs 'set' and 'get' are equal. <p> 122 * Has <b>OK</b> status if they are equal. <p> 123 * The following method tests are to be completed successfully before : 124 * <ul> 125 * <li> <code> setDataURL() </code> </li> 126 * </ul> 127 */ 128 public void _getDataURL() { 129 requiredMethod("setDataURL()") ; 130 131 String gURL = oObj.getDataURL() ; 132 tRes.tested("getDataURL()", dataURL.equals(gURL)) ; 133 } 134 } 135 136 137