org.springframework.beans.DirectFieldAccessor.getPropertyValue()

Here are the examples of the java api org.springframework.beans.DirectFieldAccessor.getPropertyValue() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

66 Examples 7

19 View Source File : TaskExecutionAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void taskExecutorBuilderShouldApplyCustomSettings() {
    this.contextRunner.withPropertyValues("spring.task.execution.pool.queue-capacity=10", "spring.task.execution.pool.core-size=2", "spring.task.execution.pool.max-size=4", "spring.task.execution.pool.allow-core-thread-timeout=true", "spring.task.execution.pool.keep-alive=5s", "spring.task.execution.thread-name-prefix=mytest-").run(replacedertTaskExecutor((taskExecutor) -> {
        DirectFieldAccessor dfa = new DirectFieldAccessor(taskExecutor);
        replacedertThat(dfa.getPropertyValue("queueCapacity")).isEqualTo(10);
        replacedertThat(taskExecutor.getCorePoolSize()).isEqualTo(2);
        replacedertThat(taskExecutor.getMaxPoolSize()).isEqualTo(4);
        replacedertThat(dfa.getPropertyValue("allowCoreThreadTimeOut")).isEqualTo(true);
        replacedertThat(taskExecutor.getKeepAliveSeconds()).isEqualTo(5);
        replacedertThat(taskExecutor.getThreadNamePrefix()).isEqualTo("mytest-");
    }));
}

19 View Source File : QuartzAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void validateDefaultProperties() {
    this.contextRunner.withUserConfiguration(ManualSchedulerConfiguration.clreplaced).run((context) -> {
        replacedertThat(context).hreplacedingleBean(SchedulerFactoryBean.clreplaced);
        SchedulerFactoryBean schedulerFactory = context.getBean(SchedulerFactoryBean.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(schedulerFactory);
        QuartzProperties properties = new QuartzProperties();
        replacedertThat(properties.isAutoStartup()).isEqualTo(schedulerFactory.isAutoStartup());
        replacedertThat((int) properties.getStartupDelay().getSeconds()).isEqualTo(dfa.getPropertyValue("startupDelay"));
        replacedertThat(properties.isWaitForJobsToCompleteOnShutdown()).isEqualTo(dfa.getPropertyValue("waitForJobsToCompleteOnShutdown"));
        replacedertThat(properties.isOverwriteExistingJobs()).isEqualTo(dfa.getPropertyValue("overwriteExistingJobs"));
    });
}

19 View Source File : QuartzAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void withCustomConfiguration() {
    this.contextRunner.withPropertyValues("spring.quartz.auto-startup=false", "spring.quartz.startup-delay=1m", "spring.quartz.wait-for-jobs-to-complete-on-shutdown=true", "spring.quartz.overwrite-existing-jobs=true").run((context) -> {
        replacedertThat(context).hreplacedingleBean(SchedulerFactoryBean.clreplaced);
        SchedulerFactoryBean schedulerFactory = context.getBean(SchedulerFactoryBean.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(schedulerFactory);
        replacedertThat(schedulerFactory.isAutoStartup()).isFalse();
        replacedertThat(dfa.getPropertyValue("startupDelay")).isEqualTo(60);
        replacedertThat(dfa.getPropertyValue("waitForJobsToCompleteOnShutdown")).isEqualTo(true);
        replacedertThat(dfa.getPropertyValue("overwriteExistingJobs")).isEqualTo(true);
    });
}

19 View Source File : QuartzAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

private ContextConsumer<replacedertableApplicationContext> replacedertSchedulerName(String schedulerName) {
    return (context) -> {
        replacedertThat(context).hreplacedingleBean(SchedulerFactoryBean.clreplaced);
        SchedulerFactoryBean schedulerFactory = context.getBean(SchedulerFactoryBean.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(schedulerFactory);
        replacedertThat(dfa.getPropertyValue("schedulerName")).isEqualTo(schedulerName);
    };
}

19 View Source File : JmxAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void customJmxDomain() {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(CustomJmxDomainConfiguration.clreplaced, JmxAutoConfiguration.clreplaced, IntegrationAutoConfiguration.clreplaced);
    this.context.refresh();
    IntegrationMBeanExporter mbeanExporter = this.context.getBean(IntegrationMBeanExporter.clreplaced);
    DirectFieldAccessor dfa = new DirectFieldAccessor(mbeanExporter);
    replacedertThat(dfa.getPropertyValue("domain")).isEqualTo("foo.my");
}

19 View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testConnectionFactoryPublisherSettings() {
    this.contextRunner.withUserConfiguration(TestConfiguration.clreplaced).withPropertyValues("spring.rabbitmq.publisher-confirms=true", "spring.rabbitmq.publisher-returns=true").run((context) -> {
        CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.clreplaced);
        RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
        replacedertThat(dfa.getPropertyValue("publisherConfirms")).isEqualTo(true);
        replacedertThat(dfa.getPropertyValue("publisherReturns")).isEqualTo(true);
        replacedertThat(getMandatory(rabbitTemplate)).isTrue();
    });
}

19 View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testDirectRabbitListenerContainerFactoryWithCustomSettings() {
    this.contextRunner.withUserConfiguration(MessageConvertersConfiguration.clreplaced, MessageRecoverersConfiguration.clreplaced).withPropertyValues("spring.rabbitmq.listener.type:direct", "spring.rabbitmq.listener.direct.retry.enabled:true", "spring.rabbitmq.listener.direct.retry.maxAttempts:4", "spring.rabbitmq.listener.direct.retry.initialInterval:2000", "spring.rabbitmq.listener.direct.retry.multiplier:1.5", "spring.rabbitmq.listener.direct.retry.maxInterval:5000", "spring.rabbitmq.listener.direct.autoStartup:false", "spring.rabbitmq.listener.direct.acknowledgeMode:manual", "spring.rabbitmq.listener.direct.consumers-per-queue:5", "spring.rabbitmq.listener.direct.prefetch:40", "spring.rabbitmq.listener.direct.defaultRequeueRejected:false", "spring.rabbitmq.listener.direct.idleEventInterval:5", "spring.rabbitmq.listener.direct.missingQueuesFatal:true").run((context) -> {
        DirectRabbitListenerContainerFactory rabbitListenerContainerFactory = context.getBean("rabbitListenerContainerFactory", DirectRabbitListenerContainerFactory.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitListenerContainerFactory);
        replacedertThat(dfa.getPropertyValue("consumersPerQueue")).isEqualTo(5);
        replacedertThat(dfa.getPropertyValue("missingQueuesFatal")).isEqualTo(true);
        checkCommonProps(context, dfa);
    });
}

19 View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testSimpleRabbitListenerContainerFactoryWithCustomSettings() {
    this.contextRunner.withUserConfiguration(MessageConvertersConfiguration.clreplaced, MessageRecoverersConfiguration.clreplaced).withPropertyValues("spring.rabbitmq.listener.simple.retry.enabled:true", "spring.rabbitmq.listener.simple.retry.maxAttempts:4", "spring.rabbitmq.listener.simple.retry.initialInterval:2000", "spring.rabbitmq.listener.simple.retry.multiplier:1.5", "spring.rabbitmq.listener.simple.retry.maxInterval:5000", "spring.rabbitmq.listener.simple.autoStartup:false", "spring.rabbitmq.listener.simple.acknowledgeMode:manual", "spring.rabbitmq.listener.simple.concurrency:5", "spring.rabbitmq.listener.simple.maxConcurrency:10", "spring.rabbitmq.listener.simple.prefetch:40", "spring.rabbitmq.listener.simple.defaultRequeueRejected:false", "spring.rabbitmq.listener.simple.idleEventInterval:5", "spring.rabbitmq.listener.simple.transactionSize:20", "spring.rabbitmq.listener.simple.missingQueuesFatal:false").run((context) -> {
        SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context.getBean("rabbitListenerContainerFactory", SimpleRabbitListenerContainerFactory.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitListenerContainerFactory);
        replacedertThat(dfa.getPropertyValue("concurrentConsumers")).isEqualTo(5);
        replacedertThat(dfa.getPropertyValue("maxConcurrentConsumers")).isEqualTo(10);
        replacedertThat(dfa.getPropertyValue("txSize")).isEqualTo(20);
        replacedertThat(dfa.getPropertyValue("missingQueuesFatal")).isEqualTo(false);
        checkCommonProps(context, dfa);
    });
}

19 View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testRabbitTemplateMessageConverters() {
    this.contextRunner.withUserConfiguration(MessageConvertersConfiguration.clreplaced).run((context) -> {
        RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.clreplaced);
        replacedertThat(rabbitTemplate.getMessageConverter()).isSameAs(context.getBean("myMessageConverter"));
        DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate);
        replacedertThat(dfa.getPropertyValue("retryTemplate")).isNull();
    });
}

