use of org.commonjava.maven.galley.model.ConcreteResource in project galley by Commonjava.
the class FastLocalCacheProviderIOTest method testTwoFilesOpenInDiffFolderAndSingleThreadDeSequenceCase1.
/**
* File IO sequence as below: (file1 and file2 NOT in same folder)
*
* file1 open-> file2 open-> file2 close -> file1 close
*/
@Test
public void testTwoFilesOpenInDiffFolderAndSingleThreadDeSequenceCase1() throws IOException {
final String content1 = "This is a test for f1";
final String content2 = "This is a test for f2";
final Location loc = new SimpleLocation("http://foo.com");
final String fname1 = "/path1/to1/my1/file1.txt";
final String fname2 = "/path2/to2/my2/file2.txt";
ConcreteResource resource1 = new ConcreteResource(loc, fname1);
OutputStream out1 = writeWithoutClose(resource1, content1);
ConcreteResource resource2 = new ConcreteResource(loc, fname2);
OutputStream out2 = writeWithoutClose(resource2, content2);
out2.close();
provider.unlockWrite(resource2);
out1.close();
provider.unlockWrite(resource1);
String result1 = readWithClose(resource1);
assertThat(result1, equalTo(content1));
String result2 = readWithClose(resource2);
assertThat(result2, equalTo(content2));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project galley by Commonjava.
the class FastLocalCacheProviderIOTest method testTwoFilesOpenInSameFolderAndSingleThreadInSequence.
/**
* File IO sequence as below: (file1 and file2 in same folder)
*
* file1 open-> file1 close-> file2 open-> file2 close
*/
@Test
public void testTwoFilesOpenInSameFolderAndSingleThreadInSequence() throws IOException {
final String content1 = "This is a test for f1";
final String content2 = "This is a test for f2";
final Location loc = new SimpleLocation("http://foo.com");
final String fname1 = "/path/to/my/file1.txt";
final String fname2 = "/path/to/my/file2.txt";
ConcreteResource resource1 = new ConcreteResource(loc, fname1);
writeWithClose(resource1, content1);
ConcreteResource resource2 = new ConcreteResource(loc, fname2);
writeWithClose(resource2, content2);
String result1 = readWithClose(resource1);
assertThat(result1, equalTo(content1));
String result2 = readWithClose(resource2);
assertThat(result2, equalTo(content2));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project galley by Commonjava.
the class FastLocalCacheProviderIOTest method testTwoFilesOpenInDiffFolderAndSingleThreadInSequence.
/**
* File IO sequence as below: (file1 and file2 NOT in same folder)
*
* file1 open-> file1 close-> file2 open-> file2 close
*/
@Test
public void testTwoFilesOpenInDiffFolderAndSingleThreadInSequence() throws IOException {
final String content1 = "This is a test for f1";
final String content2 = "This is a test for f2";
final Location loc = new SimpleLocation("http://foo.com");
final String fname1 = "/path1/to1/my1/file1.txt";
final String fname2 = "/path2/to2/my2/file2.txt";
ConcreteResource resource1 = new ConcreteResource(loc, fname1);
writeWithClose(resource1, content1);
ConcreteResource resource2 = new ConcreteResource(loc, fname2);
writeWithClose(resource2, content2);
String result1 = readWithClose(resource1);
assertThat(result1, equalTo(content1));
String result2 = readWithClose(resource2);
assertThat(result2, equalTo(content2));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project galley by Commonjava.
the class FastLocalCacheProviderIOTest 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.ConcreteResource in project galley by Commonjava.
the class FastLocalCacheProviderIOTest method testTwoFilesOpenInSameFolderAndSingleThreadDeSequenceCase1.
/**
* File IO sequence as below: (file1 and file2 in same folder)
*
* file1 open-> file2 open-> file2 close -> file1 close
*/
@Test
public void testTwoFilesOpenInSameFolderAndSingleThreadDeSequenceCase1() throws IOException {
final String content1 = "This is a test for f1";
final String content2 = "This is a test for f2";
final Location loc = new SimpleLocation("http://foo.com");
final String fname1 = "/path/to/my/file1.txt";
final String fname2 = "/path/to/my/file2.txt";
ConcreteResource resource1 = new ConcreteResource(loc, fname1);
OutputStream out1 = writeWithoutClose(resource1, content1);
ConcreteResource resource2 = new ConcreteResource(loc, fname2);
OutputStream out2 = writeWithoutClose(resource2, content2);
out2.close();
provider.unlockWrite(resource2);
out1.close();
provider.unlockWrite(resource1);
String result1 = readWithClose(resource1);
assertThat(result1, equalTo(content1));
String result2 = readWithClose(resource2);
assertThat(result2, equalTo(content2));
}
Aggregations