コード例 #1
0
  @Test
  public void addSimpleTest() {

    // we prepare the service implementing add-simple
    ImageServiceImpl imageService = new ImageServiceImpl();
    ImageDaoImpl dao = new ImageDaoImpl();
    dao.setSessionManager(sessionManager);
    imageService.setDao(dao);

    // we prepare the resource to send
    File imageFile =
        new File(this.getClass().getClassLoader().getResource("piwigo_org.png").getPath());
    //	File imageFile = new File("piwigo_org.png");
    Integer categoryTest = 98;
    String title = "title" + System.currentTimeMillis();
    try {
      imageService.addSimple(imageFile, categoryTest, title);
    } catch (JiwigoException e) {
      Assert.fail("An exception was thrown while trying to send the pictures" + e.getMessage());
    }

    // the image should be sent, let's check if piwigo added it to the category.
    boolean found = false;
    List<Image> listByCategory;
    try {
      listByCategory = imageService.listByCategory(categoryTest, true);
      for (Image image : listByCategory) {
        if (image.getName().equals(title)) {
          found = true;
          break;
        }
      }
    } catch (Exception e) {
      Assert.fail(
          "An exception was thrown while trying to fetch the pictures from category "
              + categoryTest
              + "exception was : "
              + e.getMessage());
    }
    Assert.assertTrue("The picture just sent could not be found", found);
  }
コード例 #2
0
  @Test
  public void jiwigoImageToPicture() {

    Image jiwigoImage = new Image();

    jiwigoImage.setName("Title");
    jiwigoImage.setFile("Title.jpg");
    jiwigoImage.setIdentifier(10214);
    jiwigoImage.setThumbnailUrl(
        "http://piwigo.org/index.php?/path/to/picture/10214&miniature=true");
    jiwigoImage.setWidth(768);
    jiwigoImage.setHeight(1024);
    jiwigoImage.setUrl("http://piwigo.org/index.php?/path/to/picture/10214");

    // jiwigoImage.setTitle("Title");
    // jiwigoImage.setThumbWidth(320);
    // jiwigoImage.setThumbHeight(480);
    // jiwigoImage.setResizedName("3");
    // jiwigoImage.setResizedWidth(480);
    // jiwigoImage.setResizedHeight(640);
    // jiwigoImage.setRawFilesize(10241024);
    // jiwigoImage.setCaption("caption");
    // jiwigoImage.setForceExtension("true");
    // jiwigoImage.setHidden(true);

    // String galleryUrl = "http://g2.dahanne.net";
    Picture picture = JiwigoConvertUtils.jiwigoImageToPicture(jiwigoImage);

    Picture expectedPicture = new Picture();
    expectedPicture.setId(10214L);
    expectedPicture.setTitle("Title");
    expectedPicture.setFileName("Title.jpg");
    expectedPicture.setFileUrl("http://piwigo.org/index.php?/path/to/picture/10214");
    expectedPicture.setPublicUrl("http://piwigo.org/index.php?/path/to/picture/10214");
    expectedPicture.setWidth(768);
    expectedPicture.setHeight(1024);
    // expectedPicture.setFileSize(10241024);

    expectedPicture.setThumbUrl(
        "http://piwigo.org/index.php?/path/to/picture/10214&miniature=true");
    // expectedPicture.setThumbWidth(320);
    // expectedPicture.setThumbHeight(480);
    //
    // expectedPicture.setResizedUrl(galleryUrl + "/"
    // + G2ConvertUtils.BASE_URL_DEF + 3);
    // expectedPicture.setResizedWidth(480);
    // expectedPicture.setResizedHeight(640);

    Assert.assertEquals(expectedPicture, picture);
  }
コード例 #3
0
  @Test
  public void testCreer() throws Exception {
    Category cat = null;
    CategoryServiceImpl categoryService = new CategoryServiceImpl();
    CategoryDaoImpl categoryDao = new CategoryDaoImpl();
    categoryDao.setSessionManager(sessionManager);
    categoryService.setDao(categoryDao);

    ImageServiceImpl imageService = new ImageServiceImpl();
    ImageDaoImpl imageDao = new ImageDaoImpl();
    imageDao.setSessionManager(sessionManager);
    imageService.setDao(imageDao);
    // we choose category number 3
    for (Category category : categoryService.list(true)) {
      if (category.getIdentifier().equals(3)) {
        cat = category;
        break;
      }
    }
    // we look for the first picture of category 3
    Image image = imageService.listByCategory(cat.getIdentifier(), true).get(0);
    Assert.assertEquals("test de test do not delete", cat.getName());
    Assert.assertEquals("20110329194915-0c0b3f36.jpg", image.getFile());
  }