19 View Source File : DiskSpaceHealthIndicatorAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void thresholdCanBeCustomized() {
    this.contextRunner.withPropertyValues("management.health.diskspace.threshold=20MB").run((context) -> {
        replacedertThat(context).hreplacedingleBean(DiskSpaceHealthIndicator.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(context.getBean(DiskSpaceHealthIndicator.clreplaced));
        replacedertThat(dfa.getPropertyValue("threshold")).isEqualTo(DataSize.ofMegabytes(20));
    });
}

19 View Source File : AbstractTyrusRequestUpgradeStrategy.java
License : MIT License
Project Creator : Vip-Augus

private Object createEndpoint(ServerEndpointRegistration registration, ComponentProviderService provider, WebSocketContainer container, TyrusWebSocketEngine engine) throws DeploymentException {
    DirectFieldAccessor accessor = new DirectFieldAccessor(engine);
    Object sessionListener = accessor.getPropertyValue("sessionListener");
    Object clusterContext = accessor.getPropertyValue("clusterContext");
    try {
        if (constructorWithBooleanArgument) {
            // Tyrus 1.11+
            return constructor.newInstance(registration.getEndpoint(), registration, provider, container, "/", registration.getConfigurator(), sessionListener, clusterContext, null, Boolean.TRUE);
        } else {
            return constructor.newInstance(registration.getEndpoint(), registration, provider, container, "/", registration.getConfigurator(), sessionListener, clusterContext, null);
        }
    } catch (Exception ex) {
        throw new HandshakeFailureException("Failed to register " + registration, ex);
    }
}

19 View Source File : ScriptTemplateViewTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void detectScriptTemplateConfigWithEngineName() {
    this.configurer.setEngineName("nashorn");
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.wac);
    replacedertEquals("nashorn", accessor.getPropertyValue("engineName"));
    replacedertNotNull(accessor.getPropertyValue("engine"));
    replacedertEquals("Template", accessor.getPropertyValue("renderObject"));
    replacedertEquals("render", accessor.getPropertyValue("renderFunction"));
    replacedertEquals(MediaType.TEXT_HTML_VALUE, accessor.getPropertyValue("contentType"));
    replacedertEquals(StandardCharsets.UTF_8, accessor.getPropertyValue("charset"));
}

