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

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

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

origin: vmware/xenon

/**
 * Consider using {@link #fail(Throwable)}.
 * This method exists for backward compatibility, and may be deprecated/deleted in future.
 */
public void failIteration(Throwable e) {
  fail(e);
}
origin: com.vmware.xenon/xenon-common

/**
 * Consider using {@link #fail(Throwable)}.
 * This method exists for backward compatibility, and may be deprecated/deleted in future.
 */
public void failIteration(Throwable e) {
  fail(e);
}
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: 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/xenon

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: 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

  @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: vmware/admiral

private List<PKSPlan> sendListRequest(String endpointLink) {
  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.createGet(serviceUri)
      .setCompletion((op, ex) -> {
        if (ex != null) {
          ctx.fail(ex);
          return;
        }
        plans.addAll(Arrays.asList(op.getBody(PKSPlan[].class)));
        ctx.complete();
      });
  sender.sendRequest(get);
  ctx.await();
  return plans;
}
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: com.vmware.xenon/xenon-common

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

private void changeTaskName(ExtensibilitySubscriptionCallback callback, Operation post) {
  Map<String, String> response = new HashMap<>();
  response.put("name", SELF_LINK);
  TestContext context = new TestContext(1, Duration.ofSeconds(20));
  Operation.createPost(callback.serviceCallback)
      .setReferer(getHost().getUri())
      .setBody(response)
      .setCompletion((o, e) -> {
        if (e != null) {
          post.fail(e);
          context.fail(e);
          return;
        }
        context.completeIteration();
      }).sendWith(getHost());
  context.await();
}
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 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: vmware/admiral

private void changeContainerName( Operation post) {
  DummyServiceTaskState body =  post.getBody(DummyServiceTaskState.class);
  ContainerState containerState = new ContainerState();
  containerState.name = DummySubscriber.class.getSimpleName();
  containerState.documentSelfLink = body.containerState.documentSelfLink;
  // Patch Container's name.
  TestContext context = new TestContext(1, Duration.ofSeconds(20));
  Operation.createPatch(UriUtils.buildUri(getHost(), containerState.documentSelfLink))
      .setBody(containerState)
      .setReferer(getHost().getUri())
      .setCompletion((o, e) -> {
        if (e != null) {
          post.fail(e);
          context.fail(e);
          return;
        }
      }).sendWith(getHost());
  context.await();
}
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();
}
com.vmware.xenon.common.testTestContextfail

Javadoc

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

Popular methods of TestContext

  • await
  • 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>
  • 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

  • Reactive rest calls using spring rest template
  • findViewById (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getExternalFilesDir (Context)
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top plugins for Android Studio
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