congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
TestContext.complete
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: com.vmware.xenon/xenon-common

/**
 * Consider using {@link #complete()}.
 * This method exists for backward compatibility, and may be deprecated/deleted in future.
 */
public void completeIteration() {
  complete();
}
origin: vmware/xenon

/**
 * Consider using {@link #complete()}.
 * This method exists for backward compatibility, and may be deprecated/deleted in future.
 */
public void completeIteration() {
  complete();
}
origin: vmware/xenon

public CompletionHandler getCompletion() {
  return (o, e) -> {
    if (e != null) {
      this.fail(e);
    } else {
      this.complete();
    }
  };
}
origin: com.vmware.xenon/xenon-common

public CompletionHandler getCompletion() {
  return (o, e) -> {
    if (e != null) {
      this.fail(e);
    } else {
      this.complete();
    }
  };
}
origin: vmware/xenon

public CompletionHandler getExpectedFailureCompletion() {
  return (o, e) -> {
    if (e != null) {
      this.complete();
    } else {
      this.fail(new IllegalStateException("got success, expected failure"));
    }
  };
}
origin: com.vmware.xenon/xenon-common

public CompletionHandler getExpectedFailureCompletion() {
  return (o, e) -> {
    if (e != null) {
      this.complete();
    } else {
      this.fail(new IllegalStateException("got success, expected failure"));
    }
  };
}
origin: vmware/admiral

public static void runParallel(ExecutorService es, long timeoutSeconds, int count,
    RunnableWithThrowable runnable) {
  TestContext tc = TestContext.create(count, TimeUnit.SECONDS.toMicros(timeoutSeconds));
  for (int i = 0; i < count; i++) {
    int i2 = i;
    es.submit(() -> {
      try {
        runnable.run(i2);
        tc.complete();
      } catch (Throwable e) {
        tc.fail(e);
      }
    });
  }
  tc.await();
}
origin: vmware/xenon

  @Override
  public void handleRequest(Operation update) {
    update.complete();
    if (update.getAction().equals(Action.PATCH)) {
      if (update.getUri().getHost() == null) {
        oneUseNotificationCtx.fail(new IllegalStateException(
            "Notification URI does not have host specified"));
        return;
      }
      oneUseNotificationCtx.complete();
    }
  }
};
origin: com.vmware.xenon/xenon-common

  @Override
  public void handleRequest(Operation update) {
    update.complete();
    if (update.getAction().equals(Action.PATCH)) {
      if (update.getUri().getHost() == null) {
        oneUseNotificationCtx.fail(new IllegalStateException(
            "Notification URI does not have host specified"));
        return;
      }
      oneUseNotificationCtx.complete();
    }
  }
};
origin: vmware/xenon

private void traversePageLinks(TestContext ctx, String nextPageLink, List<String> nextPageLinks) {
  nextPageLinks.add(nextPageLink);
  Operation get = Operation.createGet(this.host, nextPageLink)
      .setCompletion((o, e) -> {
        if (e != null) {
          ctx.fail(e);
          return;
        }
        QueryTask page = o.getBody(QueryTask.class);
        if (page.results.nextPageLink == null) {
          ctx.complete();
          return;
        }
        traversePageLinks(ctx, page.results.nextPageLink, nextPageLinks);
      });
  this.host.send(get);
}
origin: com.vmware.xenon/xenon-common

private void traversePageLinks(TestContext ctx, String nextPageLink, List<String> nextPageLinks) {
  nextPageLinks.add(nextPageLink);
  Operation get = Operation.createGet(this.host, nextPageLink)
      .setCompletion((o, e) -> {
        if (e != null) {
          ctx.fail(e);
          return;
        }
        QueryTask page = o.getBody(QueryTask.class);
        if (page.results.nextPageLink == null) {
          ctx.complete();
          return;
        }
        traversePageLinks(ctx, page.results.nextPageLink, nextPageLinks);
      });
  this.host.send(get);
}
origin: vmware/xenon

private void patchExampleServices(Map<URI, ExampleServiceState> states, int count)
    throws Throwable {
  TestContext ctx = this.host.testCreate(states.size() * count);
  for (ExampleServiceState st : states.values()) {
    for (int i = 0; i < count; i++) {
      st.name = "updated" + Utils.getNowMicrosUtc() + "";
      Operation patch = Operation
          .createPatch(UriUtils.buildUri(this.host, st.documentSelfLink))
          .setCompletion((o, e) -> {
            if (e != null) {
              ctx.fail(e);
              return;
            }
            ctx.complete();
          }).setBody(st);
      this.host.send(patch);
    }
  }
  this.host.testWait(ctx);
}
origin: vmware/admiral

@Test
public void testEmptyEndpoint() {
  TestContext ctx = testCreate(1);
  List<PKSPlan> plans = new ArrayList<>();
  Operation get = Operation.createGet(host, PKSPlanListService.SELF_LINK)
      .setCompletion((op, ex) -> {
        if (ex != null) {
          assertEquals(Operation.STATUS_CODE_BAD_REQUEST, op.getStatusCode());
          ctx.complete();
          return;
        }
        ctx.fail(null);
      });
  sender.sendRequest(get);
  ctx.await();
}
origin: vmware/xenon

