/sigmah/src/test/java/org/sigmah/server/endpoint/file/ImageRepositoryTest.java
Java | 47 lines | 34 code | 13 blank | 0 comment | 0 complexity | 9bb1a9c47d72ffe9618034ea6956e57e MD5 | raw file
1package org.sigmah.server.endpoint.file; 2 3import static org.hamcrest.CoreMatchers.*; 4import static org.junit.Assert.*; 5 6import java.io.IOException; 7import java.net.MalformedURLException; 8import java.util.Properties; 9 10import org.junit.Ignore; 11import org.junit.Test; 12 13public class ImageRepositoryTest { 14 15 16 @Test 17 public void acceptFile() throws MalformedURLException, IOException { 18 Properties config = new Properties(); 19 config.setProperty(ImageRepository.IMAGES_REPOSITORY_NAME, "/var/www/images"); 20 21 ImageRepository repo = new ImageRepository(config); 22 assertThat(repo.getRootUri().toString(), equalTo("file:/var/www/images")); 23 24 } 25 26 @Test @Ignore("won't pass on *nix systems") 27 public void acceptWindowsFile() throws MalformedURLException, IOException { 28 Properties config = new Properties(); 29 config.setProperty(ImageRepository.IMAGES_REPOSITORY_NAME, "C:\\www_pub\\images\\"); 30 31 ImageRepository repo = new ImageRepository(config); 32 assertThat(repo.getRootUri().toString(), equalTo("file:/c:/www_pub/images")); 33 34 } 35 36 @Test 37 public void acceptURL() throws MalformedURLException, IOException { 38 Properties config = new Properties(); 39 config.setProperty(ImageRepository.IMAGES_REPOSITORY_NAME, "https://s3.amazonaws.com/sigmah_logos/"); 40 41 ImageRepository repo = new ImageRepository(config); 42 43 repo.getImage("sif.png").toURL().openStream(); 44 45 } 46 47}