org.junit.jupiter.api.BeforeEach Java Examples
The following examples show how to use
org.junit.jupiter.api.BeforeEach.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerCaOrTofaTest.java From incubator-tuweni with Apache License 2.0 | 6 votes |
@BeforeEach void startServer(@TempDirectory Path tempDir, @VertxInstance Vertx vertx) throws Exception { knownClientsFile = tempDir.resolve("known-clients.txt"); Files.write(knownClientsFile, Arrays.asList("#First line", "foobar.com " + DUMMY_FINGERPRINT)); SelfSignedCertificate serverCert = SelfSignedCertificate.create(); HttpServerOptions options = new HttpServerOptions(); options .setSsl(true) .setClientAuth(ClientAuth.REQUIRED) .setPemKeyCertOptions(serverCert.keyCertOptions()) .setTrustOptions(VertxTrustOptions.trustClientOnFirstAccess(knownClientsFile)) .setIdleTimeout(1500) .setReuseAddress(true) .setReusePort(true); httpServer = vertx.createHttpServer(options); SecurityTestUtils.configureAndStartTestServer(httpServer); }
Example #2
Source File: EcsEncoderTest.java From ecs-logging-java with Apache License 2.0 | 6 votes |
@BeforeEach void setUp() { LoggerContext context = new LoggerContext(); logger = context.getLogger(getClass()); appender = new OutputStreamAppender(); appender.setContext(context); logger.addAppender(appender); EcsEncoder ecsEncoder = new EcsEncoder(); ecsEncoder.setServiceName("test"); ecsEncoder.setIncludeMarkers(true); ecsEncoder.setStackTraceAsArray(true); ecsEncoder.setIncludeOrigin(true); ecsEncoder.addAdditionalField(new EcsEncoder.Pair("foo", "bar")); ecsEncoder.addAdditionalField(new EcsEncoder.Pair("baz", "qux")); ecsEncoder.setEventDataset("testdataset.log"); ecsEncoder.start(); appender.setEncoder(ecsEncoder); appender.start(); }
Example #3
Source File: VirtualContainerTest.java From ofdrw with Apache License 2.0 | 6 votes |
@BeforeEach public void init() throws IOException { Path path = Paths.get(target); if (Files.exists(path)) { FileUtils.deleteDirectory(path.toFile()); } else { path = Files.createDirectories(path); } vc = new VirtualContainer(path); }
Example #4
Source File: ServerRecordTest.java From incubator-tuweni with Apache License 2.0 | 6 votes |
@BeforeEach void startServer(@TempDirectory Path tempDir, @VertxInstance Vertx vertx) throws Exception { knownClientsFile = tempDir.resolve("known-clients.txt"); Files.write(knownClientsFile, Arrays.asList("#First line", "foobar.com " + DUMMY_FINGERPRINT)); SelfSignedCertificate serverCert = SelfSignedCertificate.create(); HttpServerOptions options = new HttpServerOptions(); options .setSsl(true) .setClientAuth(ClientAuth.REQUIRED) .setPemKeyCertOptions(serverCert.keyCertOptions()) .setTrustOptions(VertxTrustOptions.recordClientFingerprints(knownClientsFile, false)) .setIdleTimeout(1500) .setReuseAddress(true) .setReusePort(true); httpServer = vertx.createHttpServer(options); SecurityTestUtils.configureAndStartTestServer(httpServer); }
Example #5
Source File: ServerTofaTest.java From incubator-tuweni with Apache License 2.0 | 6 votes |
@BeforeEach void startServer(@TempDirectory Path tempDir, @VertxInstance Vertx vertx) throws Exception { knownClientsFile = tempDir.resolve("known-clients.txt"); Files.write(knownClientsFile, Arrays.asList("#First line", "foobar.com " + DUMMY_FINGERPRINT)); SelfSignedCertificate serverCert = SelfSignedCertificate.create(); HttpServerOptions options = new HttpServerOptions(); options .setSsl(true) .setClientAuth(ClientAuth.REQUIRED) .setPemKeyCertOptions(serverCert.keyCertOptions()) .setTrustOptions(VertxTrustOptions.trustClientOnFirstAccess(knownClientsFile, false)) .setIdleTimeout(1500) .setReuseAddress(true) .setReusePort(true); httpServer = vertx.createHttpServer(options); SecurityTestUtils.configureAndStartTestServer(httpServer); }
Example #6
Source File: HibernateTimeZoneIT.java From alchemy with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() { dateTimeWrapper = new DateTimeWrapper(); dateTimeWrapper.setInstant(Instant.parse("2014-11-12T05:50:00.0Z")); dateTimeWrapper.setLocalDateTime(LocalDateTime.parse("2014-11-12T07:50:00.0")); dateTimeWrapper.setOffsetDateTime(OffsetDateTime.parse("2011-12-14T08:30:00.0Z")); dateTimeWrapper.setZonedDateTime(ZonedDateTime.parse("2011-12-14T08:30:00.0Z")); dateTimeWrapper.setLocalTime(LocalTime.parse("14:30:00")); dateTimeWrapper.setOffsetTime(OffsetTime.parse("14:30:00+02:00")); dateTimeWrapper.setLocalDate(LocalDate.parse("2016-09-10")); dateTimeFormatter = DateTimeFormatter .ofPattern("yyyy-MM-dd HH:mm:ss.S") .withZone(ZoneId.of("UTC")); timeFormatter = DateTimeFormatter .ofPattern("HH:mm:ss") .withZone(ZoneId.of("UTC")); dateFormatter = DateTimeFormatter .ofPattern("yyyy-MM-dd"); }
Example #7
Source File: TerraformModuleRepositoryIT.java From gaia with Mozilla Public License 2.0 | 6 votes |
@BeforeEach void setUp() { // sample teams Team team1 = new Team("team1"); Team team2 = new Team("team2"); // sample owners bob = new User("Bob", null); // saving sample modules TerraformModule module1 = new TerraformModule(); module1.setId("Module 1"); module1.setAuthorizedTeams(List.of(team1)); module1.getModuleMetadata().setCreatedBy(bob); TerraformModule module2 = new TerraformModule(); module2.setId("Module 2"); module2.setAuthorizedTeams(List.of(team1, team2)); module2.getModuleMetadata().setCreatedBy(bob); terraformModuleRepository.deleteAll(); terraformModuleRepository.saveAll(List.of(module1, module2)); }
Example #8
Source File: SpringDocApp9Test.java From springdoc-openapi with Apache License 2.0 | 6 votes |
@BeforeEach void init() throws IllegalAccessException { Field convertersField2 = FieldUtils.getDeclaredField(ObjectMapper.class, "_mixIns", true); SimpleMixInResolver _mixIns = (SimpleMixInResolver) convertersField2.get(Json.mapper()); Field convertersField3 = FieldUtils.getDeclaredField(SimpleMixInResolver.class, "_localMixIns", true); Map<ClassKey, Class<?>> _localMixIns = (Map<ClassKey, Class<?>>) convertersField3.get(_mixIns); Iterator<Map.Entry<ClassKey, Class<?>>> it = _localMixIns.entrySet().iterator(); while (it.hasNext()) { Map.Entry<ClassKey, Class<?>> entry = it.next(); if (entry.getKey().toString().startsWith("org.springframework")) { springMixins.put(entry.getKey(), entry.getValue()); it.remove(); } } }
Example #9
Source File: IntegrationTest.java From aiven-kafka-connect-gcs with GNU Affero General Public License v3.0 | 6 votes |
@BeforeEach void setUp() throws ExecutionException, InterruptedException { testBucketAccessor.clear(gcsPrefix); final Properties adminClientConfig = new Properties(); adminClientConfig.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers()); adminClient = AdminClient.create(adminClientConfig); final Map<String, Object> producerProps = new HashMap<>(); producerProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers()); producerProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer"); producerProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer"); producer = new KafkaProducer<>(producerProps); final NewTopic newTopic0 = new NewTopic(TEST_TOPIC_0, 4, (short) 1); final NewTopic newTopic1 = new NewTopic(TEST_TOPIC_1, 4, (short) 1); adminClient.createTopics(Arrays.asList(newTopic0, newTopic1)).all().get(); connectRunner = new ConnectRunner(pluginDir, kafka.getBootstrapServers(), OFFSET_FLUSH_INTERVAL_MS); connectRunner.start(); }
Example #10
Source File: UsersServiceImplTest.java From realworld-api-quarkus with MIT License | 5 votes |
@BeforeEach public void beforeEach() { userRepository = mock(UserRepository.class); tokenProvider = mock(TokenProvider.class); hashProvider = mock(HashProvider.class); usersService = new UsersServiceImpl(userRepository, tokenProvider, hashProvider); }
Example #11
Source File: SpannerConnectionTest.java From cloud-spanner-r2dbc with Apache License 2.0 | 5 votes |
/** * Initializes the mocks in the test. */ @BeforeEach public void setupMocks() { this.mockClient = mock(Client.class); when(this.mockClient.beginTransaction(any(), any())) .thenReturn(Mono.just(Transaction.getDefaultInstance())); when(this.mockClient.commitTransaction(any(), any())) .thenReturn(Mono.just(CommitResponse.getDefaultInstance())); when(this.mockClient.rollbackTransaction(any(), any())) .thenReturn(Mono.empty()); }
Example #12
Source File: Log4j2EcsLayoutTest.java From ecs-logging-java with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { ctx = new LoggerContext("Test"); ctx.reconfigure(); ctx.getConfiguration().getProperties().put("node.id", "foo"); root = ctx.getRootLogger(); for (final Appender appender : root.getAppenders().values()) { root.removeAppender(appender); } EcsLayout ecsLayout = EcsLayout.newBuilder() .setConfiguration(ctx.getConfiguration()) .setServiceName("test") .setIncludeMarkers(true) .setIncludeOrigin(true) .setStackTraceAsArray(true) .setEventDataset("testdataset.log") .setAdditionalFields(new KeyValuePair[]{ new KeyValuePair("cluster.uuid", "9fe9134b-20b0-465e-acf9-8cc09ac9053b"), new KeyValuePair("node.id", "${node.id}"), new KeyValuePair("empty", "${empty}"), new KeyValuePair("clazz", "%C"), new KeyValuePair("custom", "%custom"), new KeyValuePair("emptyPattern", "%notEmpty{%invalidPattern}"), }) .build(); listAppender = new ListAppender("ecs", null, ecsLayout, false, false); listAppender.start(); root.addAppender(listAppender); root.setLevel(Level.DEBUG); }
Example #13
Source File: CorsAcceptanceTest.java From ethsigner with Apache License 2.0 | 5 votes |
@BeforeEach public void setUp() { final NodeConfiguration nodeConfig = new NodeConfigurationBuilder().cors(AUTHORISED_DOMAIN).build(); final SignerConfiguration signerConfig = new SignerConfigurationBuilder().build(); ethNode = new BesuNode(DOCKER, nodeConfig); ethNode.start(); ethNode.awaitStartupCompletion(); ethSigner = new Signer(signerConfig, nodeConfig, ethNode.ports()); ethSigner.start(); ethSigner.awaitStartupCompletion(); }
Example #14
Source File: QueryCepTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@BeforeEach public void prepare() { String drl = "package org.drools.compiler.integrationtests\n" + "import " + TestEvent.class.getCanonicalName() + "\n" + "declare TestEvent\n" + " @role( event )\n" + "end\n" + "query EventsFromStream\n" + " $event : TestEvent() from entry-point FirstStream\n" + "end\n" + "query ZeroToNineteenSeconds\n" + " $event : TestEvent() from entry-point FirstStream\n" + " $result : TestEvent ( this after [0s, 19s] $event) from entry-point SecondStream\n" + "end\n"; final KieServices ks = KieServices.Factory.get(); KieFileSystem kfs = ks.newKieFileSystem(); KieModuleModel kmodule = ks.newKieModuleModel(); KieBaseModel baseModel = kmodule.newKieBaseModel("defaultKBase") .setDefault(true) .setEventProcessingMode(EventProcessingOption.STREAM); baseModel.newKieSessionModel("defaultKSession") .setDefault(true) .setClockType(ClockTypeOption.get("pseudo")); kfs.writeKModuleXML(kmodule.toXML()); kfs.write( ResourceFactory.newByteArrayResource(drl.getBytes()) .setTargetPath("org/drools/compiler/integrationtests/queries.drl") ); assertTrue(ks.newKieBuilder(kfs).buildAll().getResults().getMessages().isEmpty()); ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession(); firstEntryPoint = ksession.getEntryPoint("FirstStream"); secondEntryPoint = ksession.getEntryPoint("SecondStream"); clock = ksession.getSessionClock(); }
Example #15
Source File: SigningEthSendTransactionIntegrationTest.java From ethsigner with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { sendTransaction = new SendTransaction(); sendRawTransaction = new SendRawTransaction(jsonRpc(), credentials); final TransactionCountResponder getTransactionResponse = new TransactionCountResponder(nonce -> nonce.add(ONE), ETH_GET_TRANSACTION_COUNT); clientAndServer.when(getTransactionResponse.request()).respond(getTransactionResponse); }
Example #16
Source File: IntegrationTestBase.java From ethsigner with Apache License 2.0 | 5 votes |
@BeforeEach public void setup() { jsonRpc = new JsonRpc2_0Web3j(null, 2000, defaultExecutorService()); eeaJsonRpc = new JsonRpc2_0Eea(null); if (clientAndServer.isRunning()) { clientAndServer.reset(); } }
Example #17
Source File: ExceptionTranslatorIT.java From java-microservices-examples with Apache License 2.0 | 5 votes |
@BeforeEach public void setup() { mockMvc = MockMvcBuilders.standaloneSetup(controller) .setControllerAdvice(exceptionTranslator) .setMessageConverters(jacksonMessageConverter) .build(); }
Example #18
Source File: EntityRecordItemListenerNFTTest.java From hedera-mirror-node with Apache License 2.0 | 5 votes |
@BeforeEach void before() { entityProperties.getPersist().setCryptoTransferAmounts(true); entityProperties.getPersist().setNonFeeTransfers(false); expectedEntityNum.clear(); expectedNonFeeTransfersCount = 0; expectedTransactions.clear(); }
Example #19
Source File: ReactiveAuditingBeforeBindCallbackTest.java From sdn-rx with Apache License 2.0 | 5 votes |
@BeforeEach public void setUp() { Neo4jMappingContext mappingContext = new Neo4jMappingContext(); mappingContext.setInitialEntitySet(new HashSet<>(Arrays.asList(Sample.class, ImmutableSample.class))); mappingContext.initialize(); IsNewAwareAuditingHandler originalHandler = new IsNewAwareAuditingHandler( new PersistentEntities(Arrays.asList(mappingContext))); spyOnHandler = spy(originalHandler); callback = new ReactiveAuditingBeforeBindCallback(() -> spyOnHandler); }
Example #20
Source File: WaitFactoryTests.java From vividus with Apache License 2.0 | 5 votes |
@BeforeEach void beforeEach() { waitFactory = new WaitFactory(); waitFactory.setTimeout(TIMEOUT); waitFactory.setPollingPeriod(TIMEOUT); }
Example #21
Source File: ModuleRestControllerTest.java From gaia with Mozilla Public License 2.0 | 5 votes |
@BeforeEach void setUp() { admin = new User("admin", null); john = new User("John Dorian", null); bobsTeam = new Team("bobsTeam"); bob = new User("Bob Kelso", bobsTeam); }
Example #22
Source File: UserMapperIT.java From java-microservices-examples with Apache License 2.0 | 5 votes |
@BeforeEach public void init() { user = new User(); user.setLogin(DEFAULT_LOGIN); user.setActivated(true); user.setEmail("johndoe@localhost"); user.setFirstName("john"); user.setLastName("doe"); user.setImageUrl("image_url"); user.setLangKey("en"); userDto = new UserDTO(user); }
Example #23
Source File: SettingsRepositoryTest.java From gaia with Mozilla Public License 2.0 | 5 votes |
@BeforeEach void setUp() { settings = new Settings(); settings.setExternalUrl("externalUrl"); settings.setDockerDaemonUrl("dockerDaemonUrl"); settingsRepository = new SettingsRepository(mongoTemplate, settings); }
Example #24
Source File: ReactiveWebApplicationTest.java From sdn-rx with Apache License 2.0 | 5 votes |
@BeforeEach void setupData() throws IOException { try (BufferedReader moviesReader = new BufferedReader( new InputStreamReader(this.getClass().getResourceAsStream("/movies.cypher"))); Session session = driver.session()) { session.writeTransaction(tx -> { tx.run("MATCH (n) DETACH DELETE n"); String moviesCypher = moviesReader.lines().collect(Collectors.joining(" ")); tx.run(moviesCypher); return null; }); } }
Example #25
Source File: UserServiceIT.java From alchemy with Apache License 2.0 | 5 votes |
@BeforeEach public void init() { user = new User(); user.setLogin(DEFAULT_LOGIN); user.setPassword(RandomStringUtils.random(60)); user.setActivated(true); user.setEmail(DEFAULT_EMAIL); user.setFirstName(DEFAULT_FIRSTNAME); user.setLastName(DEFAULT_LASTNAME); user.setImageUrl(DEFAULT_IMAGEURL); user.setLangKey(DEFAULT_LANGKEY); when(dateTimeProvider.getNow()).thenReturn(Optional.of(LocalDateTime.now())); auditingHandler.setDateTimeProvider(dateTimeProvider); }
Example #26
Source File: EcsFormatterTest.java From ecs-logging-java with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { record.setInstant(Instant.ofEpochMilli(5)); record.setSourceClassName("ExampleClass"); record.setSourceMethodName("exampleMethod"); record.setThreadID(7); record.setLoggerName("ExampleLogger"); }
Example #27
Source File: ProcessInstanceManagementResourceTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) @BeforeEach public void setup() { responseBuilder = mock(ResponseBuilder.class); Response response = mock(Response.class); when((runtimeDelegate).createResponseBuilder()).thenReturn(responseBuilder); lenient().when((responseBuilder).status(any(StatusType.class))).thenReturn(responseBuilder); lenient().when((responseBuilder).entity(any())).thenReturn(responseBuilder); lenient().when((responseBuilder).build()).thenReturn(response); application = mock(Application.class); processes = mock(Processes.class); Process process = mock(Process.class); ProcessInstances instances = mock(ProcessInstances.class); processInstance = mock(ProcessInstance.class); error = mock(ProcessError.class); lenient().when(processes.processById(anyString())).thenReturn(process); lenient().when(process.instances()).thenReturn(instances); lenient().when(instances.findById(anyString())).thenReturn(Optional.of(processInstance)); lenient().when(processInstance.error()).thenReturn(Optional.of(error)); lenient().when(processInstance.id()).thenReturn("abc-def"); lenient().when(processInstance.status()).thenReturn(ProcessInstance.STATE_ACTIVE); lenient().when(error.failedNodeId()).thenReturn("xxxxx"); lenient().when(error.errorMessage()).thenReturn("Test error message"); lenient().when(application.unitOfWorkManager()).thenReturn(new DefaultUnitOfWorkManager(new CollectingUnitOfWorkFactory())); resource = spy(new ProcessInstanceManagementResource(processes, application)); }
Example #28
Source File: TagResourceIT.java From java-microservices-examples with Apache License 2.0 | 5 votes |
@BeforeEach public void setup() { MockitoAnnotations.initMocks(this); final TagResource tagResource = new TagResource(tagRepository); this.restTagMockMvc = MockMvcBuilders.standaloneSetup(tagResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setControllerAdvice(exceptionTranslator) .setConversionService(createFormattingConversionService()) .setMessageConverters(jacksonMessageConverter) .setValidator(validator).build(); }
Example #29
Source File: JsonPathBeanTest.java From camel-quarkus with Apache License 2.0 | 5 votes |
@BeforeEach public void setup() { personRequest = new PersonRequest(); personRequest.setPerson(new Person()); personRequest.getPerson().setFirstName("Christophe"); personRequest.getPerson().setMiddleName("Sylvain"); personRequest.getPerson().setLastName("Fontane"); }
Example #30
Source File: ImperativeWebApplicationTest.java From sdn-rx with Apache License 2.0 | 5 votes |
@BeforeEach void setupData() throws IOException { try (BufferedReader moviesReader = new BufferedReader( new InputStreamReader(this.getClass().getResourceAsStream("/movies.cypher"))); Session session = driver.session()) { session.writeTransaction(tx -> { tx.run("MATCH (n) DETACH DELETE n"); String moviesCypher = moviesReader.lines().collect(Collectors.joining(" ")); tx.run(moviesCypher); return null; }); } }