1 7 package com.inversoft.util.variable.test; 8 9 10 import junit.framework.TestCase; 11 12 import com.inversoft.util.variable.ExpanderException; 13 import com.inversoft.util.variable.ExpanderStrategy; 14 import com.inversoft.util.variable.SystemPropertyExpanderStrategy; 15 16 17 24 public class SystemPropertyExpanderTest extends TestCase { 25 26 29 public SystemPropertyExpanderTest(String name) { 30 super(name); 31 } 32 33 34 37 public void testCommon() { 38 39 ExpanderStrategy strat = new SystemPropertyExpanderStrategy(); 40 41 try { 42 assertTrue("Should not have been null", strat.expand("java.home") != null); 43 assertTrue("Should not have been null", strat.expand("user.home") != null); 44 } catch (ExpanderException ee) { 45 fail(ee.toString()); 46 } 47 } 48 49 52 public void testFailure() { 53 54 ExpanderStrategy strat = new SystemPropertyExpanderStrategy(); 55 56 try { 57 strat.expand("foo.bar"); 58 fail("Should have failed"); 59 } catch (ExpanderException ee) { 60 assertTrue("SHould have a message", ee.getMessage() != null); 61 } 62 } 63 64 67 public void testAssert() { 68 69 ExpanderStrategy strat = new SystemPropertyExpanderStrategy(); 70 71 try { 72 strat.expand(null); 73 fail("Should have failed"); 74 } catch (ExpanderException ee) { 75 fail("Shouldn't have thrown this"); 76 } catch (AssertionError ae) { 77 } 79 80 try { 81 strat.expand(""); 82 fail("Should have failed"); 83 } catch (ExpanderException ee) { 84 fail("Shouldn't have thrown this"); 85 } catch (AssertionError ae) { 86 } 88 } 89 } 90 | Popular Tags |