org.junit.jupiter.api.BeforeAll Java Examples

The following examples show how to use org.junit.jupiter.api.BeforeAll. 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: AzureAadUserScannerTest.java    From clouditor with Apache License 2.0 6 votes vote down vote up
@BeforeAll
static void setUpOnce() {
  discoverAssets(
      AzureAadUserScanner::new,
      api -> {
        var user1 =
            createWithId(
                ActiveDirectoryUser.class,
                "1",
                new UserInner().withUserPrincipalName("#EXT#name"));

        var user2 =
            createWithId(
                ActiveDirectoryUser.class, "2", new UserInner().withUserPrincipalName("name"));

        when(api.azure.accessManagement().activeDirectoryUsers().list())
            .thenReturn(MockedPagedList.of(user1, user2));
      });
}
 
Example #2
Source File: AzureSQLDatabaseScannerTest.java    From clouditor with Apache License 2.0 6 votes vote down vote up
@BeforeAll
static void setUpOnce() {
  discoverAssets(
      AzureSQLDatabaseScanner::new,
      api -> {
        var server = createSqlServer("id", new ServerInner());
        when(server.name()).thenReturn("myServer");

        when(api.azure.sqlServers().list()).thenReturn(MockedPagedList.of(server));

        var db = createSqlDatabase("id", "name", new DatabaseInner());
        when(db.name()).thenReturn("myDatabase");

        when(server.databases().list()).thenReturn(MockedPagedList.of(db));
      });
}
 
Example #3
Source File: DataPathFeatureFlagAcceptanceTest.java    From ethsigner with Apache License 2.0 6 votes vote down vote up
@BeforeAll
public static void setUpBase() {
  Runtime.getRuntime()
      .addShutdownHook(new Thread(DataPathFeatureFlagAcceptanceTest::tearDownBase));

  final DockerClient docker = new DockerClientFactory().create();
  final NodeConfiguration nodeConfig = new NodeConfigurationBuilder().build();

  /*
   * Dynamic port allocation for either the RPC or WS ports triggers use of the data path.
   * use_data_path = (httpRpcPort == 0 || webSocketPort == 0)
   * By defining a value for those ports, no data path is present when launching EthSigner.
   */
  final SignerConfiguration signerConfig =
      new SignerConfigurationBuilder().withHttpRpcPort(7009).withWebSocketPort(7010).build();

  ethNode = new BesuNode(docker, nodeConfig);
  ethNode.start();
  ethNode.awaitStartupCompletion();

  ethSigner = new Signer(signerConfig, nodeConfig, ethNode.ports());
  ethSigner.start();
  ethSigner.awaitStartupCompletion();
}
 
Example #4
Source File: ClientWhitelistTest.java    From incubator-tuweni with Apache License 2.0 6 votes vote down vote up
@BeforeAll
static void startServers(@TempDirectory Path tempDir, @VertxInstance Vertx vertx) throws Exception {
  SelfSignedCertificate caSignedCert = SelfSignedCertificate.create("localhost");
  caValidFingerprint = certificateHexFingerprint(Paths.get(caSignedCert.keyCertOptions().getCertPath()));
  SecurityTestUtils.configureJDKTrustStore(tempDir, caSignedCert);
  caValidServer = vertx
      .createHttpServer(new HttpServerOptions().setSsl(true).setPemKeyCertOptions(caSignedCert.keyCertOptions()))
      .requestHandler(context -> context.response().end("OK"));
  startServer(caValidServer);

  SelfSignedCertificate fooCert = SelfSignedCertificate.create("foo.com");
  fooFingerprint = certificateHexFingerprint(Paths.get(fooCert.keyCertOptions().getCertPath()));
  fooServer = vertx
      .createHttpServer(new HttpServerOptions().setSsl(true).setPemKeyCertOptions(fooCert.keyCertOptions()))
      .requestHandler(context -> context.response().end("OK"));
  startServer(fooServer);

  SelfSignedCertificate barCert = SelfSignedCertificate.create("bar.com");
  barFingerprint = certificateHexFingerprint(Paths.get(barCert.keyCertOptions().getCertPath()));
  barServer = vertx
      .createHttpServer(new HttpServerOptions().setSsl(true).setPemKeyCertOptions(barCert.keyCertOptions()))
      .requestHandler(context -> context.response().end("OK"));
  startServer(barServer);
}
 
