Java Code Examples for org.junit.jupiter.api.BeforeAll

The following examples show how to use org.junit.jupiter.api.BeforeAll. These examples are extracted from open source projects. 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 Project: quaerite   Source File: TestNDCG.java    License: 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 2
Source Project: clouditor   Source File: AwsRdsScannerTest.java    License: 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 3
Source Project: clouditor   Source File: AwsCloudTrailScannerTest.java    License: 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 4
Source Project: clouditor   Source File: AzureSQLDatabaseScannerTest.java    License: 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 5
Source Project: clouditor   Source File: AzureAadUserScannerTest.java    License: 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 6
@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 7
@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 8
Source Project: incubator-tuweni   Source File: ClientWhitelistTest.java    License: 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 9
Source Project: quaerite   Source File: TestGenerateSolrExperiments.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void setUp() throws Exception {
    JSON = Files.createTempFile("quaerite-features", ".json");
    EXPERIMENTS = Files.createTempFile("quaerite-experiments", ".json");
    Files.copy(
            TestGenerateSolrExperiments.class.getResourceAsStream(
                    "/test-documents/experiment_features_solr_1.json"),
            JSON, StandardCopyOption.REPLACE_EXISTING);
}
 
Example 10
Source Project: jstarcraft-nlp   Source File: GlobalBloomFilterTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void beforeClass() {
    // 注意此处的编解码器
    Codec codec = new JsonJacksonCodec();
    Config configuration = new Config();
    configuration.setCodec(codec);
    configuration.useSingleServer().setAddress("redis://127.0.0.1:6379");
    redisson = (Redisson) Redisson.create(configuration);
}
 
Example 11
Source Project: clouditor   Source File: AwsLambdaScannerTest.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void setUpOnce() {
  discoverAssets(
      LambdaClient.class,
      AwsLambdaScanner::new,
      api -> {
        when(api.listFunctions())
            .thenReturn(
                ListFunctionsResponse.builder()
                    .functions(
                        FunctionConfiguration.builder()
                            .functionArn(
                                "arn:aws:lambda:eu-central-1:123456789:function:function-1")
                            .functionName("function-1")
                            .kmsKeyArn("some-key")
                            .build(),
                        FunctionConfiguration.builder()
                            .functionArn(
                                "arn:aws:lambda:eu-central-1:123456789:function:function-2")
                            .functionName("function-2")
                            .build())
                    .build());

        when(api.getPolicy(GetPolicyRequest.builder().functionName("function-1").build()))
            .thenReturn(GetPolicyResponse.builder().policy("*").build());

        when(api.getPolicy(GetPolicyRequest.builder().functionName("function-2").build()))
            .thenReturn(GetPolicyResponse.builder().policy("no-wildcard").build());
      });
}
 
Example 12
Source Project: fasten   Source File: PartialCallGraphTest.java    License: 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 13
Source Project: clouditor   Source File: AzureSQLServerScannerTest.java    License: 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 14
@BeforeAll
static void setUpOnce() {
  discoverAssets(
      AzureNetworkSecurityGroupScanner::new,
      api -> {
        var nsg = createWithId(NetworkSecurityGroup.class, "id", new NetworkSecurityGroupInner());

        when(api.azure.networkSecurityGroups().list()).thenReturn(MockedPagedList.of(nsg));
      });
}
 
Example 15
Source Project: clouditor   Source File: AzureSubscriptionScannerTest.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void setUpOnce() {
  discoverAssets(
      AzureSubscriptionScanner::new,
      api -> {
        var profile =
            new LogProfileResourceInner()
                .withRetentionPolicy(new RetentionPolicy().withDays(90).withEnabled(true));

        when(api.monitor().inner().logProfiles().list()).thenReturn(MockedPagedList.of(profile));
      });
}
 
Example 16
@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 17
Source Project: smithy   Source File: UnreferencedShapesTest.java    License: 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 18
Source Project: smithy   Source File: ForwardNeighborSelectorTest.java    License: 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 19
Source Project: smithy   Source File: SelectorTest.java    License: 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 20
Source Project: MergeProcessor   Source File: SvnLinkedArtifactTest.java    License: 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 Project: smithy   Source File: EventStreamIndexTest.java    License: 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 22
Source Project: sdn-rx   Source File: ReactiveExceptionTranslationIT.java    License: 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 Project: mongo-kafka   Source File: SinkDocumentTest.java    License: 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 Project: smithy   Source File: OpenApiConverterTest.java    License: 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
@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 Project: smithy   Source File: CheckForGreedyLabelsTest.java    License: 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 Project: chart-fx   Source File: SimpleDataSetEstimatorsTest.java    License: 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
@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 29
@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());
}
 
Example 30
Source Project: sdn-rx   Source File: ExampleUsingStaticDatabaseNameTest.java    License: 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");
	}
}