EMMA Coverage Report (generated Mon Nov 29 14:43:38 PST 2010)
[all classes][com.jeantessier.dependencyfinder.web]

COVERAGE SUMMARY FOR SOURCE FILE [TestQueryBase.java]

nameclass, %method, %block, %line, %
TestQueryBase.java100% (1/1)100% (7/7)100% (1082/1082)100% (138/138)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TestQueryBase100% (1/1)100% (7/7)100% (1082/1082)100% (138/138)
TestQueryBase (): void 100% (1/1)100% (3/3)100% (1/1)
testDirectQuery (): void 100% (1/1)100% (386/386)100% (37/37)
testEscapeSquareBrackets (): void 100% (1/1)100% (79/79)100% (16/16)
testFollowDependencyLink (): void 100% (1/1)100% (128/128)100% (19/19)
testFormSubmit (): void 100% (1/1)100% (246/246)100% (23/23)
testNarrowScope (): void 100% (1/1)100% (114/114)100% (20/20)
testNarrowThanWidenScope (): void 100% (1/1)100% (126/126)100% (22/22)

1/*
2 *  Copyright (c) 2001-2009, Jean Tessier
3 *  All rights reserved.
4 *  
5 *  Redistribution and use in source and binary forms, with or without
6 *  modification, are permitted provided that the following conditions
7 *  are met:
8 *  
9 *      * Redistributions of source code must retain the above copyright
10 *        notice, this list of conditions and the following disclaimer.
11 *  
12 *      * Redistributions in binary form must reproduce the above copyright
13 *        notice, this list of conditions and the following disclaimer in the
14 *        documentation and/or other materials provided with the distribution.
15 *  
16 *      * Neither the name of Jean Tessier nor the names of his contributors
17 *        may be used to endorse or promote products derived from this software
18 *        without specific prior written permission.
19 *  
20 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
24 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 
33package com.jeantessier.dependencyfinder.web;
34 
35import com.meterware.httpunit.*;
36 
37public abstract class TestQueryBase extends TestBase {
38    public void testFormSubmit() throws Exception {
39        context.service();
40        WebResponse response = client.getResponse(request);
41 
42        assertEquals("Nb forms", 1, response.getForms().length);
43        WebForm form = response.getForms()[0];
44        assertEquals("Nb submit buttons", 1, form.getSubmitButtons().length);
45        SubmitButton button = form.getSubmitButtons()[0];
46 
47        response = form.submit(button);
48 
49        assertNotNull("Missing link to " + fooPackageName, response.getLinkWith(fooPackageName));
50        assertNull("Unwanted link to " + fooClassName, response.getLinkWith(fooClassName));
51        assertNull("Unwanted link to " + fooFeatureName, response.getLinkWith(fooFeatureName));
52        assertNotNull("Missing link to " + barPackageName, response.getLinkWith(barPackageName));
53        assertNull("Unwanted link to " + barClassName, response.getLinkWith(barClassName));
54        assertNull("Unwanted link to " + barFeatureName, response.getLinkWith(barFeatureName));
55        assertNotNull("Missing link to " + bazPackageName, response.getLinkWith(bazPackageName));
56        assertNull("Unwanted link to " + bazClassName, response.getLinkWith(bazClassName));
57        assertNull("Unwanted link to " + bazFeatureName, response.getLinkWith(bazFeatureName));
58        assertNotNull("Missing link to " + leftPackageName, response.getLinkWith(leftPackageName));
59        assertNull("Unwanted link to " + leftClassName, response.getLinkWith(leftClassName));
60        assertNull("Unwanted link to " + leftFeatureName, response.getLinkWith(leftFeatureName));
61        assertNotNull("Missing link to " + rightPackageName, response.getLinkWith(rightPackageName));
62        assertNull("Unwanted link to " + rightClassName, response.getLinkWith(rightClassName));
63        assertNull("Unwanted link to " + rightFeatureName, response.getLinkWith(rightFeatureName));
64    }
65 
66    public void testDirectQuery() throws Exception {
67        request.setParameter("scope-includes", "//");
68        request.setParameter("package-scope", "on");
69        request.setParameter("filter-includes", "//");
70        request.setParameter("package-filter", "on");
71        request.setParameter("show-inbounds", "on");
72        request.setParameter("show-outbounds", "on");
73        request.setParameter("show-empty-nodes", "on");
74        request.setParameter("submit", "Run Query");
75 
76        context.service();
77        WebResponse response = client.getResponse(request);
78 
79        assertNotNull("Missing link to " + fooPackageName, response.getLinkWith(fooPackageName));
80        assertNull("Unwanted link to " + fooClassName, response.getLinkWith(fooClassName));
81        assertNull("Unwanted link to " + fooFeatureName, response.getLinkWith(fooFeatureName));
82        assertNotNull("Missing link to " + barPackageName, response.getLinkWith(barPackageName));
83        assertNull("Unwanted link to " + barClassName, response.getLinkWith(barClassName));
84        assertNull("Unwanted link to " + barFeatureName, response.getLinkWith(barFeatureName));
85        assertNotNull("Missing link to " + bazPackageName, response.getLinkWith(bazPackageName));
86        assertNull("Unwanted link to " + bazClassName, response.getLinkWith(bazClassName));
87        assertNull("Unwanted link to " + bazFeatureName, response.getLinkWith(bazFeatureName));
88        assertNotNull("Missing link to " + leftPackageName, response.getLinkWith(leftPackageName));
89        assertNull("Unwanted link to " + leftClassName, response.getLinkWith(leftClassName));
90        assertNull("Unwanted link to " + leftFeatureName, response.getLinkWith(leftFeatureName));
91        assertNotNull("Missing link to " + rightPackageName, response.getLinkWith(rightPackageName));
92        assertNull("Unwanted link to " + rightClassName, response.getLinkWith(rightClassName));
93        assertNull("Unwanted link to " + rightFeatureName, response.getLinkWith(rightFeatureName));
94 
95        assertNotNull("Missing link foo", response.getLinkWithID(fooPackageName));
96        assertNotNull("Missing link foo --> bar", response.getLinkWithID(fooPackageName + "_to_" + barPackageName));
97        assertNotNull("Missing link bar", response.getLinkWithID(barPackageName));
98        assertNotNull("Missing link bar <-- foo", response.getLinkWithID(barPackageName + "_from_" + fooPackageName));
99        assertNotNull("Missing link bar --> baz", response.getLinkWithID(barPackageName + "_to_" + bazPackageName));
100        assertNotNull("Missing link baz", response.getLinkWithID(bazPackageName));
101        assertNotNull("Missing link baz <-- bar", response.getLinkWithID(bazPackageName + "_from_" + barPackageName));
102        assertNotNull("Missing link left", response.getLinkWithID(leftPackageName));
103        assertNotNull("Missing link left <-> right", response.getLinkWithID(leftPackageName + "_bidirectional_" + rightPackageName));
104        assertNotNull("Missing link right", response.getLinkWithID(rightPackageName));
105        assertNotNull("Missing link right <-> left", response.getLinkWithID(rightPackageName + "_bidirectional_" + leftPackageName));
106    }
107 
108    public void testFollowDependencyLink() throws Exception {
109        context.service();
110        WebResponse response = client.getResponse(request);
111 
112        WebForm form = response.getForms()[0];
113        form.setCheckbox("package-scope", false);
114        form.setCheckbox("feature-scope", true);
115        form.setCheckbox("package-filter", false);
116        form.setCheckbox("feature-filter", true);
117 
118        response = form.submit(form.getSubmitButtons()[0]);
119        response = response.getLinkWithID(fooFeatureName + "_to_" + barFeatureName).click();
120 
121        assertNull("Unwanted link foo", response.getLinkWithID(fooPackageName));
122        assertNotNull("Missing link bar", response.getLinkWithID(barPackageName));
123        assertNotNull("Missing link bar.Bar", response.getLinkWithID(barClassName));
124        assertNotNull("Missing link bar.Bar.bar()", response.getLinkWithID(barFeatureName));
125        assertNotNull("Missing link bar.Bar.bar() <-- foo.Foo.foo()", response.getLinkWithID(barFeatureName + "_from_" + fooFeatureName));
126        assertNotNull("Missing link bar.Bar.bar() --> baz.Baz.baz()", response.getLinkWithID(barFeatureName + "_to_" + bazFeatureName));
127        assertNull("Unwanted link baz", response.getLinkWithID(bazPackageName));
128        assertNull("Unwanted link left", response.getLinkWithID(leftPackageName));
129        assertNull("Unwanted link right", response.getLinkWithID(rightPackageName));
130    }
131 
132    public void testNarrowScope() throws Exception {
133        factory.createFeature(foo2FeatureName);
134 
135        context.service();
136        WebResponse response = client.getResponse(request);
137 
138        WebForm form = response.getForms()[0];
139        form.setCheckbox("package-scope", false);
140        form.setCheckbox("feature-scope", true);
141        form.setCheckbox("package-filter", false);
142        form.setCheckbox("feature-filter", true);
143 
144        response = form.submit(form.getSubmitButtons()[0]);
145        response = response.getLinkWithID(fooFeatureName).click();
146 
147        assertNotNull("Missing link foo", response.getLinkWithID(fooPackageName));
148        assertNotNull("Missing link foo.Foo", response.getLinkWithID(fooClassName));
149        assertNotNull("Missing link foo.Foo.foo()", response.getLinkWithID(fooFeatureName));
150        assertNotNull("Missing link foo.Foo.foo() --> bar.Bar.bar()", response.getLinkWithID(fooFeatureName + "_to_" + barFeatureName));
151        assertNull("Unwanted link foo.Foo2", response.getLinkWithID(foo2ClassName));
152        assertNull("Unwanted link bar", response.getLinkWithID(barPackageName));
153        assertNull("Unwanted link baz", response.getLinkWithID(bazPackageName));
154        assertNull("Unwanted link left", response.getLinkWithID(leftPackageName));
155        assertNull("Unwanted link right", response.getLinkWithID(rightPackageName));
156    }
157 
158    public void testNarrowThanWidenScope() throws Exception {
159        factory.createFeature(foo2FeatureName);
160 
161        context.service();
162        WebResponse response = client.getResponse(request);
163 
164        WebForm form = response.getForms()[0];
165        form.setCheckbox("package-scope", false);
166        form.setCheckbox("feature-scope", true);
167        form.setCheckbox("package-filter", false);
168        form.setCheckbox("feature-filter", true);
169 
170        response = form.submit(form.getSubmitButtons()[0]);
171        response = response.getLinkWithID(fooFeatureName).click();
172        response = response.getLinkWithID(fooPackageName).click();
173 
174        assertNotNull("Missing link foo", response.getLinkWithID(fooPackageName));
175        assertNotNull("Missing link foo.Foo", response.getLinkWithID(fooClassName));
176        assertNotNull("Missing link foo.Foo.foo()", response.getLinkWithID(fooFeatureName));
177        assertNotNull("Missing link foo.Foo.foo() --> bar.Bar.bar()", response.getLinkWithID(fooFeatureName + "_to_" + barFeatureName));
178        assertNotNull("Missing link foo.Foo2", response.getLinkWithID(foo2ClassName));
179        assertNotNull("Missing link foo.Foo2.foo2()", response.getLinkWithID(foo2FeatureName));
180        assertNull("Unwanted link bar", response.getLinkWithID(barPackageName));
181        assertNull("Unwanted link baz", response.getLinkWithID(bazPackageName));
182        assertNull("Unwanted link left", response.getLinkWithID(leftPackageName));
183        assertNull("Unwanted link right", response.getLinkWithID(rightPackageName));
184    }
185 
186    public void testEscapeSquareBrackets() throws Exception {
187        String mainFeatureName = fooClassName + ".main(java.lang.String[])";
188        factory.createFeature(mainFeatureName);
189 
190        context.service();
191        WebResponse response = client.getResponse(request);
192 
193        WebForm form = response.getForms()[0];
194        form.setCheckbox("package-scope", false);
195        form.setCheckbox("feature-scope", true);
196        form.setCheckbox("package-filter", false);
197        form.setCheckbox("feature-filter", true);
198        form.setParameter("scope-includes", "/\\[/");
199 
200        response = form.submit(form.getSubmitButtons()[0]);
201        WebLink webLink = response.getLinkWithID(mainFeatureName);
202        assertNotNull("Missing link for " + mainFeatureName, webLink);
203        response = webLink.click();
204        assertEquals("response code", 200, response.getResponseCode());
205    }
206}

[all classes][com.jeantessier.dependencyfinder.web]
EMMA 2.0.5312 (C) Vladimir Roubtsov