本文整理汇总了Java中org.junit.gen5.api.Test类的典型用法代码示例。如果您正苦于以下问题:Java Test类的具体用法?Java Test怎么用?Java Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Test类属于org.junit.gen5.api包,在下文中一共展示了Test类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: persistResolvedProject
import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("can dump and load resolved projects")
void persistResolvedProject() {
ResolvedProject project = new ResolvedProject(
ProjectCoordinates.from("project", "artifact"),
of(
ArtifactCoordinates.from("project", "artifact", "v1"),
ArtifactCoordinates.from("project", "artifact", "v2"))
);
String artifactAsYaml = persister.writeResolvedProject(project);
ResolvedProject loadedProject = persister.readResolvedProject(artifactAsYaml);
assertThat(loadedProject).isEqualTo(project);
// equality is based on coordinates so we have to check versions explicitly
assertThat(loadedProject.versions()).isEqualTo(project.versions());
}
示例2: persistResolvedArtifact
import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("can dump and load resolved artifacts")
void persistResolvedArtifact() {
ResolvedArtifact artifact = new ResolvedArtifact(
ArtifactCoordinates.from("artifact.group", "artifact", "version"),
of(
ArtifactCoordinates.from("dependee1.group", "dep", "v1"),
ArtifactCoordinates.from("dependee2.group", "dependee", "v2"))
);
String artifactAsYaml = persister.writeResolvedArtifact(artifact);
ResolvedArtifact loadedArtifact = persister.readResolvedArtifact(artifactAsYaml);
assertThat(loadedArtifact).isEqualTo(artifact);
// equality is based on coordinates so we have to check dependees explicitly
assertThat(loadedArtifact.dependees()).isEqualTo(artifact.dependees());
}
示例3: persistAnalyzedArtifact
import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("can dump and load analyzed artifacts")
void persistAnalyzedArtifact() {
AnalyzedArtifact artifact = new AnalyzedArtifact(
ArtifactCoordinates.from("artifact.group", "artifact", "version"),
of(
Violation.buildFor(
Type.of("artifact.package", "Class"),
of(
InternalType.of("sun.misc", "Unsafe", "internal", "JDK-internal"),
InternalType.of("sun.misc", "BASE64Encoder", "internal", "JDK-internal"))),
Violation.buildFor(
Type.of("artifact.package", "Class"),
of(
InternalType.of("sun.misc", "Unsafe", "internal", "JDK-internal"),
InternalType.of("sun.misc", "BASE64Encoder", "internal", "JDK-internal"))))
);
String artifactAsYaml = persister.writeAnalyzedArtifact(artifact);
AnalyzedArtifact loadedArtifact = persister.readAnalyzedArtifact(artifactAsYaml);
assertThat(loadedArtifact).isEqualTo(artifact);
// equality is based on coordinates so we have to check violations explicitly
assertThat(loadedArtifact.violations()).isEqualTo(artifact.violations());
}
示例4: testClone
import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that the {@link QueueElement#clone()} method will clone correctly. */
@Test
public void testClone() {
final QueueElement elem = new QueueElement();
final QueueElement clone;
final SongInfo song = new SongInfo(5);
final SongInfo cloneSong;
elem.setID(7);
elem.setQueueIndex(11);
elem.setPlayIndex(13);
elem.setSong(song);
clone = elem.clone();
assertNotNull(clone);
assertTrue(elem != clone);
assertEquals(elem.getID(), clone.getID());
assertEquals(elem.getQueueIndex(), clone.getQueueIndex());
assertEquals(elem.getPlayIndex(), clone.getPlayIndex());
cloneSong = clone.getSong();
assertNotNull(cloneSong);
assertTrue(song != cloneSong);
assertEquals(song.getID(), cloneSong.getID());
}
示例5: testSize
import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that the {@link IDSet#size()} returns the set's size correctly. */
@Test
public void testSize() {
final IDSet<TestIdentifiable> s = new IDSet<>();
assertEquals(0, s.size());
s.add(new TestIdentifiable(3));
assertEquals(1, s.size());
s.add(new TestIdentifiable(7));
assertEquals(2, s.size());
s.add(new TestIdentifiable(11));
assertEquals(3, s.size());
s.clear();
assertEquals(0, s.size());
assertEquals("[]", s.toString());
}
示例6: testSetPlayIndex_ValidQueue_MiddleElement
import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that a queue's play index can be set one of its middle elements */
@Test
public void testSetPlayIndex_ValidQueue_MiddleElement() throws IOException {
final Library lib = LibraryRESTCalls.getLibrary();
final int songID1 = lib.getSongs().get(0).getID();
final int songID2 = lib.getSongs().get(1).getID();
final int songID3 = lib.getSongs().get(2).getID();
Queue q = QueueRESTCalls.createQueue();
final int qID;
queuesToCleanup.add(q);
qID = q.getID();
// Add songs to the queue
q = QueueRESTCalls.addLast(200, qID, songID1, songID2, songID3);
// Verify that the play index can be set to 1
q = QueueRESTCalls.setPlayIndex(qID, 1);
assertThat(q.getPlayIndex(), is(equalTo(1)));
assertThat(q.getElement(0).getPlayIndex(), is(equalTo(-1)));
assertThat(q.getElement(1).getPlayIndex(), is(equalTo(0)));
assertThat(q.getElement(2).getPlayIndex(), is(equalTo(1)));
}
示例7: testRemoveElement_Only
import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that the a song can be removed from a queue when it is the only element in the queue. */
@Test
public void testRemoveElement_Only() throws IOException {
final Library lib = LibraryRESTCalls.getLibrary();
Queue q = QueueRESTCalls.createQueue();
final int qID;
queuesToCleanup.add(q);
qID = q.getID();
// Add a song to the queue
q = QueueRESTCalls.addLast(200, qID, lib.getSongs().get(0).getID());
// Remove the song and verify the returned queue does not contain the song
q = QueueRESTCalls.removeElement(qID, 0);
assertEquals(0, q.size());
// Get the queue and verify the song has been removed
q = QueueRESTCalls.getQueue(qID);
assertEquals(0, q.size());
}
示例8: testSortDescNullsFirst
import org.junit.gen5.api.Test; //导入依赖的package包/类
/**
* Tests to ensure that a {@link NullComparator} can be used to sort a collection that contains {@code null}
* elements in descending order. The {@code null}s should be at the beginning of the sorted collection.
*/
@Test
public void testSortDescNullsFirst() {
final Integer a = 13;
final Integer b = null;
final Integer c = 7;
final Integer d = null;
final Integer e = 11;
final List<Integer> list = new ArrayList<>();
list.add(a);
list.add(b);
list.add(c);
list.add(d);
list.add(e);
Collections.sort(list, new IntegerNullComparator(NullComparator.Order.DESC_NULLS_FIRST));
assertNull(list.get(0));
assertNull(list.get(1));
assertEquals(a, list.get(2));
assertEquals(e, list.get(3));
assertEquals(c, list.get(4));
}
示例9: testSetPlayIndex_ValidQueue_FirstElement
import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that a queue's play index can be set to its first element */
@Test
public void testSetPlayIndex_ValidQueue_FirstElement() throws IOException {
final Library lib = LibraryRESTCalls.getLibrary();
final int songID1 = lib.getSongs().get(0).getID();
final int songID2 = lib.getSongs().get(1).getID();
final int songID3 = lib.getSongs().get(2).getID();
Queue q = QueueRESTCalls.createQueue();
final int qID;
queuesToCleanup.add(q);
qID = q.getID();
// Add songs to the queue
q = QueueRESTCalls.addLast(200, qID, songID1, songID2, songID3);
// Verify that the play index can be set to 2
q = QueueRESTCalls.setPlayIndex(qID, 0);
assertThat(q.getPlayIndex(), is(equalTo(0)));
assertThat(q.getElement(0).getPlayIndex(), is(equalTo(0)));
assertThat(q.getElement(1).getPlayIndex(), is(equalTo(1)));
assertThat(q.getElement(2).getPlayIndex(), is(equalTo(2)));
}
示例10: testIndicesAfterAddSongLast
import org.junit.gen5.api.Test; //导入依赖的package包/类
/**
* Tests to ensure that the queue elements' indices are correct after the {@link Queue#addSongLast(SongInfo)}
* function is used to add a song to the queue.
*/
@Test
public void testIndicesAfterAddSongLast() {
final Queue queue = new Queue();
final SongInfo a = new SongInfo(5);
final SongInfo b = new SongInfo(7);
final SongInfo c = new SongInfo(11);
queue.addSongLast(a);
assertEquals(0, queue.getElement(0).getPlayIndex());
assertEquals(0, queue.getElement(0).getQueueIndex());
queue.addSongLast(b);
assertEquals(0, queue.getElement(0).getPlayIndex());
assertEquals(0, queue.getElement(0).getQueueIndex());
assertEquals(1, queue.getElement(1).getPlayIndex());
assertEquals(1, queue.getElement(1).getQueueIndex());
queue.addSongLast(c);
assertEquals(0, queue.getElement(0).getPlayIndex());
assertEquals(0, queue.getElement(0).getQueueIndex());
assertEquals(1, queue.getElement(1).getPlayIndex());
assertEquals(1, queue.getElement(1).getQueueIndex());
assertEquals(2, queue.getElement(2).getPlayIndex());
assertEquals(2, queue.getElement(2).getQueueIndex());
}
示例11: testClear
import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that the {@link IDSet#clear()} function empties the set. */
@Test
@SuppressWarnings("unused")
public void testClear() {
final IDSet<TestIdentifiable> s = new IDSet<>();
int count = 0;
s.add(new TestIdentifiable(3));
s.add(new TestIdentifiable(7));
s.add(new TestIdentifiable(11));
assertNotEquals(0, s.size());
assertNotEquals("[]", s.toString());
s.clear();
assertEquals(0, s.size());
for(TestIdentifiable i : s) {
count++;
}
assertEquals(0, count);
assertEquals("[]", s.toString());
}
示例12: testCreateServiceInfo
import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("Given a valid kubernetes service we provide a valid config service info")
public void testCreateServiceInfo() throws Exception {
Service service = new Service();
service.setMetadata(getObjectMeta());
service.setSpec(getServiceSpec());
ConfigServerServiceInfo serviceInfo = configServerServiceInfoCreator.createServiceInfo(service);
assertNotNull(serviceInfo);
assertEquals("http://config-service:8080/", serviceInfo.getUri());
}
开发者ID:serenity-devstack,项目名称:spring-cloud-services-connector,代码行数:13,代码来源:ConfigServerServiceInfoCreatorTest.java
示例13: testCreateServiceInfo_ServiceNoPorts
import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("Given a kubernetes service without ports we launch a NPE")
public void testCreateServiceInfo_ServiceNoPorts() throws Exception {
Service service = new Service();
service.setMetadata(getObjectMeta());
expectThrows(NullPointerException.class, () -> configServerServiceInfoCreator.createServiceInfo(service));
}
开发者ID:serenity-devstack,项目名称:spring-cloud-services-connector,代码行数:9,代码来源:ConfigServerServiceInfoCreatorTest.java
示例14: testCreateServiceInfo_ServiceNoMetadata
import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("Given a kubernetes service without metadata we launch a NPE")
public void testCreateServiceInfo_ServiceNoMetadata() throws Exception {
Service service = new Service();
service.setSpec(getServiceSpec());
expectThrows(NullPointerException.class, () -> configServerServiceInfoCreator.createServiceInfo(service));
}
开发者ID:serenity-devstack,项目名称:spring-cloud-services-connector,代码行数:10,代码来源:ConfigServerServiceInfoCreatorTest.java
示例15: testKubernetesServiceInfoCreatorFromServiceFile
import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("Given the service file, when we instantiate the content then we get a KubernetesServiceInfoCreator")
public void testKubernetesServiceInfoCreatorFromServiceFile() throws Exception {
InputStream resourceAsStream = this.getClass().getResourceAsStream(
"/META-INF/services/org.springframework.cloud.kubernetes.connector.KubernetesServiceInfoCreator");
byte[] bytes = new byte[resourceAsStream.available()];
resourceAsStream.read(bytes);
Class<?> aClass = Class.forName(new String(bytes));
Object o = aClass.newInstance();
assertTrue(o instanceof KubernetesServiceInfoCreator);
}
开发者ID:serenity-devstack,项目名称:spring-cloud-services-connector,代码行数:12,代码来源:ConfigServerServiceInfoCreatorTest.java