1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir package ifc.configuration.backend; 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir import com.sun.star.configuration.backend.XBackend; 31*cdf0e10cSrcweir import com.sun.star.configuration.backend.XLayerImporter; 32*cdf0e10cSrcweir import lib.MultiMethodTest; 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir public class _XLayerImporter extends MultiMethodTest { 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir public XLayerImporter oObj; 37*cdf0e10cSrcweir public XBackend xBackend = null; 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir public void _getTargetBackend() { 40*cdf0e10cSrcweir xBackend = oObj.getTargetBackend(); 41*cdf0e10cSrcweir tRes.tested("getTargetBackend()", xBackend != null); 42*cdf0e10cSrcweir } 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir public void _importLayer() { 45*cdf0e10cSrcweir boolean res = false; 46*cdf0e10cSrcweir log.println("checking for exception is argument null is given"); 47*cdf0e10cSrcweir try { 48*cdf0e10cSrcweir oObj.importLayer(null); 49*cdf0e10cSrcweir log.println("\tException expected -- FAILED"); 50*cdf0e10cSrcweir } catch (com.sun.star.lang.NullPointerException ne) { 51*cdf0e10cSrcweir res = true; 52*cdf0e10cSrcweir log.println("\tExpected exception was thrown -- OK"); 53*cdf0e10cSrcweir } catch (com.sun.star.configuration.backend.MalformedDataException mde) { 54*cdf0e10cSrcweir res = false; 55*cdf0e10cSrcweir log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED"); 56*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException iae) { 57*cdf0e10cSrcweir res = false; 58*cdf0e10cSrcweir log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED"); 59*cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException wte) { 60*cdf0e10cSrcweir res = false; 61*cdf0e10cSrcweir log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED"); 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir log.println("checking own implementation of XLayer"); 65*cdf0e10cSrcweir try { 66*cdf0e10cSrcweir util.XLayerImpl xLayer = new util.XLayerImpl(); 67*cdf0e10cSrcweir oObj.importLayer(xLayer); 68*cdf0e10cSrcweir if (! xLayer.hasBeenCalled()) { 69*cdf0e10cSrcweir log.println("\tXLayer hasn't been imported -- FAILED"); 70*cdf0e10cSrcweir res &= false; 71*cdf0e10cSrcweir } else { 72*cdf0e10cSrcweir log.println("\tXLayer has been imported -- OK"); 73*cdf0e10cSrcweir res &= true; 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir } catch (com.sun.star.lang.NullPointerException ne) { 76*cdf0e10cSrcweir res &= false; 77*cdf0e10cSrcweir log.println("\tExpected exception "+ne+" was thrown -- FAILED"); 78*cdf0e10cSrcweir } catch (com.sun.star.configuration.backend.MalformedDataException mde) { 79*cdf0e10cSrcweir res &= false; 80*cdf0e10cSrcweir log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED"); 81*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException iae) { 82*cdf0e10cSrcweir res &= false; 83*cdf0e10cSrcweir log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED"); 84*cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException wte) { 85*cdf0e10cSrcweir res &= false; 86*cdf0e10cSrcweir log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED"); 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir tRes.tested("importLayer()",res); 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir public void _importLayerForEntity() { 93*cdf0e10cSrcweir boolean res = false; 94*cdf0e10cSrcweir log.println("checking for exception for argument (null,\"\")"); 95*cdf0e10cSrcweir try { 96*cdf0e10cSrcweir oObj.importLayerForEntity(null,""); 97*cdf0e10cSrcweir log.println("\tException expected -- FAILED"); 98*cdf0e10cSrcweir } catch (com.sun.star.lang.NullPointerException ne) { 99*cdf0e10cSrcweir res = true; 100*cdf0e10cSrcweir log.println("\tExpected exception was thrown -- OK"); 101*cdf0e10cSrcweir } catch (com.sun.star.configuration.backend.MalformedDataException mde) { 102*cdf0e10cSrcweir res = false; 103*cdf0e10cSrcweir log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED"); 104*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException iae) { 105*cdf0e10cSrcweir res = false; 106*cdf0e10cSrcweir log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED"); 107*cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException wte) { 108*cdf0e10cSrcweir res = false; 109*cdf0e10cSrcweir log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED"); 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir log.println("checking own implementation of XLayer"); 113*cdf0e10cSrcweir try { 114*cdf0e10cSrcweir util.XLayerImpl xLayer = new util.XLayerImpl(); 115*cdf0e10cSrcweir oObj.importLayerForEntity(xLayer,""); 116*cdf0e10cSrcweir if (! xLayer.hasBeenCalled()) { 117*cdf0e10cSrcweir log.println("\tXLayer hasn't been imported -- FAILED"); 118*cdf0e10cSrcweir res &= false; 119*cdf0e10cSrcweir } else { 120*cdf0e10cSrcweir log.println("\tXLayer has been imported -- OK"); 121*cdf0e10cSrcweir res &= true; 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir } catch (com.sun.star.lang.NullPointerException ne) { 124*cdf0e10cSrcweir res &= false; 125*cdf0e10cSrcweir log.println("\tExpected exception "+ne+" was thrown -- FAILED"); 126*cdf0e10cSrcweir } catch (com.sun.star.configuration.backend.MalformedDataException mde) { 127*cdf0e10cSrcweir res &= false; 128*cdf0e10cSrcweir log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED"); 129*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException iae) { 130*cdf0e10cSrcweir res &= false; 131*cdf0e10cSrcweir log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED"); 132*cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException wte) { 133*cdf0e10cSrcweir res &= false; 134*cdf0e10cSrcweir log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED"); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir tRes.tested("importLayerForEntity()",res); 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir public void _setTargetBackend() { 141*cdf0e10cSrcweir requiredMethod("getTargetBackend()"); 142*cdf0e10cSrcweir boolean res = false; 143*cdf0e10cSrcweir log.println("checking for exception if argument null is given"); 144*cdf0e10cSrcweir try { 145*cdf0e10cSrcweir oObj.setTargetBackend(null); 146*cdf0e10cSrcweir log.println("\tException expected -- FAILED"); 147*cdf0e10cSrcweir } catch (com.sun.star.lang.NullPointerException ne) { 148*cdf0e10cSrcweir res = true; 149*cdf0e10cSrcweir log.println("\tExpected exception was thrown -- OK"); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir log.println("checking argument previously gained by getTargetBackend"); 153*cdf0e10cSrcweir try { 154*cdf0e10cSrcweir oObj.setTargetBackend(xBackend); 155*cdf0e10cSrcweir log.println("\t No Exception thrown -- OK"); 156*cdf0e10cSrcweir res &= true; 157*cdf0e10cSrcweir } catch (com.sun.star.lang.NullPointerException ne) { 158*cdf0e10cSrcweir res &= false; 159*cdf0e10cSrcweir log.println("\tException was thrown -- FAILED"); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir tRes.tested("setTargetBackend()",res); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir } 167