/sigmah/src/test/java/org/sigmah/server/endpoint/file/ImageRepositoryTest.java

http://sigma-h.googlecode.com/ · Java · 47 lines · 31 code · 16 blank · 0 comment · 0 complexity · 9bb1a9c47d72ffe9618034ea6956e57e MD5 · raw file

  1. package org.sigmah.server.endpoint.file;
  2. import static org.hamcrest.CoreMatchers.*;
  3. import static org.junit.Assert.*;
  4. import java.io.IOException;
  5. import java.net.MalformedURLException;
  6. import java.util.Properties;
  7. import org.junit.Ignore;
  8. import org.junit.Test;
  9. public class ImageRepositoryTest {
  10. @Test
  11. public void acceptFile() throws MalformedURLException, IOException {
  12. Properties config = new Properties();
  13. config.setProperty(ImageRepository.IMAGES_REPOSITORY_NAME, "/var/www/images");
  14. ImageRepository repo = new ImageRepository(config);
  15. assertThat(repo.getRootUri().toString(), equalTo("file:/var/www/images"));
  16. }
  17. @Test @Ignore("won't pass on *nix systems")
  18. public void acceptWindowsFile() throws MalformedURLException, IOException {
  19. Properties config = new Properties();
  20. config.setProperty(ImageRepository.IMAGES_REPOSITORY_NAME, "C:\\www_pub\\images\\");
  21. ImageRepository repo = new ImageRepository(config);
  22. assertThat(repo.getRootUri().toString(), equalTo("file:/c:/www_pub/images"));
  23. }
  24. @Test
  25. public void acceptURL() throws MalformedURLException, IOException {
  26. Properties config = new Properties();
  27. config.setProperty(ImageRepository.IMAGES_REPOSITORY_NAME, "https://s3.amazonaws.com/sigmah_logos/");
  28. ImageRepository repo = new ImageRepository(config);
  29. repo.getImage("sif.png").toURL().openStream();
  30. }
  31. }