01: package org.drools;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import java.util.Arrays;
20: import java.util.Collection;
21:
22: import junit.framework.TestCase;
23:
24: public abstract class DroolsTestCase extends TestCase {
25: public DroolsTestCase() {
26: super ();
27: }
28:
29: public DroolsTestCase(final String name) {
30: super (name);
31: }
32:
33: public void assertLength(final int len, final Object[] array) {
34: assertEquals(Arrays.asList(array) + " does not have length of "
35: + len, len, array.length);
36: }
37:
38: public void assertLength(final int len, final Collection collection) {
39: assertEquals(collection + " does not have length of " + len,
40: len, collection.size());
41: }
42:
43: public void assertNotContains(final Object obj, final Object[] array) {
44: try {
45: assertContains(obj, array);
46: fail(Arrays.asList(array) + " contains " + obj);
47: } catch (Throwable t) {
48: // do nothing as this is assertion is ok
49: }
50: }
51:
52: public void assertContains(final Object obj, final Object[] array) {
53: for (int i = 0; i < array.length; ++i) {
54: if (array[i] == obj) {
55: return;
56: }
57: }
58:
59: fail(Arrays.asList(array) + " does not contain " + obj);
60: }
61:
62: public void assertNotContains(final Object obj,
63: final Collection collection) {
64: try {
65: assertContains(obj, collection);
66: fail(collection + " does not contain " + obj);
67: } catch (Throwable t) {
68: // do nothing as this is assertion is ok
69: }
70: }
71:
72: public void assertContains(final Object obj,
73: final Collection collection) {
74: assertTrue(collection + " does not contain " + obj, collection
75: .contains(obj));
76: }
77:
78: }
|