Package org.apache.deltacloud.client

Examples of org.apache.deltacloud.client.Instance


    assertEquals(State.STOPPED, testInstance.getState());
  }

  @Test
  public void canStartInstance() throws DeltaCloudClientException {
    Instance testInstance = testSetup.getTestInstance();
    DeltaCloudClient client = testSetup.getClient();
    if (testInstance.getState() == State.RUNNING) {
      testInstance.stop(client);
    }
    testInstance.start(client);
    testInstance = client.listInstances(testInstance.getId()); // reload!
    assertEquals(State.RUNNING, testInstance.getState());
  }
View Full Code Here


    assertEquals(State.RUNNING, testInstance.getState());
  }

  @Test
  public void canStartInstanceByAction() throws DeltaCloudClientException {
    Instance testInstance = testSetup.getTestInstance();
    DeltaCloudClient client = testSetup.getClient();
    if (testInstance.getState() == State.RUNNING) {
      testInstance.stop(client);
    }
    assertTrue(testInstance.start(client));
    testInstance = client.listInstances(testInstance.getId()); // reload!
    assertEquals(State.RUNNING, testInstance.getState());
  }
View Full Code Here

    assertEquals(State.RUNNING, testInstance.getState());
  }

  @Test
  public void cannotStartRunningInstance() throws DeltaCloudClientException {
    Instance testInstance = testSetup.getTestInstance();
    DeltaCloudClient client = testSetup.getClient();
    testInstance.start(client);
    assertFalse(testInstance.start(client));
  }
View Full Code Here

    assertFalse(testInstance.start(client));
  }

  @Test
  public void cannotStopStoppedInstance() throws DeltaCloudClientException {
    Instance testInstance = testSetup.getTestInstance();
    DeltaCloudClient client = testSetup.getClient();
    try {
      testInstance.stop(client);
      assertFalse(testInstance.stop(client));
    } finally {
      testInstance.start(client);
    }
  }
View Full Code Here

    }
  }

  @Test
  public void cannotDestroyRunningInstance() throws DeltaCloudClientException {
    Instance testInstance = testSetup.getTestInstance();
    DeltaCloudClient client = testSetup.getClient();
    testInstance = client.listInstances(testInstance.getId()); // reload
    assertTrue(testInstance.getState() == State.RUNNING);
    assertFalse(testInstance.destroy(client));
  }
View Full Code Here

    assertEquals(InstanceActionResponse.method.toUpperCase(), instanceAction.getMethod().toString().toUpperCase());
  }

  @Test
  public void instanceMayBeUnmarshalled() throws DeltaCloudClientException {
    Instance instance = new Instance();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(InstanceResponse.response.getBytes());
    new InstanceUnmarshaller().unmarshall(inputStream, instance);
    assertNotNull(instance);
    assertEquals(InstanceResponse.id1, instance.getId());
    assertEquals(InstanceResponse.name1, instance.getName());
    assertEquals(InstanceResponse.ownerId1, instance.getOwnerId());
    assertEquals(InstanceResponse.image1Id, instance.getImageId());
    assertEquals(InstanceResponse.hardwareProfile1Id, instance.getProfileId());
    assertEquals(InstanceResponse.realm1Id, instance.getRealmId());
    assertEquals(InstanceResponse.state, instance.getState());
    assertEquals(InstanceResponse.keyname1, instance.getKeyId());
    assertEquals(2, instance.getActions().size());
    assertEquals(InstanceResponse.actionNameStop, instance.getActions().get(0).getName());
    assertEquals(InstanceResponse.actionNameReboot, instance.getActions().get(1).getName());
    assertEquals(1, instance.getPublicAddresses().size());
    assertEquals(InstanceResponse.publicAddress1, instance.getPublicAddresses().get(0));
    assertEquals(1, instance.getPrivateAddresses().size());
    assertEquals(InstanceResponse.privateAddress1, instance.getPrivateAddresses().get(0));

  }
View Full Code Here

    ByteArrayInputStream inputStream = new ByteArrayInputStream(InstancesResponse.response.getBytes());
    List<Instance> instances = new ArrayList<Instance>();
    new InstancesUnmarshaller().unmarshall(inputStream, instances);
    assertEquals(2, instances.size());

    Instance instance = instances.get(0);
    assertEquals(InstancesResponse.id1, instance.getId());
    assertEquals(InstancesResponse.name1, instance.getName());

    instance = instances.get(1);
    assertEquals(InstancesResponse.id2, instance.getId());
    assertEquals(InstancesResponse.name2, instance.getName());
    assertEquals(2, instance.getActions().size());
  }
View Full Code Here

    super("instances", "instance");
  }

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

TOP

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

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.