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

项目:java-learn    文件:MockitoTest.java   
/**
     * Methods inherited from class org.mockito.ArgumentMatchers
     * any, any, anyBoolean, anyByte, anyChar, anyCollection, anyCollectionOf, anyDouble, anyFloat,
     * anyInt, anyIterable, anyIterableOf, anyList, anyListOf, anyLong, anyMap, anyMapOf, anyObject,
     * anySet, anySetOf, anyShort, anyString, anyVararg, argThat, booleanThat, byteThat, charThat,
     * contains, doubleThat, endsWith, eq, eq, eq, eq, eq, eq, eq, eq, eq, floatThat, intThat, isA,
     * isNotNull, isNotNull, isNull, isNull, longThat, matches, matches, notNull, notNull, nullable,
     * refEq, same, shortThat, startsWith
     */
    @Test
    @DisplayName("参数匹配器")
    void paramMatcher(){

        //You can mock concrete classes, not just interfaces
        LinkedList mockedList = mock(LinkedList.class);

        //stubbing
//        when(mockedList.get(1)).thenThrow(new RuntimeException());
        when(mockedList.get(anyInt())).thenReturn("first");

        System.out.println(mockedList.get(0));
        System.out.println(mockedList.get(1));

    }
项目:reactive-ms-example    文件:ReactiveMsApplicationTest.java   
@Test
@DisplayName("post location")
void postLocationTest() {
    final LocationResponse response = post(
            builder -> builder.path(LOCATION_PATH).build(),
            new LocationRequest(GOOGLE_ADDRESS),
            LocationResponse.class);

    assertThat(response.getGeographicCoordinates(), not(nullValue()));
    assertThat(response.getGeographicCoordinates().getLatitude(), not(nullValue()));
    assertThat(response.getGeographicCoordinates().getLongitude(), not(nullValue()));

    assertThat(response.getSunriseSunset(), not(nullValue()));
    assertThat(response.getSunriseSunset().getSunrise(), not(isEmptyOrNullString()));
    assertThat(response.getSunriseSunset().getSunset(), not(isEmptyOrNullString()));
}
项目:verify-matching-service-adapter    文件:LevelOfAssuranceTwoScenario.java   
@Test
@DisplayName("Complex request with level of assurance 2")
public void runForComplexCase() throws Exception {
    String jsonString = fileUtils.readFromResources("LoA2-extensive-case.json")
        .replace("%yesterdayDate%", Instant.now().minus(1, DAYS).toString())
        .replace("%within405days-100days%", Instant.now().minus(100, DAYS).toString())
        .replace("%within405days-101days%", Instant.now().minus(150, DAYS).toString())
        .replace("%within405days-200days%", Instant.now().minus(400, DAYS).toString())
        .replace("%within180days-100days%", Instant.now().minus(100, DAYS).toString())
        .replace("%within180days-101days%", Instant.now().minus(140, DAYS).toString())
        .replace("%within180days-150days%", Instant.now().minus(160, DAYS).toString());

    Response response = client.target(configuration.getLocalMatchingServiceMatchUrl())
        .request(APPLICATION_JSON)
        .post(Entity.json(jsonString));

    validateMatchNoMatch(response);
}
项目:iStudent    文件:GreetingServiceTest.java   
@Test
@DisplayName("Updating a greeting should work")
void updateGreeting() {
    // Given we have a greeting already saved
    GreetingDto savedGreeting = service.createGreeting(createGreetingDto("We come in peace!"));
    Assumptions.assumeTrue(savedGreeting != null);
    // When we update it
    savedGreeting.setMessage("Updated message");
    service.updateGreetingWithId(savedGreeting.getId(), savedGreeting);
    // Then it should be updated
    Optional<GreetingDto> updatedGreetingOptional = service.findGreetingById(savedGreeting.getId());
    Assertions.assertAll("Updating a greeting by id should work",
            () -> assertTrue(updatedGreetingOptional.isPresent(), "Could not find greeting by id"),
            () -> assertEquals(savedGreeting.getId(), updatedGreetingOptional.get().getId(), "Updated greeting has invalid id"),
            () -> assertEquals("Updated message", updatedGreetingOptional.get().getMessage(), "Updated greeting has different message from the expected updated one"));

}
项目:agroal    文件:BasicNarayanaTests.java   
@Test
@DisplayName( "Basic rollback test" )
public void basicRollbackTest() throws SQLException {
    TransactionManager txManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
    TransactionSynchronizationRegistry txSyncRegistry = new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple();

    AgroalDataSourceConfigurationSupplier configurationSupplier = new AgroalDataSourceConfigurationSupplier()
            .connectionPoolConfiguration( cp -> cp
                    .transactionIntegration( new NarayanaTransactionIntegration( txManager, txSyncRegistry ) )
            );

    try ( AgroalDataSource dataSource = AgroalDataSource.from( configurationSupplier ) ) {
        txManager.begin();

        Connection connection = dataSource.getConnection();
        logger.info( format( "Got connection {0}", connection ) );

        txManager.rollback();

        assertTrue( connection.isClosed() );
    } catch ( NotSupportedException | SystemException e ) {
        fail( "Exception: " + e.getMessage() );
    }
}
项目:micrometer    文件:ExecutorServiceMetricsTest.java   
@DisplayName("ExecutorService can be monitored with a default set of metrics")
@Test
void monitorExecutorService() throws InterruptedException {
    ExecutorService pool = ExecutorServiceMetrics.monitor(registry, Executors.newSingleThreadExecutor(), "beep.pool", userTags);
    CountDownLatch taskStart = new CountDownLatch(1);
    CountDownLatch taskComplete = new CountDownLatch(1);

    pool.submit(() -> {
        taskStart.countDown();
        taskComplete.await(1, TimeUnit.SECONDS);
        System.out.println("beep");
        return 0;
    });
    pool.submit(() -> System.out.println("boop"));

    taskStart.await(1, TimeUnit.SECONDS);
    assertThat(registry.mustFind("beep.pool.queued").tags(userTags).gauge().value()).isEqualTo(1.0);

    taskComplete.countDown();
    pool.awaitTermination(1, TimeUnit.SECONDS);

    assertThat(registry.mustFind("beep.pool").tags(userTags).timer().count()).isEqualTo(2L);
    assertThat(registry.mustFind("beep.pool.queued").tags(userTags).gauge().value()).isEqualTo(0.0);
}
项目:micrometer    文件:CompositeMeterRegistryTest.java   
@DisplayName("metrics stop receiving updates when their registry parent is removed from a composite")
@Test
void metricAfterRegistryRemove() {
    composite.add(simple);

    Counter compositeCounter = composite.counter("counter");
    compositeCounter.increment();

    Counter simpleCounter = simple.mustFind("counter").counter();
    assertThat(simpleCounter.count()).isEqualTo(1);

    composite.remove(simple);
    compositeCounter.increment();

    // simple counter doesn't receive the increment after simple is removed from the composite
    assertThat(simpleCounter.count()).isEqualTo(1);

    composite.add(simple);
    compositeCounter.increment();

    // now it receives updates again
    assertThat(simpleCounter.count()).isEqualTo(2);
}
项目:agroal    文件:BasicNarayanaTests.java   
@Test
@DisplayName( "Multiple close test" )
public void multipleCloseTest() throws SQLException {
    TransactionManager txManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
    TransactionSynchronizationRegistry txSyncRegistry = new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple();

    AgroalDataSourceConfigurationSupplier configurationSupplier = new AgroalDataSourceConfigurationSupplier()
            .connectionPoolConfiguration( cp -> cp
                    .transactionIntegration( new NarayanaTransactionIntegration( txManager, txSyncRegistry ) )
            );

    try ( AgroalDataSource dataSource = AgroalDataSource.from( configurationSupplier ) ) {

        // there is a call to connection#close in the try-with-resources block and another on the callback from the transaction#commit()
        try ( Connection connection = dataSource.getConnection() ) {
            logger.info( format( "Got connection {0}", connection ) );
            try {
                txManager.begin();
                txManager.commit();
            } catch ( NotSupportedException | SystemException | RollbackException | HeuristicMixedException | HeuristicRollbackException e ) {
                fail( "Exception: " + e.getMessage() );
            }
        }  
    }
}
项目:odotCore    文件:CategoryDaoTest.java   
@Test
@DisplayName("Update Category")
public void testUpdate() {
  // Not sure what IDs are there, so let's grab
  /// them all, update one and make sure the update works
  List<Category> categories = classUnderTest.findAll();
  assertNotNull(categories, "List cannot be null!");
  assertFalse(categories.isEmpty());
  Category cat0 = categories.get(0);
  cat0.withDescription(cat0.getDescription() + "_UPDATED");
  boolean succeeded = classUnderTest.update(cat0);
  assertTrue(succeeded);// , "Update should succeed");
  Category catUpdated = classUnderTest.findById(cat0.getId());
  assertNotNull(catUpdated);
  doFieldByFieldAssertEquals(cat0, catUpdated);
}
项目:moppepojkar    文件:CommunicationsMediatorImplTest.java   
@Test
@DisplayName("should unsubscribe a subscribing receiver")
void unsubscribe() {
    // Arrange
    DataReceiver receiver = new DataReceiver() {
        @Override
        public void dataReceived(String data) {
            assert false;
        }
    };

    comInstance.subscribe(Direction.INTERNAL, receiver);

    // Act
    comInstance.unsubscribe(Direction.INTERNAL, receiver);

    // Assert
    comInstance.transmitData(value, Direction.INTERNAL);

}
项目:Nukkit-Java9    文件:VarIntTest.java   
@DisplayName("ZigZag")
@Test
void testZigZag() {
    assertAll(
            () -> assertEquals(0x2468acf0, VarInt.encodeZigZag32(0x12345678)),
            () -> assertEquals(0x2b826b1d, VarInt.encodeZigZag32(0xea3eca71)),
            () -> assertEquals(0x12345678, VarInt.decodeZigZag32(0x2468acf0)),
            () -> assertEquals(0xea3eca71, VarInt.decodeZigZag32(0x2b826b1d)),
            () -> assertEquals(2623536930346282224L, VarInt.encodeZigZag64(0x1234567812345678L)),
            () -> assertEquals(3135186066796324391L, VarInt.encodeZigZag64(0xea3eca710becececL)),
            () -> assertEquals(0x1234567812345678L, VarInt.decodeZigZag64(2623536930346282224L)),
            () -> assertEquals(0xea3eca710becececL, VarInt.decodeZigZag64(3135186066796324391L))
    );
}
项目:Nukkit-Java9    文件:VarIntTest.java   
@DisplayName("Reading")
@Test
void testRead() {
    assertAll(
            () -> assertEquals(2412, VarInt.readUnsignedVarInt(wrapBinaryStream("EC123EC456"))),
            () -> assertEquals(583868, VarInt.readUnsignedVarInt(wrapBinaryStream("BCD123EFA0"))),
            () -> assertEquals(1206, VarInt.readVarInt(wrapBinaryStream("EC123EC456"))),
            () -> assertEquals(291934, VarInt.readVarInt(wrapBinaryStream("BCD123EFA0"))),
            () -> assertEquals(6015, VarInt.readUnsignedVarLong(wrapBinaryStream("FF2EC456EC789EC012EC"))),
            () -> assertEquals(3694, VarInt.readUnsignedVarLong(wrapBinaryStream("EE1CD34BCD56BCD78BCD"))),
            () -> assertEquals(-3008, VarInt.readVarLong(wrapBinaryStream("FF2EC456EC789EC012EC"))),
            () -> assertEquals(1847, VarInt.readVarLong(wrapBinaryStream("EE1CD34BCD56BCD78BCD")))
    );
}
项目:junit5-demo    文件:BowlingGameTest.java   
@Test
@DisplayName("the score should be 0")
void testGutterGame() {
    rollMany(20, 0);

    assertEquals(0, game.score());
}
项目:mastering-junit5    文件:CustomNamesParameterizedTest.java   
@DisplayName("Display name of test container")
@ParameterizedTest(name = "[{index}] first argument=\"{0}\", second argument={1}")
@CsvSource({ "mastering, 1", "parameterized, 2", "tests, 3" })
void testWithCustomDisplayNames(String first, int second) {
    System.out.println(
            "Testing with parameters: " + first + " and " + second);
}
项目:stf-console-client    文件:StfCommanderTest.java   
@DisplayName("test_abi is parsed in command")
@ParameterizedTest(name = "Command is {0}")
@EnumSource(DeviceParamsProducingCommand.class)
void testAllDevicesEnabledByFlag(DeviceParamsProducingCommand source) throws Exception {
    DevicesParams params = runDeviceParamsTest(source, "--all");
    assertTrue(params.isAllDevices());
}
项目:stiletto    文件:InjectorAnnotationTest.java   
@Test
@DisplayName(".get(Class)")
void get() {
    final Injector inj = Injector.builder()
        .fromProviders(CompA.class.getPackage().getName())
        .build();

    assertTrue(inj.get(CompA.class).isPresent(), "CompA interface");
    assertTrue(inj.get(CompB.class).isPresent(), "CompB interface");
    assertFalse(inj.get(CompC.class).isPresent(), "CompC interface");

    assertTrue(inj.get(CompAImpl.class).isPresent(), "CompA class");
    assertTrue(inj.get(CompBImpl.class).isPresent(), "CompB class");
}
项目:junit5-demo    文件:BowlingGameTest.java   
@Test
@DisplayName("the score should be 300")
void testPerfectGame() {
    rollMany(12, 10);

    assertEquals(300, game.score());
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:CustomNamesParameterizedTest.java   
@DisplayName("Display name of test container")
@ParameterizedTest(name = "[{index}] first argument=\"{0}\", second argument={1}")
@CsvSource({ "mastering, 1", "parameterized, 2", "tests, 3" })
void testWithCustomDisplayNames(String first, int second) {
    System.out.println(
            "Testing with parameters: " + first + " and " + second);
}
项目:slang-steroids    文件:PipelineTest.java   
@Test
@DisplayName("can receive operations after mapping")
public void canReceiveOperationsAfterMapping(){
    String result = Pipeline.of("1")
            .with(value -> value + "1")
            .with(Integer::parseInt)
            .map(Tuple::of)
            .with(value -> value + "test")
            .map((tuple, string) -> string)
            .execute();
    Assertions.assertEquals("1test", result);
}
项目:stiletto    文件:InjectorAnnotationTest.java   
@Test
@DisplayName(".fromProviders()")
void fromProviderSpecs(){

    // Find the types when we scan the entire class path
    final Injector inj = Injector.builder()
        .fromProviders()
        .build();

    assertTrue(inj.get("a").isPresent(), "'a' qualifier");
    assertTrue(inj.get("b").isPresent(), "'b' qualifier");
    assertFalse(inj.get("c").isPresent(), "'c' qualifier");

    // Also find the types when we point to the correct pacakge root 
    final Injector inj2 = Injector.builder()
        .fromProviders(InjectorAnnotationTest.class.getPackage().getName() + ".testtype")
        .build();

    assertTrue(inj2.get("a").isPresent(), "'a' qualifier");
    assertTrue(inj2.get("b").isPresent(), "'b' qualifier");
    assertFalse(inj2.get("c").isPresent(), "'c' qualifier");

    // Don't find the types when we point to the wrong package root
    final Injector inj3 = Injector.builder()
        .fromProviders(InjectorAnnotationTest.class.getPackage().getName() + ".testtype2")
        .build();

    assertFalse(inj3.get("a").isPresent(), "'a' qualifier");
    assertFalse(inj3.get("b").isPresent(), "'b' qualifier");
    assertFalse(inj3.get("c").isPresent(), "'c' qualifier");
}
项目:membrane-spring-boot-starter    文件:MatcherSpecificationTests.java   
@Test
@DisplayName("should set the path pathPrefix on the service proxy")
void testSetPathPrefix() {
    matcherSpecification.pathPrefix("/api/");

    assertThat(serviceProxy.getPath()).isEqualToComparingFieldByField(new Path(false, "/api/"));
}
项目:dataj    文件:NullableFieldsTest.java   
@Test
@DisplayName("should apply JSR305 annotations to a setter")
void testSetterAnnotation() {
    // nullable
    assertThat(actualSource, andCompilationUnit(referenceSource)
            .hasSame(method("setName").ofClass("NullableFieldsData").withParams("String")));

    // nonnull
    assertThat(actualSource, andCompilationUnit(referenceSource)
            .hasSame(method("setAge").ofClass("NullableFieldsData").withParams("Integer")));
}
项目:molten-json    文件:JsonObjectTests.java   
@Test
@DisplayName("should add a string property")
void addStringProperty() throws JSONException {
    jsonObject.string("key", "value");

    assertEquals(new JSONObject().put("key", "value"), jsonOrgObject, STRICT);
}
项目:stiletto    文件:InjectorTest.java   
@Test
@DisplayName(".has(Class)")
void has() {
    final Injector inj = Injector.builder()
        .withType(CompAImpl.class, "a")
        .withType(CompBImpl.class)
        .build();

    assertTrue(inj.has(CompA.class), "CompA interface");
    assertTrue(inj.has(CompB.class), "CompB interface");
    assertFalse(inj.has(CompC.class), "CompC interface");

    assertTrue(inj.has(CompAImpl.class), "CompA class");
    assertTrue(inj.has(CompBImpl.class), "CompB class");
}
项目:odotCore    文件:ItemDaoTest.java   
@Test
@DisplayName("Update non-existent Item should fail")
public void testUpdate() {
  Item item = new Item().withDescription("DESCRIPTION");
  // Attempt to update, fails
  boolean succeeded = classUnderTest.update(item);
  assertFalse(succeeded);
}
项目:autotest    文件:BaiduTest.java   
@Test
@DisplayName("测试百度搜索页面")
void baiduTest() {
    d.get("http://www.baidu.com");
    d.findElement(By.id("kw")).sendKeys("junit");
    d.findElement(By.id("su")).click();
    sleep(2);
}
项目:iStudent    文件:GreetingServiceTest.java   
@Test
@DisplayName("Retrieving a greeting by id should work")
void findGreetingById() {
    // Given we have a greeting already saved
    GreetingDto savedGreeting = service.createGreeting(createGreetingDto("We come in peace!"));
    Assumptions.assumeTrue(savedGreeting != null);
    // When we try to retrieve it
    Optional<GreetingDto> greetingByIdOptional = service.findGreetingById(savedGreeting.getId());
    // Then it should be there
    Assertions.assertAll("Retrieving a greeting by id should work",
            () -> assertTrue(greetingByIdOptional.isPresent(), "Could not find greeting by id"),
            () -> assertEquals(savedGreeting.getId(), greetingByIdOptional.get().getId(), "Retrieved greeting has invalid id"),
            () -> assertEquals(savedGreeting.getMessage(), greetingByIdOptional.get().getMessage(), "Retrieved greeting has different message from the saved one"));

}
项目:slang-steroids    文件:PipelineTest.java   
@Test
@DisplayName("can have two operations")
public void canHaveTwoOperations(){
    Assertions.assertEquals(
        new Integer(2),
        Pipeline.of("test")
                .with(value -> value)
                .with(value -> value)
                .size()
    );
}
项目:micrometer    文件:CompositeMeterRegistryTest.java   
@DisplayName("function timer base units are delegated to registries in the composite")
@Test
void functionTimerUnits() {
    composite.add(simple);
    Object o = new Object();

    composite.more().timer("function.timer", emptyList(),
        o, o2 -> 1, o2 -> 1, TimeUnit.MILLISECONDS);

    FunctionTimer functionTimer = simple.mustFind("function.timer").functionTimer();
    assertThat(functionTimer.count()).isEqualTo(1);
    assertThat(functionTimer.totalTime(TimeUnit.MILLISECONDS)).isEqualTo(1);
}
项目:micrometer    文件:DistributionSummaryTest.java   
@Test
@DisplayName("negative quantities are ignored")
default void recordNegative(MeterRegistry registry) {
    DistributionSummary ds = registry.summary("myDistributionSummary");

    ds.record(-10);
    assertAll(() -> assertEquals(0, ds.count()),
            () -> assertEquals(0L, ds.totalAmount()));
}
项目:stiletto    文件:InjectorAnnotationTest.java   
@Test
@DisplayName(".has(Class)")
void has() {
    final Injector inj = Injector.builder()
        .fromProviders("com.github.pyknic.stiletto.testtype")
        .build();

    assertTrue(inj.has(CompA.class), "CompA interface");
    assertTrue(inj.has(CompB.class), "CompB interface");
    assertFalse(inj.has(CompC.class), "CompC interface");

    assertTrue(inj.has(CompAImpl.class), "CompA class");
    assertTrue(inj.has(CompBImpl.class), "CompB class");
}
项目:membrane-spring-boot-starter    文件:PathResolverTests.java   
@Test
@DisplayName("should return the list of regex paths")
void regexPaths() {
    PathResolver pathResolver = new PathResolver(emptyList(), singletonList("^/api/.*$"));

    assertThat(pathResolver.regexPaths()).containsOnly("^/api/.*$");
}
项目:moppepojkar    文件:CommunicationsMediatorImplTest.java   
@Test
@DisplayName("should contact subscribers on multiple channels")
void subscribeInternalTest() {
    // Arrange
    final int[] called = new int[1];
    called[0] = 0;

    DataReceiver receiver = new DataReceiver() {
        int[] call = called;

        @Override
        public void dataReceived(String data) {
            call[0]++;
        }
    };

    comInstance.subscribe(Direction.INTERNAL, receiver);
    comInstance.subscribe(Direction.EXTERNAL, receiver);

    // Act
    comInstance.transmitData(value, Direction.EXTERNAL);
    comInstance.transmitData(value, Direction.INTERNAL);

    // Asserts
    assertEquals(2, called[0]);

}
项目:java-learn    文件:TestedServiceTest.java   
@BeforeEach
@DisplayName("BeforeEach")
void init() {

    log.info("-*--*--*--*--*--*--*--*--*-- BeforeEach --*--*--*--*--*--*--*--*--*-: {}",
            System.currentTimeMillis());
    service = new TestedService();
}
项目:micrometer    文件:TimerTest.java   
@Test
@DisplayName("total time and count are preserved for a single timing")
default void record(MeterRegistry registry) {
    Timer t = registry.timer("myTimer");
    t.record(42, TimeUnit.MILLISECONDS);
    clock(registry).add(step());

    assertAll(() -> assertEquals(1L, t.count()),
            () -> assertEquals(42, t.totalTime(TimeUnit.MILLISECONDS), 1.0e-12));
}
项目:micrometer    文件:TimerTest.java   
@Test
@DisplayName("record with stateful Sample instance")
default void recordWithSample(MeterRegistry registry) throws Exception {
    Timer timer = registry.timer("myTimer");
    Timer.Sample sample = Timer.start(registry);

    clock(registry).add(10, TimeUnit.NANOSECONDS);
    sample.stop(timer);
    clock(registry).add(step());

    assertAll(() -> assertEquals(1L, timer.count()),
        () -> assertEquals(10, timer.totalTime(TimeUnit.NANOSECONDS) ,1.0e-12));
}
项目:micrometer    文件:MeterRegistryCompatibilityKit.java   
@Test
@DisplayName("find meters by name and class type matching a subset of their tags")
void findMeters(MeterRegistry registry) {
    Counter c1 = registry.counter("foo", "k", "v");
    Counter c2 = registry.counter("bar", "k", "v", "k2", "v");

    assertThat(registry.mustFind("foo").tags("k", "v").counter()).isSameAs(c1);
    assertThat(registry.mustFind("bar").tags("k", "v").counter()).isSameAs(c2);
}
项目:agroal    文件:BasicHikariTests.java   
@Test
@DisplayName( "Acquisition timeout" )
public void basicAcquisitionTimeoutTest() throws SQLException {
    int MAX_POOL_SIZE = 100, ACQUISITION_TIMEOUT_MS = 1000, VALIDATION_MS = 1000;

    AgroalDataSourceConfigurationSupplier configurationSupplier = new AgroalDataSourceConfigurationSupplier()
            .dataSourceImplementation( HIKARI )
            .connectionPoolConfiguration( cp -> cp
                    .maxSize( MAX_POOL_SIZE )
                    .acquisitionTimeout( ofMillis( ACQUISITION_TIMEOUT_MS ) )
                    .validationTimeout( ofMillis( VALIDATION_MS ) )
                    .connectionFactoryConfiguration( cf -> cf
                            .driverClassName( fakeDriver.getClass().getName() )
                            .jdbcUrl( "jdbc://" )
                    )
            );

    try ( AgroalDataSource dataSource = AgroalDataSource.from( configurationSupplier ) ) {

        for ( int i = 0; i < MAX_POOL_SIZE; i++ ) {
            Connection connection = dataSource.getConnection();
            assertNotNull( connection.getSchema(), "Expected non null value" );
            //connection.close();
        }
        logger.info( format( "Holding all {0} connections from the pool and requesting a new one", MAX_POOL_SIZE ) );

        long start = nanoTime(), timeoutBound = (long) ( ACQUISITION_TIMEOUT_MS * 1.1 );
        assertTimeoutPreemptively( ofMillis( timeoutBound ), () -> assertThrows( SQLException.class, dataSource::getConnection ), "Expecting acquisition timeout" );

        long elapsed = NANOSECONDS.toMillis( nanoTime() - start );
        logger.info( format( "Acquisition timeout after {0}ms - Configuration is {1}ms", elapsed, ACQUISITION_TIMEOUT_MS ) );
        assertTrue( elapsed > ACQUISITION_TIMEOUT_MS, "Acquisition timeout before time" );
    }
}
项目:membrane-spring-boot-starter    文件:LogSpecificationTests.java   
@Test
@DisplayName("should set the category on the log interceptor")
void testSetCategory() {
    logSpecification.category("logSpecification");

    assertThat(logInterceptor.getCategory()).isEqualTo("logSpecification");
}