Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / runner / lib / TestEnvironment.java
blob9848a5b2b633a81efed220cb7e33c9759ee393a2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 package lib;
29 import com.sun.star.uno.XInterface;
31 import java.util.Hashtable;
34 /**
35 * The class contains an instance of a given implementation object and
36 * auxiliary objects associated with it and required for the object testing.
38 * @see TestCase
41 public final class TestEnvironment {
42 /**
43 * Contains object relations - auxiliary objects associated with the
44 * tested object and required for testing.
46 private final Hashtable relations = new Hashtable(10);
48 /**
49 * An instance of the tested implementation object.
51 private final XInterface testObject;
53 /**
54 * Indicates that the testObject is in invalid state and should notbe
55 * used for testing anymore.
57 private boolean disposed = false;
59 /**
60 * A reference to TestCase which has created the test environment.
62 private TestCase tCase;
64 /**
65 * Creates an instance of test environment with testObject.
67 * @param testObject object to test
69 * @throws java.lang.IllegalArgumentException if the testObject is
70 * <tt>null</tt>.
72 public TestEnvironment( XInterface testObject ) {
73 if (testObject == null) {
74 throw new IllegalArgumentException(
75 "Couldn't create a test object");
77 this.testObject = testObject;
80 /**
81 * @return the object to test.
83 public XInterface getTestObject() {
84 return testObject;
87 /**
88 * Adds to the environment an auxiliary object required for testing.
90 * @param name a name to reference the auxiliary object
92 * @param relation the auxiliary object related to the tested one
94 public void addObjRelation( String name, Object relation) {
95 relations.put( name, relation );
98 /**
99 * Returns an auxiliary object referenced by tname.
101 * @param name a name of the object relation
103 * @return the auxiliary object(object relation)
105 public Object getObjRelation( String name ) {
106 return relations.get( name );
110 * Checks if an auxiliary object has been registered with name
112 * @param name a name referencing an auxiliarx object
114 * @return <tt>true</tt> if the object has been associated, <tt>false</tt>
115 * otherwise.
117 public boolean hasObjRelation(String name) {
118 return (relations.get(name) != null) ;
122 * Sets the <code>TestCase</code> that created the environment.
124 public void setTestCase( TestCase tCase) {
125 this.tCase = tCase;
129 * @return the <code>TestCase</code> created the environment.
131 public TestCase getTestCase() {
132 return tCase;
136 * Makes the environment invalid, i.e. it should not be used for
137 * testing anymore.
139 public void dispose() {
140 disposed = true;
144 * Checks if the environment has been disposed.
146 * @return <tt>true</tt< if it has been disposed, <tt>false</tt> otherwise.
148 * @see #dispose()
150 public boolean isDisposed() {
151 return disposed;