01: /*
02: * ========================================================================
03: *
04: * Copyright 2004 The Apache Software Foundation.
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: */
20:
21: package org.apache.cactus.integration.maven.test;
22:
23: import org.apache.cactus.ServletTestCase;
24: import java.io.InputStream;
25:
26: /**
27: * Verify that resources included with the
28: * <code>cactus.resources.dirs</code> properties are found in the resulting
29: * cactified WAR. Note that we're testing this by executing this code inside
30: * the container.
31: *
32: * @version $Id: TestResources.java 239086 2004-11-08 23:18:32Z felipeal $
33: */
34: public class TestResources extends ServletTestCase {
35: private void includesTest(String resource) {
36: Thread currentThread = Thread.currentThread();
37: ClassLoader classLoader = currentThread.getContextClassLoader();
38: InputStream input = classLoader.getResourceAsStream(resource);
39: assertNotNull("could not open resource " + resource, input);
40: }
41:
42: private void excludesTest(String resource) {
43: Thread currentThread = Thread.currentThread();
44: ClassLoader classLoader = currentThread.getContextClassLoader();
45: InputStream input = classLoader.getResourceAsStream(resource);
46: assertNull("should not have opened resource " + resource, input);
47: }
48:
49: public void testConfigProperties() {
50: includesTest("test.properties");
51: }
52:
53: public void testConfigXml() {
54: includesTest("test.xml");
55: }
56:
57: public void testIncludes() {
58: includesTest("testKO.properties");
59: }
60:
61: public void testExcludes() {
62: excludesTest("testbad.properties");
63: }
64:
65: public void testRecursive() {
66: includesTest("recursiveResources/test-recursive.properties");
67: }
68:
69: public void testRecursiveDefault() {
70: includesTest("recursiveResources/test-recursive-default.xml");
71: }
72: }
|