Exemplo n.º 1
0
  @Test
  public void testConstructor() {
    int tickLengthUnit = Calendar.DAY_OF_MONTH;
    int tickLength = 1;

    IMocksControl control = createControl();

    GregorianCalendar startDateMock = control.createMock(GregorianCalendar.class);
    GregorianCalendar startDateCloneMock = control.createMock(GregorianCalendar.class);
    expect(startDateMock.clone()).andReturn(startDateCloneMock).once();

    EventBus eventBusMock = control.createMock(EventBus.class);

    control.replay();

    TimeManagerImpl manager =
        new TimeManagerImpl(startDateMock, tickLengthUnit, tickLength, eventBusMock);

    assertSame(startDateMock, manager.getStartDate());
    assertEquals(tickLengthUnit, manager.getTickLengthUnit());
    assertEquals(tickLength, manager.getTickLength());
    assertNotSame(startDateMock, manager.getCurrentDate());
    assertSame(startDateCloneMock, manager.getCurrentDate());

    control.verify();
  }
Exemplo n.º 2
0
  @Test
  public void test_checkMove_pass() throws GameMoveException {
    final Dictionary dictionary = createDictionary("abcd", "def", "fefgabcd");
    final TilesBank tilesBank = new TilesBank(editor.createTilesBankInfo());
    final ScribbleBoard board =
        new ScribbleBoard(
            settings, Arrays.asList(player1, player2, player3), tilesBank, dictionary);
    h1 = board.getPlayerHand(player1);
    h2 = board.getPlayerHand(player2);
    h3 = board.getPlayerHand(player3);

    h1.setTiles(tilesBank.getTiles(0, 3, 6, 9, 12, 15, 18)); // abcdefg
    h2.setTiles(tilesBank.getTiles(1, 4, 7, 10, 13, 16, 19)); // abcdefg
    h3.setTiles(tilesBank.getTiles(2, 5, 8, 11, 14, 17, 20)); // abcdefg

    final Personality person = board.getPlayerTurn();
    final ScribblePlayerHand hand = board.getPlayerHand(person);
    board.passTurn(person);

    assertEquals(7, hand.getTiles().length);
    assertEquals(1, board.getGameMoves().size());
    assertEquals(PassTurn.class, board.getGameMoves().get(0).getClass());
    assertEquals(13, tilesBank.getTilesLimit());

    assertNotSame(hand, board.getPlayerTurn());
  }
 @Test
 public void testGetAllEvents_informationHidingSecurity() throws XWikiException {
   List<EventApi> list = Collections.emptyList();
   expect(eventMgrMock.getEvents(same(cal), eq(0), eq(0))).andReturn(list).once();
   replayAll();
   List<EventApi> events = cal.getAllEvents();
   verifyAll();
   assertNotSame("getAllEvents may not leak internal data references.", eventList, events);
 }
 @Test
 public void testSetStartDate() {
   Date startDate = cal.getStartDate();
   Date newStartDate = new Date();
   cal.setStartDate(newStartDate);
   assertNotNull(cal.getStartDate());
   assertNotSame(startDate, cal.getStartDate());
   assertSame(newStartDate, cal.getStartDate());
 }
  @Test
  public void springSupport() {

    // TODOJ7: change try
    ClassPathXmlApplicationContext context = null;
    // try (ClosableClassPathXmlApplicationContext context = new
    // ClosableClassPathXmlApplicationContext("org/filterinterceptor/proxy/spring/spring-config.xml");) {
    try {
      context =
          new ClassPathXmlApplicationContext(
              "org/filterinterceptor/proxy/spring/spring-config.xml");

      IService service = (IService) context.getBean("service");
      IService realService = (IService) context.getBean("realService");
      FilterService filterService = (FilterService) context.getBean("filterService");

      String paramValue = "correctParam";
      DtoSample2 param = new DtoSample2(0, null, paramValue, null);

      // test controle
      DtoSample2 ret = realService.test2(param);
      // check
      assertTrue("References must be equals", param == ret);
      assertSame("C property must be unchanged: real service called", paramValue, ret.getC());

      // test on proxy
      ret = service.test2(param);
      // check
      assertTrue("References must be equals", param == ret);
      assertNotSame(
          "C property must be reassigned to a new value: filter called", paramValue, ret.getC());

      // unactivate the filter
      Filter<?> filter = filterService.getActiveFilter(ServiceImpl.class, "test2");
      filterService.setFilterActiveStatus(filter, false);

      // test on proxy
      param.setC(paramValue);
      ret = service.test2(param);
      // check
      assertTrue("References must be equals", param == ret);
      assertSame("C property must be unchanged: filter is unactivate", paramValue, ret.getC());
    } finally { // TODOJ7: remove
      if (context != null) context.close();
    }
  }