1 16 17 package org.apache.avalon.util.defaults.test; 18 19 import java.util.Properties ; 20 import java.io.File ; 21 import java.io.IOException ; 22 23 import junit.framework.TestCase ; 24 25 import org.apache.avalon.util.defaults.DefaultsBuilder; 26 27 33 public class DefaultsBuilderTestCase extends TestCase 34 { 35 private static final String KEY = "test"; 36 37 private DefaultsBuilder m_builder; 38 39 protected void setUp() throws Exception 40 { 41 File base = new File ( System.getProperty( "basedir" ) ); 42 File dir = new File ( 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 49 { 50 System.out.println( "inst: " + m_builder.getHomeDirectory() ); 51 } 52 53 public void testHomeProperties() throws Exception 54 { 55 System.out.println( "home: " + m_builder.getHomeProperties() ); 56 } 57 58 public void testUserProperties() throws Exception 59 { 60 System.out.println( "user: " + m_builder.getUserProperties() ); 61 } 62 63 public void testDirProperties() throws Exception 64 { 65 System.out.println( "dir: " + m_builder.getDirProperties() ); 66 } 67 68 public void testConsolidatedProperties() throws Exception 69 { 70 File base = new File ( System.getProperty( "basedir" ) ); 71 File dir = new File ( base, "target/test-classes" ); 72 File props = new File ( dir, "test.keys" ); 73 Properties properties = DefaultsBuilder.getProperties( props ); 74 String [] keys = (String []) properties.keySet().toArray( new String [0] ); 75 Properties 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 |