19 View Source File : ScriptTemplateViewTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void detectScriptTemplateConfigWithEngine() {
    InvocableScriptEngine engine = mock(InvocableScriptEngine.clreplaced);
    this.configurer.setEngine(engine);
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    this.configurer.setContentType(MediaType.TEXT_PLAIN_VALUE);
    this.configurer.setCharset(StandardCharsets.ISO_8859_1);
    this.configurer.setSharedEngine(true);
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.wac);
    replacedertEquals(engine, accessor.getPropertyValue("engine"));
    replacedertEquals("Template", accessor.getPropertyValue("renderObject"));
    replacedertEquals("render", accessor.getPropertyValue("renderFunction"));
    replacedertEquals(MediaType.TEXT_PLAIN_VALUE, accessor.getPropertyValue("contentType"));
    replacedertEquals(StandardCharsets.ISO_8859_1, accessor.getPropertyValue("charset"));
    replacedertEquals(true, accessor.getPropertyValue("sharedEngine"));
}

19 View Source File : ScriptTemplateViewTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void customEngineAndRenderFunction() throws Exception {
    ScriptEngine engine = mock(InvocableScriptEngine.clreplaced);
    given(engine.get("key")).willReturn("value");
    this.view.setEngine(engine);
    this.view.setRenderFunction("render");
    this.view.setApplicationContext(this.wac);
    engine = this.view.getEngine();
    replacedertNotNull(engine);
    replacedertEquals("value", engine.get("key"));
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    replacedertNull(accessor.getPropertyValue("renderObject"));
    replacedertEquals("render", accessor.getPropertyValue("renderFunction"));
    replacedertEquals(StandardCharsets.UTF_8, accessor.getPropertyValue("charset"));
}

19 View Source File : ScriptTemplateViewTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void customEngineAndRenderFunction() throws Exception {
    ScriptEngine engine = mock(InvocableScriptEngine.clreplaced);
    given(engine.get("key")).willReturn("value");
    this.view.setEngine(engine);
    this.view.setRenderFunction("render");
    this.view.setApplicationContext(this.context);
    engine = this.view.getEngine();
    replacedertNotNull(engine);
    replacedertEquals("value", engine.get("key"));
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    replacedertNull(accessor.getPropertyValue("renderObject"));
    replacedertEquals("render", accessor.getPropertyValue("renderFunction"));
    replacedertEquals(StandardCharsets.UTF_8, accessor.getPropertyValue("defaultCharset"));
}

19 View Source File : ScriptTemplateViewTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void detectScriptTemplateConfigWithEngineName() {
    this.configurer.setEngineName("nashorn");
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.context);
    replacedertEquals("nashorn", accessor.getPropertyValue("engineName"));
    replacedertNotNull(accessor.getPropertyValue("engine"));
    replacedertEquals("Template", accessor.getPropertyValue("renderObject"));
    replacedertEquals("render", accessor.getPropertyValue("renderFunction"));
    replacedertEquals(StandardCharsets.UTF_8, accessor.getPropertyValue("defaultCharset"));
}

19 View Source File : ScriptTemplateViewTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void detectScriptTemplateConfigWithEngine() {
    InvocableScriptEngine engine = mock(InvocableScriptEngine.clreplaced);
    this.configurer.setEngine(engine);
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    this.configurer.setCharset(StandardCharsets.ISO_8859_1);
    this.configurer.setSharedEngine(true);
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.context);
    replacedertEquals(engine, accessor.getPropertyValue("engine"));
    replacedertEquals("Template", accessor.getPropertyValue("renderObject"));
    replacedertEquals("render", accessor.getPropertyValue("renderFunction"));
    replacedertEquals(StandardCharsets.ISO_8859_1, accessor.getPropertyValue("defaultCharset"));
    replacedertEquals(true, accessor.getPropertyValue("sharedEngine"));
}

19 View Source File : MethodJmsListenerEndpointTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void setExtraCollaborators() {
    MessageConverter messageConverter = mock(MessageConverter.clreplaced);
    DestinationResolver destinationResolver = mock(DestinationResolver.clreplaced);
    this.container.setMessageConverter(messageConverter);
    this.container.setDestinationResolver(destinationResolver);
    MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod("resolveObjectPayload", MyBean.clreplaced), this.container);
    DirectFieldAccessor accessor = new DirectFieldAccessor(listener);
    replacedertSame(messageConverter, accessor.getPropertyValue("messageConverter"));
    replacedertSame(destinationResolver, accessor.getPropertyValue("destinationResolver"));
}

19 View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
public void customEngineAndRenderFunction() {
    ScriptEngine engine = mock(InvocableScriptEngine.clreplaced);
    given(engine.get("key")).willReturn("value");
    this.view.setEngine(engine);
    this.view.setRenderFunction("render");
    this.view.setApplicationContext(this.wac);
    engine = this.view.getEngine();
    replacedertThat(engine).isNotNull();
    replacedertThat(engine.get("key")).isEqualTo("value");
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    replacedertThat(accessor.getPropertyValue("renderObject")).isNull();
    replacedertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
    replacedertThat(accessor.getPropertyValue("charset")).isEqualTo(StandardCharsets.UTF_8);
}

