merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / runner / lib / TestEnvironment.java
blobbd97bdba3ff0580e83cff9dd063ecb25cac501cf
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: TestEnvironment.java,v $
10 * $Revision: 1.3 $
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 lib;
32 import com.sun.star.uno.XInterface;
34 import java.util.Hashtable;
37 /**
38 * The class contains an instance of a given implementation object and
39 * auxiliary objects associated with it and required for the object testing.
41 * @see TestCase
44 public class TestEnvironment {
45 /**
46 * Contains object relations - auxiliary objects associated with the
47 * tested object and required for testing.
49 protected Hashtable relations = new Hashtable(10);
51 /**
52 * An instance of the tested implementation object.
54 protected XInterface testObject;
56 /**
57 * Indicates that the testObject is in invalid state and should notbe
58 * used for testing anymore.
60 protected boolean disposed = false;
62 /**
63 * A reference to TestCase which has created the test environment.
65 private TestCase tCase;
67 /**
68 * Creates an instance of test environment with testObject.
70 * @param testObject object to test
72 * @throws java.lang.IllegalArgumentException if the testObject is
73 * <tt>null</tt>.
75 public TestEnvironment( XInterface testObject ) {
76 if (testObject == null) {
77 throw new IllegalArgumentException(
78 "Couldn't create a test object");
80 this.testObject = testObject;
83 /**
84 * @return the object to test.
86 public XInterface getTestObject() {
87 return testObject;
90 /**
91 * Adds to the environment an auxiliary object required for testing.
93 * @param name a name to reference the auxiliary object
95 * @param relation the auxiliary object related to the tested one
97 public void addObjRelation( String name, Object relation) {
98 relations.put( name, relation );
102 * Returns an auxiliary object referenced by tname.
104 * @param name a name of the object relation
106 * @return the auxiliary object(object relation)
108 public Object getObjRelation( String name ) {
109 return relations.get( name );
113 * Checks if an auxiliary object has been registered with name
115 * @param name a name referencing an auxiliarx object
117 * @return <tt>true</tt> if the object has been associated, <tt>false</tt>
118 * otherwise.
120 public boolean hasObjRelation(String name) {
121 return (relations.get(name) != null) ;
125 * Sets the <code>TestCase</code> that created the environment.
127 public void setTestCase( TestCase tCase) {
128 this.tCase = tCase;
132 * @return the <code>TestCase</code> created the environment.
134 public TestCase getTestCase() {
135 return tCase;
139 * Makes the environment invalid, i.e. it should not be used for
140 * testing anymore.
142 public void dispose() {
143 disposed = true;
147 * Checks if the environment has been disposed.
149 * @return <tt>true</tt< if it has been disposed, <tt>false</tt> otherwise.
151 * @see #dispose()
153 public boolean isDisposed() {
154 return disposed;