use of org.commonjava.maven.galley.model.SimpleLocation in project galley by Commonjava.
the class EmbeddableCDI_HTTPArtifactMetadataDownload_Test method resolveArtifactViaHttp.
@Test
public void resolveArtifactViaHttp() throws Exception {
String path = "/group/artifact/1-SNAPSHOT/maven-metadata.xml";
String content = "this is a test.";
server.expect(path, 200, content);
Transfer transfer = transfers.retrieve(new SimpleLocation(server.getBaseUri()), new SimpleProjectVersionRef("group", "artifact", "1-SNAPSHOT").asPomArtifact());
assertThat(transfer, notNullValue());
InputStream stream = null;
try {
stream = transfer.openInputStream();
assertThat(IOUtils.toString(stream), equalTo(content));
} finally {
IOUtils.closeQuietly(stream);
}
}
use of org.commonjava.maven.galley.model.SimpleLocation in project galley by Commonjava.
the class FastLocalCacheProviderTest method testSimultaneousWritesResourceExistence.
@Test
@BMScript("SimultaneousWritesResourceExistence.btm")
public void testSimultaneousWritesResourceExistence() throws Exception {
final String content = "This is a test";
final Location loc = new SimpleLocation("http://foo.com");
final String dir = "/path/to/my/";
final String fname1 = dir + "file1.txt";
final String fname2 = dir + "file2.txt";
CountDownLatch latch = new CountDownLatch(2);
start(new WriteFileThread(content, loc, fname1, latch));
start(new WriteFileThread(content, loc, fname2, latch));
latchWait(latch);
assertThat(provider.exists(new ConcreteResource(loc, fname1)), equalTo(true));
assertThat(provider.exists(new ConcreteResource(loc, fname2)), equalTo(true));
assertThat(provider.isDirectory(new ConcreteResource(loc, dir)), equalTo(true));
final Set<String> listing = new HashSet<String>(Arrays.asList(provider.list(new ConcreteResource(loc, dir))));
assertThat(listing.size() > 1, equalTo(true));
assertThat(listing.contains("file1.txt"), equalTo(true));
assertThat(listing.contains("file2.txt"), equalTo(true));
}
use of org.commonjava.maven.galley.model.SimpleLocation in project galley by Commonjava.
the class FastLocalCacheProviderTest method testWriteDeleteAndVerifyNonExistence.
@Test
@BMScript("WriteDeleteAndVerifyNonExistence.btm")
public void testWriteDeleteAndVerifyNonExistence() throws Exception {
final String content = "This is a test";
final Location loc = new SimpleLocation("http://foo.com");
final String fname = "/path/to/my/file.txt";
CountDownLatch latch = new CountDownLatch(2);
start(new WriteFileThread(content, loc, fname, latch));
start(new DeleteFileThread(loc, fname, latch));
latchWait(latch);
assertThat(provider.exists(new ConcreteResource(loc, fname)), equalTo(false));
}
use of org.commonjava.maven.galley.model.SimpleLocation in project galley by Commonjava.
the class FastLocalCacheProviderTest method testLongTimeWaitBeforeClose.
@BMRule(name = "longTimeWaitBeforeCloseTest", targetClass = "FastLocalCacheProvider", targetMethod = "openOutputStream", targetLocation = "EXIT", action = "java.lang.Thread.sleep(60*1000)")
@Test
public void testLongTimeWaitBeforeClose() throws IOException {
final Location loc = new SimpleLocation("http://foo.com");
ConcreteResource resource = new ConcreteResource(loc, String.format("/path/to/my/%s", "file-write-close.text"));
provider.openOutputStream(resource);
provider.cleanupCurrentThread();
}
use of org.commonjava.maven.galley.model.SimpleLocation in project galley by Commonjava.
the class FastLocalCacheProviderTest method testLockThenWaitForUnLock.
@Test
@BMScript("WriteReadLockVerify.btm")
public void testLockThenWaitForUnLock() throws Exception {
final Location loc = new SimpleLocation("http://foo.com");
final String path = "my/path.txt";
final ConcreteResource res = new ConcreteResource(loc, path);
CountDownLatch latch = new CountDownLatch(2);
start(new ReadLockThread(res, latch));
start(new WriteLockThread(res, latch));
latchWait(latch);
assertThat(provider.isWriteLocked(res), equalTo(false));
assertThat(provider.isReadLocked(res), equalTo(false));
}
Aggregations