19 View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
public void detectScriptTemplateConfigWithEngine() {
    InvocableScriptEngine engine = mock(InvocableScriptEngine.clreplaced);
    this.configurer.setEngine(engine);
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    this.configurer.setContentType(MediaType.TEXT_PLAIN_VALUE);
    this.configurer.setCharset(StandardCharsets.ISO_8859_1);
    this.configurer.setSharedEngine(true);
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.wac);
    replacedertThat(accessor.getPropertyValue("engine")).isEqualTo(engine);
    replacedertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
    replacedertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
    replacedertThat(accessor.getPropertyValue("contentType")).isEqualTo(MediaType.TEXT_PLAIN_VALUE);
    replacedertThat(accessor.getPropertyValue("charset")).isEqualTo(StandardCharsets.ISO_8859_1);
    replacedertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true);
}

19 View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot

// gh-23258
@Test
public void engineSupplierWithSharedEngine() {
    this.configurer.setEngineSupplier(() -> mock(InvocableScriptEngine.clreplaced));
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    this.configurer.setSharedEngine(true);
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.wac);
    ScriptEngine engine1 = this.view.getEngine();
    ScriptEngine engine2 = this.view.getEngine();
    replacedertThat(engine1).isNotNull();
    replacedertThat(engine2).isNotNull();
    replacedertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
    replacedertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
    replacedertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true);
}

19 View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
public void detectScriptTemplateConfigWithEngineName() {
    this.configurer.setEngineName("nashorn");
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.wac);
    replacedertThat(accessor.getPropertyValue("engineName")).isEqualTo("nashorn");
    replacedertThat(accessor.getPropertyValue("engine")).isNotNull();
    replacedertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
    replacedertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
    replacedertThat(accessor.getPropertyValue("contentType")).isEqualTo(MediaType.TEXT_HTML_VALUE);
    replacedertThat(accessor.getPropertyValue("charset")).isEqualTo(StandardCharsets.UTF_8);
}

19 View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot

// gh-23258
@Test
public void engineSupplierWithSharedEngine() {
    this.configurer.setEngineSupplier(() -> mock(InvocableScriptEngine.clreplaced));
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    this.configurer.setSharedEngine(true);
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.context);
    ScriptEngine engine1 = this.view.getEngine();
    ScriptEngine engine2 = this.view.getEngine();
    replacedertThat(engine1).isNotNull();
    replacedertThat(engine2).isNotNull();
    replacedertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
    replacedertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
    replacedertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true);
}

19 View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
public void detectScriptTemplateConfigWithEngineName() {
    this.configurer.setEngineName("nashorn");
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.context);
    replacedertThat(accessor.getPropertyValue("engineName")).isEqualTo("nashorn");
    replacedertThat(accessor.getPropertyValue("engine")).isNotNull();
    replacedertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
    replacedertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
    replacedertThat(accessor.getPropertyValue("defaultCharset")).isEqualTo(StandardCharsets.UTF_8);
}

19 View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
public void detectScriptTemplateConfigWithEngine() {
    InvocableScriptEngine engine = mock(InvocableScriptEngine.clreplaced);
    this.configurer.setEngine(engine);
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    this.configurer.setCharset(StandardCharsets.ISO_8859_1);
    this.configurer.setSharedEngine(true);
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.context);
    replacedertThat(accessor.getPropertyValue("engine")).isEqualTo(engine);
    replacedertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
    replacedertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
    replacedertThat(accessor.getPropertyValue("defaultCharset")).isEqualTo(StandardCharsets.ISO_8859_1);
    replacedertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true);
}

19 View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
public void customEngineAndRenderFunction() throws Exception {
    ScriptEngine engine = mock(InvocableScriptEngine.clreplaced);
    given(engine.get("key")).willReturn("value");
    this.view.setEngine(engine);
    this.view.setRenderFunction("render");
    this.view.setApplicationContext(this.context);
    engine = this.view.getEngine();
    replacedertThat(engine).isNotNull();
    replacedertThat(engine.get("key")).isEqualTo("value");
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    replacedertThat(accessor.getPropertyValue("renderObject")).isNull();
    replacedertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
    replacedertThat(accessor.getPropertyValue("defaultCharset")).isEqualTo(StandardCharsets.UTF_8);
}

19 View Source File : MethodJmsListenerEndpointTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
void setExtraCollaborators() {
    MessageConverter messageConverter = mock(MessageConverter.clreplaced);
    DestinationResolver destinationResolver = mock(DestinationResolver.clreplaced);
    this.container.setMessageConverter(messageConverter);
    this.container.setDestinationResolver(destinationResolver);
    MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod("resolveObjectPayload", MyBean.clreplaced), this.container);
    DirectFieldAccessor accessor = new DirectFieldAccessor(listener);
    replacedertThat(accessor.getPropertyValue("messageConverter")).isSameAs(messageConverter);
    replacedertThat(accessor.getPropertyValue("destinationResolver")).isSameAs(destinationResolver);
}

19 View Source File : ConnectionIntrospector.java
License : Apache License 2.0
Project Creator : pgjdbc

/**
 * Return the underlying {@link ReactorNettyClient}.
 *
 * @return the underlying {@link ReactorNettyClient}.
 */
public ReactorNettyClient getClient() {
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.connection);
    Object value = accessor.getPropertyValue("client");
    replacedert.requireType(value, ReactorNettyClient.clreplaced, "Client must be of type ReactorNettyClient. Was: " + value.getClreplaced().getName());
    return (ReactorNettyClient) value;
}

19 View Source File : MethodJmsListenerEndpointTests.java
License : Apache License 2.0
Project Creator : langtianya

