001: /*
002: * Copyright (c) 2001-2007, Jean Tessier
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions
007: * are met:
008: *
009: * * Redistributions of source code must retain the above copyright
010: * notice, this list of conditions and the following disclaimer.
011: *
012: * * Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: *
016: * * Neither the name of Jean Tessier nor the names of his contributors
017: * may be used to endorse or promote products derived from this software
018: * without specific prior written permission.
019: *
020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
021: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
022: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
023: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
024: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
027: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
028: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
029: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031: */
032:
033: package com.jeantessier.dependencyfinder.web;
034:
035: import com.meterware.httpunit.*;
036:
037: public abstract class TestClosureBase extends TestBase {
038: public void testDirectQuery() throws Exception {
039: request.setParameter("start-includes", "/" + barPackageName
040: + "/");
041: request.setParameter("scope", "package");
042: request.setParameter("filter", "package");
043: request.setParameter("maximum-inbound-depth", "");
044: request.setParameter("maximum-outbound-depth", "");
045: request.setParameter("submit", "Run Query");
046:
047: context.service();
048: WebResponse response = client.getResponse(request);
049:
050: assertNotNull("Missing link to " + fooPackageName, response
051: .getLinkWith(fooPackageName));
052: assertNull("Unwanted link to " + fooClassName, response
053: .getLinkWith(fooClassName));
054: assertNull("Unwanted link to " + fooFeatureName, response
055: .getLinkWith(fooFeatureName));
056: assertNotNull("Missing link to " + barPackageName, response
057: .getLinkWith(barPackageName));
058: assertNull("Unwanted link to " + barClassName, response
059: .getLinkWith(barClassName));
060: assertNull("Unwanted link to " + barFeatureName, response
061: .getLinkWith(barFeatureName));
062: assertNotNull("Missing link to " + bazPackageName, response
063: .getLinkWith(bazPackageName));
064: assertNull("Unwanted link to " + bazClassName, response
065: .getLinkWith(bazClassName));
066: assertNull("Unwanted link to " + bazFeatureName, response
067: .getLinkWith(bazFeatureName));
068: assertNull("Unwanted link to " + leftPackageName, response
069: .getLinkWith(leftPackageName));
070: assertNull("Unwanted link to " + leftClassName, response
071: .getLinkWith(leftClassName));
072: assertNull("Unwanted link to " + leftFeatureName, response
073: .getLinkWith(leftFeatureName));
074: assertNull("Unwanted link to " + rightPackageName, response
075: .getLinkWith(rightPackageName));
076: assertNull("Unwanted link to " + rightClassName, response
077: .getLinkWith(rightClassName));
078: assertNull("Unwanted link to " + rightFeatureName, response
079: .getLinkWith(rightFeatureName));
080:
081: assertNotNull("Missing link foo", response
082: .getLinkWithID(fooPackageName));
083: assertNotNull("Missing link foo --> bar",
084: response.getLinkWithID(fooPackageName + "_to_"
085: + barPackageName));
086: assertNotNull("Missing link bar", response
087: .getLinkWithID(barPackageName));
088: assertNotNull("Missing link bar <-- foo", response
089: .getLinkWithID(barPackageName + "_from_"
090: + fooPackageName));
091: assertNotNull("Missing link bar --> baz",
092: response.getLinkWithID(barPackageName + "_to_"
093: + bazPackageName));
094: assertNotNull("Missing link baz", response
095: .getLinkWithID(bazPackageName));
096: assertNotNull("Missing link baz <-- bar", response
097: .getLinkWithID(bazPackageName + "_from_"
098: + barPackageName));
099: assertNull("Unwanted link left", response
100: .getLinkWithID(leftPackageName));
101: assertNull("Unwanted link left <-> right", response
102: .getLinkWithID(leftPackageName + "_bidirectional_"
103: + rightPackageName));
104: assertNull("Unwanted link right", response
105: .getLinkWithID(rightPackageName));
106: assertNull("Unwanted link right <-> left", response
107: .getLinkWithID(rightPackageName + "_bidirectional_"
108: + leftPackageName));
109: }
110:
111: public void testFollowDownstreamLink() throws Exception {
112: request.setParameter("start-includes", "/" + fooPackageName
113: + "/");
114: request.setParameter("scope", "package");
115: request.setParameter("filter", "package");
116: request.setParameter("maximum-inbound-depth", "0");
117: request.setParameter("maximum-outbound-depth", "1");
118: request.setParameter("submit", "Run Query");
119:
120: context.service();
121: WebResponse response = client.getResponse(request);
122:
123: assertNotNull("Missing link to " + fooPackageName, response
124: .getLinkWith(fooPackageName));
125: assertNotNull("Missing link to " + barPackageName, response
126: .getLinkWith(barPackageName));
127: assertNull("Unwanted link to " + bazPackageName, response
128: .getLinkWith(bazPackageName));
129:
130: assertNotNull("Missing link foo", response
131: .getLinkWithID(fooPackageName));
132: assertNotNull("Missing link foo --> bar",
133: response.getLinkWithID(fooPackageName + "_to_"
134: + barPackageName));
135: assertNotNull("Missing link bar", response
136: .getLinkWithID(barPackageName));
137: assertNotNull("Missing link bar <-- foo", response
138: .getLinkWithID(barPackageName + "_from_"
139: + fooPackageName));
140: assertNull("Unwanted link bar --> baz",
141: response.getLinkWithID(barPackageName + "_to_"
142: + bazPackageName));
143: assertNull("Unwanted link baz", response
144: .getLinkWithID(bazPackageName));
145: assertNull("Unwanted link baz <-- bar", response
146: .getLinkWithID(bazPackageName + "_from_"
147: + barPackageName));
148:
149: response = response.getLinkWithID(
150: fooPackageName + "_to_" + barPackageName).click();
151:
152: assertNull("Unwanted link to " + fooPackageName, response
153: .getLinkWith(fooPackageName));
154: assertNotNull("Missing link to " + barPackageName, response
155: .getLinkWith(barPackageName));
156: assertNotNull("Missing link to " + bazPackageName, response
157: .getLinkWith(bazPackageName));
158:
159: assertNull("Unwanted link foo", response
160: .getLinkWithID(fooPackageName));
161: assertNull("Unwanted link foo --> bar",
162: response.getLinkWithID(fooPackageName + "_to_"
163: + barPackageName));
164: assertNotNull("Missing link bar", response
165: .getLinkWithID(barPackageName));
166: assertNull("Unwanted link bar <-- foo", response
167: .getLinkWithID(barPackageName + "_from_"
168: + fooPackageName));
169: assertNotNull("Missing link bar --> baz",
170: response.getLinkWithID(barPackageName + "_to_"
171: + bazPackageName));
172: assertNotNull("Missing link baz", response
173: .getLinkWithID(bazPackageName));
174: assertNotNull("Missing link baz <-- bar", response
175: .getLinkWithID(bazPackageName + "_from_"
176: + barPackageName));
177: }
178: }
|