001: /*
002: * Bossa Workflow System
003: *
004: * $Id: ResourceTest.java,v 1.7 2004/01/29 21:24:37 gdvieira Exp $
005: *
006: * Copyright (C) 2003,2004 OpenBR Sistemas S/C Ltda.
007: *
008: * This file is part of Bossa.
009: *
010: * Bossa is free software; you can redistribute it and/or modify it
011: * under the terms of version 2 of the GNU General Public License as
012: * published by the Free Software Foundation.
013: *
014: * This program is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * General Public License for more details.
018: *
019: * You should have received a copy of the GNU General Public
020: * License along with this program; if not, write to the
021: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
022: * Boston, MA 02111-1307, USA.
023: */
024:
025: package com.bigbross.bossa.resource;
026:
027: import java.util.Set;
028:
029: import junit.framework.TestCase;
030:
031: public class ResourceTest extends TestCase {
032:
033: Resource r0, r1, r2;
034:
035: public ResourceTest(String name) {
036: super (name);
037: }
038:
039: protected void setUp() {
040: r0 = new Resource(null, "r0");
041: r1 = new Resource(null, "r1");
042: r2 = new Resource(null, "r2");
043: }
044:
045: public void testGroupId() {
046: assertEquals("r0", r0.getId());
047: }
048:
049: public void testInclude() {
050: assertTrue(r0.includeImpl(r1, false));
051: assertFalse(r0.contains(r2));
052:
053: assertTrue(r1.includeImpl(r2, false));
054: assertTrue(r0.contains(r2));
055: }
056:
057: public void testIncludeCircle() {
058: assertFalse(r0.includeImpl(r0, false));
059:
060: assertTrue(r0.includeImpl(r1, false));
061: assertTrue(r1.includeImpl(r2, false));
062:
063: assertFalse(r2.includeImpl(r1, false));
064: assertFalse(r2.includeImpl(r0, false));
065: }
066:
067: public void testExclude() {
068: assertTrue(r0.includeImpl(r1, false));
069: assertTrue(r1.includeImpl(r2, false));
070: assertTrue(r0.contains(r2));
071:
072: assertTrue(r0.excludeImpl(r2, false));
073: assertFalse(r0.contains(r2));
074: }
075:
076: public void testExcludeCircle() {
077: assertFalse(r0.excludeImpl(r0, false));
078:
079: assertTrue(r0.excludeImpl(r1, false));
080: assertTrue(r1.excludeImpl(r2, false));
081:
082: assertFalse(r1.excludeImpl(r0, false));
083: assertFalse(r2.excludeImpl(r0, false));
084:
085: assertFalse(r0.contains(r2));
086: assertFalse(r2.contains(r0));
087: }
088:
089: public void testDoubleCircle() {
090: assertTrue(r0.includeImpl(r1, false));
091: assertTrue(r0.excludeImpl(r2, false));
092:
093: assertFalse(r2.includeImpl(r0, false));
094:
095: assertTrue(r0.contains(r1));
096: }
097:
098: public void testRemove() {
099: assertTrue(r0.includeImpl(r1, false));
100: assertTrue(r1.includeImpl(r2, false));
101: assertTrue(r0.contains(r2));
102:
103: assertTrue(r0.excludeImpl(r2, false));
104: assertFalse(r0.contains(r2));
105:
106: r0.removeImpl(r2, false);
107: assertTrue(r0.contains(r2));
108:
109: r0.removeImpl(r1, false);
110: assertFalse(r0.contains(r2));
111: }
112:
113: public void testLists() {
114: assertTrue(r0.includeImpl(r1, false));
115: assertTrue(r0.includeImpl(r2, false));
116: Set includes = r0.getIncludes();
117: assertEquals(2, includes.size());
118:
119: assertTrue(r0.excludeImpl(r1, false));
120: assertTrue(r0.excludeImpl(r2, false));
121: includes = r0.getIncludes();
122: Set excludes = r0.getExcludes();
123: assertEquals(0, includes.size());
124: assertEquals(2, excludes.size());
125: }
126: }
|