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


Java BeforeEach類代碼示例

本文整理匯總了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)));
}
 
開發者ID:bonigarcia,項目名稱:mastering-junit5,代碼行數:23,代碼來源:RemoteFileTest.java

示例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);

}
 
開發者ID:jcustenborder,項目名稱:kafka-connect-kinesis,代碼行數:17,代碼來源:KinesisSourceTaskTest.java

示例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());
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:20,代碼來源:MongoCannedDatasetsWriterTest.java

示例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));
}
 
開發者ID:trellis-ldp,項目名稱:trellis-jms,代碼行數:19,代碼來源:JmsPublisherTest.java

示例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();
}
 
開發者ID:HPI-Information-Systems,項目名稱:AdvancedDataProfilingSeminar,代碼行數:22,代碼來源:SpiderTest.java

示例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);
}
 
開發者ID:HPI-Information-Systems,項目名稱:AdvancedDataProfilingSeminar,代碼行數:19,代碼來源:DeMarchiTest.java

示例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");
}
 
開發者ID:alek-sys,項目名稱:dataj,代碼行數:19,代碼來源:NullableFieldsTest.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);
}
 
開發者ID:jcustenborder,項目名稱:kafka-connect-kinesis,代碼行數:8,代碼來源:KinesisSourceConnectorTest.java

示例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);
}
 
開發者ID:trellis-ldp,項目名稱:trellis,代碼行數:10,代碼來源:WebACFilterTest.java

示例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();
}
 
開發者ID:ProgrammingLife2017,項目名稱:hygene,代碼行數:20,代碼來源:UITestBase.java

示例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();
}
 
開發者ID:Java-Publications,項目名稱:vaadin-016-helloworld-14,代碼行數:9,代碼來源:ShiroTest.java

示例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);
}
 
開發者ID:ProgrammingLife2017,項目名稱:hygene,代碼行數:8,代碼來源:ConsoleMessageTest.java

示例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());
}
 
開發者ID:ProgrammingLife2017,項目名稱:hygene,代碼行數:9,代碼來源:GraphDimensionsCalculatorTest.java

示例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);
}
 
開發者ID:ProgrammingLife2017,項目名稱:hygene,代碼行數:9,代碼來源:GraphAnnotationVisualizerTest.java


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