Example #5
Source File: ValueTransferWithAzureAcceptanceTest.java    From ethsigner with Apache License 2.0 6 votes vote down vote up
@BeforeAll
public static void setUpBase() {
  Runtime.getRuntime()
      .addShutdownHook(new Thread(ValueTransferWithAzureAcceptanceTest::tearDownBase));

  Assumptions.assumeTrue(
      System.getenv("ETHSIGNER_AZURE_CLIENT_ID") != null
          && System.getenv("ETHSIGNER_AZURE_CLIENT_SECRET") != null,
      "Ensure Azure client id and client secret env variables are set");

  final DockerClient docker = new DockerClientFactory().create();
  final NodeConfiguration nodeConfig = new NodeConfigurationBuilder().build();

  ethNode = new BesuNode(docker, nodeConfig);
  ethNode.start();
  ethNode.awaitStartupCompletion();

  final SignerConfiguration signerConfig =
      new SignerConfigurationBuilder().withAzureKeyVault("ethsignertestkey").build();

  ethSigner = new Signer(signerConfig, nodeConfig, ethNode.ports());
  ethSigner.start();
  ethSigner.awaitStartupCompletion();
}
 
Example #6
Source File: TestNDCG.java    From quaerite with Apache License 2.0 6 votes vote down vote up
@BeforeAll
public static void setUp() {

    JUDGMENTS.addJudgment("1", 3);
    JUDGMENTS.addJudgment("2", 2);
    JUDGMENTS.addJudgment("3", 3);
    JUDGMENTS.addJudgment("5", 1);
    JUDGMENTS.addJudgment("6", 2);
    JUDGMENTS.addJudgment("7", 3);
    JUDGMENTS.addJudgment("8", 2);
    List<String> ids = new ArrayList<>();
    for (int i = 1; i <= 6; i++) {
        ids.add(Integer.toString(i));
    }
    RESULT_SET = new SearchResultSet(1000, 10, 100, ids);
}
 
Example #7
Source File: AwsCloudTrailScannerTest.java    From clouditor with Apache License 2.0 6 votes vote down vote up
@BeforeAll
static void setUpOnce() throws IOException {
  discoverAssets(
      CloudTrailClient.class,
      AwsCloudTrailScanner::new,
      api ->
          when(api.describeTrails())
              .thenReturn(
                  DescribeTrailsResponse.builder()
                      .trailList(
                          Trail.builder()
                              .trailARN(ENCRYPTED_TRAIL)
                              .kmsKeyId("some-key-arn")
                              .build(),
                          Trail.builder().trailARN(UNENCRYPTED_TRAIL).build())
                      .build()));
}
 
Example #8
Source File: AwsRdsScannerTest.java    From clouditor with Apache License 2.0 6 votes vote down vote up
@BeforeAll
static void setUpOnce() throws IOException {
  discoverAssets(
      RdsClient.class,
      AwsRdsScanner::new,
      api ->
          when(api.describeDBInstances())
              .thenReturn(
                  DescribeDbInstancesResponse.builder()
                      .dbInstances(
                          DBInstance.builder()
                              .dbInstanceArn("arn:aws:rds:us-east-1:1234567890:db:mysqldb")
                              .storageEncrypted(true)
                              .publiclyAccessible(false)
                              .build())
                      .build()));
}
 
Example #9
Source File: UnreferencedShapesTest.java    From smithy with Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void before() {
    model = Model.assembler()
            .addImport(UnreferencedShapesTest.class.getResource("unreferenced-test.json"))
            .assemble()
            .unwrap();
}
 