@Test
public void setExtraCollaborators() {
    MessageConverter messageConverter = mock(MessageConverter.clreplaced);
    DestinationResolver destinationResolver = mock(DestinationResolver.clreplaced);
    this.container.setMessageConverter(messageConverter);
    this.container.setDestinationResolver(destinationResolver);
    MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod("resolveObjectPayload", MyBean.clreplaced), container);
    DirectFieldAccessor accessor = new DirectFieldAccessor(listener);
    replacedertSame(messageConverter, accessor.getPropertyValue("messageConverter"));
    replacedertSame(destinationResolver, accessor.getPropertyValue("destinationResolver"));
}

18 View Source File : KafkaAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testConcurrentKafkaListenerContainerFactoryWithCustomAfterRollbackProcessor() {
    this.contextRunner.withUserConfiguration(AfterRollbackProcessorConfiguration.clreplaced).run((context) -> {
        ConcurrentKafkaListenerContainerFactory<?, ?> factory = context.getBean(ConcurrentKafkaListenerContainerFactory.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(factory);
        replacedertThat(dfa.getPropertyValue("afterRollbackProcessor")).isSameAs(context.getBean("afterRollbackProcessor"));
    });
}

18 View Source File : KafkaAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testConcurrentKafkaListenerContainerFactoryWithCustomMessageConverters() {
    this.contextRunner.withUserConfiguration(MessageConverterConfiguration.clreplaced).run((context) -> {
        ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory = context.getBean(ConcurrentKafkaListenerContainerFactory.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(kafkaListenerContainerFactory);
        replacedertThat(dfa.getPropertyValue("messageConverter")).isSameAs(context.getBean("myMessageConverter"));
    });
}

18 View Source File : KafkaAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testConcurrentKafkaListenerContainerFactoryWithKafkaTemplate() {
    this.contextRunner.run((context) -> {
        ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory = context.getBean(ConcurrentKafkaListenerContainerFactory.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(kafkaListenerContainerFactory);
        replacedertThat(dfa.getPropertyValue("replyTemplate")).isSameAs(context.getBean(KafkaTemplate.clreplaced));
    });
}

18 View Source File : RabbitPropertiesTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void directContainerUseConsistentDefaultValues() {
    DirectRabbitListenerContainerFactory factory = new DirectRabbitListenerContainerFactory();
    DirectMessageListenerContainer container = factory.createListenerContainer();
    DirectFieldAccessor dfa = new DirectFieldAccessor(container);
    RabbitProperties.DirectContainer direct = this.properties.getListener().getDirect();
    replacedertThat(direct.isAutoStartup()).isEqualTo(container.isAutoStartup());
    replacedertThat(direct.isMissingQueuesFatal()).isEqualTo(dfa.getPropertyValue("missingQueuesFatal"));
}

18 View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

private void replacedertListenerRetryTemplate(AbstractRabbitListenerContainerFactory<?> rabbitListenerContainerFactory, RetryPolicy retryPolicy) {
    DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitListenerContainerFactory);
    Advice[] adviceChain = (Advice[]) dfa.getPropertyValue("adviceChain");
    replacedertThat(adviceChain).isNotNull();
    replacedertThat(adviceChain.length).isEqualTo(1);
    dfa = new DirectFieldAccessor(adviceChain[0]);
    RetryTemplate retryTemplate = (RetryTemplate) dfa.getPropertyValue("retryOperations");
    dfa = new DirectFieldAccessor(retryTemplate);
    replacedertThat(dfa.getPropertyValue("retryPolicy")).isSameAs(retryPolicy);
}

18 View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testRabbitTemplateRetryWithCustomizer() {
    this.contextRunner.withUserConfiguration(RabbitRetryTemplateCustomizerConfiguration.clreplaced).withPropertyValues("spring.rabbitmq.template.retry.enabled:true", "spring.rabbitmq.template.retry.initialInterval:2000").run((context) -> {
        RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate);
        RetryTemplate retryTemplate = (RetryTemplate) dfa.getPropertyValue("retryTemplate");
        replacedertThat(retryTemplate).isNotNull();
        dfa = new DirectFieldAccessor(retryTemplate);
        replacedertThat(dfa.getPropertyValue("backOffPolicy")).isSameAs(context.getBean(RabbitRetryTemplateCustomizerConfiguration.clreplaced).backOffPolicy);
        ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) dfa.getPropertyValue("backOffPolicy");
        replacedertThat(backOffPolicy.getInitialInterval()).isEqualTo(100);
    });
}

18 View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testConnectionFactoryCacheSettings() {
    this.contextRunner.withUserConfiguration(TestConfiguration.clreplaced).withPropertyValues("spring.rabbitmq.cache.channel.size=23", "spring.rabbitmq.cache.channel.checkoutTimeout=1000", "spring.rabbitmq.cache.connection.mode=CONNECTION", "spring.rabbitmq.cache.connection.size=2").run((context) -> {
        CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
        replacedertThat(dfa.getPropertyValue("channelCacheSize")).isEqualTo(23);
        replacedertThat(dfa.getPropertyValue("cacheMode")).isEqualTo(CacheMode.CONNECTION);
        replacedertThat(dfa.getPropertyValue("connectionCacheSize")).isEqualTo(2);
        replacedertThat(dfa.getPropertyValue("channelCheckoutTimeout")).isEqualTo(1000L);
    });
}

18 View Source File : TaskExecutorBuilderTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void poolSettingsShouldApply() {
    ThreadPoolTaskExecutor executor = this.builder.queueCapacity(10).corePoolSize(4).maxPoolSize(8).allowCoreThreadTimeOut(true).keepAlive(Duration.ofMinutes(1)).build();
    DirectFieldAccessor dfa = new DirectFieldAccessor(executor);
    replacedertThat(dfa.getPropertyValue("queueCapacity")).isEqualTo(10);
    replacedertThat(executor.getCorePoolSize()).isEqualTo(4);
    replacedertThat(executor.getMaxPoolSize()).isEqualTo(8);
    replacedertThat(dfa.getPropertyValue("allowCoreThreadTimeOut")).isEqualTo(true);
    replacedertThat(executor.getKeepAliveSeconds()).isEqualTo(60);
}

18 View Source File : ViewResolverRegistryTests.java
License : MIT License
Project Creator : Vip-Augus

private void checkPropertyValues(ViewResolver resolver, Object... nameValuePairs) {
    DirectFieldAccessor accessor = new DirectFieldAccessor(resolver);
    for (int i = 0; i < nameValuePairs.length; i++, i++) {
        Object expected = nameValuePairs[i + 1];
        Object actual = accessor.getPropertyValue((String) nameValuePairs[i]);
        replacedertEquals(expected, actual);
    }
}

18 View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot

@SuppressWarnings("unchecked")
// gh-23258
@Test
public void engineSupplierWithNonSharedEngine() {
    this.configurer.setEngineSupplier(() -> mock(InvocableScriptEngine.clreplaced));
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    this.configurer.setSharedEngine(false);
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.wac);
    ScriptEngine engine1 = this.view.getEngine();
    ScriptEngine engine2 = this.view.getEngine();
    replacedertThat(engine1).isNotNull();
    replacedertThat(engine2).isNotNull();
    replacedertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
    replacedertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
    replacedertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(false);
}

18 View Source File : ViewResolverRegistryTests.java
License : Apache License 2.0
Project Creator : SourceHot

private void checkPropertyValues(ViewResolver resolver, Object... nameValuePairs) {
    DirectFieldAccessor accessor = new DirectFieldAccessor(resolver);
    for (int i = 0; i < nameValuePairs.length; i++, i++) {
        Object expected = nameValuePairs[i + 1];
        Object actual = accessor.getPropertyValue((String) nameValuePairs[i]);
        replacedertThat(actual).isEqualTo(expected);
    }
}

18 View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot

@SuppressWarnings("unchecked")
// gh-23258
@Test
public void engineSupplierWithNonSharedEngine() {
    this.configurer.setEngineSupplier(() -> mock(InvocableScriptEngine.clreplaced));
    this.configurer.setRenderObject("Template");
    this.configurer.setRenderFunction("render");
    this.configurer.setSharedEngine(false);
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
    this.view.setApplicationContext(this.context);
    ScriptEngine engine1 = this.view.getEngine();
    ScriptEngine engine2 = this.view.getEngine();
    replacedertThat(engine1).isNotNull();
    replacedertThat(engine2).isNotNull();
    replacedertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
    replacedertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
    replacedertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(false);
}

18 View Source File : ViewResolverRegistryTests.java
License : Apache License 2.0
Project Creator : SourceHot

// SPR-16431
@Test
public void scriptTemplate() {
    this.registry.scriptTemplate().prefix("/").suffix(".html");
    List<ViewResolver> viewResolvers = this.registry.getViewResolvers();
    replacedertThat(viewResolvers.size()).isEqualTo(1);
    replacedertThat(viewResolvers.get(0).getClreplaced()).isEqualTo(ScriptTemplateViewResolver.clreplaced);
    DirectFieldAccessor accessor = new DirectFieldAccessor(viewResolvers.get(0));
    replacedertThat(accessor.getPropertyValue("prefix")).isEqualTo("/");
    replacedertThat(accessor.getPropertyValue("suffix")).isEqualTo(".html");
}

17 View Source File : ExprListenerImpl.java
License : Apache License 2.0
Project Creator : XiaoMi

/**
 * 计算属性
 *
 * @param ctx
 */
