use of org.apache.hadoop.fs.swift.util.SwiftObjectPath in project hadoop by apache.
the class TestSwiftObjectPath method testRootDirProbeRootPath.
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testRootDirProbeRootPath() throws Throwable {
SwiftObjectPath object = new SwiftObjectPath("container", "/");
assertTrue(SwiftUtils.isRootDir(object));
}
use of org.apache.hadoop.fs.swift.util.SwiftObjectPath in project hadoop by apache.
the class TestSwiftObjectPath method testRootDirProbeEmptyPath.
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testRootDirProbeEmptyPath() throws Throwable {
SwiftObjectPath object = new SwiftObjectPath("container", "");
assertTrue(SwiftUtils.isRootDir(object));
}
use of org.apache.hadoop.fs.swift.util.SwiftObjectPath in project hadoop by apache.
the class TestSwiftObjectPath method testChildOfProbe.
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testChildOfProbe() throws Throwable {
SwiftObjectPath parent = new SwiftObjectPath("container", "/parent");
SwiftObjectPath parent2 = new SwiftObjectPath("container", "/parent2");
SwiftObjectPath child = new SwiftObjectPath("container", "/parent/child");
SwiftObjectPath sibling = new SwiftObjectPath("container", "/parent/sibling");
SwiftObjectPath grandchild = new SwiftObjectPath("container", "/parent/child/grandchild");
assertParentOf(parent, child);
assertParentOf(parent, grandchild);
assertParentOf(child, grandchild);
assertParentOf(parent, parent);
assertNotParentOf(child, parent);
assertParentOf(child, child);
assertNotParentOf(parent, parent2);
assertNotParentOf(grandchild, parent);
}
use of org.apache.hadoop.fs.swift.util.SwiftObjectPath in project hadoop by apache.
the class TestSwiftObjectPath method testParseUrlPath.
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testParseUrlPath() throws Exception {
final String pathString = "swift://container.service1/home/user/files/file1";
final URI uri = new URI(pathString);
final Path path = new Path(pathString);
final SwiftObjectPath expected = SwiftObjectPath.fromPath(uri, path);
final SwiftObjectPath actual = new SwiftObjectPath(RestClientBindings.extractContainerName(uri), "/home/user/files/file1");
assertEquals(expected, actual);
}
use of org.apache.hadoop.fs.swift.util.SwiftObjectPath in project hadoop by apache.
the class TestSwiftRestClient method testPutAndDelete.
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testPutAndDelete() throws Throwable {
assumeEnabled();
SwiftRestClient client = createClient();
client.authenticate();
Path path = new Path("restTestPutAndDelete");
SwiftObjectPath sobject = SwiftObjectPath.fromPath(serviceURI, path);
byte[] stuff = new byte[1];
stuff[0] = 'a';
client.upload(sobject, new ByteArrayInputStream(stuff), stuff.length);
//check file exists
Duration head = new Duration();
Header[] responseHeaders = client.headRequest("expect success", sobject, SwiftRestClient.NEWEST);
head.finished();
LOG.info("head request duration " + head);
for (Header header : responseHeaders) {
LOG.info(header.toString());
}
//delete the file
client.delete(sobject);
//check file is gone
try {
Header[] headers = client.headRequest("expect fail", sobject, SwiftRestClient.NEWEST);
Assert.fail("Expected deleted file, but object is still present: " + sobject);
} catch (FileNotFoundException e) {
//expected
}
for (DurationStats stats : client.getOperationStatistics()) {
LOG.info(stats);
}
}
Aggregations