Example #10
Source File: BaseIT.java    From apicurio-registry with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void beforeAll() throws Exception {
    if (!TestUtils.isExternalRegistry()) {
        registry.start();
    } else {
        LOGGER.info("Going to use already running registries on {}", TestUtils.getRegistryUrl());
    }
    TestUtils.waitFor("Cannot connect to registries on " + TestUtils.getRegistryUrl() + " in timeout!",
                      Constants.POLL_INTERVAL, Constants.TIMEOUT_FOR_REGISTRY_START_UP, TestUtils::isReachable);
    TestUtils.waitFor("Registry reports is ready",
            Constants.POLL_INTERVAL, Constants.TIMEOUT_FOR_REGISTRY_READY, () -> TestUtils.isReady(false), () -> TestUtils.isReady(true));
    RestAssured.baseURI = TestUtils.getRegistryUrl();
    LOGGER.info("Registry app is running on {}", RestAssured.baseURI);
    RestAssured.defaultParser = Parser.JSON;
}
 
Example #11
Source File: SelectorTest.java    From smithy with Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void before() {
    modelJson = Model.assembler().addImport(SelectorTest.class.getResource("model.json"))
            .disablePrelude()
            .assemble()
            .unwrap();
    traitModel = Model.assembler()
            .addImport(SelectorTest.class.getResource("nested-traits.smithy"))
            .assemble()
            .unwrap();
}
 
Example #12
Source File: ForwardNeighborSelectorTest.java    From smithy with Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void before() {
    model = Model.assembler()
            .addImport(ForwardNeighborSelectorTest.class.getResource("neighbor-test.smithy"))
            .assemble()
            .unwrap();
}
 
Example #13
Source File: RepositoryWithADifferentDatabaseIT.java    From sdn-rx with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void createTestDatabase() {

	try (Session session = neo4jConnectionSupport.driverInstance.session(SessionConfig.forDatabase("system"))) {

		session.run("CREATE DATABASE " + TEST_DATABASE_NAME).consume();
	}
}
 
Example #14
Source File: EventStreamIndexTest.java    From smithy with Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void beforeAll() {
    model = Model.assembler()
            .addImport(EventStreamIndexTest.class.getResource("event-stream-index.json"))
            .assemble()
            .unwrap();
}
 
Example #15
Source File: WalaResultAnalyzerTest.java    From fasten with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void setUp() throws ClassHierarchyException, CallGraphBuilderCancelException, IOException {
    var path = new File(Thread.currentThread().getContextClassLoader()
            .getResource("SingleSourceToTarget.jar")
            .getFile()).getAbsolutePath();

    graph = CallGraphConstructor.generateCallGraph(path);
}
 
Example #16
Source File: AzureSQLServerScannerTest.java    From clouditor with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void setUpOnce() {
  discoverAssets(
      AzureSQLServerScanner::new,
      api -> {
        var server = createSqlServer("id", new ServerInner());
        when(server.name()).thenReturn("myServer");

        when(api.azure.sqlServers().list()).thenReturn(MockedPagedList.of(server));
      });
}
 
Example #17
Source File: PartialCallGraphTest.java    From fasten with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void setUp() throws ClassHierarchyException, CallGraphBuilderCancelException, IOException {
    var path = Paths.get(new File(Thread.currentThread().getContextClassLoader()
            .getResource("SingleSourceToTarget.jar")
            .getFile()).getAbsolutePath());

    graph = WalaResultAnalyzer.wrap(CallGraphConstructor.generateCallGraph(path.toString()));

    type = graph.getClassHierarchy()
            .get(new FastenJavaURI("/name.space/SingleSourceToTarget"));
}
 
Example #18
Source File: ProductRepositorySpec.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
@BeforeAll
void setupTest() {
    Manufacturer apple = manufacturerRepository.save("Apple");
    productRepository.saveAll(Arrays.asList(
            new Product(
                    "MacBook",
                    apple
            ),
            new Product(
                    "iPhone",
                    apple
            )
    ));
}
 