@Override
public void exitPro(ExprParser.ProContext ctx) {
    log.debug("pro");
    ExpNode node = this.stack.pop();
    if (node.type.equals("id")) {
        // 计算属性
        Object obj = this.stack.pop().value;
        String property = node.value.toString();
        DirectFieldAccessor accessor = new DirectFieldAccessor(obj);
        Object value = accessor.getPropertyValue(property);
        this.stack.add(new ExpNode("id", value));
    } else if (node.type.equals("method")) {
        // 执行方法
        String method = node.value.toString();
        // string to map  私有函数:把string变为map.但string必须符合json格式
        if (method.equals("toMap")) {
            Object obj = this.stack.pop().value;
            Gson gson = new Gson();
            String str = "";
            if (obj.getClreplaced().equals(byte[].clreplaced)) {
                str = new String((byte[]) obj);
            } else {
                str = obj.toString();
            }
            Map m = gson.fromJson(str, Map.clreplaced);
            this.stack.add(new ExpNode("id", m));
            return;
        }
        if (method.equals("toList")) {
            Object obj = this.stack.pop().value;
            Gson gson = new Gson();
            String str = "";
            if (obj.getClreplaced().equals(byte[].clreplaced)) {
                str = new String((byte[]) obj);
            } else {
                str = obj.toString();
            }
            List l = gson.fromJson(str, List.clreplaced);
            this.stack.add(new ExpNode("id", l));
            return;
        }
        if (method.equals("json")) {
            Object obj = this.stack.pop().value;
            Gson gson = new Gson();
            String str = "";
            if (obj.getClreplaced().equals(byte[].clreplaced)) {
                str = new String((byte[]) obj);
            } else {
                str = obj.toString();
            }
            JsonObject jobj = gson.fromJson(str, JsonObject.clreplaced);
            this.stack.add(new ExpNode("id", jobj));
            return;
        }
        List<Object> list = Lists.newArrayList();
        // 包括参数
        if (this.stack.peek().type.equals("params")) {
            String params = this.stack.pop().value.toString();
            // 参数
            log.debug("========" + params);
            String[] ss = params.split(",");
            for (String s : ss) {
                String[] pp = s.split(":");
                if (pp[1].equals("int")) {
                    list.add(Integer.parseInt(pp[0]));
                } else if (pp[1].equals("long")) {
                    list.add(Long.valueOf(pp[0]));
                } else if (pp[1].equals("string")) {
                    list.add(pp[0]);
                }
            }
        }
        Object obj = this.stack.pop().value;
        try {
            Object res = null;
            if (list.size() > 0) {
                res = MethodUtils.invokeMethod(obj, method, list.toArray());
            } else {
                res = MethodUtils.invokeMethod(obj, method, null);
            }
            this.stack.add(new ExpNode("id", res));
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}

17 View Source File : SubProtocolWebSocketHandlerTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
@SuppressWarnings("unchecked")
public void checkSession() throws Exception {
    TestWebSocketSession session1 = new TestWebSocketSession("id1");
    TestWebSocketSession session2 = new TestWebSocketSession("id2");
    session1.setOpen(true);
    session2.setOpen(true);
    session1.setAcceptedProtocol("v12.stomp");
    session2.setAcceptedProtocol("v12.stomp");
    this.webSocketHandler.setProtocolHandlers(Arrays.asList(this.stompHandler));
    this.webSocketHandler.afterConnectionEstablished(session1);
    this.webSocketHandler.afterConnectionEstablished(session2);
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(this.webSocketHandler);
    Map<String, ?> map = (Map<String, ?>) handlerAccessor.getPropertyValue("sessions");
    DirectFieldAccessor session1Accessor = new DirectFieldAccessor(map.get("id1"));
    DirectFieldAccessor session2Accessor = new DirectFieldAccessor(map.get("id2"));
    long sixtyOneSecondsAgo = System.currentTimeMillis() - 61 * 1000;
    handlerAccessor.setPropertyValue("lastSessionCheckTime", sixtyOneSecondsAgo);
    session1Accessor.setPropertyValue("createTime", sixtyOneSecondsAgo);
    session2Accessor.setPropertyValue("createTime", sixtyOneSecondsAgo);
    this.webSocketHandler.start();
    this.webSocketHandler.handleMessage(session1, new TextMessage("foo"));
    replacedertTrue(session1.isOpen());
    replacedertNull(session1.getCloseStatus());
    replacedertFalse(session2.isOpen());
    replacedertEquals(CloseStatus.SESSION_NOT_RELIABLE, session2.getCloseStatus());
    replacedertNotEquals("lastSessionCheckTime not updated", sixtyOneSecondsAgo, handlerAccessor.getPropertyValue("lastSessionCheckTime"));
}

17 View Source File : ViewResolverRegistryTests.java
License : MIT License
Project Creator : Vip-Augus

// SPR-16431
@Test
public void scriptTemplate() {
    this.registry.scriptTemplate().prefix("/").suffix(".html");
    List<ViewResolver> viewResolvers = this.registry.getViewResolvers();
    replacedertEquals(1, viewResolvers.size());
    replacedertEquals(ScriptTemplateViewResolver.clreplaced, viewResolvers.get(0).getClreplaced());
    DirectFieldAccessor accessor = new DirectFieldAccessor(viewResolvers.get(0));
    replacedertEquals("/", accessor.getPropertyValue("prefix"));
    replacedertEquals(".html", accessor.getPropertyValue("suffix"));
}

17 View Source File : SubProtocolWebSocketHandlerTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
@SuppressWarnings("unchecked")
public void checkSession() throws Exception {
    TestWebSocketSession session1 = new TestWebSocketSession("id1");
    TestWebSocketSession session2 = new TestWebSocketSession("id2");
    session1.setOpen(true);
    session2.setOpen(true);
    session1.setAcceptedProtocol("v12.stomp");
    session2.setAcceptedProtocol("v12.stomp");
    this.webSocketHandler.setProtocolHandlers(Arrays.asList(this.stompHandler));
    this.webSocketHandler.afterConnectionEstablished(session1);
    this.webSocketHandler.afterConnectionEstablished(session2);
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(this.webSocketHandler);
    Map<String, ?> map = (Map<String, ?>) handlerAccessor.getPropertyValue("sessions");
    DirectFieldAccessor session1Accessor = new DirectFieldAccessor(map.get("id1"));
    DirectFieldAccessor session2Accessor = new DirectFieldAccessor(map.get("id2"));
    long sixtyOneSecondsAgo = System.currentTimeMillis() - 61 * 1000;
    handlerAccessor.setPropertyValue("lastSessionCheckTime", sixtyOneSecondsAgo);
    session1Accessor.setPropertyValue("createTime", sixtyOneSecondsAgo);
    session2Accessor.setPropertyValue("createTime", sixtyOneSecondsAgo);
    this.webSocketHandler.start();
    this.webSocketHandler.handleMessage(session1, new TextMessage("foo"));
    replacedertThat(session1.isOpen()).isTrue();
    replacedertThat(session1.getCloseStatus()).isNull();
    replacedertThat(session2.isOpen()).isFalse();
    replacedertThat(session2.getCloseStatus()).isEqualTo(CloseStatus.SESSION_NOT_RELIABLE);
    replacedertThat(handlerAccessor.getPropertyValue("lastSessionCheckTime")).as("lastSessionCheckTime not updated").isNotEqualTo(sixtyOneSecondsAgo);
}

16 View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testDefaultRabbitConfiguration() {
    this.contextRunner.withUserConfiguration(TestConfiguration.clreplaced).run((context) -> {
        RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.clreplaced);
        RabbitMessagingTemplate messagingTemplate = context.getBean(RabbitMessagingTemplate.clreplaced);
        CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
        RabbitAdmin amqpAdmin = context.getBean(RabbitAdmin.clreplaced);
        replacedertThat(rabbitTemplate.getConnectionFactory()).isEqualTo(connectionFactory);
        replacedertThat(getMandatory(rabbitTemplate)).isFalse();
        replacedertThat(messagingTemplate.getRabbitTemplate()).isEqualTo(rabbitTemplate);
        replacedertThat(amqpAdmin).isNotNull();
        replacedertThat(connectionFactory.getHost()).isEqualTo("localhost");
        replacedertThat(dfa.getPropertyValue("publisherConfirms")).isEqualTo(false);
        replacedertThat(dfa.getPropertyValue("publisherReturns")).isEqualTo(false);
        replacedertThat(context.containsBean("rabbitListenerContainerFactory")).as("Listener container factory should be created by default").isTrue();
    });
}

16 View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testRabbitTemplateRetry() {
    this.contextRunner.withUserConfiguration(TestConfiguration.clreplaced).withPropertyValues("spring.rabbitmq.template.retry.enabled:true", "spring.rabbitmq.template.retry.maxAttempts:4", "spring.rabbitmq.template.retry.initialInterval:2000", "spring.rabbitmq.template.retry.multiplier:1.5", "spring.rabbitmq.template.retry.maxInterval:5000", "spring.rabbitmq.template.receiveTimeout:123", "spring.rabbitmq.template.replyTimeout:456").run((context) -> {
        RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.clreplaced);
        DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate);
        replacedertThat(dfa.getPropertyValue("receiveTimeout")).isEqualTo(123L);
        replacedertThat(dfa.getPropertyValue("replyTimeout")).isEqualTo(456L);
        RetryTemplate retryTemplate = (RetryTemplate) dfa.getPropertyValue("retryTemplate");
        replacedertThat(retryTemplate).isNotNull();
        dfa = new DirectFieldAccessor(retryTemplate);
        SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) dfa.getPropertyValue("retryPolicy");
        ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) dfa.getPropertyValue("backOffPolicy");
        replacedertThat(retryPolicy.getMaxAttempts()).isEqualTo(4);
        replacedertThat(backOffPolicy.getInitialInterval()).isEqualTo(2000);
        replacedertThat(backOffPolicy.getMultiplier()).isEqualTo(1.5);
        replacedertThat(backOffPolicy.getMaxInterval()).isEqualTo(5000);
    });
}

