KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > util > defaults > test > DefaultsBuilderTestCase


1 /*
2  * Copyright 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.avalon.util.defaults.test;
18
19 import java.util.Properties JavaDoc;
20 import java.io.File JavaDoc;
21 import java.io.IOException JavaDoc;
22
23 import junit.framework.TestCase ;
24
25 import org.apache.avalon.util.defaults.DefaultsBuilder;
26
27 /**
28  * DefaultsBuilderTestCase
29  *
30  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
31  * @version $Revision: 1.3 $
32  */

33 public class DefaultsBuilderTestCase extends TestCase
34 {
35     private static final String JavaDoc KEY = "test";
36
37     private DefaultsBuilder m_builder;
38
39     protected void setUp() throws Exception JavaDoc
40     {
41         File JavaDoc base = new File JavaDoc( System.getProperty( "basedir" ) );
42         File JavaDoc dir = new File JavaDoc( base, "target/test-classes" );
43         System.out.println( "dir: " + dir );
44
45         m_builder = new DefaultsBuilder( KEY, dir );
46     }
47
48     public void testHomeDirectory() throws Exception JavaDoc
49     {
50         System.out.println( "inst: " + m_builder.getHomeDirectory() );
51     }
52
53     public void testHomeProperties() throws Exception JavaDoc
54     {
55         System.out.println( "home: " + m_builder.getHomeProperties() );
56     }
57
58     public void testUserProperties() throws Exception JavaDoc
59     {
60         System.out.println( "user: " + m_builder.getUserProperties() );
61     }
62
63     public void testDirProperties() throws Exception JavaDoc
64     {
65         System.out.println( "dir: " + m_builder.getDirProperties() );
66     }
67
68     public void testConsolidatedProperties() throws Exception JavaDoc
69     {
70         File JavaDoc base = new File JavaDoc( System.getProperty( "basedir" ) );
71         File JavaDoc dir = new File JavaDoc( base, "target/test-classes" );
72         File JavaDoc props = new File JavaDoc( dir, "test.keys" );
73         Properties JavaDoc properties = DefaultsBuilder.getProperties( props );
74         String JavaDoc[] keys = (String JavaDoc[]) properties.keySet().toArray( new String JavaDoc[0] );
75         Properties JavaDoc defaults =
76           DefaultsBuilder.getProperties(
77             DefaultsBuilderTestCase.class.getClassLoader(),
78             "static.properties" );
79         System.out.println(
80           "con: "
81           + m_builder.getConsolidatedProperties( defaults, keys ) );
82     }
83
84 }
85
Popular Tags