Package org.apache.deltacloud.client

Examples of org.apache.deltacloud.client.Key


  @Test
  public void canCreateKey() throws DeltaCloudClientException {
    String id = "test" + System.currentTimeMillis();
    DeltaCloudClient client = testSetup.getClient();
    try {
      Key key = client.createKey(id);
      assertNotNull(key);
      assertEquals(id, key.getId());
    } finally {
      quietlyDeleteKey(id);
    }
  }
View Full Code Here


   */
  @Test(expected = DeltaCloudNotFoundClientException.class)
  public void canDeleteKey() throws DeltaCloudClientException {
    String id = "test" + System.currentTimeMillis();
    DeltaCloudClient client = testSetup.getClient();
    Key key = client.createKey(id);
    assertNotNull(key);
    assertEquals(id, key.getId());
    key.destroy(client);
    client.listKey(key.getId());
  }
View Full Code Here

  @Test
  public void canListKey() throws DeltaCloudClientException {
    String id = String.valueOf(System.currentTimeMillis());
    DeltaCloudClient client = testSetup.getClient();
    try {
      Key createdKey = client.createKey(id);
      Key listedKey = client.listKey(id);
      assertEquals(createdKey.getId(), listedKey.getId());
    } finally {
      quietlyDeleteKey(id);
    }
  }
View Full Code Here

  @Test
  public void canListKeys() throws DeltaCloudClientException {
    String id = String.valueOf(System.currentTimeMillis());
    DeltaCloudClient client = testSetup.getClient();
    try {
      final Key createdKey = client.createKey(id);
      List<Key> keys = client.listKeys();
      assertNotNull(keys);
      assertThat(keys, hasItem(new BaseMatcher<Key>() {

        @Override
        public boolean matches(Object item) {
          if (item instanceof Key) {
            Key listedKey = (Key) item;
            return
              createdKey.getId().equals(listedKey.getId())
                  && createdKey.getFingerprint().equals(listedKey.getFingerprint())
                  && createdKey.getPem().equals(listedKey.getPem())
                  && createdKey.getUrl().equals(listedKey.getUrl())
                  && createdKey.getActions().size() == listedKey.getActions().size();
            }
            return false;
          }

        @Override
View Full Code Here

  }

  private void quietlyDeleteKey(String id) {
    try {
      DeltaCloudClient client = testSetup.getClient();
      Key key = client.listKey(id);
      key.destroy(client);
    } catch (Exception e) {
      // ignore
    }
  }
View Full Code Here

    assertEquals(KeyActionResponse.method.toUpperCase(), keyAction.getMethod().toString().toUpperCase());
  }

  @Test
  public void keyMayBeUnmarshalled() throws MalformedURLException, JAXBException, DeltaCloudClientException {
    Key key = new Key();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(KeyResponse.keyResponse.getBytes());
    new KeyUnmarshaller().unmarshall(inputStream, key);
    assertNotNull(key);
    assertEquals(KeyResponseFakes.KeyResponse.id, key.getId());
    assertEquals(KeyResponse.fingerprint, key.getFingerprint());
    assertEquals(new URL(KeyResponse.url), key.getUrl());
    assertEquals(KeyResponse.pem, key.getPem());
    assertEquals(1, key.getActions().size());
    Action<Key> action = key.getActions().get(0);
    assertNotNull(action);
    assertEquals(KeyResponse.url, action.getUrl().toString());
    assertEquals(KeyResponse.name, action.getName());
    assertEquals(HttpMethod.valueOf(KeyResponse.method.toUpperCase()), action.getMethod());
  }
View Full Code Here

  public void keysMayBeUnmarshalled() throws MalformedURLException, JAXBException, DeltaCloudClientException {
    ByteArrayInputStream inputStream = new ByteArrayInputStream(KeysResponse.keysResponse.getBytes());
    List<Key> keys = new ArrayList<Key>();
    new KeysUnmarshaller().unmarshall(inputStream, keys);
    assertEquals(2, keys.size());
    Key key = keys.get(0);
    assertEquals(KeysResponse.id1, key.getId());
    assertEquals(KeysResponse.fingerprint1, key.getFingerprint());
    assertEquals(new URL(KeysResponse.url1), key.getUrl());
    assertEquals(KeysResponse.pem1, key.getPem());
    assertEquals(1, key.getActions().size());
    Action<Key> action = key.getActions().get(0);
    assertNotNull(action);
    assertEquals(KeysResponse.url1, action.getUrl().toString());
    assertEquals(KeysResponse.name1, action.getName());
    assertEquals(HttpMethod.valueOf(KeysResponse.method1.toUpperCase()), action.getMethod());
  }
View Full Code Here

    super("keys", "key");
  }

  @Override
  protected Key unmarshallChild(Node node) throws DeltaCloudClientException {
    Key key = new KeyUnmarshaller().unmarshall((Element) node, new Key());
    return key;
  }
View Full Code Here

TOP

Related Classes of org.apache.deltacloud.client.Key

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.