Example #19
Source File: ServerTofaTest.java    From incubator-tuweni with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void setupClients(@TempDirectory Path tempDir, @VertxInstance Vertx vertx) throws Exception {
  SelfSignedCertificate caClientCert = SelfSignedCertificate.create("example.com");
  caFingerprint = certificateHexFingerprint(Paths.get(caClientCert.keyCertOptions().getCertPath()));
  SecurityTestUtils.configureJDKTrustStore(tempDir, caClientCert);
  caClient = vertx
      .createHttpClient(
          new HttpClientOptions()
              .setTrustOptions(InsecureTrustOptions.INSTANCE)
              .setSsl(true)
              .setKeyCertOptions(caClientCert.keyCertOptions()));

  SelfSignedCertificate fooCert = SelfSignedCertificate.create("foo.com");
  fooFingerprint = certificateHexFingerprint(Paths.get(fooCert.keyCertOptions().getCertPath()));
  HttpClientOptions fooClientOptions = new HttpClientOptions();
  fooClientOptions
      .setSsl(true)
      .setKeyCertOptions(fooCert.keyCertOptions())
      .setTrustOptions(InsecureTrustOptions.INSTANCE)
      .setConnectTimeout(1500)
      .setReuseAddress(true)
      .setReusePort(true);
  fooClient = vertx.createHttpClient(fooClientOptions);

  SelfSignedCertificate foobarCert = SelfSignedCertificate.create("foobar.com");
  HttpClientOptions foobarClientOptions = new HttpClientOptions();
  foobarClientOptions
      .setSsl(true)
      .setKeyCertOptions(foobarCert.keyCertOptions())
      .setTrustOptions(InsecureTrustOptions.INSTANCE)
      .setConnectTimeout(1500)
      .setReuseAddress(true)
      .setReusePort(true);
  foobarClient = vertx.createHttpClient(foobarClientOptions);
}
 
Example #20
Source File: SvnLinkedArtifactTest.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void setUp() throws CmdUtilException, IOException, SvnClientException {
	LogUtil.entering();
	final TempSvnRepository createAndFillTempSvnRepository = TempSvnRepositoryFactory
			.createAndFillTempSvnRepository();
	testRepoUrlString = createAndFillTempSvnRepository.testRepoUrlString;
	client = new SvnClientJavaHl(() -> new String[0], new JUnitConfiguration());
}
 
Example #21
Source File: ExampleUsingMultipleTransactionManagerTest.java    From sdn-rx with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void createDatabase(@Autowired Driver driver) {

	try (Session session = driver.session(SessionConfig.forDatabase("system"))) {
		session.run("CREATE DATABASE movies");
		session.run("CREATE DATABASE otherDb");
	}
}
 
Example #22
Source File: ReactiveExceptionTranslationIT.java    From sdn-rx with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void createConstraints(@Autowired Driver driver) {

	Flux.using(driver::rxSession,
		session -> session.run("CREATE CONSTRAINT ON (person:SimplePerson) ASSERT person.name IS UNIQUE").consume(),
		RxSession::close
	).then().as(StepVerifier::create).verifyComplete();
}
 
Example #23
Source File: SinkDocumentTest.java    From mongo-kafka with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void initBsonDocs() {

  flatStructKey = new BsonDocument();
  flatStructKey.put("_id", new BsonObjectId(ObjectId.get()));
  flatStructKey.put("myBoolean", new BsonBoolean(true));
  flatStructKey.put("myInt", new BsonInt32(42));
  flatStructKey.put("myBytes", new BsonBinary(new byte[] {65, 66, 67}));
  BsonArray ba1 = new BsonArray();
  ba1.addAll(asList(new BsonInt32(1), new BsonInt32(2), new BsonInt32(3)));
  flatStructKey.put("myArray", ba1);

  flatStructValue = new BsonDocument();
  flatStructValue.put("myLong", new BsonInt64(42L));
  flatStructValue.put("myDouble", new BsonDouble(23.23d));
  flatStructValue.put("myString", new BsonString("BSON"));
  flatStructValue.put("myBytes", new BsonBinary(new byte[] {120, 121, 122}));
  BsonArray ba2 = new BsonArray();
  ba2.addAll(asList(new BsonInt32(9), new BsonInt32(8), new BsonInt32(7)));
  flatStructValue.put("myArray", ba2);

  nestedStructKey = new BsonDocument();
  nestedStructKey.put("_id", new BsonDocument("myString", new BsonString("doc")));
  nestedStructKey.put(
      "mySubDoc", new BsonDocument("mySubSubDoc", new BsonDocument("myInt", new BsonInt32(23))));

  nestedStructValue = new BsonDocument();
  nestedStructValue.put("mySubDocA", new BsonDocument("myBoolean", new BsonBoolean(false)));
  nestedStructValue.put(
      "mySubDocB",
      new BsonDocument(
          "mySubSubDocC", new BsonDocument("myString", new BsonString("some text..."))));
}
 
