Bump version to 24.04.3.4
[LibreOffice.git] / qadevOOo / runner / lib / TestEnvironment.java
blobbba50c18fc25508e935229be8ff322d5e66625f2
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 lib;
20 import com.sun.star.uno.XInterface;
22 import java.util.HashMap;
25 /**
26 * The class contains an instance of a given implementation object and
27 * auxiliary objects associated with it and required for the object testing.
29 * @see TestCase
32 public final class TestEnvironment {
33 /**
34 * Contains object relations - auxiliary objects associated with the
35 * tested object and required for testing.
37 private final HashMap<String, Object> relations = new HashMap<String, Object>(10);
39 /**
40 * An instance of the tested implementation object.
42 private final XInterface testObject;
44 /**
45 * Indicates that the testObject is in invalid state and should not be
46 * used for testing anymore.
48 private boolean disposed = false;
50 /**
51 * A reference to TestCase which has created the test environment.
53 private TestCase tCase;
55 /**
56 * Creates an instance of test environment with testObject.
58 * @param testObject object to test
60 * @throws java.lang.IllegalArgumentException if the testObject is
61 * <tt>null</tt>.
63 public TestEnvironment( XInterface testObject ) {
64 if (testObject == null) {
65 throw new IllegalArgumentException(
66 "Couldn't create a test object");
68 this.testObject = testObject;
71 /**
72 * @return the object to test.
74 public XInterface getTestObject() {
75 return testObject;
78 /**
79 * Adds to the environment an auxiliary object required for testing.
81 * @param name a name to reference the auxiliary object
83 * @param relation the auxiliary object related to the tested one
85 public void addObjRelation( String name, Object relation) {
86 relations.put( name, relation );
89 /**
90 * Returns an auxiliary object referenced by tname.
92 * @param name a name of the object relation
94 * @return the auxiliary object(object relation)
96 public Object getObjRelation( String name ) {
97 return relations.get( name );
101 * Sets the <code>TestCase</code> that created the environment.
103 public void setTestCase( TestCase tCase) {
104 this.tCase = tCase;
108 * @return the <code>TestCase</code> created the environment.
110 public TestCase getTestCase() {
111 return tCase;
115 * Makes the environment invalid, i.e. it should not be used for
116 * testing anymore.
118 public void dispose() {
119 disposed = true;
123 * Checks if the environment has been disposed.
125 * @return <tt>true</tt< if it has been disposed, <tt>false</tt> otherwise.
127 * @see #dispose()
129 public boolean isDisposed() {
130 return disposed;