Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _ucprmt / ContentProvider.java
blobeceb9d7d55581117a4662265ea44c36587134980
1 /*
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 .
19 package mod._ucprmt;
21 import java.io.PrintWriter;
23 import lib.Status;
24 import lib.StatusException;
25 import lib.TestCase;
26 import lib.TestEnvironment;
27 import lib.TestParameters;
29 import com.sun.star.lang.XMultiServiceFactory;
30 import com.sun.star.ucb.XContentIdentifierFactory;
31 import com.sun.star.uno.UnoRuntime;
32 import com.sun.star.uno.XInterface;
34 /**
35 * Test for object which is represented by service
36 * <code>com.sun.star.ucb.RemoteAccessContentProvider</code>. <p>
37 * Object implements the following interfaces :
38 * <ul>
39 * <li> <code>com::sun::star::ucb::XContentProvider</code></li>
40 * <li> <code>com::sun::star::ucb::XFileIdentifierConverter</code></li>
41 * <li> <code>com::sun::star::ucb::XContentIdentifierFactory</code></li>
42 * <li> <code>com::sun::star::ucb::XParameterizedContentProvider</code></li>
43 * </ul>
44 * This object test <b> is NOT </b> designed to be run in several
45 * threads concurently.
46 * @see com.sun.star.ucb.XContentProvider
47 * @see com.sun.star.ucb.XFileIdentifierConverter
48 * @see com.sun.star.ucb.XContentIdentifierFactory
49 * @see com.sun.star.ucb.XParameterizedContentProvider
50 * @see ifc.ucb._XContentProvider
51 * @see ifc.ucb._XFileIdentifierConverter
52 * @see ifc.ucb._XContentIdentifierFactory
53 * @see ifc.ucb._XParameterizedContentProvider
55 public class ContentProvider extends TestCase {
57 /**
58 * Creating a Testenvironment for the interfaces to be tested.
59 * Creates an instance of the service
60 * <code>com.sun.star.ucprmt.ContentProvider</code>. <p>
61 * Object relations created :
62 * <ul>
63 * <li> <code>'FACTORY'</code> for
64 * {@link ifc.ucb._XContentProvider} factory for
65 * content identifiers. Here it is
66 * <code>UniversalContentBroker</code> service.</li>
67 * <li> <code>'CONTENT1'</code> for
68 * {@link ifc.ucb._XContentProvider}: suitable
69 * content URL for this provider </li>
70 * <li> <code>'CONTENT2'</code> for
71 * {@link ifc.ucb._XContentProvider}: another suitable
72 * content URL for this provider </li>
73 * </ul>
75 @Override
76 public TestEnvironment createTestEnvironment
77 (TestParameters Param, PrintWriter log ) {
78 XInterface oObj = null;
79 XMultiServiceFactory xMSF = Param.getMSF();
80 XContentIdentifierFactory cntIDFac = null ;
82 try {
83 oObj = (XInterface) xMSF.createInstance
84 ("com.sun.star.ucb.RemoteAccessContentProvider");
85 cntIDFac = UnoRuntime.queryInterface
86 (XContentIdentifierFactory.class, oObj) ;
88 catch( com.sun.star.uno.Exception e ) {
89 log.println("Can't create an object." );
90 throw new StatusException( "Can't create an object", e );
93 if (oObj == null) {
94 log.println("!!! Object wasn't created !!!") ;
95 throw new StatusException(Status.failed
96 ("!!! Object wasn't created !!!")) ;
99 TestEnvironment tEnv = new TestEnvironment( oObj );
101 // adding relation for XContentProvider
102 tEnv.addObjRelation("FACTORY", cntIDFac) ;
103 tEnv.addObjRelation("CONTENT1","vnd.sun.star.wfs:///user/work");
104 tEnv.addObjRelation("CONTENT2","vnd.sun.star.wfs:///user/config");
106 return tEnv;
107 } // finish method getTestEnvironment