Here are the examples of the java api org.springframework.beans.DirectFieldAccessor taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
104 Examples
19
View Source File : CrossOriginTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private CorsConfiguration getCorsConfiguration(HandlerExecutionChain chain, boolean isPreFlightRequest) {
if (isPreFlightRequest) {
Object handler = chain.getHandler();
replacedertTrue(handler.getClreplaced().getSimpleName().equals("PreFlightHandler"));
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
return (CorsConfiguration) accessor.getPropertyValue("config");
} else {
HandlerInterceptor[] interceptors = chain.getInterceptors();
if (interceptors != null) {
for (HandlerInterceptor interceptor : interceptors) {
if (interceptor.getClreplaced().getSimpleName().equals("CorsInterceptor")) {
DirectFieldAccessor accessor = new DirectFieldAccessor(interceptor);
return (CorsConfiguration) accessor.getPropertyValue("config");
}
}
}
}
return null;
}
19
View Source File : MappingJackson2JsonViewTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
private void validateResult() throws Exception {
String json = response.getContentreplacedtring();
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(view);
String jsonPrefix = (String) viewAccessor.getPropertyValue("jsonPrefix");
if (jsonPrefix != null) {
json = json.substring(5);
}
Object jsResult = jsContext.evaluateString(jsScope, "(" + json + ")", "JSON Stream", 1, null);
replacedertThat(jsResult).as("Json Result did not eval as valid JavaScript").isNotNull();
replacedertThat(response.getContentType()).isEqualTo("application/json");
}
19
View Source File : CrossOriginTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
private CorsConfiguration getCorsConfiguration(HandlerExecutionChain chain, boolean isPreFlightRequest) {
if (isPreFlightRequest) {
Object handler = chain.getHandler();
replacedertThat(handler.getClreplaced().getSimpleName().equals("PreFlightHandler")).isTrue();
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
return (CorsConfiguration) accessor.getPropertyValue("config");
} else {
HandlerInterceptor[] interceptors = chain.getInterceptors();
if (interceptors != null) {
for (HandlerInterceptor interceptor : interceptors) {
if (interceptor.getClreplaced().getSimpleName().equals("CorsInterceptor")) {
DirectFieldAccessor accessor = new DirectFieldAccessor(interceptor);
return (CorsConfiguration) accessor.getPropertyValue("config");
}
}
}
}
return null;
}
19
View Source File : ConnectionIntrospector.java
License : Apache License 2.0
Project Creator : pgjdbc
License : Apache License 2.0
Project Creator : pgjdbc
/**
* Return the transport {@link Channel}.
*
* @return the transport {@link Channel}.
*/
public Channel getChannel() {
DirectFieldAccessor accessor = new DirectFieldAccessor(getClient());
Connection connection = (Connection) accessor.getPropertyValue("connection");
return connection.channel();
}
19
View Source File : PropertyComparator.java
License : Apache License 2.0
Project Creator : HotelsDotCom
License : Apache License 2.0
Project Creator : HotelsDotCom
private Object get(T object, String propertyPath) {
Object value = null;
DirectFieldAccessor accessor = new DirectFieldAccessor(object);
String[] tokens = propertyPath.split("\\.");
for (int i = 0; i < tokens.length; i++) {
value = accessor.getPropertyValue(tokens[i]);
if (value != null) {
accessor = new DirectFieldAccessor(value);
} else if (i == tokens.length - 1) {
return null;
} else {
throw new IllegalArgumentException("Intermediate property '" + tokens[i] + "' is null");
}
}
return value;
}
18
View Source File : QuartzAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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);
};
}
18
View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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();
});
}
18
View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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();
});
}
18
View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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);
});
}
18
View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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);
});
}
18
View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void testRabbitListenerContainerFactoryBackOff() {
this.contextRunner.withUserConfiguration(TestConfiguration5.clreplaced).run((context) -> {
SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context.getBean("rabbitListenerContainerFactory", SimpleRabbitListenerContainerFactory.clreplaced);
rabbitListenerContainerFactory.setTxSize(10);
verify(rabbitListenerContainerFactory).setTxSize(10);
DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitListenerContainerFactory);
Advice[] adviceChain = (Advice[]) dfa.getPropertyValue("adviceChain");
replacedertThat(adviceChain).isNull();
});
}
18
View Source File : AbstractTyrusRequestUpgradeStrategy.java
License : MIT License
Project Creator : Vip-Augus
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);
}
}
18
View Source File : ScriptTemplateViewTests.java
License : MIT License
Project Creator : Vip-Augus
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"));
}
18
View Source File : ScriptTemplateViewTests.java
License : MIT License
Project Creator : Vip-Augus
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"));
}
18
View Source File : ScriptTemplateViewTests.java
License : MIT License
Project Creator : Vip-Augus
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"));
}
18
View Source File : MappingJackson2JsonViewTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private void validateResult() throws Exception {
String json = response.getContentreplacedtring();
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(view);
String jsonPrefix = (String) viewAccessor.getPropertyValue("jsonPrefix");
if (jsonPrefix != null) {
json = json.substring(5);
}
Object jsResult = jsContext.evaluateString(jsScope, "(" + json + ")", "JSON Stream", 1, null);
replacedertNotNull("Json Result did not eval as valid JavaScript", jsResult);
replacedertEquals("application/json", response.getContentType());
}
18
View Source File : CorsAbstractHandlerMappingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@SuppressWarnings("ConstantConditions")
private CorsConfiguration getRequiredCorsConfiguration(HandlerExecutionChain chain, boolean isPreFlightRequest) {
CorsConfiguration corsConfig = null;
if (isPreFlightRequest) {
Object handler = chain.getHandler();
replacedertEquals("PreFlightHandler", handler.getClreplaced().getSimpleName());
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
corsConfig = (CorsConfiguration) accessor.getPropertyValue("config");
} else {
HandlerInterceptor[] interceptors = chain.getInterceptors();
if (!ObjectUtils.isEmpty(interceptors)) {
DirectFieldAccessor accessor = new DirectFieldAccessor(interceptors[0]);
corsConfig = (CorsConfiguration) accessor.getPropertyValue("config");
}
}
replacedertNotNull(corsConfig);
return corsConfig;
}
18
View Source File : MethodJmsListenerEndpointTests.java
License : MIT License
Project Creator : Vip-Augus
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"));
}
18
View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot
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);
}
18
View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot
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);
}
18
View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot
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);
}
18
View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot
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);
}
18
View Source File : ScriptTemplateViewResolverTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void viewClreplaced() throws Exception {
ScriptTemplateViewResolver resolver = new ScriptTemplateViewResolver();
replacedertThat(resolver.requiredViewClreplaced()).isEqualTo(ScriptTemplateView.clreplaced);
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
Clreplaced<?> viewClreplaced = (Clreplaced<?>) viewAccessor.getPropertyValue("viewClreplaced");
replacedertThat(viewClreplaced).isEqualTo(ScriptTemplateView.clreplaced);
}
18
View Source File : GroovyMarkupViewTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void customTemplateEngine() throws Exception {
GroovyMarkupView view = new GroovyMarkupView();
view.setTemplateEngine(new TestTemplateEngine());
view.setApplicationContext(this.webAppContext);
DirectFieldAccessor accessor = new DirectFieldAccessor(view);
TemplateEngine engine = (TemplateEngine) accessor.getPropertyValue("engine");
replacedertThat(engine).isNotNull();
replacedertThat(engine.getClreplaced()).isEqualTo(TestTemplateEngine.clreplaced);
}
18
View Source File : GroovyMarkupViewTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void detectTemplateEngine() throws Exception {
GroovyMarkupView view = new GroovyMarkupView();
view.setTemplateEngine(new TestTemplateEngine());
view.setApplicationContext(this.webAppContext);
DirectFieldAccessor accessor = new DirectFieldAccessor(view);
TemplateEngine engine = (TemplateEngine) accessor.getPropertyValue("engine");
replacedertThat(engine).isNotNull();
replacedertThat(engine.getClreplaced()).isEqualTo(TestTemplateEngine.clreplaced);
}
18
View Source File : GroovyMarkupViewResolverTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void viewClreplaced() throws Exception {
GroovyMarkupViewResolver resolver = new GroovyMarkupViewResolver();
replacedertThat(resolver.requiredViewClreplaced()).isEqualTo(GroovyMarkupView.clreplaced);
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
Clreplaced<?> viewClreplaced = (Clreplaced<?>) viewAccessor.getPropertyValue("viewClreplaced");
replacedertThat(viewClreplaced).isEqualTo(GroovyMarkupView.clreplaced);
}
18
View Source File : CorsAbstractHandlerMappingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@SuppressWarnings("ConstantConditions")
private CorsConfiguration getRequiredCorsConfiguration(HandlerExecutionChain chain, boolean isPreFlightRequest) {
CorsConfiguration corsConfig = null;
if (isPreFlightRequest) {
Object handler = chain.getHandler();
replacedertThat(handler.getClreplaced().getSimpleName()).isEqualTo("PreFlightHandler");
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
corsConfig = (CorsConfiguration) accessor.getPropertyValue("config");
} else {
HandlerInterceptor[] interceptors = chain.getInterceptors();
if (!ObjectUtils.isEmpty(interceptors)) {
DirectFieldAccessor accessor = new DirectFieldAccessor(interceptors[0]);
corsConfig = (CorsConfiguration) accessor.getPropertyValue("config");
}
}
replacedertThat(corsConfig).isNotNull();
return corsConfig;
}
18
View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot
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);
}
18
View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot
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);
}
18
View Source File : MethodJmsListenerEndpointTests.java
License : Apache License 2.0
Project Creator : SourceHot
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);
}
18
View Source File : ConnectionIntrospector.java
License : Apache License 2.0
Project Creator : pgjdbc
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;
}
18
View Source File : MethodJmsListenerEndpointTests.java
License : Apache License 2.0
Project Creator : langtianya
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 : PubSubMessageChannelBinderTests.java
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
@Test
public void testProducerAndConsumerCustomizers() {
baseContext.withUserConfiguration(PubSubBinderTestConfig.clreplaced).withPropertyValues("spring.cloud.stream.bindings.input.group=testGroup").run(context -> {
DirectFieldAccessor channelBindingServiceAccessor = new DirectFieldAccessor(context.getBean(BindingService.clreplaced));
@SuppressWarnings("unchecked")
Map<String, List<Binding<MessageChannel>>> consumerBindings = (Map<String, List<Binding<MessageChannel>>>) channelBindingServiceAccessor.getPropertyValue("consumerBindings");
replacedertThat(new DirectFieldAccessor(consumerBindings.get("input").get(0)).getPropertyValue("lifecycle.beanName")).isEqualTo("setByCustomizer:input");
@SuppressWarnings("unchecked")
Map<String, Binding<MessageChannel>> producerBindings = (Map<String, Binding<MessageChannel>>) channelBindingServiceAccessor.getPropertyValue("producerBindings");
replacedertThat(new DirectFieldAccessor(producerBindings.get("output")).getPropertyValue("val$producerMessageHandler.beanName")).isEqualTo("setByCustomizer:output");
});
}
17
View Source File : TaskExecutionAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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-");
}));
}
17
View Source File : QuartzAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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"));
});
}
17
View Source File : QuartzAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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);
});
}
17
View Source File : KafkaAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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"));
});
}
17
View Source File : KafkaAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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"));
});
}
17
View Source File : KafkaAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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));
});
}
17
View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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);
}
17
View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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);
});
}
17
View Source File : RabbitAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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);
});
}
17
View Source File : DiskSpaceHealthIndicatorAutoConfigurationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
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));
});
}
17
View Source File : ScriptTemplateViewResolverTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void viewClreplaced() throws Exception {
ScriptTemplateViewResolver resolver = new ScriptTemplateViewResolver();
replacedert.replacedertEquals(ScriptTemplateView.clreplaced, resolver.requiredViewClreplaced());
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
Clreplaced<?> viewClreplaced = (Clreplaced<?>) viewAccessor.getPropertyValue("viewClreplaced");
replacedert.replacedertEquals(ScriptTemplateView.clreplaced, viewClreplaced);
}
17
View Source File : GroovyMarkupViewTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void customTemplateEngine() throws Exception {
GroovyMarkupView view = new GroovyMarkupView();
view.setTemplateEngine(new TestTemplateEngine());
view.setApplicationContext(this.webAppContext);
DirectFieldAccessor accessor = new DirectFieldAccessor(view);
TemplateEngine engine = (TemplateEngine) accessor.getPropertyValue("engine");
replacedertNotNull(engine);
replacedertEquals(TestTemplateEngine.clreplaced, engine.getClreplaced());
}
17
View Source File : GroovyMarkupViewTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void detectTemplateEngine() throws Exception {
GroovyMarkupView view = new GroovyMarkupView();
view.setTemplateEngine(new TestTemplateEngine());
view.setApplicationContext(this.webAppContext);
DirectFieldAccessor accessor = new DirectFieldAccessor(view);
TemplateEngine engine = (TemplateEngine) accessor.getPropertyValue("engine");
replacedertNotNull(engine);
replacedertEquals(TestTemplateEngine.clreplaced, engine.getClreplaced());
}
17
View Source File : GroovyMarkupViewResolverTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void viewClreplaced() throws Exception {
GroovyMarkupViewResolver resolver = new GroovyMarkupViewResolver();
replacedert.replacedertEquals(GroovyMarkupView.clreplaced, resolver.requiredViewClreplaced());
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
Clreplaced<?> viewClreplaced = (Clreplaced<?>) viewAccessor.getPropertyValue("viewClreplaced");
replacedert.replacedertEquals(GroovyMarkupView.clreplaced, viewClreplaced);
}
17
View Source File : ViewResolverRegistryTests.java
License : MIT License
Project Creator : Vip-Augus
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);
}
}
17
View Source File : ScriptTemplateViewTests.java
License : MIT License
Project Creator : Vip-Augus
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"));
}
17
View Source File : ScriptTemplateViewTests.java
License : Apache License 2.0
Project Creator : SourceHot
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);
}
See More Examples