use of org.commonjava.maven.galley.model.ConcreteResource in project galley by Commonjava.
the class EmbeddableCDI_HTTPDownload_Test method resolveFileViaHttp.
@Test
public void resolveFileViaHttp() throws Exception {
String path = "/path/to/file.txt";
String content = "this is a test.";
server.expect(path, 200, content);
Transfer transfer = transfers.retrieve(new ConcreteResource(new SimpleLocation(server.getBaseUri()), path));
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.ConcreteResource in project galley by Commonjava.
the class CacheProviderTCK method writeAndVerifyExistence.
@Test
public void writeAndVerifyExistence() 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";
final CacheProvider provider = getCacheProvider();
final OutputStream out = provider.openOutputStream(new ConcreteResource(loc, fname));
out.write(content.getBytes("UTF-8"));
out.close();
assertThat(provider.exists(new ConcreteResource(loc, fname)), equalTo(true));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project galley by Commonjava.
the class CacheProviderTCK method lockThenWaitForLockReturnsImmediatelyInSameThread.
@Test
public void lockThenWaitForLockReturnsImmediatelyInSameThread() throws Exception {
final Location loc = new SimpleLocation("http://foo.com");
final String path = "my/path.txt";
final ConcreteResource res = new ConcreteResource(loc, path);
final CacheProvider cache = getCacheProvider();
cache.lockWrite(res);
cache.waitForWriteUnlock(res);
assertThat(cache.isWriteLocked(res), equalTo(false));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project galley by Commonjava.
the class CacheProviderTCK method writeAndVerifyDirectory.
@Test
public void writeAndVerifyDirectory() 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 fname = dir + "file.txt";
final CacheProvider provider = getCacheProvider();
final OutputStream out = provider.openOutputStream(new ConcreteResource(loc, fname));
out.write(content.getBytes("UTF-8"));
out.close();
assertThat(provider.isDirectory(new ConcreteResource(loc, dir)), equalTo(true));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project galley by Commonjava.
the class FastLocalCacheProviderConcurrentTest method testBothReadWithNFS.
@Test
public void testBothReadWithNFS() throws Exception {
final ConcreteResource resource = createTestResource("file_both_read_has_only_NFS.txt");
prepareNFSResource(resource, content);
final Future<String> readingFuture1 = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch));
final Future<String> readingFuture2 = testPool.submit((Callable<String>) new ReadTask(provider, content, resource, latch));
latchWait(latch);
final String readingResult1 = readingFuture1.get();
assertThat(readingResult1, equalTo(content));
final String readingResult2 = readingFuture2.get();
assertThat(readingResult2, equalTo(content));
}
Aggregations