io.airlift.testing.Assertions.fail()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(52)

本文整理了Java中io.airlift.testing.Assertions.fail()方法的一些代码示例,展示了Assertions.fail()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assertions.fail()方法的具体详情如下:
包路径:io.airlift.testing.Assertions
类名称:Assertions
方法名:fail

Assertions.fail介绍

暂无

代码示例

代码示例来源:origin: io.airlift/testing

public static void assertContains(String actual, String expectedPart, String message)
{
  assertNotNull(actual, "actual is null");
  assertNotNull(expectedPart, "expectedPart is null");
  if (actual.contains(expectedPart)) {
    // ok
    return;
  }
  fail("%sexpected:<%s> to contain <%s>", toMessageString(message), actual, expectedPart);
}

代码示例来源:origin: airlift/airlift

public static void assertContains(String actual, String expectedPart, String message)
{
  assertNotNull(actual, "actual is null");
  assertNotNull(expectedPart, "expectedPart is null");
  if (actual.contains(expectedPart)) {
    // ok
    return;
  }
  fail("%sexpected:<%s> to contain <%s>", toMessageString(message), actual, expectedPart);
}

代码示例来源:origin: airlift/airlift

public static <T, U extends T> void assertInstanceOf(T actual, Class<U> expectedType, String message)
{
  assertNotNull(actual, "actual is null");
  assertNotNull(expectedType, "expectedType is null");
  if (expectedType.isInstance(actual)) {
    // ok
    return;
  }
  fail("%sexpected:<%s> to be an instance of <%s>", toMessageString(message), actual, expectedType.getName());
}

代码示例来源:origin: com.teradata.airlift/testing

public static void assertContains(String actual, String expectedPart, String message)
{
  assertNotNull(actual, "actual is null");
  assertNotNull(expectedPart, "expectedPart is null");
  if (actual.contains(expectedPart)) {
    // ok
    return;
  }
  fail("%sexpected:<%s> to contain <%s>", toMessageString(message), actual, expectedPart);
}

代码示例来源:origin: com.teradata.airlift/testing

public static void assertEqualsIgnoreCase(String actual, String expected, String message)
{
  assertNotNull(actual, "actual is null");
  if (actual.equalsIgnoreCase(expected)) {
    // ok
    return;
  }
  fail("%sexpected:<%s> to equal ignoring case <%s>", toMessageString(message), actual, expected);
}

代码示例来源:origin: com.teradata.airlift/testing

public static <T, U extends T> void assertInstanceOf(T actual, Class<U> expectedType, String message)
{
  assertNotNull(actual, "actual is null");
  assertNotNull(expectedType, "expectedType is null");
  if (expectedType.isInstance(actual)) {
    // ok
    return;
  }
  fail("%sexpected:<%s> to be an instance of <%s>", toMessageString(message), actual, expectedType.getName());
}

代码示例来源:origin: io.airlift/testing

public static void assertEqualsIgnoreCase(String actual, String expected, String message)
{
  assertNotNull(actual, "actual is null");
  if (actual.equalsIgnoreCase(expected)) {
    // ok
    return;
  }
  fail("%sexpected:<%s> to equal ignoring case <%s>", toMessageString(message), actual, expected);
}

代码示例来源:origin: io.airlift/testing

public static <T, U extends T> void assertInstanceOf(T actual, Class<U> expectedType, String message)
{
  assertNotNull(actual, "actual is null");
  assertNotNull(expectedType, "expectedType is null");
  if (expectedType.isInstance(actual)) {
    // ok
    return;
  }
  fail("%sexpected:<%s> to be an instance of <%s>", toMessageString(message), actual, expectedType.getName());
}

代码示例来源:origin: airlift/airlift

public static void assertEqualsIgnoreCase(String actual, String expected, String message)
{
  assertNotNull(actual, "actual is null");
  if (actual.equalsIgnoreCase(expected)) {
    // ok
    return;
  }
  fail("%sexpected:<%s> to equal ignoring case <%s>", toMessageString(message), actual, expected);
}

