當前位置: 首頁>>代碼示例>>Java>>正文


Java Assertions.assertEquals方法代碼示例

本文整理匯總了Java中org.junit.jupiter.api.Assertions.assertEquals方法的典型用法代碼示例。如果您正苦於以下問題:Java Assertions.assertEquals方法的具體用法?Java Assertions.assertEquals怎麽用?Java Assertions.assertEquals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.junit.jupiter.api.Assertions的用法示例。


在下文中一共展示了Assertions.assertEquals方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkWrite

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
private <T> void checkWrite(MockConnection connection, PlcWriteRequest request, T value) throws InterruptedException, ExecutionException {
  // this is really a tests of our mock tooling but knowing it's behaving as expected
  // will help identify problems in the adapter/supplier/consumer
  connection.setDataValue(request.getRequestItems().get(0).getAddress(), value);
  
  CompletableFuture<PlcWriteResponse> cf = connection.write(request);
  
  Assertions.assertTrue(cf.isDone());
  PlcWriteResponse response = cf.get();
  Assertions.assertNotNull(response);
  T writtenData = (T) connection.getDataValue(request.getRequestItems().get(0).getAddress());
  if(writtenData.getClass().isArray()) {
    writtenData = (T) Array.get(writtenData, 0);
  }
  Assertions.assertEquals(value, writtenData);
}
 
開發者ID:apache,項目名稱:incubator-plc4x,代碼行數:17,代碼來源:PlcConnectionAdapterTest.java

