本文整理匯總了Java中org.junit.jupiter.api.BeforeEach類的典型用法代碼示例。如果您正苦於以下問題:Java BeforeEach類的具體用法?Java BeforeEach怎麽用?Java BeforeEach使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BeforeEach類屬於org.junit.jupiter.api包,在下文中一共展示了BeforeEach類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setup
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
void setup() throws Exception {
// Look for free port for SUT instantiation
int port;
try (ServerSocket socket = new ServerSocket(0)) {
port = socket.getLocalPort();
}
remoteFileService = new RemoteFileService("http://localhost:" + port);
// Mock server
wireMockServer = new WireMockServer(options().port(port));
wireMockServer.start();
configureFor("localhost", wireMockServer.port());
// Stubbing service
stubFor(post(urlEqualTo("/api/v1/paths/" + filename + "/open-file"))
.willReturn(aResponse().withStatus(200).withBody(streamId)));
stubFor(post(urlEqualTo("/api/v1/streams/" + streamId + "/read"))
.willReturn(aResponse().withStatus(200).withBody(contentFile)));
stubFor(post(urlEqualTo("/api/v1/streams/" + streamId + "/close"))
.willReturn(aResponse().withStatus(200)));
}
示例2: before
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
public void before() {
this.sourceTaskContext = mock(SourceTaskContext.class);
this.offsetStorageReader = mock(OffsetStorageReader.class);
when(this.sourceTaskContext.offsetStorageReader()).thenReturn(this.offsetStorageReader);
this.task = new KinesisSourceTask();
this.task.initialize(this.sourceTaskContext);
this.kinesisClient = mock(AmazonKinesis.class);
this.task.time = mock(Time.class);
this.task.kinesisClientFactory = mock(KinesisClientFactory.class);
when(this.task.kinesisClientFactory.create(any())).thenReturn(this.kinesisClient);
this.settings = TestData.settings();
this.config = new KinesisSourceConnectorConfig(this.settings);
}
示例3: setUp
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
public void setUp() {
Injector injector =
Guice.createInjector(
Modules.override(
new DatasetModule(), new CannedDatasetsModule(), new ConfigurationModule())
.with(
new MongoOverrideModule(),
new AbstractModule() {
@Override
protected void configure() {
bind(CannedDatasetsLoader.class)
.toInstance(Mockito.mock(CannedDatasetsLoader.class));
}
}));
injector.injectMembers(this);
when(mongoProvider.provide()).thenReturn(getMongoClient());
}
示例4: setUp
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
public void setUp() throws JMSException {
initMocks(this);
when(mockEvent.getTarget()).thenReturn(of(rdf.createIRI("trellis:repository/resource")));
when(mockEvent.getAgents()).thenReturn(singleton(Trellis.AdministratorAgent));
when(mockEvent.getCreated()).thenReturn(time);
when(mockEvent.getIdentifier()).thenReturn(rdf.createIRI("urn:test"));
when(mockEvent.getTypes()).thenReturn(singleton(AS.Update));
when(mockEvent.getTargetTypes()).thenReturn(singleton(LDP.RDFSource));
when(mockEvent.getInbox()).thenReturn(empty());
when(mockConnection.createSession(anyBoolean(), eq(AUTO_ACKNOWLEDGE))).thenReturn(mockSession);
when(mockSession.createQueue(eq(queueName))).thenReturn(mockQueue);
when(mockSession.createTextMessage(anyString())).thenReturn(mockMessage);
when(mockSession.createProducer(any(Queue.class))).thenReturn(mockProducer);
doNothing().when(mockProducer).send(any(TextMessage.class));
}
示例5: setUp
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
input = RelationalInputStub.builder()
.relationName("Test")
.columnName(COL_A).columnName(COL_B).columnName(COL_C)
.row(Row.of("x", "z", null))
.row(Row.of("x", "y", null))
.row(Row.of("y", "x", null))
.build();
given(generator.generateNewCopy()).willReturn(input);
configuration = SpiderConfiguration.builder()
.tempFileGenerator(new FileGeneratorFake())
.resultReceiver(resultReceiver)
.relationalInputGenerator(generator)
.tpmmsConfiguration(TPMMSConfiguration.withDefaults())
.build();
}
示例6: setUp
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
columnNames = asList("a", "b", "c", "d");
columnTypes = asList("str", "int", "int", "str");
generator = TableInputGeneratorStub.builder()
.relationName("Test")
.columnNames(columnNames)
.row(Row.of("1", "1", "1", null))
.row(Row.of("1", "1", "3", null))
.row(Row.of(null, "2", "2", null))
.build();
given(tableInfoFactory.create(anyList(), anyList())).willReturn(tableFixture());
impl = new DeMarchi(tableInfoFactory);
}
示例7: setUp
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
void setUp() throws IOException {
String source = "package com.example; " +
"import org.dataj.Data; " +
"import javax.annotation.Nonnull;" +
"import javax.annotation.Nullable;" +
"@Data class NullableFields { @Nonnull String name; @Nullable Integer age; }";
Compilation compilation = javac()
.withProcessors(new AnnotationProcessor())
.compile(
JavaFileObjects.forSourceString("NullableFields", source)
);
JavaFileObject outputFile = compilation.generatedSourceFile("com.example.NullableFieldsData").get();
actualSource = JavaParser.parse(outputFile.openInputStream());
referenceSource = JavaParser.parseResource("NullableFieldsData.java");
}
示例8: setup
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
public void setup() {
this.kinesisClient = mock(AmazonKinesis.class, withSettings().verboseLogging());
this.connector = new KinesisSourceConnector();
this.connector.kinesisClientFactory = mock(KinesisClientFactory.class);
when(this.connector.kinesisClientFactory.create(any())).thenReturn(this.kinesisClient);
}
示例9: setUp
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
public void setUp() {
initMocks(this);
when(mockAccessControlService.getAccessModes(any(IRI.class), any(Session.class))).thenReturn(allModes);
when(mockContext.getUriInfo()).thenReturn(mockUriInfo);
when(mockUriInfo.getQueryParameters()).thenReturn(mockQueryParams);
when(mockQueryParams.getOrDefault(eq("ext"), eq(emptyList()))).thenReturn(emptyList());
when(mockUriInfo.getPath()).thenReturn(REPO1);
}
示例10: basicBeforeEach
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
/**
* Set up application before each test.
* Afterwards, calls the {@link #beforeEach()} method.
*
* @throws TimeoutException if unable to set up application
* @throws UIInitialisationException if ui was not properly initialized
* @see FxToolkit#setupApplication(Class, String...)
*/
@BeforeEach
public final void basicBeforeEach() throws TimeoutException, UIInitialisationException {
this.primaryStage = FxToolkit.registerPrimaryStage();
this.application = (Hygene) FxToolkit.setupApplication(Hygene.class);
this.context = Hygene.getInstance().getContext();
FxToolkit.showStage();
beforeEach();
}
示例11: setUp
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
void setUp() {
IniSecurityManagerFactory factory = new IniSecurityManagerFactory("./src/test/resources/shiro-test.ini");
SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
subject = SecurityUtils.getSubject();
}
示例12: setUp
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
void setUp() {
consoleMessage = new ConsoleMessage("The message");
logEvent = mock(LogEvent.class);
message = mock(Message.class);
when(logEvent.getMessage()).thenReturn(message);
}
示例13: setup
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@Before
@BeforeEach
public void setup() {
ResourcesBuilder builder = ResourcesBuilder.getInstance();
builder.build(Arrays.asList(new OtherParameterController()));
CollectionResources resources = builder.getResources();
assertNotNull(resources);
Resource r = resources.getResource("/other/parameter");
endpoints = r.getEndpoints();
assertEquals("POST", endpoints.get(POST).getHttpMethod());
}
開發者ID:damianwajser,項目名稱:spring-rest-commons-options,代碼行數:13,代碼來源:GetOtherParameterControllerTest.java
示例14: beforeEach
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
public void beforeEach() {
graphStore = new GraphStore();
graphDimensionsCalculator = new GraphDimensionsCalculator(graphStore);
graphDimensionsCalculator.setGraph(createGraph());
graphDimensionsCalculator.setCanvasSize(mockCanvas().getWidth(), mockCanvas().getHeight());
}
示例15: beforeEach
import org.junit.jupiter.api.BeforeEach; //導入依賴的package包/類
@BeforeEach
void beforeEach() {
final GraphDimensionsCalculator graphDimensionsCalculator = mock(GraphDimensionsCalculator.class);
final GraphicsContext graphicsContext = mock(GraphicsContext.class);
graphAnnotationVisualizer = new GraphAnnotationVisualizer(graphDimensionsCalculator);
graphAnnotationVisualizer.setGraphicsContext(graphicsContext);
}