代码示例来源:origin: airlift/airlift

public static void assertNotEquals(Object actual, Object expected, String message)
{
  if (actual == null) {
    if (expected != null) {
      // ok
      return;
    }
  }
  else {
    if (!actual.equals(expected)) {
      // ok
      return;
    }
  }
  fail("%sexpected:<%s> to not equal <%s>", toMessageString(message), actual, expected);
}

代码示例来源:origin: io.airlift/testing

public static void assertNotEquals(Object actual, Object expected, String message)
{
  if (actual == null) {
    if (expected != null) {
      // ok
      return;
    }
  }
  else {
    if (!actual.equals(expected)) {
      // ok
      return;
    }
  }
  fail("%sexpected:<%s> to not equal <%s>", toMessageString(message), actual, expected);
}

代码示例来源:origin: com.teradata.airlift/testing

public static void assertNotEquals(Object actual, Object expected, String message)
{
  if (actual == null) {
    if (expected != null) {
      // ok
      return;
    }
  }
  else {
    if (!actual.equals(expected)) {
      // ok
      return;
    }
  }
  fail("%sexpected:<%s> to not equal <%s>", toMessageString(message), actual, expected);
}

代码示例来源:origin: airlift/airlift

public static <T extends Comparable<T>> void assertBetweenInclusive(T actual, T lowerBound, T upperBound, String message)
{
  assertNotNull(actual, "actual is null");
  try {
    if (actual.compareTo(lowerBound) >= 0 && actual.compareTo(upperBound) <= 0) {
      // ok
      return;
    }
  }
  catch (ClassCastException e) {
    fail(e, "%sexpected:<%s> to be between <%s> and <%s> inclusive, but %s is not comparable with %s or %s",
        toMessageString(message),
        actual,
        lowerBound,
        upperBound,
        actual.getClass().getName(),
        lowerBound.getClass().getName(),
        upperBound.getClass().getName());
  }
  fail("%sexpected:<%s> to be between <%s> and <%s> inclusive", toMessageString(message), actual, lowerBound, upperBound);
}

代码示例来源:origin: com.teradata.airlift/testing

public static <T extends Comparable<T>> void assertGreaterThanOrEqual(T actual, T expected, String message)
{
  assertNotNull(actual, "actual is null");
  try {
    int compareValue = actual.compareTo(expected);
    if (compareValue >= 0) {
      int reverseCompareValue = expected.compareTo(actual);
      if (!(reverseCompareValue <= 0 && (compareValue != 0 || reverseCompareValue == 0))) {
        fail("%scomparison symmetry: <%s> is greater than or equal to <%s>, but <%s> is not less than or equal to<%s>",
            toMessageString(message),
            actual,
            expected,
            expected,
            actual);
      }
      // ok
      return;
    }
  }
  catch (ClassCastException e) {
    fail(e, "%sexpected:<%s> to be greater than or equal to <%s>, but %s is not comparable %s",
        toMessageString(message),
        actual,
        expected,
        actual.getClass().getName(),
        expected.getClass().getName());
  }
  fail("%sexpected:<%s> to be greater than or equal to <%s>", toMessageString(message), actual, expected);
}

代码示例来源:origin: io.airlift/testing

public static <T extends Comparable<T>> void assertBetweenExclusive(T actual, T lowerBound, T upperBound, String message)
{
  assertNotNull(actual, "actual is null");
  try {
    if (actual.compareTo(lowerBound) > 0 && actual.compareTo(upperBound) < 0) {
      // ok
      return;
    }
  }
  catch (ClassCastException e) {
    fail(e, "%sexpected:<%s> to be between <%s> and <%s> exclusive, but %s is not comparable with %s or %s",
        toMessageString(message),
        actual,
        lowerBound,
        upperBound,
        actual.getClass().getName(),
        lowerBound.getClass().getName(),
        upperBound.getClass().getName());
  }
  fail("%sexpected:<%s> to be between <%s> and <%s> exclusive", toMessageString(message), actual, lowerBound, upperBound);
}

