本文整理汇总了Java中org.junit.jupiter.api.Test类的典型用法代码示例。如果您正苦于以下问题:Java Test类的具体用法?Java Test怎么用?Java Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Test类属于org.junit.jupiter.api包,在下文中一共展示了Test类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_IF_ACMPNE
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
public void test_IF_ACMPNE(){
// x != y
Object x = "a";
Object[] values = new Object[]{new Object(), x, "foo", 5};
for(Object val: values){
Truthness eq = getForObjectComparison(x, val, Opcodes.IF_ACMPEQ);
Truthness ne = getForObjectComparison(x, val, Opcodes.IF_ACMPNE);
//should be inverted
assertEquals(eq.getOfTrue(), ne.getOfFalse(), 0.001);
assertEquals(eq.getOfFalse(), ne.getOfTrue(), 0.001);
}
}
示例2: encodeDisconnectionConfirm
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
@Tag("fast")
public void encodeDisconnectionConfirm() throws Exception {
ChannelHandlerContext ctx = new MockChannelHandlerContext();
ByteBuf buf = Unpooled.buffer();
DisconnectConfirmTpdu tpdu = new DisconnectConfirmTpdu((short)0x1, (short)(0x2), Collections.emptyList(), buf);
ArrayList<Object> out = new ArrayList<>();
isoTPProtocol.encode(ctx, tpdu, out);
assertTrue(out.size() == 1, "Message not decoded");
ByteBuf userData = ((IsoOnTcpMessage)out.get(0)).getUserData();
assertTrue(userData.writerIndex() == 6, "Incorrect message length");
assertTrue(userData.readByte() == (byte)0x5, "Incorrect header length");
assertTrue(userData.readByte() == TpduCode.DISCONNECT_CONFIRM.getCode(), "Incorrect Tpdu code");
assertTrue(userData.readShort() == (short)0x1, "Incorrect destination reference code");
assertTrue(userData.readShort() == (short)0x2, "Incorrect source reference code");
}
示例3: testRdfToNonRDFSource
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
public void testRdfToNonRDFSource() {
when(mockResource.getInteractionModel()).thenReturn(LDP.NonRDFSource);
when(mockLdpRequest.getContentType()).thenReturn(TEXT_TURTLE);
when(mockLdpRequest.getLink()).thenReturn(fromUri(LDP.NonRDFSource.getIRIString()).rel("type").build());
final File entity = new File(getClass().getResource("/simpleTriple.ttl").getFile());
final PutHandler putHandler = new PutHandler(mockLdpRequest, entity, mockResourceService,
mockIoService, mockBinaryService, null);
final Response res = putHandler.setResource(mockResource).build();
assertEquals(NO_CONTENT, res.getStatusInfo());
assertTrue(res.getLinks().stream().anyMatch(hasType(LDP.Resource)));
assertFalse(res.getLinks().stream().anyMatch(hasType(LDP.RDFSource)));
assertFalse(res.getLinks().stream().anyMatch(hasType(LDP.Container)));
assertTrue(res.getLinks().stream().anyMatch(hasType(LDP.NonRDFSource)));
}
示例4: testPurge
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
public void testPurge() throws Exception {
final String myPartition = new File(getClass().getResource("/purgeable").toURI()).getAbsolutePath();
service = new FileResourceService(myPartition, baseUrl, curator, mockProducer, mockEventService,
mockIdSupplier, false);
assertTrue(service.get(identifier).isPresent());
final List<IRI> binaries = service.purge(identifier).collect(toList());
assertEquals(1L, binaries.size());
assertEquals(rdf.createIRI("s3://bucket/some-resource"), binaries.get(0));
assertFalse(service.get(identifier).isPresent());
assertTrue(service.get(testResource).isPresent());
assertEquals(0L, service.purge(testResource).count());
assertFalse(service.get(testResource).isPresent());
}
示例5: testInvalidMeasureId
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
void testInvalidMeasureId() {
Node measureReferenceResultsNode = new MeasureReferenceBuilder()
.addMeasureId("InvalidMeasureId")
.addSubPopulationMeasureDataWithCounts(SubPopulations.IPOP, REQUIRES_DENOM_EXCLUSION_IPOP_GUID, ONE_HUNDRED)
.addSubPopulationMeasureDataWithCounts(SubPopulations.DENOM, REQUIRES_DENOM_EXCLUSION_DENOM_GUID, ONE_HUNDRED)
.addSubPopulationMeasureDataWithCounts(SubPopulations.NUMER, REQUIRES_DENOM_EXCLUSION_NUMER_GUID, ONE_HUNDRED)
.addSubPopulationMeasureDataWithCounts(SubPopulations.DENEX, REQUIRES_DENOM_EXCLUSION_DENEX_GUID, ONE_HUNDRED)
.build();
Set<Detail> details = objectUnderTest.validateSingleNode(measureReferenceResultsNode);
assertWithMessage("There must be one validation errors.")
.that(details).comparingElementsUsing(DetailsErrorEquals.INSTANCE)
.containsExactly(ErrorCode.MEASURE_GUID_MISSING);
}
示例6: testNoChildEncoder
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
void testNoChildEncoder() throws EncodeException {
JsonWrapper jsonWrapper = new JsonWrapper();
AciNumeratorDenominatorEncoder objectUnderTest = new AciNumeratorDenominatorEncoder(new Context());
Node unknownNode = new Node();
aciProportionMeasureNode.addChildNode(unknownNode);
//execute
objectUnderTest.internalEncode(jsonWrapper, aciProportionMeasureNode);
//assert
assertThat(objectUnderTest.getDetails())
.hasSize(1);
assertWithMessage("The validation error must be the inability to find an encoder")
.that(objectUnderTest.getDetails().get(0).getMessage())
.isEqualTo("Failed to find an encoder");
}
示例7: testResourcePast
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
public void testResourcePast() {
final Instant time = parse("2017-02-15T11:00:00Z");
final Resource res = service.get(identifier, time).get();
assertEquals(identifier, res.getIdentifier());
assertEquals(LDP.Container, res.getInteractionModel());
assertFalse(res.getMembershipResource().isPresent());
assertFalse(res.getMemberRelation().isPresent());
assertFalse(res.getMemberOfRelation().isPresent());
assertFalse(res.getInsertedContentRelation().isPresent());
assertFalse(res.getBinary().isPresent());
assertTrue(res.isMemento());
assertFalse(res.getInbox().isPresent());
assertEquals(parse("2017-02-15T10:05:00Z"), res.getModified());
assertEquals(0L, res.getTypes().size());
assertEquals(0L, res.stream().filter(TestUtils.isContainment.or(TestUtils.isMembership)).count());
final List<Triple> triples = res.stream().filter(TestUtils.isUserManaged)
.map(Quad::asTriple).collect(toList());
assertEquals(0L, triples.size());
final List<VersionRange> mementos = res.getMementos();
assertEquals(1L, mementos.size());
assertEquals(parse("2017-02-15T10:05:00Z"), mementos.get(0).getFrom());
assertEquals(parse("2017-02-15T11:15:00Z"), mementos.get(0).getUntil());
}
示例8: constructor_super
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
public void constructor_super() {
String testSource = String.format(
"package %s;\n" +
"\n" +
"import %s;\n" +
"\n" +
"public class %s {\n" +
"\n" +
" public %s(@NotNull Integer intParam) {\n" +
" super();\n" +
" }\n" +
"\n" +
" public static void main(String[] args) {\n" +
" new %s(null);\n" +
" }\n" +
"}", PACKAGE, NotNull.class.getName(), CLASS_NAME, CLASS_NAME, CLASS_NAME);
expectNpeFromParameterCheck(testSource, "intParam", expectRunResult);
doTest(testSource);
}
示例9: canHandleFailureWhenGettingADatasetSample
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
public void canHandleFailureWhenGettingADatasetSample() {
Dataset dataset = aPersistedDataset();
when(datasetDao.get(dataset.getId())).thenReturn(dataset);
Throwable exception = new RuntimeException("boom!");
when(reader.read(dataset, "", "", "", 10)).thenReturn(Observable.error(exception));
String endpoint = "dataset/" + dataset.getId() + "/sample";
HttpResponse response = read(endpoint);
assertThat(response.getStatusCode(), is(INTERNAL_SERVER_ERROR.code()));
assertThat(response.getStatusMessage(), is(INTERNAL_SERVER_ERROR.reasonPhrase()));
assertThatErrorResponseIsCorrect(
response.getPayload(), exception.getMessage(), endpoint, INTERNAL_SERVER_ERROR);
}
示例10: testExceptionAddsValidation
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
void testExceptionAddsValidation() throws EncodeException {
Node numeratorDenominatorNode;
List<Node> nodes;
numeratorDenominatorNode = new Node(TemplateId.ACI_AGGREGATE_COUNT);
numeratorDenominatorNode.putValue("aggregateCount", "600");
nodes = new ArrayList<>();
nodes.add(numeratorDenominatorNode);
QppOutputEncoder encoder = new QppOutputEncoder(new Context());
encoder.setNodes(nodes);
FailingWriter failWrite = new FailingWriter();
encoder.encode(new BufferedWriter(failWrite));
assertThat(encoder.getDetails()).hasSize(1);
assertThat(encoder.getDetails().get(0).getMessage())
.isEqualTo("Fake IOException");
}
示例11: testPartition3
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
public void testPartition3() {
assertEquals(join(separator, "2a", "79", "8c", "70a37cae7da1c312e0d052297e9921aa"),
FileUtils.partition("trellis:repository/other"));
assertEquals(join(separator, "2a", "79", "8c", "70a37cae7da1c312e0d052297e9921aa"),
FileUtils.partition(rdf.createIRI("trellis:repository/other")));
}
示例12: testGraph
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
public void testGraph() {
final Authorization auth = Authorization.from(subject, graph);
assertEquals(subject, auth.getIdentifier());
assertEquals(2, auth.getAgent().size());
assertTrue(auth.getAgent().contains(rdf.createIRI("info:agent/foo")));
assertTrue(auth.getAgent().contains(rdf.createIRI("info:agent/bar")));
assertEquals(1, auth.getAgentClass().size());
assertTrue(auth.getAgentClass().contains(rdf.createIRI("info:agent/SomeClass")));
assertEquals(4, auth.getAgentGroup().size());
assertTrue(auth.getAgentGroup().contains(rdf.createIRI("info:group/group1")));
assertEquals(1, auth.getMode().size());
assertTrue(auth.getMode().contains(ACL.Read));
assertEquals(3, auth.getAccessTo().size());
assertTrue(auth.getAccessTo().contains(rdf.createIRI("trellis:repository/resource2")));
assertTrue(auth.getAccessTo().contains(rdf.createIRI("trellis:repository/resource3")));
assertTrue(auth.getAccessTo().contains(rdf.createIRI("trellis:repository/resource4")));
assertEquals(1, auth.getDefault().size());
assertTrue(auth.getDefault().contains(rdf.createIRI("trellis:repository/container")));
}
示例13: plcWriteRequestItem
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
@Tag("fast")
void plcWriteRequestItem() {
MockAddress address = new MockAddress("mock:/DATA");
WriteRequestItem writeRequestItem = new WriteRequestItem(Byte.class, address, (byte) 0x45);
assertTrue(writeRequestItem.getAddress().equals(address), "Unexpected address");
assertTrue(writeRequestItem.getDatatype() == Byte.class, "Unexpected data type");
assertTrue((Byte) writeRequestItem.getValues()[0] == 0x45, "Unexpected value");
}
示例14: testPut1
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
public void testPut1() {
final Response res = target("repo1/resource").queryParam("ext", "acl").request()
.put(entity("<> <http://purl.org/dc/terms/title> \"A title\" . ", APPLICATION_N_TRIPLES_TYPE));
assertEquals(FORBIDDEN, res.getStatusInfo());
}
示例15: testBasicFileAttributesToFileStat
import org.junit.jupiter.api.Test; //导入依赖的package包/类
@Test
public void testBasicFileAttributesToFileStat() {
Instant instant = Instant.ofEpochSecond(424242l, 42);
FileTime ftime = FileTime.from(instant);
BasicFileAttributes attr = Mockito.mock(BasicFileAttributes.class);
Mockito.when(attr.isDirectory()).thenReturn(true);
Mockito.when(attr.lastModifiedTime()).thenReturn(ftime);
Mockito.when(attr.creationTime()).thenReturn(ftime);
Mockito.when(attr.lastAccessTime()).thenReturn(ftime);
Mockito.when(attr.size()).thenReturn(42l);
FileAttributesUtil util = new FileAttributesUtil();
FileStat stat = util.basicFileAttributesToFileStat(attr);
Assertions.assertTrue((FileStat.S_IFDIR & stat.st_mode.intValue()) == FileStat.S_IFDIR);
Assertions.assertEquals(424242l, stat.st_mtim.tv_sec.get());
Assertions.assertEquals(42, stat.st_mtim.tv_nsec.intValue());
Assertions.assertEquals(424242l, stat.st_ctim.tv_sec.get());
Assertions.assertEquals(42, stat.st_ctim.tv_nsec.intValue());
Assumptions.assumingThat(Platform.IS_MAC || Platform.IS_WINDOWS, () -> {
Assertions.assertEquals(424242l, stat.st_birthtime.tv_sec.get());
Assertions.assertEquals(42, stat.st_birthtime.tv_nsec.intValue());
});
Assertions.assertEquals(424242l, stat.st_atim.tv_sec.get());
Assertions.assertEquals(42, stat.st_atim.tv_nsec.intValue());
Assertions.assertEquals(42l, stat.st_size.longValue());
}