@Test public void good() throws JoranException { simpleConfigurator.doConfigure(DEFINE_INPUT_DIR + GOOD_XML); InterpretationContext ic = simpleConfigurator.getInterpreter().getInterpretationContext(); String inContextFoo = ic.getProperty("foo"); assertEquals("monster", inContextFoo); }
@Test public void noClass() throws JoranException { simpleConfigurator.doConfigure(DEFINE_INPUT_DIR + NOCLASS_XML); String inContextFoo = context.getProperty("foo"); assertNull(inContextFoo); checker.assertContainsMatch( Status.ERROR, "Missing class name for property definer. Near \\[define\\] line 1"); }
@Before public void setUp() throws Exception { HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>(); rulesMap.put(new Pattern("define"), new DefinePropertyAction()); simpleConfigurator = new SimpleConfigurator(rulesMap); simpleConfigurator.setContext(context); }
@Test public void testBadClass() throws JoranException { simpleConfigurator.doConfigure(DEFINE_INPUT_DIR + BADCLASS_XML); // get from context String inContextFoo = context.getProperty("foo"); assertNull(inContextFoo); // check context errors checker.assertContainsMatch(Status.ERROR, "Could not create an PropertyDefiner of type"); }
@Test public void noName() throws JoranException { simpleConfigurator.doConfigure(DEFINE_INPUT_DIR + NONAME_XML); // get from context String inContextFoo = context.getProperty("foo"); assertNull(inContextFoo); // check context errors checker.assertContainsMatch( Status.ERROR, "Missing property name for property definer. Near \\[define\\] line 1"); }