@Test public void testStore() throws Exception { InputStream data = ByteStreams.newInputStreamSupplier("hejsan vad bra".getBytes()).getInput(); String path = Joiner.on(File.separatorChar) .join("com", "bygg", "bygg-test-artifact", "2.3", "bygg-test-artifact-2.3.jar"); File expectedFile = new File(repositoryDirectory, path); expectedFile.delete(); assertFalse(expectedFile.exists()); URL actualURl = repository.store(new ArtifactVersion(ARTIFACT, "2.3"), data); assertThat( actualURl, equalTo( new URL( "file:" + repositoryDirectory.getAbsolutePath() + "/com/bygg/bygg-test-artifact/2.3/bygg-test-artifact-2.3.jar"))); assertTrue(expectedFile.exists()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteStreams.copy(new FileInputStream(expectedFile), outputStream); assertThat(outputStream.toString(), equalTo("hejsan vad bra")); }
@Test public void testLookupExists() throws Exception { artifactVersion = new ArtifactVersion(ARTIFACT, "1.2"); // TODO: this test is probably broken on windows, so fix it assertThat( repository.lookup(artifactVersion), equalTo( new URL( "file:" + repositoryDirectory.getAbsolutePath() + "/com/bygg/bygg-test-artifact/1.2/bygg-test-artifact-1.2.jar"))); }
@Test public void testLookupNotFound() throws Exception { artifactVersion = new ArtifactVersion(ARTIFACT, "1.2-SNAPSHOT"); assertThat(repository.lookup(artifactVersion), CoreMatchers.<Object>nullValue()); }