Tabnine Logo
TestContext.failIteration
Code IndexAdd Tabnine to your IDE (free)

How to use
failIteration
method
in
com.vmware.xenon.common.test.TestContext

Best Java code snippets using com.vmware.xenon.common.test.TestContext.failIteration (Showing top 20 results out of 315)

origin: vmware/xenon

public <T> BiConsumer<T, ? super Throwable> getCompletionDeferred() {
  return (ignore, e) -> {
    if (e != null) {
      if (e instanceof CompletionException) {
        e = e.getCause();
      }
      failIteration(e);
      return;
    }
    completeIteration();
  };
}
origin: com.vmware.xenon/xenon-common

public <T> BiConsumer<T, ? super Throwable> getCompletionDeferred() {
  return (ignore, e) -> {
    if (e != null) {
      if (e instanceof CompletionException) {
        e = e.getCause();
      }
      failIteration(e);
      return;
    }
    completeIteration();
  };
}
origin: com.vmware.xenon/xenon-common

public CompletionHandler getSafeHandler(TestContext ctx, CompletionHandler handler) {
  return (o, e) -> {
    try {
      handler.handle(o, e);
      ctx.completeIteration();
    } catch (Throwable t) {
      ctx.failIteration(t);
    }
  };
}
origin: vmware/xenon

public CompletionHandler getSafeHandler(TestContext ctx, CompletionHandler handler) {
  return (o, e) -> {
    try {
      handler.handle(o, e);
      ctx.completeIteration();
    } catch (Throwable t) {
      ctx.failIteration(t);
    }
  };
}
origin: vmware/xenon

private <T> BiConsumer<T, ? super Throwable> getExpectedExceptionCompletion(TestContext ctx) {
  return (ignore, ex) -> {
    try {
      Assert.assertNotNull(ex);
      if (ex instanceof CompletionException) {
        Assert.assertNotNull(ex.getCause());
        ex = ex.getCause();
      }
      Assert.assertEquals(TestException.class, ex.getClass());
      ctx.completeIteration();
    } catch (Throwable e) {
      ctx.failIteration(e);
    }
  };
}
origin: com.vmware.xenon/xenon-common

private <T> BiConsumer<T, ? super Throwable> getExpectedExceptionCompletion(TestContext ctx) {
  return (ignore, ex) -> {
    try {
      Assert.assertNotNull(ex);
      if (ex instanceof CompletionException) {
        Assert.assertNotNull(ex.getCause());
        ex = ex.getCause();
      }
      Assert.assertEquals(TestException.class, ex.getClass());
      ctx.completeIteration();
    } catch (Throwable e) {
      ctx.failIteration(e);
    }
  };
}
origin: vmware/xenon

public void failIteration(Throwable e) {
  if (this.isSingleton) {
    throw new IllegalStateException("Use startTest on singleton, shared host instances");
  }
  if (isStopping()) {
    log("Received completion after stop");
    return;
  }
  TestContext ctx = this.context;
  if (ctx == null) {
    log("Test finished, ignoring completion. This might indicate wrong count was used in testStart(count)");
    return;
  }
  log("test failed: %s", e.toString());
  ctx.failIteration(e);
}
origin: com.vmware.xenon/xenon-common

public void failIteration(Throwable e) {
  if (this.isSingleton) {
    throw new IllegalStateException("Use startTest on singleton, shared host instances");
  }
  if (isStopping()) {
    log("Received completion after stop");
    return;
  }
  TestContext ctx = this.context;
  if (ctx == null) {
    log("Test finished, ignoring completion. This might indicate wrong count was used in testStart(count)");
    return;
  }
  log("test failed: %s", e.toString());
  ctx.failIteration(e);
}
origin: vmware/admiral

private <T> T doGet(TestManagementHost host, Class<T> clazz, URI uri) throws Throwable {
  TestContext ctx = BaseTestCase.testCreate(1);
  AtomicReference<T> result = new AtomicReference<>();
  Operation op = Operation.createGet(uri)
      .setReferer(host.getUri())
      .setCompletion((o, e) -> {
        if (e == null) {
          result.set(o.getBody(clazz));
          ctx.completeIteration();
        } else {
          ctx.failIteration(e);
        }
      });
  host.sendRequest(op);
  ctx.await();
  return result.get();
}
origin: vmware/admiral

@Test
public void testInvalidSessionShouldFail() {
  TestContext ctx = testCreate(1);
  Operation get = Operation.createGet(host, ManagementUriParts.AUTH_LOGOUT)
      .setReferer(host.getUri())
      .setCompletion((o, ex) -> {
        if (ex != null && ex instanceof IllegalAccessError) {
          ctx.completeIteration();
          return;
        }
        ctx.failIteration(new IllegalStateException());
      });
  host.send(get);
  ctx.await();
}
origin: vmware/admiral

protected SecurityContext getSecurityContext() {
  final SecurityContext[] context = new SecurityContext[1];
  TestContext ctx = testCreate(1);
  host.send(Operation.createGet(host, SessionService.SELF_LINK)
      .setCompletion((o, ex) -> {
        if (ex != null) {
          ctx.failIteration(ex);
          return;
        }
        context[0] = o.getBody(SecurityContext.class);
        ctx.completeIteration();
      }));
  ctx.await();
  return context[0];
}
origin: vmware/admiral

