Skip to content

Instantly share code, notes, and snippets.

@brianm
Created July 3, 2009 04:15
Show Gist options
  • Select an option

  • Save brianm/139901 to your computer and use it in GitHub Desktop.

Select an option

Save brianm/139901 to your computer and use it in GitHub Desktop.
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