Package net.alteiar.shared

Examples of net.alteiar.shared.UniqueID


  public void testSequenceUniqueId() {
    // TODO increase to have a better test but take long time
    int idCount = 100;
    UniqueID[] ids = new UniqueID[idCount];
    for (int i = 0; i < ids.length; i++) {
      ids[i] = new UniqueID();
    }

    for (int i = 0; i < ids.length; i++) {
      for (int j = i + 1; j < ids.length; j++) {
        if (ids[i].equals(ids[j])) {
View Full Code Here


    Thread tr1 = new Thread(new Runnable() {
      @Override
      public void run() {
        for (int i = 0; i < ids1.length; i++) {
          ids1[i] = new UniqueID();
        }
      }
    });
    Thread tr2 = new Thread(new Runnable() {
      @Override
      public void run() {
        for (int i = 0; i < ids2.length; i++) {
          ids2[i] = new UniqueID();
        }
      }
    });
    Thread tr3 = new Thread(new Runnable() {
      @Override
      public void run() {
        for (int i = 0; i < ids3.length; i++) {
          ids3[i] = new UniqueID();
        }
      }
    });
    Thread tr4 = new Thread(new Runnable() {
      @Override
      public void run() {
        for (int i = 0; i < ids4.length; i++) {
          ids4[i] = new UniqueID();
        }
      }
    });

    tr1.start();
View Full Code Here

    assertEquals(0, countObjectFile(ImageBean.class));
  }

  @Test(timeout = 1000)
  public void testSaveBattle() {
    UniqueID battleId = null;
    try {
      battleId = TestMap.createBattle("test-map-save",
          TestMap.getDefaultImage());
    } catch (IOException e) {
      fail("no exception should occur");
View Full Code Here

  public void testBattleWithMapElement() {
    Long waitingTime = 1000L;
    MapBean emptyBattle = new MapBean("");
    assertEquals("verify emptyBattle", emptyBattle, emptyBattle);

    UniqueID battleId = null;
    try {
      battleId = createBattle("test battle 10", getDefaultImage());
    } catch (IOException e) {
      fail("fail to create battle");
    }
    assertNotNull("the battle id must'nt be null", battleId);
    MapBean battle = CampaignClient.getInstance().getBean(battleId,
        waitingTime);
    assertNotNull("the battle should not be null", battle);

    PropertyChangeListener listener = new PropertyChangeListener() {
      @Override
      public void propertyChange(PropertyChangeEvent evt) {
        innerClassCall();
      }
    };
    battle.addPropertyChangeListener(listener);

    Point position = new Point(5, 5);
    Color color = Color.GREEN;
    MapElementSize width = new MapElementSizeMeter(6.0);
    MapElementSize height = new MapElementSizePixel(42.0);

    RectangleElement rectangle = new RectangleElement(position, color,
        width, height);

    Collection<UniqueID> elementsOnMap = battle.getElements();
    assertTrue("The map shouldn't have any element",
        elementsOnMap.isEmpty());

    MapElementFactory.buildMapElement(rectangle, battle);

    // wait for the element to be in the element list
    while (elementsOnMap.isEmpty()) {
      sleep(10);
      elementsOnMap = battle.getElements();
    }

    assertEquals("The map should have 1 element", 1, elementsOnMap.size());
    assertEquals("The rectangle id should be the same", rectangle.getId(),
        elementsOnMap.iterator().next());

    assertEquals(
        "The map should have at least 1 element at the position (6,6)",
        1, battle.getElementsAt(new Point(6, 6)).size());
    assertEquals(
        "The map should'nt have any element at the position (4,4)", 0,
        battle.getElementsAt(new Point(4, 4)).size());

    battle.removeElement(elementsOnMap.iterator().next());
    while (!elementsOnMap.isEmpty()) {
      sleep(10);
      elementsOnMap = battle.getElements();
    }

    assertTrue("The map should'nt have any element",
        elementsOnMap.isEmpty());

    battle.setScale(new Scale(25, 1.5));
    battle.setFilter(new UniqueID());

    sleep();
    // Should have 4 call
    // (add element, remove element, scale change, filter change)
    verifyInnerClassCall(4);
View Full Code Here

    map.setHeight(newHeight);

    ImageBean imageBean = createBeanImage();

    CampaignClient.getInstance().addBean(imageBean);
    UniqueID newImage = imageBean.getId();

    map.setBackground(newImage);

    UniqueID newFilter = new UniqueID();
    map.setFilter(newFilter);

    HashSet<UniqueID> set = new HashSet<UniqueID>();
    set.add(new UniqueID());
    set.add(new UniqueID());
    map.setElements(set);

    waitForChange(map, "getScale", newScale);
    waitForChange(map, "getWidth", newWidth);
    waitForChange(map, "getHeight", newHeight);
View Full Code Here

    }
  }

  @Test(timeout = 10000)
  public void testBattle() {
    UniqueID battleId = null;
    try {
      battleId = createBattle("test battle", getDefaultImage());
    } catch (IOException e) {
      fail("fail to create battle");
    }
View Full Code Here

  @Test
  public void testBattleGrid() {
    Long waitingTime = 1000L;
    File battleImageFile = getDefaultImage();
    UniqueID battleId1 = null;
    UniqueID battleId2 = null;
    try {
      battleId1 = createBattle("new battle1", battleImageFile);
      battleId2 = createBattle("new battle2", battleImageFile);
    } catch (IOException e) {
      fail("fail to create battle");
View Full Code Here

  @Test
  public void testMapFilter() {
    Long waitingTime = 1000L;
    File battleImageFile = getDefaultImage();
    UniqueID battleId = null;
    try {
      battleId = createBattle("new battle", battleImageFile);
    } catch (IOException e) {
      fail("fail to create battle");
    }
    MapBean mapFiltered = CampaignClient.getInstance().getBean(battleId,
        waitingTime);

    int width = mapFiltered.getWidth();
    int height = mapFiltered.getHeight();

    try {
      BufferedImage targetImages = ImageIO.read(battleImageFile);
      int expectedWidth = targetImages.getWidth();
      int expectedHeight = targetImages.getHeight();
      assertEquals("width should be same", width, expectedWidth);
      assertEquals("height should be same", height, expectedHeight);

      // Test filter
      double compareZoomFactor = 2.75;

      ManualMapFilter filter = new ManualMapFilter(battleId);
      filter.showPolygon(new Polygon(new int[] { 5, 25, 25, 5 },
          new int[] { 5, 5, 25, 25 }, 4));
      filter.hidePolygon(new Polygon(new int[] { 5, 25, 25, 5 },
          new int[] { 5, 5, 25, 25 }, 4));

      CampaignClient.getInstance().addBean(filter);
      UniqueID filterId = filter.getId();

      mapFiltered.setFilter(filterId);
      filter = CampaignClient.getInstance()
          .getBean(filterId, waitingTime);
View Full Code Here

        rectangle.getCenterPosition());
    assertEquals("The battle id should be the same as the map id",
        battleId, rectangle.getMapId());

    // Change battle link
    UniqueID newBattleId = null;
    try {
      newBattleId = TestMap.createBattle("new battle",
          TestMap.getDefaultImage());
    } catch (IOException e) {
      fail("fail to create battle");
View Full Code Here

    try {
      Timer t = new Timer();
      t.start();
      ImageBean bean = new ImageBean(new WebImage(new URL(
          "http://www.alteiar.net/images/cartes/Carte_du_monde.jpg")));
      UniqueID id = bean.getId();

      CampaignClient.getInstance().addBean(bean);
      t.end("server sended");
      bean = CampaignClient.getInstance().getBean(id, time10second);
      if (bean != null) {
View Full Code Here

TOP

Related Classes of net.alteiar.shared.UniqueID

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.