KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cactus > integration > maven > test > TestResources


1 /*
2  * ========================================================================
3  *
4  * Copyright 2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
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 JavaDoc;
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,v 1.2 2004/11/08 23:18:32 felipeal Exp $
33  */

34 public class TestResources extends ServletTestCase
35 {
36     private void includesTest( String JavaDoc resource )
37     {
38         Thread JavaDoc currentThread = Thread.currentThread();
39         ClassLoader JavaDoc classLoader = currentThread.getContextClassLoader();
40         InputStream JavaDoc input = classLoader.getResourceAsStream(resource);
41         assertNotNull("could not open resource " + resource, input);
42     }
43
44     private void excludesTest( String JavaDoc resource )
45     {
46         Thread JavaDoc currentThread = Thread.currentThread();
47         ClassLoader JavaDoc classLoader = currentThread.getContextClassLoader();
48         InputStream JavaDoc input = classLoader.getResourceAsStream(resource);
49         assertNull("should not have opened resource " + resource, input);
50     }
51
52     public void testConfigProperties()
53     {
54         includesTest( "test.properties" );
55     }
56   
57     public void testConfigXml()
58     {
59         includesTest( "test.xml" );
60     }
61     
62     public void testIncludes()
63     {
64         includesTest( "testKO.properties" );
65     }
66     
67     public void testExcludes()
68     {
69         excludesTest( "testbad.properties" );
70     }
71
72     public void testRecursive()
73     {
74         includesTest( "recursiveResources/test-recursive.properties" );
75     }
76     
77     public void testRecursiveDefault()
78     {
79         includesTest( "recursiveResources/test-recursive-default.xml");
80     }
81 }
82
Popular Tags