merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _ucprmt / ContentProvider.java
blob395bb98d471c124ddad1d52a974fbe9183a23600
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: ContentProvider.java,v $
10 * $Revision: 1.5 $
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._ucprmt;
33 import java.io.PrintWriter;
35 import lib.Status;
36 import lib.StatusException;
37 import lib.TestCase;
38 import lib.TestEnvironment;
39 import lib.TestParameters;
41 import com.sun.star.lang.XMultiServiceFactory;
42 import com.sun.star.ucb.XContentIdentifierFactory;
43 import com.sun.star.uno.UnoRuntime;
44 import com.sun.star.uno.XInterface;
46 /**
47 * Test for object which is represented by service
48 * <code>com.sun.star.ucb.RemoteAccessContentProvider</code>. <p>
49 * Object implements the following interfaces :
50 * <ul>
51 * <li> <code>com::sun::star::ucb::XContentProvider</code></li>
52 * <li> <code>com::sun::star::ucb::XFileIdentifierConverter</code></li>
53 * <li> <code>com::sun::star::ucb::XContentIdentifierFactory</code></li>
54 * <li> <code>com::sun::star::ucb::XParameterizedContentProvider</code></li>
55 * </ul>
56 * This object test <b> is NOT </b> designed to be run in several
57 * threads concurently.
58 * @see com.sun.star.ucb.XContentProvider
59 * @see com.sun.star.ucb.XFileIdentifierConverter
60 * @see com.sun.star.ucb.XContentIdentifierFactory
61 * @see com.sun.star.ucb.XParameterizedContentProvider
62 * @see ifc.ucb._XContentProvider
63 * @see ifc.ucb._XFileIdentifierConverter
64 * @see ifc.ucb._XContentIdentifierFactory
65 * @see ifc.ucb._XParameterizedContentProvider
67 public class ContentProvider extends TestCase {
69 /**
70 * Creating a Testenvironment for the interfaces to be tested.
71 * Creates an instance of the service
72 * <code>com.sun.star.ucprmt.ContentProvider</code>. <p>
73 * Object relations created :
74 * <ul>
75 * <li> <code>'FACTORY'</code> for
76 * {@link ifc.ucb._XContentProvider} factory for
77 * content identifiers. Here it is
78 * <code>UniversalContentBroker</code> service.</li>
79 * <li> <code>'CONTENT1'</code> for
80 * {@link ifc.ucb._XContentProvider}: suitable
81 * content URL for this provider </li>
82 * <li> <code>'CONTENT2'</code> for
83 * {@link ifc.ucb._XContentProvider}: another suitable
84 * content URL for this provider </li>
85 * </ul>
87 public TestEnvironment createTestEnvironment
88 (TestParameters Param, PrintWriter log ) {
89 XInterface oObj = null;
90 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
91 XContentIdentifierFactory cntIDFac = null ;
93 try {
94 oObj = (XInterface) xMSF.createInstance
95 ("com.sun.star.ucb.RemoteAccessContentProvider");
96 cntIDFac = (XContentIdentifierFactory) UnoRuntime.queryInterface
97 (XContentIdentifierFactory.class, oObj) ;
99 catch( com.sun.star.uno.Exception e ) {
100 log.println("Can't create an object." );
101 throw new StatusException( "Can't create an object", e );
104 if (oObj == null) {
105 log.println("!!! Object wasn't created !!!") ;
106 throw new StatusException(Status.failed
107 ("!!! Object wasn't created !!!")) ;
110 TestEnvironment tEnv = new TestEnvironment( oObj );
112 // adding relation for XContentProvider
113 tEnv.addObjRelation("FACTORY", cntIDFac) ;
114 tEnv.addObjRelation("CONTENT1","vnd.sun.star.wfs:///user/work");
115 tEnv.addObjRelation("CONTENT2","vnd.sun.star.wfs:///user/config");
117 return tEnv;
118 } // finish method getTestEnvironment