예제 #1
0
 /** NotRule.getRule(Stack) throws exception if only one rule provided. */
 public void test1() {
   Stack stack = new Stack();
   try {
     NotRule.getRule(stack);
     fail("Should have thrown IllegalArgumentException");
   } catch (IllegalArgumentException ex) {
   }
 }
예제 #2
0
 /** Test deserialized Not. */
 public void test5() throws IOException, ClassNotFoundException {
   Stack stack = new Stack();
   stack.push(LevelEqualsRule.getRule("INFO"));
   Rule rule = (Rule) SerializationTestHelper.serializeClone(NotRule.getRule(stack));
   assertEquals(0, stack.size());
   Calendar cal = new GregorianCalendar(2008, 04, 21, 00, 45, 44);
   LoggingEvent event =
       new LoggingEvent(
           "org.apache.log4j.Logger",
           Logger.getRootLogger(),
           cal.getTimeInMillis(),
           Level.INFO,
           "Hello, World",
           null);
   assertFalse(rule.evaluate(event, null));
 }
예제 #3
0
 /** Test Not of Level when Level does not match. */
 public void test4() {
   Stack stack = new Stack();
   stack.push(LevelEqualsRule.getRule("INFO"));
   Rule rule = NotRule.getRule(stack);
   assertEquals(0, stack.size());
   Calendar cal = new GregorianCalendar(2008, 04, 21, 00, 45, 44);
   LoggingEvent event =
       new LoggingEvent(
           "org.apache.log4j.Logger",
           Logger.getRootLogger(),
           cal.getTimeInMillis(),
           Level.WARN,
           "Hello, World",
           null);
   assertTrue(rule.evaluate(event, null));
 }