org.ldp4j.commons.testing.Utils类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(89)

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

Utils介绍

[英]Common testing utilities.
[中]通用测试工具。

代码示例

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

@Test
public void testIsLibrary$notUtilityClass$methodClass() {
  final class NotStaticMethodClass {
  }
  assertThat(Utils.isUtilityClass(NotStaticMethodClass.class),equalTo(false));
}

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

@Test
public void testDefaultToString$regularImplementation() {
  Object obj=new Object();
  assertThat(Utils.defaultToString(obj),equalTo(obj.toString()));
}

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

/**
 * Determine whether a class is a proper utility class (final class +
 * private no-arg constructor).
 *
 * @param <T> the type of library
 * @param clazz
 *            the library class to evaluate
 * @return {@code true} if the specified class is a propery utility class.
 */
public static <T> boolean isUtilityClass(final Class<? extends T> clazz) {
  if(!isPotentialLibraryClass(clazz)) {
    return false;
  }
  final Constructor<?>[] constructor = clazz.getDeclaredConstructors();
  if(constructor.length!=1) {
    return false;
  }
  final Constructor<?> defaultConstructor = constructor[0];
  if(isValidDefaultConstructor(defaultConstructor)) {
    invoke(defaultConstructor);
    return true;
  }
  return false;
}

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

@Test
public void isUtilityClass() throws Exception {
  assertThat(Utils.isUtilityClass(Qualities.class),equalTo(true));
}

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

@Test
public void testDefaultToString$customObjectOverridingHashButNotEquals() {
  Object obj=new CustomHashObject(1234);
  assertThat(Utils.defaultToString(obj),equalTo(obj.toString()));
}

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

@Test
public void isUtilityClass() throws Exception {
  assertThat(Utils.isUtilityClass(MoreStrings.class),equalTo(true));
}

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

@Test
public void testToString() throws Exception {
  assertThat(
    this.sut.toString(),
    not(equalTo(Utils.defaultToString(sut))));
}

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

@Test
public void isUtilityClass() throws Exception {
  assertThat(Utils.isUtilityClass(Variants.class),equalTo(true));
}

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

@Test
public void testDefaultToString$customObjectNotOverridingHashNorEquals() {
  Object obj=new CustomObject();
  assertThat(Utils.defaultToString(obj),equalTo(obj.toString()));
}

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

@Test
public void testIsLibrary$notUtilityClass$notStaticClass() {
  assertThat(Utils.isUtilityClass(NonStaticClass.class),equalTo(false));
}

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

@Test
public void testToString() throws Exception {
  assertThat(
    this.sut.toString(),
    not(equalTo(Utils.defaultToString(sut))));
}

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

@Test
public void testIsLibrary$notUtilityClass$innerClass() {
  assertThat(Utils.isUtilityClass(NotStaticInnerClass.class),equalTo(false));
}

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

@Test
public void testToString$nonEmpty() throws Exception {
  assertThat(this.sut.toString(),not(equalTo(Utils.defaultToString(this.sut))));
}

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

@Test
public void testIsLibrary$notUtilityClass$constructorWithArgs() {
  assertThat(Utils.isUtilityClass(CustomHashObject.class),equalTo(false));
}

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

@Test
public void hasCustomToString() throws Exception {
  assertThat(sut.toString(),not(equalTo(Utils.defaultToString(sut))));
}

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

@Test
public void isUtilityClass() throws Exception {
  assertThat(Utils.isUtilityClass(CharacterEncodings.class),equalTo(true));
}

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

@Test
public void testHasCustomStringRepresentation() {
  ImmutableElementParameter sut = createParameter("header", "value");
  assertThat(sut.toString(),not(equalTo(Utils.defaultToString(sut))));
}

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

@Test
public void verifyIsUtilityClass() {
  assertThat(Utils.isUtilityClass(DataDSL.class),equalTo(true));
}

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

@Test
public void testHasCustomStringRepresentation() {
  ImmutableElement sut = createElement("header");
  assertThat(sut.toString(),not(equalTo(Utils.defaultToString(sut))));
}

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

@Test
public void verifyIsUtilityClass() {
  assertThat(Utils.isUtilityClass(RDFS.class),equalTo(true));
}

相关文章