示例2: buildConditions

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@ParameterizedTest
@MethodSource("goodMapConditionAndResult")
void buildConditions(final Map<String, String> params, final List<FilterValue> filterValues, final Condition expectedCondition) {
    filteringJooqImpl1.getFilterValues().addAll(filterValues);
    final Condition condition = filteringJooqImpl1.buildConditions(params);
    Assertions.assertEquals(expectedCondition, condition);
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:8,代碼來源:FilteringJooqTest.java

示例3: testDescriptorGenerator

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testDescriptorGenerator(){
    String desc = newDescriptor()
            .returns(void.class)
            .toString();
    String desc2 = newDescriptor()
            .returns(Void.class)
            .toString();
    String desc3 = newDescriptor()
            .accepts(int.class, int.class)
            .returns(String.class)
            .toString();
    Assertions.assertEquals("()V", desc);
    Assertions.assertEquals("()Ljava/lang/Void;", desc2); // huh?
    Assertions.assertEquals("(II)Ljava/lang/String;", desc3);
}
 
開發者ID:mikroskeem,項目名稱:Shuriken,代碼行數:17,代碼來源:DescriptorTester.java

示例4: testMethodReflectorReUse

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testMethodReflectorReUse() {
    ClassWrapper<TestClass> tc = wrapClass(TestClass.class);
    MethodReflector<DummyInterface> reflector1 = newInstance(tc, DummyInterface.class);
    MethodReflector<DummyInterface> reflector2 = newInstance(tc, DummyInterface.class);
    MethodReflector<DummyInterface> reflector3 = newInstance(tc, DummyInterface.class);
    MethodReflector<DummyInterface> reflector4 = newInstance(tc, DummyInterface.class);

    /* With reflector1 */
    Assertions.assertEquals(reflector1, reflector2);
    Assertions.assertEquals(reflector1, reflector3);
    Assertions.assertEquals(reflector1, reflector4);

    /* With reflector2 */
    Assertions.assertEquals(reflector2, reflector3);
    Assertions.assertEquals(reflector2, reflector4);

    /* With reflector3 */
    Assertions.assertEquals(reflector3, reflector4);
}
 
開發者ID:mikroskeem,項目名稱:Shuriken,代碼行數:21,代碼來源:MethodReflectorTester.java

示例5: of6

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void of6() {
    final KeyParser6<Integer, String, LocalTime, Locale, Byte, LocalDateTime> keyParser = KeyParsers.of(
        "key1", val -> 0,
        "key2", val -> "other",
        "key3", val -> LocalTime.MIDNIGHT,
        "key4", val -> Locale.ENGLISH,
        "key5", val -> (byte) 0xFF,
        "key6", val -> LocalDateTime.MAX);
    Assertions.assertEquals("key6", keyParser.key6());
    Assertions.assertEquals("key6", keyParser.getKeys()[5]);
    Assertions.assertEquals(6, keyParser.size());
    Assertions.assertEquals(6, keyParser.getKeys().length);

    Assertions.assertEquals(LocalDateTime.MAX, keyParser.parser6().apply("any"));
    Assertions.assertEquals(6, keyParser.getParsers().length);
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:18,代碼來源:KeyParsersTest.java

示例6: testDefaultBuilder

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testDefaultBuilder() throws Exception {
    List<Dependency> dependencies = Arrays.asList(UriUtilsTest.SAMPLE_DEPENDENCY, UriUtilsTest.SAMPLE_DEPENDENCY2);
    try (
        PicoMaven picoMaven = new PicoMaven.Builder()
            .withDownloadPath(downloadDir.toPath())
            .withRepositories(Arrays.asList(MAVEN_CENTRAL_REPOSITORY, UriUtilsTest.DEFAULT_REPOSITORY2))
            .withDependencies(dependencies)
                .withDebugLoggerImpl(new DebugLoggerImpl() {
                    @Override
                    public void debug(String format, Object... contents) {
                        System.err.format(format + "\n", contents);
                    }
                })
            .build()
    ) {
        List<Path> downloadedDeps = picoMaven.downloadAll();
        Assertions.assertEquals(dependencies.size(), downloadedDeps.size());
    }
}
 
開發者ID:mikroskeem,項目名稱:PicoMaven,代碼行數:21,代碼來源:ClientTest.java

示例7: parseWithApiException

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void parseWithApiException() {
    Assertions.assertEquals("5", FilterParser.ofIdentity().parseWithApiException("5"));
    Assertions.assertEquals("-5", FilterParser.ofIdentity().parseWithApiException("-5"));
    Assertions.assertEquals("0", FilterParser.ofIdentity().parseWithApiException("0"));
    Assertions.assertEquals("066", FilterParser.ofIdentity().parseWithApiException("066"));
    Assertions.assertEquals("312313", FilterParser.ofIdentity().parseWithApiException("312313"));
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:9,代碼來源:FilterParserIdentityTest.java

示例8: buildConditionsSkipOnMissingValueForConditionCreator

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void buildConditionsSkipOnMissingValueForConditionCreator() {
    // It skips by setting the value to "" but that will throw an exception at parsing if parser expect something
    final FilteringJooqImpl2 filteringJooqImpl2 = new FilteringJooqImpl2();
    filteringJooqImpl2.getFilterValues().add(Filter.of("key1", v1 -> "val1", val1 -> DSL.trueCondition()));
    filteringJooqImpl2.getFilterValues().add(Filter.of("key2", v1 -> "val1", val1 -> DSL.trueCondition()));
    // Does not throw as parser is not parsing ^^
    Assertions.assertEquals(createNTrueCondition(2), filteringJooqImpl2.buildConditions(ImmutableMap.of("key1", "", "key2", "12:25:30")));
    Assertions.assertEquals(createNTrueCondition(1), filteringJooqImpl2.buildConditions(ImmutableMap.of("key1", "   ")));

    // Now it will throw
    filteringJooqImpl2.getFilterValues().set(0, Filter.of("key", LocalDateTime::parse, val1 -> DSL.trueCondition()));
    Assertions.assertThrows(FilteringApiException.class, () -> filteringJooqImpl2.buildConditions(ImmutableMap.of("key1", "", "key2", "12:25:30")));
    Assertions.assertThrows(FilteringApiException.class, () -> filteringJooqImpl2.buildConditions(ImmutableMap.of("key1", "   ")));
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:16,代碼來源:FilteringJooqTest.java

示例9: assertNumHookInstances

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
public static void assertNumHookInstances(int expectedNumberOfInstances, Class<?> hookClass) {
    long actualNumberOfInstances = captures.stream()
            .filter(c -> c.hook.getClass().equals(hookClass))
            .map(c -> c.hook)
            .distinct()
            .count();
    Assertions.assertEquals(expectedNumberOfInstances, (int) actualNumberOfInstances);
}
 
開發者ID:fstab,項目名稱:promagent,代碼行數:9,代碼來源:MethodCallCounter.java

示例10: testInstanceWrapping

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testInstanceWrapping() throws Exception {
    Class<TestClassOne> testClass = TestClassOne.class;
    TestClassOne testClassOne = new TestClassOne();
    ClassWrapper<TestClassOne> cw = Reflect.wrapInstance(testClassOne);
    Assertions.assertEquals(testClass, cw.getWrappedClass(), "Classes should match!");
}
 
開發者ID:mikroskeem,項目名稱:Shuriken,代碼行數:8,代碼來源:ClassWrapperTester.java

示例11: parseOrDefault

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void parseOrDefault() {
    final LocalTime result = FilterParser.ofTime().parseOrDefault(correctFormatTime1, time1);
    Assertions.assertEquals(time1, result);

    final LocalTime result2 = FilterParser.ofTime().parseOrDefault(correctFormatTime2, time2);
    Assertions.assertEquals(time2, result2);
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:9,代碼來源:FilterParserLocalTimeTest.java

示例12: of3

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void of3() {
    final FilterValue filterValue3 = Filter.of(
        "key", "key2", "key3",
        val1 -> "value", val2 -> "value", val3 -> "value",
        value -> DSL.trueCondition());
    Assertions.assertEquals(3, filterValue3.size());
    Assertions.assertNotNull(filterValue3);
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:10,代碼來源:FilterTest.java

示例13: testOpenFlagsMaskToSet

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@ParameterizedTest
@MethodSource("openOptionsProvider")
public void testOpenFlagsMaskToSet(Set<OpenOption> expectedOptions, Set<OpenFlags> flags) {
	BitMaskEnumUtil enumUtil = Mockito.mock(BitMaskEnumUtil.class);
	Mockito.verifyNoMoreInteractions(enumUtil);
	OpenOptionsUtil util = new OpenOptionsUtil(enumUtil);
	Set<OpenOption> options = util.fuseOpenFlagsToNioOpenOptions(flags);
	Assertions.assertEquals(expectedOptions, options);
}
 
開發者ID:cryptomator,項目名稱:fuse-nio-adapter,代碼行數:10,代碼來源:OpenOptionsUtilTest.java

示例14: canHaveOperationsOfDifferentResultTypes

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
@DisplayName("can have operations of different result types")
public void canHaveOperationsOfDifferentResultTypes(){
    Tuple2<String, Integer> result = Pipeline.of("1")
            .with(value -> value + "1")
            .with(Integer::parseInt)
            .execute();
    Assertions.assertEquals("11", result._1());
    Assertions.assertEquals(new Integer(1), result._2());
}
 
開發者ID:santiagopoli,項目名稱:slang-steroids,代碼行數:11,代碼來源:PipelineTest.java

示例15: testCompareVersions

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testCompareVersions() {
	Assertions.assertThrows(NullPointerException.class, () -> UpdateUtility.compareVersions(null, null));
	Assertions.assertThrows(NullPointerException.class, () -> UpdateUtility.compareVersions(null, "1.6.8"));
	Assertions.assertThrows(NullPointerException.class, () -> UpdateUtility.compareVersions("1.6.8", null));

	Assertions.assertThrows(IllegalArgumentException.class, () -> UpdateUtility.compareVersions("", ""));
	Assertions.assertThrows(IllegalArgumentException.class, () -> UpdateUtility.compareVersions("", "1"));
	Assertions.assertThrows(IllegalArgumentException.class, () -> UpdateUtility.compareVersions("f", ""));

	Assertions.assertThrows(NumberFormatException.class, () -> UpdateUtility.compareVersions("A", "1"));
	Assertions.assertThrows(NumberFormatException.class, () -> UpdateUtility.compareVersions("1", "A"));
	Assertions.assertThrows(NumberFormatException.class, () -> UpdateUtility.compareVersions("A", "A"));

	Assertions.assertEquals(CompareResult.EQUAL, UpdateUtility.compareVersions("1", "1"), "'1' and '1' should have been equal.");
	Assertions.assertEquals(CompareResult.EQUAL, UpdateUtility.compareVersions("3.4", "3.4"), "'3.4' and '3.4' should have been equal.");
	Assertions.assertEquals(CompareResult.EQUAL, UpdateUtility.compareVersions("1.6.8", "1.6.8"), "'1.6.8' and '1.6.8' should have been equal.");
	Assertions.assertEquals(CompareResult.EQUAL, UpdateUtility.compareVersions("1.6.1", "1.6.1"), "'1.6.1' and '1.6.1' should have been equal.");
	Assertions.assertEquals(CompareResult.EQUAL, UpdateUtility.compareVersions("2.0", "2"), "'2.0' and '2' should have been equal.");

	Assertions.assertEquals(CompareResult.GREATER, UpdateUtility.compareVersions("2", "1"), "'2' and '1' should have been greater.");
	Assertions.assertEquals(CompareResult.GREATER, UpdateUtility.compareVersions("1.2", "1"), "'1.2' and '1' should have been greater.");
	Assertions.assertEquals(CompareResult.GREATER, UpdateUtility.compareVersions("1.2", "1.1"), "'1.2' and '1.1' should have been greater.");
	Assertions.assertEquals(CompareResult.GREATER, UpdateUtility.compareVersions("1.2.0", "1.1.0"), "'1.2.0' and '1.1.0' should have been greater.");
	Assertions.assertEquals(CompareResult.GREATER, UpdateUtility.compareVersions("1.2.7", "1"), "'1.2.7' and '1' should have been greater.");
	Assertions.assertEquals(CompareResult.GREATER, UpdateUtility.compareVersions("1.2.7", "1.2"), "'1.2.7' and '1.2' should have been greater.");
	Assertions.assertEquals(CompareResult.GREATER, UpdateUtility.compareVersions("1.2.9", "1.2.8"), "'1.2.9' and '1.2.8' should have been greater.");
	Assertions.assertEquals(CompareResult.GREATER, UpdateUtility.compareVersions("1.8", "1.3"), "'1.8' and '1.3' should have been greater.");
	Assertions.assertEquals(CompareResult.GREATER, UpdateUtility.compareVersions("2.1", "2"), "'2.1' and '2' should have been greater.");

	Assertions.assertEquals(CompareResult.LESS, UpdateUtility.compareVersions("1.1", "2"), "'1.1' and '2' should have been less.");
	Assertions.assertEquals(CompareResult.LESS, UpdateUtility.compareVersions("1.0", "2"), "'1.0' and '2' should have been less.");
	Assertions.assertEquals(CompareResult.LESS, UpdateUtility.compareVersions("1", "2"), "'1' and '2' should have been less.");
	Assertions.assertEquals(CompareResult.LESS, UpdateUtility.compareVersions("1", "1.2"), "'1' and '1.2' should have been less.");
	Assertions.assertEquals(CompareResult.LESS, UpdateUtility.compareVersions("1.1", "1.2"), "'1.1' and '1.2' should have been less.");
	Assertions.assertEquals(CompareResult.LESS, UpdateUtility.compareVersions("1.1.0", "1.2.0"), "'1.1.0' and '1.2.0' should have been less.");
	Assertions.assertEquals(CompareResult.LESS, UpdateUtility.compareVersions("1", "1.2.8"), "'1' and '1.2.8' should have been less.");
	Assertions.assertEquals(CompareResult.LESS, UpdateUtility.compareVersions("1.2", "1.2.8"), "'1.2' and '1.2.8' should have been less.");
	Assertions.assertEquals(CompareResult.LESS, UpdateUtility.compareVersions("1.2.7", "1.2.8"), "'1.2.7' and '1.2.8' should have been less.");
	Assertions.assertEquals(CompareResult.LESS, UpdateUtility.compareVersions("1.3", "1.8"), "'1.3' and '1.8' should have been less.");
}
 
開發者ID:Bios-Marcel,項目名稱:ServerBrowser,代碼行數:42,代碼來源:UpdateUtilityTest.java


注:本文中的org.junit.jupiter.api.Assertions.assertEquals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。