use of org.commonjava.maven.galley.model.Location 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.Location 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.Location 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.Location in project galley by Commonjava.
the class FastLocalCacheProviderTest method ConcurrentWriteAndReadFile.
@Test
@BMScript("ConcurrentWriteAndReadFile.btm")
public void ConcurrentWriteAndReadFile() 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 ReadFileThread(loc, fname, latch));
start(new WriteFileThread(content, loc, fname, latch));
latchWait(latch);
assertThat(result, equalTo(content));
}
use of org.commonjava.maven.galley.model.Location in project galley by Commonjava.
the class FileCacheProvider method createAlias.
@Override
public void createAlias(final ConcreteResource from, final ConcreteResource to) throws IOException {
// if the download landed in a different repository, copy it to the current one for
// completeness...
final Location fromKey = from.getLocation();
final Location toKey = to.getLocation();
final String fromPath = from.getPath();
final String toPath = to.getPath();
if (fromKey != null && toKey != null && !fromKey.equals(toKey) && fromPath != null && toPath != null && !fromPath.equals(toPath)) {
if (config.isAliasLinking()) {
final File fromFile = getDetachedFile(from);
final File toFile = getDetachedFile(to);
FileUtils.copyFile(fromFile, toFile);
// Files.createLink( Paths.get( fromFile.toURI() ), Paths.get( toFile.toURI() ) );
} else {
copy(from, to);
}
}
}
Aggregations