private <T> void doDelete(TestManagementHost host, URI uri) throws Throwable {
  TestContext ctx = BaseTestCase.testCreate(1);
  Operation op = Operation.createDelete(uri)
      .setReferer(host.getUri())
      .setCompletion((o, e) -> {
        if (e == null) {
          ctx.completeIteration();
        } else {
          ctx.failIteration(e);
        }
      });
  host.sendRequest(op);
  ctx.await();
}
origin: vmware/admiral

protected SecurityContext getSecurityContext(String principalId) {
  final SecurityContext[] context = new SecurityContext[1];
  TestContext ctx = testCreate(1);
  host.send(Operation.createGet(host, UriUtils.buildUriPath(PrincipalService.SELF_LINK,
      principalId, PrincipalService.SECURITY_CONTEXT_SUFFIX))
      .setCompletion((o, ex) -> {
        if (ex != null) {
          ctx.failIteration(ex);
          return;
        }
        context[0] = o.getBody(SecurityContext.class);
        ctx.completeIteration();
      }));
  ctx.await();
  return context[0];
}
origin: vmware/xenon

private void updateExampleService(String txid, URI exampleServiceUri,
    ExampleServiceState exampleServiceState) throws Throwable {
  TestContext ctx = testCreate(1);
  Operation put = Operation
      .createPut(exampleServiceUri)
      .setTransactionId(txid)
      .setBody(exampleServiceState)
      .setCompletion((o, e) -> {
        if (e != null) {
          ctx.failIteration(e);
          return;
        }
        ctx.completeIteration();
      });
  this.defaultHost.send(put);
  testWait(ctx);
}
origin: vmware/admiral

private void queryTemplateImages() {
  TestContext ctx = BaseTestCase.testCreate(1);
  host.sendRequest(Operation.createGet(UriUtils.buildUri(host,
      templateQuery))
      .setReferer(host.getUri())
      .setCompletion((o, ex) -> {
        if (ex != null) {
          ctx.failIteration(ex);
        } else {
          ctx.completeIteration();
        }
      }));
  ctx.await();
}
origin: vmware/admiral

public void delete(String selfLink) throws Throwable {
  TestContext ctx = testCreate(1);
  Operation delete = Operation
      .createDelete(UriUtils.buildUri(host, selfLink))
      .setBody(new ServiceDocument())
      .setCompletion((o, e) -> {
        if (e != null) {
          ctx.failIteration(e);
          return;
        }
        ctx.completeIteration();
      });
  host.send(delete);
  ctx.await();
}
origin: vmware/admiral

public void deleteUser(String user) {
  TestContext ctx = testCreate(1);
  Operation delete = Operation.createDelete(host, AuthUtil
      .buildUserServicePathFromPrincipalId(user))
      .setReferer(host.getUri())
      .setCompletion((o, ex) -> {
        if (ex != null) {
          ctx.failIteration(ex);
          return;
        }
        ctx.completeIteration();
      });
  host.send(delete);
  ctx.await();
}
origin: vmware/admiral

public void deleteUserGroup(String userGroup) {
  TestContext ctx = testCreate(1);
  Operation delete = Operation
      .createDelete(host, UriUtils.buildUriPath(UserGroupService.FACTORY_LINK, userGroup))
      .setReferer(host.getUri())
      .setCompletion((o, ex) -> {
        if (ex != null) {
          ctx.failIteration(ex);
          return;
        }
        ctx.completeIteration();
      });
  host.send(delete);
  ctx.await();
}
origin: vmware/admiral

protected void doPatch(Object state, String documentSelfLink) {
  TestContext ctx = testCreate(1);
  Operation patch = Operation.createPatch(host, documentSelfLink)
      .setBody(state)
      .setReferer(host.getUri())
      .setCompletion((o, ex) -> {
        if (ex != null) {
          ctx.failIteration(ex);
          return;
        }
        ctx.completeIteration();
      });
  host.send(patch);
  ctx.await();
}
origin: vmware/admiral

@Override
protected void doPatch(Object state, String documentSelfLink) {
  TestContext ctx = testCreate(1);
  Operation patch = Operation.createPatch(host, documentSelfLink)
      .setBody(state)
      .setReferer(host.getUri())
      .setCompletion((o, ex) -> {
        if (ex != null) {
          ctx.failIteration(ex);
          return;
        }
        ctx.completeIteration();
      });
  host.send(patch);
  ctx.await();
}
com.vmware.xenon.common.testTestContextfailIteration

Javadoc

Consider using #fail(Throwable). This method exists for backward compatibility, and may be deprecated/deleted in future.

Popular methods of TestContext

  • await
  • fail
  • completeIteration
    Consider using #complete(). This method exists for backward compatibility, and may be deprecated/del
  • <init>
  • complete
  • getCompletion
  • create
    Consider using #TestContext(int,Duration)This method exists for backward compatibility, and may be d
  • getExpectedFailureCompletion
  • getCompletionDeferred
  • logAfter
  • logBefore
  • setCheckInterval
  • logBefore,
  • setCheckInterval,
  • setTestName,
  • waitFor

Popular in Java

  • Start an intent from android
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • notifyDataSetChanged (ArrayAdapter)
  • String (java.lang)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • JTable (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now