16 View Source File : MvcNamespaceTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void testAsyncSupportOptions() throws Exception {
    loadBeanDefinitions("mvc-config-async-support.xml");
    RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.clreplaced);
    replacedertNotNull(adapter);
    DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter);
    replacedertEquals(ConcurrentTaskExecutor.clreplaced, fieldAccessor.getPropertyValue("taskExecutor").getClreplaced());
    replacedertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout"));
    CallableProcessingInterceptor[] callableInterceptors = (CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors");
    replacedertEquals(1, callableInterceptors.length);
    DeferredResultProcessingInterceptor[] deferredResultInterceptors = (DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors");
    replacedertEquals(1, deferredResultInterceptors.length);
}

16 View Source File : WebMvcConfigurationSupportExtensionTests.java
License : MIT License
Project Creator : Vip-Augus

@SuppressWarnings("unchecked")
@Test
public void viewResolvers() throws Exception {
    ViewResolverComposite viewResolver = (ViewResolverComposite) this.config.mvcViewResolver(this.config.mvcContentNegotiationManager());
    replacedertEquals(Ordered.HIGHEST_PRECEDENCE, viewResolver.getOrder());
    List<ViewResolver> viewResolvers = viewResolver.getViewResolvers();
    DirectFieldAccessor accessor = new DirectFieldAccessor(viewResolvers.get(0));
    replacedertEquals(1, viewResolvers.size());
    replacedertEquals(ContentNegotiatingViewResolver.clreplaced, viewResolvers.get(0).getClreplaced());
    replacedertFalse((Boolean) accessor.getPropertyValue("useNotAcceptableStatusCode"));
    replacedertNotNull(accessor.getPropertyValue("contentNegotiationManager"));
    List<View> defaultViews = (List<View>) accessor.getPropertyValue("defaultViews");
    replacedertNotNull(defaultViews);
    replacedertEquals(1, defaultViews.size());
    replacedertEquals(MappingJackson2JsonView.clreplaced, defaultViews.get(0).getClreplaced());
    viewResolvers = (List<ViewResolver>) accessor.getPropertyValue("viewResolvers");
    replacedertNotNull(viewResolvers);
    replacedertEquals(1, viewResolvers.size());
    replacedertEquals(InternalResourceViewResolver.clreplaced, viewResolvers.get(0).getClreplaced());
    accessor = new DirectFieldAccessor(viewResolvers.get(0));
    replacedertEquals("/", accessor.getPropertyValue("prefix"));
    replacedertEquals(".jsp", accessor.getPropertyValue("suffix"));
}

See More Examples