merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _cfgmgr2 / LayerParser.java
blobc5b505c61a62d187d1896d4bdb79ab387b9022fc
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: LayerParser.java,v $
10 * $Revision: 1.4 $
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 mod._cfgmgr2;
33 import com.sun.star.io.XActiveDataSink;
34 import com.sun.star.io.XInputStream;
35 import com.sun.star.lang.XMultiServiceFactory;
36 import com.sun.star.ucb.XSimpleFileAccess;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.uno.XInterface;
39 import java.io.PrintWriter;
40 import lib.TestCase;
41 import lib.TestEnvironment;
42 import lib.TestParameters;
44 /**
46 * @author sw93809
48 public class LayerParser extends TestCase {
51 /** Called to create an instance of <code>TestEnvironment</code> with an
52 * object to test and related objects. Subclasses should implement this
53 * method to provide the implementation and related objects. The method is
54 * called from <code>getTestEnvironment()</code>.
56 * @param tParam test parameters
57 * @param log writer to log information while testing
59 * @see TestEnvironment
60 * @see #getTestEnvironment()
63 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
64 XInterface oObj = null;
65 Object Pipe = null;
66 XSimpleFileAccess simpleAccess = null;
67 XInputStream xStream = null;
69 try {
70 oObj = (XInterface) ((XMultiServiceFactory)tParam.getMSF())
71 .createInstance("com.sun.star.comp.configuration.backend.xml.LayerParser");
72 Object fileacc = ((XMultiServiceFactory)tParam.getMSF()).createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
73 simpleAccess = (XSimpleFileAccess)
74 UnoRuntime.queryInterface(XSimpleFileAccess.class,fileacc);
75 String filename = util.utils.getOfficeURL((XMultiServiceFactory)tParam.getMSF())+"/../share/registry/data/org/openoffice/Setup.xcu";
76 log.println("Going to parse: "+filename);
77 xStream = simpleAccess.openFileRead(filename);
78 } catch (com.sun.star.uno.Exception e) {
81 log.println("Implementation name: "+ util.utils.getImplName(oObj));
83 XActiveDataSink xSink = (XActiveDataSink) UnoRuntime.queryInterface(XActiveDataSink.class, oObj);
84 xSink.setInputStream(xStream);
85 TestEnvironment tEnv = new TestEnvironment(oObj);
87 tEnv.addObjRelation("InputStream", xStream);
89 return tEnv;