代码示例来源:origin: airlift/airlift

public static <T extends Comparable<T>> void assertBetweenExclusive(T actual, T lowerBound, T upperBound, String message)
{
  assertNotNull(actual, "actual is null");
  try {
    if (actual.compareTo(lowerBound) > 0 && actual.compareTo(upperBound) < 0) {
      // ok
      return;
    }
  }
  catch (ClassCastException e) {
    fail(e, "%sexpected:<%s> to be between <%s> and <%s> exclusive, but %s is not comparable with %s or %s",
        toMessageString(message),
        actual,
        lowerBound,
        upperBound,
        actual.getClass().getName(),
        lowerBound.getClass().getName(),
        upperBound.getClass().getName());
  }
  fail("%sexpected:<%s> to be between <%s> and <%s> exclusive", toMessageString(message), actual, lowerBound, upperBound);
}

代码示例来源:origin: io.airlift/testing

public static <T extends Comparable<T>> void assertBetweenInclusive(T actual, T lowerBound, T upperBound, String message)
{
  assertNotNull(actual, "actual is null");
  try {
    if (actual.compareTo(lowerBound) >= 0 && actual.compareTo(upperBound) <= 0) {
      // ok
      return;
    }
  }
  catch (ClassCastException e) {
    fail(e, "%sexpected:<%s> to be between <%s> and <%s> inclusive, but %s is not comparable with %s or %s",
        toMessageString(message),
        actual,
        lowerBound,
        upperBound,
        actual.getClass().getName(),
        lowerBound.getClass().getName(),
        upperBound.getClass().getName());
  }
  fail("%sexpected:<%s> to be between <%s> and <%s> inclusive", toMessageString(message), actual, lowerBound, upperBound);
}

代码示例来源:origin: io.airlift/testing

public static void assertEqualsIgnoreOrder(Iterable<?> actual, Iterable<?> expected, String message)
{
  assertNotNull(actual, "actual is null");
  assertNotNull(expected, "expected is null");
  ImmutableMultiset<?> actualSet = ImmutableMultiset.copyOf(actual);
  ImmutableMultiset<?> expectedSet = ImmutableMultiset.copyOf(expected);
  if (!actualSet.equals(expectedSet)) {
    Joiner joiner = Joiner.on("\n      ");
    fail("%sexpected: collections to be equal (ignoring order).%nActual:%n      %s%nExpected:%n      %s", toMessageString(message), joiner.join(actual), joiner.join(expected));
  }
}

代码示例来源:origin: airlift/airlift

public static void assertEqualsIgnoreOrder(Iterable<?> actual, Iterable<?> expected, String message)
{
  assertNotNull(actual, "actual is null");
  assertNotNull(expected, "expected is null");
  ImmutableMultiset<?> actualSet = ImmutableMultiset.copyOf(actual);
  ImmutableMultiset<?> expectedSet = ImmutableMultiset.copyOf(expected);
  if (!actualSet.equals(expectedSet)) {
    Joiner joiner = Joiner.on("\n      ");
    fail("%sexpected: collections to be equal (ignoring order).%nActual:%n      %s%nExpected:%n      %s", toMessageString(message), joiner.join(actual), joiner.join(expected));
  }
}

代码示例来源:origin: com.teradata.airlift/testing

public static void assertEqualsIgnoreOrder(Iterable<?> actual, Iterable<?> expected, String message)
{
  assertNotNull(actual, "actual is null");
  assertNotNull(expected, "expected is null");
  ImmutableMultiset<?> actualSet = ImmutableMultiset.copyOf(actual);
  ImmutableMultiset<?> expectedSet = ImmutableMultiset.copyOf(expected);
  if (!actualSet.equals(expectedSet)) {
    Joiner joiner = Joiner.on("\n      ");
    fail("%sexpected: collections to be equal (ignoring order).%nActual:%n      %s%nExpected:%n      %s", toMessageString(message), joiner.join(actual), joiner.join(expected));
  }
}

相关文章