コード例 #1
0
    @Test(dataProvider = "ValidStartStates")
    public void testValidStartState(String containerId) throws Throwable {
      ContainerService.State startState = TestHelper.getContainerServiceStartState();
      startState.containerId = containerId;
      Operation startOperation = testHost.startServiceSynchronously(containerService, startState);
      assertThat(startOperation.getStatusCode(), is(200));

      ContainerService.State savedState = testHost.getServiceState(ContainerService.State.class);
      assertThat(savedState.containerTemplateServiceLink, is("CONTAINER_TEMPLATE_SERVICE_LINK"));
      assertThat(savedState.vmServiceLink, is("VM_SERVICE_LINK"));
      assertThat(savedState.containerId, is(containerId));
    }
コード例 #2
0
    @Test(expectedExceptions = XenonRuntimeException.class)
    public void testInvalidPatchStateOverwriteExistingContainerId() throws Throwable {
      ContainerService.State startState = TestHelper.getContainerServiceStartState();
      startState.containerId = "CONTAINER_ID";
      Operation startOperation = testHost.startServiceSynchronously(containerService, startState);
      assertThat(startOperation.getStatusCode(), is(200));

      ContainerService.State patchState = new ContainerService.State();
      patchState.containerId = "CONTAINER_ID";

      Operation patchOperation =
          Operation.createPatch(UriUtils.buildUri(testHost, TestHost.SERVICE_URI, null))
              .setBody(patchState);

      testHost.sendRequestAndWait(patchOperation);
    }
コード例 #3
0
    @Test(dataProvider = "ValidContainerIdPatchValues")
    public void testValidPatchStateContainerIdFieldSet(String containerId) throws Throwable {
      createContainerService();
      ContainerService.State patchState = new ContainerService.State();
      patchState.containerId = containerId;

      Operation patchOperation =
          Operation.createPatch(UriUtils.buildUri(testHost, TestHost.SERVICE_URI, null))
              .setBody(patchState);

      Operation patchResult = testHost.sendRequestAndWait(patchOperation);
      assertThat(patchResult.getStatusCode(), is(200));

      ContainerService.State savedState = testHost.getServiceState(ContainerService.State.class);
      assertThat(savedState.containerId, is(containerId));
    }
コード例 #4
0
 @AfterMethod
 public void tearDownTest() throws Throwable {
   try {
     testHost.deleteServiceSynchronously();
   } catch (ServiceHost.ServiceNotFoundException e) {
     // Exceptions are expected in the case where a service instance was not successfully
     // created.
   }
 }
コード例 #5
0
    @Test(
        expectedExceptions = XenonRuntimeException.class,
        dataProvider = "fieldNamesWithMissingValue")
    public void testMissingRequiredStateFieldValue(String fieldName) throws Throwable {
      ContainerService.State startState = TestHelper.getContainerServiceStartState();
      Field declaredField = startState.getClass().getDeclaredField(fieldName);
      declaredField.set(startState, null);

      testHost.startServiceSynchronously(containerService, startState);
    }
コード例 #6
0
    @Test(expectedExceptions = XenonRuntimeException.class)
    public void testInvalidPatchStateVmServiceLinkFieldSet() throws Throwable {
      createContainerService();
      ContainerService.State patchState = new ContainerService.State();
      patchState.vmServiceLink = "VM_SERVICE_LINK";

      Operation patchOperation =
          Operation.createPatch(UriUtils.buildUri(testHost, TestHost.SERVICE_URI, null))
              .setBody(patchState);

      testHost.sendRequestAndWait(patchOperation);
    }
コード例 #7
0
 @AfterClass
 public void tearDownClass() throws Throwable {
   TestHost.destroy(testHost);
 }
コード例 #8
0
 @BeforeClass
 public void setUpClass() throws Throwable {
   testHost = TestHost.create();
 }
コード例 #9
0
 @AfterMethod
 public void tearDownTest() throws Throwable {
   testHost.deleteServiceSynchronously();
 }
コード例 #10
0
 private void createContainerService() throws Throwable {
   ContainerService.State startState = TestHelper.getContainerServiceStartState();
   Operation startOperation = testHost.startServiceSynchronously(containerService, startState);
   assertThat(startOperation.getStatusCode(), is(200));
 }