Example #24
Source File: OpenApiConverterTest.java    From smithy with Apache License 2.0 5 votes vote down vote up
@BeforeAll
private static void setup() {
    testService = Model.assembler()
            .addImport(OpenApiConverterTest.class.getResource("test-service.json"))
            .discoverModels()
            .assemble()
            .unwrap();
}
 
Example #25
Source File: RSocketServerToClientITest.java    From spring-rsocket-demo with GNU General Public License v3.0 5 votes vote down vote up
@BeforeAll
public static void setupOnce() {
    // create a client identity spring for this test suite
    clientId = UUID.randomUUID().toString();

    // create a Spring context for this test suite and obtain some beans
    context = new AnnotationConfigApplicationContext(ServerConfig.class);

    // Create an RSocket server for use in testing
    RSocketMessageHandler messageHandler = context.getBean(RSocketMessageHandler.class);
    server = RSocketServer.create(messageHandler.responder())
            .payloadDecoder(PayloadDecoder.ZERO_COPY)
            .bind(TcpServerTransport.create("localhost", 0))
            .block();
}
 
Example #26
Source File: CheckForGreedyLabelsTest.java    From smithy with Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void before() {
    model = Model.assembler()
            .addImport(RemoveUnusedComponentsTest.class.getResource("greedy-labels.smithy"))
            .discoverModels()
            .assemble()
            .unwrap();
}
 
Example #27
Source File: SimpleDataSetEstimatorsTest.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void setUp() {
    triangle = new TriangleFunction("Triangle Function", N_SAMPLES, 0);
    triangleWithNaN = new DoubleDataSet(triangle);
    ((DoubleDataSet) triangleWithNaN).set(N_SAMPLES / 4, N_SAMPLES / 4, Double.NaN);
    ((DoubleDataSet) triangleWithNaN).set(N_SAMPLES / 4 * 3, Double.NaN, Double.NaN);
    emptyDataSet = new DefaultDataSet("EmptyDataSet");
    testGauss = new GaussFunction("testGauss", N_SAMPLES);
}
 
Example #28
Source File: ExampleUsingStaticDatabaseNameTest.java    From sdn-rx with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void createDatabase(@Autowired Driver driver) {

	try (Session session = driver.session(SessionConfig.forDatabase("system"))) {
		session.run("CREATE DATABASE movies");
	}
}
 
Example #29
Source File: RSocketClientDeniedConnectionToSecuredServerITest.java    From spring-rsocket-demo with GNU General Public License v3.0 5 votes vote down vote up
@BeforeAll
public static void setupOnce(@Autowired RSocketRequester.Builder builder,
                             @LocalRSocketServerPort Integer port,
                             @Autowired RSocketStrategies strategies) {

    mimeType = MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_AUTHENTICATION.getString());
    reqbuilder = builder;
    theport = port;

    // *******  The user 'fake' is NOT in the user list! **********
    credentials = new UsernamePasswordMetadata("fake", "pass");


}
 
Example #30
Source File: KnowledgeBuilderWithSecurityManagerTest.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void initSecurityManager() throws NoSuchAlgorithmException {
    oldSecurityManager = System.getSecurityManager();
    oldPolicy = Policy.getPolicy();
    // permissive policy
    Policy.setPolicy(new Policy() {
        @Override
        public boolean implies(ProtectionDomain domain, Permission permission) {
            return true;
        }
    });

    System.setSecurityManager(new SecurityManager());
}