/**
  * inner test method that expects service extraction to fail -if not prints a meaningful error
  * message.
  *
  * @param hostname hostname to parse
  */
 public static void expectExtractServiceFail(String hostname) {
   try {
     String service = RestClientBindings.extractServiceName(hostname);
     fail("Expected an error -got a service of '" + service + "' from " + hostname);
   } catch (SwiftConfigurationException expected) {
     // expected
   }
 }
 /**
  * inner test method that expects container extraction to fail -if not prints a meaningful error
  * message.
  *
  * @param hostname hostname to parse
  */
 private static void expectExtractContainerFail(String hostname) {
   try {
     String container = RestClientBindings.extractContainerName(hostname);
     fail("Expected an error -got a container of '" + container + "' from " + hostname);
   } catch (SwiftConfigurationException expected) {
     // expected
   }
 }
  @Test
  public void testBindAgainstConf() throws Exception {
    Properties props = RestClientBindings.bind(filesysURI, conf);
    assertPropertyEquals(props, SWIFT_CONTAINER_PROPERTY, CONTAINER);
    assertPropertyEquals(props, SWIFT_SERVICE_PROPERTY, SERVICE);
    assertPropertyEquals(props, SWIFT_AUTH_PROPERTY, AUTH_URL);
    assertPropertyEquals(props, SWIFT_AUTH_PROPERTY, AUTH_URL);
    assertPropertyEquals(props, SWIFT_USERNAME_PROPERTY, USER);
    assertPropertyEquals(props, SWIFT_PASSWORD_PROPERTY, PASS);

    assertPropertyEquals(props, SWIFT_TENANT_PROPERTY, null);
    assertPropertyEquals(props, SWIFT_REGION_PROPERTY, null);
    assertPropertyEquals(props, SWIFT_HTTP_PORT_PROPERTY, null);
    assertPropertyEquals(props, SWIFT_HTTPS_PORT_PROPERTY, null);
  }
 @Test(expected = SwiftConfigurationException.class)
 public void testDottedServiceURL() throws Exception {
   RestClientBindings.bind(new URI("swift://hadoop.apache.org/"), conf);
 }
 @Test(expected = SwiftConfigurationException.class)
 public void testBindAgainstConfIncompleteInstance() throws Exception {
   String instance = RestClientBindings.buildSwiftInstancePrefix(SERVICE);
   conf.unset(instance + DOT_PASSWORD);
   RestClientBindings.bind(filesysURI, conf);
 }
 @Test(expected = SwiftConfigurationException.class)
 public void testBindAgainstConfMissingInstance() throws Exception {
   Configuration badConf = new Configuration();
   RestClientBindings.bind(filesysURI, badConf);
 }
 @Test
 public void testPrefixBuilder() throws Throwable {
   String built = RestClientBindings.buildSwiftInstancePrefix(SERVICE);
   assertEquals("fs.swift.service." + SERVICE, built);
 }
 private void setInstanceVal(Configuration conf, String host, String key, String val) {
   String instance = RestClientBindings.buildSwiftInstancePrefix(host);
   String confkey = instance + key;
   conf.set(confkey, val);
 }
 @Test(expected = SwiftConfigurationException.class)
 public void testMissingServiceURL() throws Exception {
   RestClientBindings.bind(new URI("swift:///"), conf);
 }