@Test
public void testGetNowWithValue() throws Throwable {
  TestContext ctx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
  TestContext synchCtx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
  int defaultValue = 0;
  int value = 10;
  DeferredResult<Integer> deferredResult = new DeferredResult<>();
  deferredResult.whenComplete(ctx.getCompletionDeferred());
  runAfter(synchCtx, () -> deferredResult.complete(value));
  Assert.assertEquals(defaultValue, deferredResult.getNow(defaultValue).intValue());
  synchCtx.complete();
  ctx.await();
  Assert.assertEquals(value, deferredResult.getNow(defaultValue).intValue());
}
origin: com.vmware.xenon/xenon-common

@Test
public void testGetNowWithValue() throws Throwable {
  TestContext ctx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
  TestContext synchCtx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
  int defaultValue = 0;
  int value = 10;
  DeferredResult<Integer> deferredResult = new DeferredResult<>();
  deferredResult.whenComplete(ctx.getCompletionDeferred());
  runAfter(synchCtx, () -> deferredResult.complete(value));
  Assert.assertEquals(defaultValue, deferredResult.getNow(defaultValue).intValue());
  synchCtx.complete();
  ctx.await();
  Assert.assertEquals(value, deferredResult.getNow(defaultValue).intValue());
}
origin: vmware/xenon

@Test
public void testGetNowWithSlowWhenComplete() throws Throwable {
  TestContext ctx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
  DeferredResult<String> original = new DeferredResult<>();
  DeferredResult<String> result = original
      .whenComplete((ignore, error) -> {
        if (error != null) {
          ctx.fail(error.getCause());
        } else {
          ctx.complete();
        }
        sleep(500);
      });
  runAfter(1, () -> original.complete("foo"));
  ctx.await();
  Assert.assertEquals("bar", result.getNow("bar"));
}
origin: com.vmware.xenon/xenon-common

@Test
public void testGetNowWithSlowWhenComplete() throws Throwable {
  TestContext ctx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
  DeferredResult<String> original = new DeferredResult<>();
  DeferredResult<String> result = original
      .whenComplete((ignore, error) -> {
        if (error != null) {
          ctx.fail(error.getCause());
        } else {
          ctx.complete();
        }
        sleep(500);
      });
  runAfter(1, () -> original.complete("foo"));
  ctx.await();
  Assert.assertEquals("bar", result.getNow("bar"));
}
origin: com.vmware.xenon/xenon-common

@Test
public void testGetNow() throws Throwable {
  TestContext ctx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
  TestContext synchCtx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
  int value = 10;
  DeferredResult<Integer> deferredResult = new DeferredResult<>();
  deferredResult.whenComplete(ctx.getCompletionDeferred());
  runAfter(synchCtx, () -> deferredResult.complete(value));
  try {
    deferredResult.getNow(exceptionSupplier("expected"));
    Assert.fail();
  } catch (RuntimeException e) {
    Assert.assertEquals("expected", e.getMessage());
  }
  synchCtx.complete();
  ctx.await();
  Assert.assertEquals(value, deferredResult.getNow(exceptionSupplier()).intValue());
}
origin: vmware/admiral

@Test
public void testPost() {
  String endpointLink = createEndpoint().documentSelfLink;
  URI serviceUri = UriUtils.buildUri(host, PKSPlanListService.SELF_LINK,
      UriUtils.buildUriQuery(PKS_ENDPOINT_QUERY_PARAM_NAME, endpointLink));
  TestContext ctx = testCreate(1);
  List<PKSPlan> plans = new ArrayList<>();
  Operation get = Operation.createPost(serviceUri)
      .setCompletion((op, ex) -> {
        if (ex != null) {
          assertEquals(Operation.STATUS_CODE_BAD_METHOD, op.getStatusCode());
          ctx.complete();
          return;
        }
        ctx.fail(null);
      });
  sender.sendRequest(get);
  ctx.await();
}
origin: com.vmware.xenon/xenon-common

@Test
public void testGetNowWithValueFailed() throws Throwable {
  TestContext ctx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
  TestContext synchCtx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
  int defaultValue = 0;
  DeferredResult<Integer> deferredResult = new DeferredResult<>();
  deferredResult.whenComplete(getExpectedExceptionCompletion(ctx));
  runAfter(synchCtx, () -> deferredResult.fail(new TestException()));
  Assert.assertEquals(defaultValue, deferredResult.getNow(defaultValue).intValue());
  synchCtx.complete();
  ctx.await();
  try {
    deferredResult.getNow(defaultValue);
    Assert.fail();
  } catch (CompletionException e) {
    Assert.assertNotNull(e.getCause());
    Assert.assertEquals(TestException.class, e.getCause().getClass());
  }
}
com.vmware.xenon.common.testTestContextcomplete

Javadoc

Consider using #complete(). 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
  • failIteration
    Consider using #fail(Throwable). This method exists for backward compatibility, and may be deprecate
  • <init>
  • 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

  • Creating JSON documents from java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • putExtra (Intent)
  • getResourceAsStream (ClassLoader)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • Menu (java.awt)
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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