Java 类org.junit.jupiter.api.BeforeEach 实例源码

项目:kafka-connect-kinesis    文件:KinesisSourceTaskTest.java   
@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);

}
项目:dragoman    文件:MongoCannedDatasetsWriterTest.java   
@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());
}
项目:trellis-jms    文件:JmsPublisherTest.java   
@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));
}
项目:AdvancedDataProfilingSeminar    文件:SpiderTest.java   
@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();
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:RemoteFileTest.java   
@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)));
}
项目:AdvancedDataProfilingSeminar    文件:DeMarchiTest.java   
@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);
}
项目:dataj    文件:NullableFieldsTest.java   
@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");
}
项目:mastering-junit5    文件:RemoteFileTest.java   
@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)));
}
项目:kafka-connect-kinesis    文件:KinesisSourceConnectorTest.java   
@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);
}
项目:trellis    文件:WebACFilterTest.java   
@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);
}
项目:hygene    文件:UITestBase.java   
/**
 * 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();
}
项目:vaadin-016-helloworld-14    文件:ShiroTest.java   
@BeforeEach
void setUp() {

  IniSecurityManagerFactory factory = new IniSecurityManagerFactory("./src/test/resources/shiro-test.ini");
  SecurityManager securityManager = factory.getInstance();
  SecurityUtils.setSecurityManager(securityManager);
  subject = SecurityUtils.getSubject();
}
项目:hygene    文件:ConsoleMessageTest.java   
@BeforeEach
void setUp() {
    consoleMessage = new ConsoleMessage("The message");
    logEvent = mock(LogEvent.class);
    message = mock(Message.class);
    when(logEvent.getMessage()).thenReturn(message);
}
项目:spring-rest-commons-options    文件:GetOtherParameterControllerTest.java   
@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());

}
项目:hygene    文件:GraphDimensionsCalculatorTest.java   
@BeforeEach
public void beforeEach() {
    graphStore = new GraphStore();
    graphDimensionsCalculator = new GraphDimensionsCalculator(graphStore);

    graphDimensionsCalculator.setGraph(createGraph());
    graphDimensionsCalculator.setCanvasSize(mockCanvas().getWidth(), mockCanvas().getHeight());
}
项目:hygene    文件:GraphAnnotationVisualizerTest.java   
@BeforeEach
void beforeEach() {
    final GraphDimensionsCalculator graphDimensionsCalculator = mock(GraphDimensionsCalculator.class);
    final GraphicsContext graphicsContext = mock(GraphicsContext.class);

    graphAnnotationVisualizer = new GraphAnnotationVisualizer(graphDimensionsCalculator);
    graphAnnotationVisualizer.setGraphicsContext(graphicsContext);
}
项目:dragoman    文件:MongoDatasetDaoTest.java   
@BeforeEach
public void setUp() {
  Injector injector =
      Guice.createInjector(
          Modules.override(new DatasetModule(), new ConfigurationModule())
              .with(new MongoOverrideModule()));
  injector.injectMembers(this);

  when(mongoProvider.provide()).thenReturn(getMongoClient());
}
项目:autotest    文件:WebTestBase.java   
@BeforeEach
void init() {
    //打开chrome浏览器
    System.setProperty("webdriver.chrome.driver", Thread.currentThread().getContextClassLoader()
            .getResource("autotest/" + "chromedriver.exe").getPath());
    ChromeOptions options = new ChromeOptions();
    options.addArguments("disable-infobars");
    d = new ChromeDriver(options);
    d.manage().window().maximize();
    d.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
}
项目:trellis    文件:BinaryServiceTest.java   
@BeforeEach
public void setUp() {
    initMocks(this);
    doCallRealMethod().when(mockBinaryService).calculateDigest(any(), any());
    doCallRealMethod().when(mockBinaryService).setContent(any(), any());
    when(mockBinaryService.getContent(any())).thenReturn(of(mockInputStream));
    when(mockBinaryService.exists(eq(identifier))).thenReturn(true);
    when(mockBinaryService.digest(any(), any())).thenReturn(of(checksum));
}
项目:shuffleboard    文件:SingleKeyNetworkTableSourceTest.java   
@BeforeEach
public void setUp() {
  AsyncUtils.setAsyncRunner(Runnable::run);
  NetworkTableUtils.shutdown();
  inst = NetworkTableInstance.create();
  inst.waitForEntryListenerQueue(-1.0);
  inst.setUpdateRate(0.01);
  table = inst.getTable("");
}
项目:qpp-conversion-tool    文件:ValidationServiceImplTest.java   
@BeforeEach
void before() throws NoSuchFieldException, IllegalAccessException {
    ValidationServiceImpl meep = new ValidationServiceImpl(environment);
    Field rt = meep.getClass().getDeclaredField("restTemplate");
    rt.setAccessible(true);
    rt.set(meep, restTemplate);
    rt.setAccessible(false);
    objectUnderTest = spy(meep);

    Converter.ConversionReport report = mock(Converter.ConversionReport.class);
    when(report.getEncoded()).thenReturn(qppWrapper);
    when(converter.getReport()).thenReturn(report);
}
项目:EvoMaster    文件:BranchCovSCTest.java   
@BeforeEach
public void initTest() throws Exception {
    InstrumentingClassLoader cl = new InstrumentingClassLoader("com.foo");

    sc = (StringCalls)
            cl.loadClass(StringCallsImp.class.getName())
                    .newInstance();
}
项目:trellis    文件:OptionsHandlerTest.java   
@BeforeEach
public void setUp() {
    initMocks(this);
    when(mockResource.getMementos()).thenReturn(emptyList());
    when(mockResource.isMemento()).thenReturn(false);
    when(mockResource.getExtraLinkRelations()).thenAnswer(inv -> empty());
    when(mockRequest.getBaseUrl()).thenReturn(baseUrl);
    when(mockRequest.getPath()).thenReturn("/");
}
项目:traute    文件:AbstractTrauteTest.java   
@BeforeEach
public void commonSetUp() {
    settingsBuilder = TrautePluginSettingsBuilder.settingsBuilder();
    expectCompilationResult = CompilationResultExpectationBuilder.expectCompilationResult();
    expectRunResult = RunResultExpectationBuilder.expectRunResult();

    Assumptions.assumeTrue(Boolean.getBoolean(ACTIVATION_PROPERTY));
}
项目:trellis    文件:EventSerializerTest.java   
@BeforeEach
public void setUp() {
    initMocks(this);
    when(mockEvent.getIdentifier()).thenReturn(rdf.createIRI("info:event/12345"));
    when(mockEvent.getAgents()).thenReturn(singleton(rdf.createIRI("info:user/test")));
    when(mockEvent.getTarget()).thenReturn(of(rdf.createIRI("trellis:repository/resource")));
    when(mockEvent.getTypes()).thenReturn(singleton(Create));
    when(mockEvent.getTargetTypes()).thenReturn(singleton(Container));
    when(mockEvent.getInbox()).thenReturn(of(rdf.createIRI("info:ldn/inbox")));
    when(mockEvent.getCreated()).thenReturn(time);
}
项目:dataj    文件:AnnotatedClassProcessingTest.java   
@BeforeEach
void setUp() throws Exception {
    String source = "package com.example; import org.dataj.Data; @Entity @Data class Annotated { int age; }";

    Compilation compilation = javac()
            .withProcessors(new AnnotationProcessor())
            .compile(
                    JavaFileObjects.forResource("Entity.java"),
                    JavaFileObjects.forSourceString("Annotated", source)
            );

    JavaFileObject outputFile = compilation.generatedSourceFile("com.example.AnnotatedData").get();
    actualSource = JavaParser.parse(outputFile.openInputStream());
    referenceSource = JavaParser.parseResource("AnnotatedData.java");
}
项目:trellis    文件:AuthorizationTest.java   
@BeforeEach
public void setUp() {

    final IRI other = rdf.createIRI("trellis:repository/other");

    graph.clear();

    graph.add(rdf.createTriple(subject, ACL.agent, rdf.createIRI("info:agent/foo")));
    graph.add(rdf.createTriple(subject, ACL.agent, rdf.createIRI("info:agent/bar")));
    graph.add(rdf.createTriple(other, ACL.agent, rdf.createIRI("info:agent/baz")));

    graph.add(rdf.createTriple(subject, ACL.agentClass, rdf.createIRI("info:agent/SomeClass")));
    graph.add(rdf.createTriple(other, ACL.agentClass, rdf.createIRI("info:agent/SomeOtherClass")));

    graph.add(rdf.createTriple(subject, ACL.agentGroup, rdf.createIRI("info:group/group1")));
    graph.add(rdf.createTriple(subject, ACL.agentGroup, rdf.createIRI("info:group/group2")));
    graph.add(rdf.createTriple(subject, ACL.agentGroup, rdf.createIRI("info:group/group3")));
    graph.add(rdf.createTriple(subject, ACL.agentGroup, rdf.createIRI("info:group/group4")));

    graph.add(rdf.createTriple(subject, ACL.mode, ACL.Read));

    graph.add(rdf.createTriple(subject, ACL.accessTo, rdf.createIRI("trellis:repository/resource2")));
    graph.add(rdf.createTriple(subject, ACL.accessTo, rdf.createIRI("trellis:repository/resource3")));
    graph.add(rdf.createTriple(subject, ACL.accessTo, rdf.createIRI("trellis:repository/resource4")));
    graph.add(rdf.createTriple(subject, ACL.accessTo, rdf.createIRI("trellis:repository/resource4")));
    graph.add(rdf.createTriple(other, ACL.accessTo, rdf.createIRI("trellis:repository/resource5")));

    graph.add(rdf.createTriple(subject, ACL.accessToClass, PROV.Activity));
    graph.add(rdf.createTriple(other, ACL.accessToClass, PROV.Entity));

    graph.add(rdf.createTriple(subject, ACL.default_, rdf.createIRI("trellis:repository/container")));
}
项目:spring-rest-commons-options    文件:PageableControllerTest.java   
@BeforeEach
private void initJunit5() {
    ResourcesBuilder builder = ResourcesBuilder.getInstance();
    builder.build(Arrays.asList(new PageableController()));
    resources = builder.getResources();

}
项目:trellis    文件:DefaultAuditServiceTest.java   
@BeforeEach
public void setUp() {
    initMocks(this);
    when(mockSession.getAgent()).thenReturn(Trellis.AnonymousAgent);
    when(mockSession.getCreated()).thenReturn(created);
    when(mockSession.getDelegatedBy()).thenReturn(of(Trellis.AdministratorAgent));
}
项目:qpp-conversion-tool    文件:AggregateCountEncoderTest.java   
/**
 * Set up a default node to be pass to an encoder
 */
