Created
July 3, 2009 04:15
-
-
Save brianm/139901 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void testValidateOne() throws Exception { | |
| Properties props = new Properties(); | |
| props.setProperty("foo", "-3"); | |
| Configamajig cfg = new Configamajig(props); | |
| try { | |
| cfg.configure(Foo.class); | |
| fail("should have raised an exception"); | |
| } | |
| catch (IllegalStateException e) { | |
| assertTrue(true); | |
| } | |
| } | |
| public void testValidateTwo() throws Exception { | |
| Properties props = new Properties(); | |
| props.setProperty("bar", "13"); | |
| Configamajig cfg = new Configamajig(props); | |
| try { | |
| cfg.configure(Foo.class); | |
| fail("should have raised an exception"); | |
| } | |
| catch (IllegalStateException e) { | |
| assertTrue(true); | |
| } | |
| } | |
| public static abstract class Foo | |
| { | |
| @Property(value="foo", validate="(> *val* 0)", missing="18") | |
| public abstract Integer getFoo(); | |
| @Property(value="bar", validate="(. *this* isNice *val*)", missing="7") | |
| public abstract Integer getBar(); | |
| public boolean isNice(Integer i) { | |
| return i != 13; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment