Package com.mdimension.jchronic.handlers

Examples of com.mdimension.jchronic.handlers.Handler


    super.setUp();
    _now = Time.construct(2006, 8, 16, 14, 0, 0, 0);
  }
 
  public void testHandlerClass1() {
    Handler handler = new Handler(new DummyHandler(), new TagPattern(Repeater.class));
    List<Token> tokens = new LinkedList<Token>();
    tokens.add(new Token("friday"));
    tokens.get(0).tag(new RepeaterDayName(RepeaterDayName.DayName.FRIDAY));
   
    assertTrue(handler.match(tokens, Handler.definitions()));
   
    tokens.add(new Token("afternoon"));
    tokens.get(1).tag(new EnumRepeaterDayPortion(RepeaterDayPortion.DayPortion.AFTERNOON));
   
    assertFalse(handler.match(tokens, Handler.definitions()));
  }
View Full Code Here


   
    assertFalse(handler.match(tokens, Handler.definitions()));
  }
 
  public void testHandlerClass2() {
    Handler handler = new Handler(new DummyHandler(), new TagPattern(Repeater.class), new TagPattern(Repeater.class, true));
    List<Token> tokens = new LinkedList<Token>();
    tokens.add(new Token("friday"));
    tokens.get(0).tag(new RepeaterDayName(RepeaterDayName.DayName.FRIDAY));
   
    assertTrue(handler.match(tokens, Handler.definitions()));
   
    tokens.add(new Token("afternoon"));
    tokens.get(1).tag(new EnumRepeaterDayPortion(RepeaterDayPortion.DayPortion.AFTERNOON));
   
    assertTrue(handler.match(tokens, Handler.definitions()));
   
    tokens.add(new Token("afternoon"));
    tokens.get(2).tag(new EnumRepeaterDayPortion(RepeaterDayPortion.DayPortion.AFTERNOON));
   
    assertFalse(handler.match(tokens, Handler.definitions()));
  }
View Full Code Here

   
    assertFalse(handler.match(tokens, Handler.definitions()));
  }

  public void testHandlerClass3() {
    Handler handler = new Handler(new DummyHandler(), new TagPattern(Repeater.class), new HandlerTypePattern(Handler.HandlerType.TIME, true));
    List<Token> tokens = new LinkedList<Token>();
    tokens.add(new Token("friday"));
    tokens.get(0).tag(new RepeaterDayName(RepeaterDayName.DayName.FRIDAY));
   
    assertTrue(handler.match(tokens, Handler.definitions()));
   
    tokens.add(new Token("afternoon"));
    tokens.get(1).tag(new EnumRepeaterDayPortion(RepeaterDayPortion.DayPortion.AFTERNOON));
   
    assertFalse(handler.match(tokens, Handler.definitions()));
  }
View Full Code Here

   
    assertFalse(handler.match(tokens, Handler.definitions()));
  }

  public void testHandlerClass4() {
    Handler handler = new Handler(new DummyHandler(), new TagPattern(RepeaterMonthName.class), new TagPattern(ScalarDay.class), new HandlerTypePattern(Handler.HandlerType.TIME, true));
    List<Token> tokens = new LinkedList<Token>();
    tokens.add(new Token("may"));
    tokens.get(0).tag(new RepeaterMonthName(RepeaterMonthName.MonthName.MAY));
   
    assertFalse(handler.match(tokens, Handler.definitions()));
   
    tokens.add(new Token("27"));
    tokens.get(1).tag(new ScalarDay(Integer.valueOf(27)));
   
    assertTrue(handler.match(tokens, Handler.definitions()));
  }
View Full Code Here

   
    assertTrue(handler.match(tokens, Handler.definitions()));
  }

  public void testHandlerClass5() {
    Handler handler = new Handler(new DummyHandler(), new TagPattern(Repeater.class), new HandlerTypePattern(Handler.HandlerType.TIME, true));
    List<Token> tokens = new LinkedList<Token>();
    tokens.add(new Token("friday"));
    tokens.get(0).tag(new RepeaterDayName(RepeaterDayName.DayName.FRIDAY));
   
    assertTrue(handler.match(tokens, Handler.definitions()));
   
    tokens.add(new Token("5:00"));
    tokens.get(1).tag(new RepeaterTime("5:00"));
   
    assertTrue(handler.match(tokens, Handler.definitions()));
   
    tokens.add(new Token("pm"));
    tokens.get(2).tag(new EnumRepeaterDayPortion(RepeaterDayPortion.DayPortion.PM));
   
    assertTrue(handler.match(tokens, Handler.definitions()));
  }
View Full Code Here

   
    assertTrue(handler.match(tokens, Handler.definitions()));
  }

  public void testHandlerClass6() {
    Handler handler = new Handler(new DummyHandler(), new TagPattern(Scalar.class), new TagPattern(Repeater.class), new TagPattern(Pointer.class));
    List<Token> tokens = new LinkedList<Token>();
    tokens.add(new Token("3"));
    tokens.add(new Token("years"));
    tokens.add(new Token("past"));
   
    tokens.get(0).tag(new Scalar(Integer.valueOf(3)));
    tokens.get(1).tag(new RepeaterYear());
    tokens.get(2).tag(new Pointer(Pointer.PointerType.PAST));
   
    assertTrue(handler.match(tokens, Handler.definitions()));
  }
View Full Code Here

TOP

Related Classes of com.mdimension.jchronic.handlers.Handler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.