@BeforeEach
void createNode() {
    numeratorDenominatorNode = new Node(TemplateId.ACI_AGGREGATE_COUNT);
    numeratorDenominatorNode.putValue("aggregateCount", "600");

    nodes = new ArrayList<>();
    nodes.add(numeratorDenominatorNode);
}
项目:trellis    文件:GetHandlerTest.java   
@BeforeEach
public void setUp() {
    initMocks(this);
    when(mockResource.getMementos()).thenReturn(emptyList());
    when(mockResource.getInteractionModel()).thenReturn(LDP.RDFSource);
    when(mockResource.getModified()).thenReturn(time);
    when(mockResource.getBinary()).thenReturn(empty());
    when(mockResource.isMemento()).thenReturn(false);
    when(mockResource.getExtraLinkRelations()).thenAnswer(inv -> Stream.empty());

    when(mockLdpRequest.getRequest()).thenReturn(mockRequest);
    when(mockLdpRequest.getPath()).thenReturn("");
    when(mockLdpRequest.getBaseUrl()).thenReturn(baseUrl);
    when(mockLdpRequest.getHeaders()).thenReturn(mockHeaders);
}
项目:trellis-amqp    文件:AmqpPublisherTest.java   
@BeforeEach
public void setUp() throws IOException {
    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());
    doNothing().when(mockChannel).basicPublish(eq(exchangeName), eq(queueName), anyBoolean(), anyBoolean(),
            any(BasicProperties.class), any(byte[].class));
}
项目:dataj    文件:AnnotationProcessorTest.java   
@BeforeEach
void setUp() throws Exception {
    compilation = compile();

    JavaFileObject outputFile = compilation.generatedSourceFile("com.example.TestData").get();
    actualSource = JavaParser.parse(outputFile.openInputStream());
    referenceSource = JavaParser.parseResource("TestData.java");
}
项目:trellis-rosid    文件:NamespacesTest.java   
@BeforeEach
public void setUpMocks() throws Exception {
    initMocks(this);
    when(mockCurator.create()).thenReturn(mockCreateBuilder);
    when(mockCreateBuilder.orSetData()).thenReturn(mockCreateBuilder2);
    when(mockCache.getListenable()).thenReturn(mockListenable);
}
项目:qpp-conversion-tool    文件:InOrderAsyncActionServiceTest.java   
@BeforeEach
void runBeforeEachTest() {
    doAnswer(invocationOnMock -> {
        Runnable method = invocationOnMock.getArgument(0);
        CompletableFuture.runAsync(method);
        return null;
    }).when(taskExecutor).execute(any(Runnable.class));
}
项目:stf-console-client    文件:ConnectCommandTest.java   
@BeforeEach
@Override
protected void setUp() throws IOException {
    super.setUp();
    when(cache.getCachedFiles()).thenReturn(cachedDevices);
    when(farmClient.connectToDevices(any(DevicesParams.class))).thenReturn(Flowable.just((Notification.createOnNext("url"))));
    connectCommand = new ConnectCommand(farmClient, adbRunner, cache, logger);
}
项目:odotCore    文件:ItemDaoTest.java   
@BeforeEach
void setUp() {
  log.info("Test beginning...");
}
项目:DAT104    文件:ItemEntityEAOTest.java   
@BeforeEach
void setUp() {
    itemEAO = new ItemEAO();
    emf = Persistence.createEntityManagerFactory("eclipselink");
    em = emf.createEntityManager();
}
项目:kafka-connect-transform-cef    文件:CEFTransformationTest.java   
@BeforeEach
public void before() {
  this.transformation = new CEFTransformation<>();
  this.transformation.configure(ImmutableMap.of());
}
项目:xrpc    文件:XConfigTest.java   
@BeforeEach
void setUp() {}