本文整理匯總了Java中org.junit.jupiter.api.Assertions.assertThrows方法的典型用法代碼示例。如果您正苦於以下問題:Java Assertions.assertThrows方法的具體用法?Java Assertions.assertThrows怎麽用?Java Assertions.assertThrows使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.junit.jupiter.api.Assertions
的用法示例。
在下文中一共展示了Assertions.assertThrows方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCpcPlusFileFailures
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@ParameterizedTest
@MethodSource("failureData")
void testCpcPlusFileFailures(Path entry) throws IOException {
String fileName = entry.getFileName().toString();
assertWithMessage("No associated entry in fixture.json for the file %s", fileName).that(fixtureValues).containsKey(fileName);
Converter converter = new Converter(new PathSource(entry));
TransformException expected = Assertions.assertThrows(TransformException.class, converter::transform);
//runnning conversions on individual files
List<Detail> details = expected.getDetails().getErrors().get(0).getDetails();
verifyOutcome(fileName, details);
}
示例2: nonexistentJsonPath
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void nonexistentJsonPath() throws IOException, XmlException {
Assertions.assertThrows(PathNotFoundException.class, () -> {
String jsonPath = "meep.mawp";
helper.executeAttributeTest(jsonPath, "", "");
});
}
示例3: throwWithWrongCountValueBuildCondition3AndMore
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void throwWithWrongCountValueBuildCondition3AndMore() {
// TODO Should we care about not enough or too many ? (not supposed to happen if use public API)
Assertions.assertThrows(IllegalArgumentException.class, () -> filterValue3.buildCondition(Collections.emptyList()));
filterValue3.buildCondition(Arrays.asList("val1", "val2"));
filterValue3.buildCondition(Arrays.asList("val1", "val2", "val3", "val4"));
Assertions.assertThrows(IllegalArgumentException.class, () -> filterValue5.buildCondition(Collections.emptyList()));
filterValue5.buildCondition(Arrays.asList("val1", "val2"));
filterValue5.buildCondition(Arrays.asList("val1", "val2", "val3", "val4", "val5", "val6"));
}
示例4: testFalseCondition
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testFalseCondition() throws Exception {
UnsupportedOperationException e = Assertions.assertThrows(UnsupportedOperationException.class, () ->
Ensure.ensureCondition(false, UnsupportedOperationException.class, of("foo"))
);
Assertions.assertEquals("foo", e.getMessage(), "Exception message didn't match!");
}
示例5: buildConditionsThrowsOnMissingValueForConditionCreator
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void buildConditionsThrowsOnMissingValueForConditionCreator() {
filteringJooqImpl1.getFilterValues().add(Filter.of("key1", v1 -> "val1", val1 -> DSL.trueCondition()));
filteringJooqImpl1.getFilterValues().add(Filter.of("key2", v1 -> "val1", val1 -> DSL.trueCondition()));
Assertions.assertThrows(FilteringApiException.class, () -> filteringJooqImpl1.buildConditions(ImmutableMap.of("key1", "", "key2", "12:25:30")));
Assertions.assertThrows(FilteringApiException.class, () -> filteringJooqImpl1.buildConditions(ImmutableMap.of("key1", " ")));
}
示例6: parseWithApiExceptionThrows
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void parseWithApiExceptionThrows() {
Assertions.assertThrows(FilteringApiException.class, () -> FilterParser.ofTime().parseWithApiException("12 43"));
Assertions.assertThrows(FilteringApiException.class, () -> FilterParser.ofTime().parseWithApiException("12:23 45"));
Assertions.assertThrows(FilteringApiException.class, () -> FilterParser.ofTime().parseWithApiException("Odwdw0"));
Assertions.assertThrows(FilteringApiException.class, () -> FilterParser.ofTime().parseWithApiException("O"));
Assertions.assertThrows(FilteringApiException.class, () -> FilterParser.ofTime().parseWithApiException(" 5 "));
}
示例7: testBadFormattedMeasureDataFile
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void testBadFormattedMeasureDataFile() {
IllegalArgumentException thrown = Assertions.assertThrows(IllegalArgumentException.class, () ->
MeasureConfigs.setMeasureDataFile("bad_formatted_measures_data.json"));
assertThat(thrown).hasCauseThat().isInstanceOf(JsonMappingException.class);
}
示例8: ofSupplierThrowsIfWrongBuildCondition
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void ofSupplierThrowsIfWrongBuildCondition() {
final FilterValue filter = Filter.of("myKey", () -> null);
Assertions.assertThrows(IllegalStateException.class, () -> filter.buildCondition(Collections.singletonList("obj1")));
Assertions.assertThrows(IllegalStateException.class, () -> filter.buildCondition(Arrays.asList("obj1", "obj2")));
Assertions.assertThrows(IllegalStateException.class, () -> filter.buildCondition(Arrays.asList("obj1", "obj2", "obj3")));
}
示例9: shouldAllowEmptyTemplateScope
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void shouldAllowEmptyTemplateScope() throws ParseException {
//when
Assertions.assertThrows(MissingArgumentException.class, () -> {
CommandLine line = ConversionEntry.cli("-t");
ConversionEntry.shouldContinue(line);
});
}
示例10: getInvalidUriTest
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
/**
* In this test case a driver is requested which is not registered with the {@link PlcDriverManager}.
*/
@Test
@Tag("fast")
void getInvalidUriTest() throws PlcException {
Assertions.assertThrows(PlcConnectionException.class,
() -> new PlcDriverManager().getConnection("The quick brown fox jumps over the lazy dog"));
}
示例11: noValuesThrows
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void noValuesThrows() {
Assertions.assertThrows(FilteringApiException.class, () -> FilterMultipleValueParser.ofInt().parse(""));
Assertions.assertThrows(FilteringApiException.class, () -> FilterMultipleValueParser.ofInt().parse("", 3));
Assertions.assertThrows(FilteringApiException.class, () -> FilterMultipleValueParser.ofInt().parse("", ","));
Assertions.assertThrows(FilteringApiException.class, () -> FilterMultipleValueParser.ofInt().parse("", ",", 3));
}
示例12: throwWithWrongCountValueBuildCondition2
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void throwWithWrongCountValueBuildCondition2() {
Assertions.assertThrows(IndexOutOfBoundsException.class, () -> filterValue2.buildCondition(Collections.emptyList()));
Assertions.assertThrows(IndexOutOfBoundsException.class, () -> filterValue2.buildCondition(Collections.singletonList("val1")));
// TODO Should we care about too many ? (not supposed to happen if use public API)
filterValue2.buildCondition(Arrays.asList("val1", "val2", "val3"));
}
示例13: emptyValueThrows
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void emptyValueThrows() {
Assertions.assertThrows(IllegalArgumentException.class, ValueImpl::new);
Assertions.assertThrows(IllegalArgumentException.class, () -> new ValueImpl<>(new Object[0]));
final Object ff = null;
Assertions.assertThrows(IllegalArgumentException.class, () -> new ValueImpl<>(ff));
Assertions.assertThrows(IllegalArgumentException.class, () -> new ValueImpl<>(Collections.emptyList()));
}
示例14: buildConditionsThrowsByDefaultForMissingKeyMultiple
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@ParameterizedTest
@MethodSource("incompleteMapOfFilterMultipleKeys")
void buildConditionsThrowsByDefaultForMissingKeyMultiple(final Map<String, String> params, final List<FilterValue> filterValues) {
filteringJooqImpl1.getFilterValues().addAll(filterValues);
Assertions.assertThrows(FilteringApiException.class, () -> filteringJooqImpl1.buildConditions(params));
}
示例15: testGetUniqueIdForKeyNullSubPopulationThrowsNullPointerException
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void testGetUniqueIdForKeyNullSubPopulationThrowsNullPointerException() {
Assertions.assertThrows(NullPointerException.class, () ->
SubPopulations.getUniqueIdForKey("not null", null));
}