Questions tagged [context-configuration]

20 questions
20
votes
1 answer

How do I prevent Android device Display size scaling in my app?

I'm developing an app with React Native for both iOS and Android, and I am trying to prevent device-specific scaling of the display in the app. For text/font size scaling, putting the following code in the root-level App.js file solves the issue for…
11
votes
2 answers

What are advantages of using @ContextHierarchy over pure @ContextConfiguration

Hi I don't understand what advantages give me usage of @ContextHierarchy like below: @ContextHierarchy({ @ContextConfiguration("/test-db-setup-context.xml"), …
7
votes
2 answers

Using RestTemplateBuilder with @ContextConfiguration in IT tests

I am running into problems while using RestTemplateBuilder with @ContextConfiguration in a Spring boot application (I have tried to add @SpringBootTest, @RunWith(SpringRunner.class) annotation without any luck). Any help is appreciated. Here is the…
7
votes
1 answer

Order of bean destruction in Spring context hierarchy

Is it correct to say that when a Spring context hierarchy is closed, there is no guaranteed order in which the beans will be destroyed? E.g. the beans in the child context will be destroyed before the parent context. From a minimal example the…
4
votes
4 answers

Junit - Spring boot: @Value is always null while testing

There is a @Value annotated constant, which is not getting initialized when running test, it throws NullPointerException when it is required inside constructor. Sample Class to be tested: class TestClass { @Value("${test.value1}") private…
3
votes
0 answers

How to create an ApplicationContext for tests in kotlin?

I have been struggling to start an application context during tests so I can inject bean at run-time but it seems I can't get the ApplicationContext wired here is what I am trying package com.wayfair.samworkgroupsservice.adapter import…
Lucas
  • 746
  • 8
  • 23
2
votes
1 answer

How to prevent app layout changes when user change display size from the android setting application?

Currently, I am developing one android app so in that, I need to implement such functionality that prevents layout scaling whenever user change display size from the android device setting app. I am using the below library for font size and view…
2
votes
0 answers

How to set up an automated integration test to check an aspect functionality with Spring-Boot

I've added an AOP (Aspect Oriented Programming) Aspect to my working project. It does work, but it won't be called when trying to Test it's functionality with an Integration Test. The problem is, that the aspect is not called when the tests runs…
2
votes
1 answer

Parameter classes for @ContextConfiguration cannot be recognized

In the following test class import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import…
Krzysztof
  • 129
  • 2
  • 11
2
votes
1 answer

Why NoSuchBeanDefinedException while running Spring Integration test

I have a Spring Boot project for which one of the developers has written Integration tests against an in-memory DB. Here is some background before I put my question : We have following Maven modules : 1) web-persistence : which store all entities…
1
vote
1 answer

While @Autowired with @Qualifier in Junit Test Case showing Unable load application context and Illegalstate exception

I am using @KafkaListener in my application that's why I am using @Configuration static class ContextConfiguration { //create the beans } My class using @Autowired @Qualifier("someName") for configuration while writing test class…
1
vote
1 answer

Groovy test class using @ContextHierarchy

I am using Groovy for my Spring application and I try to use multiple XML beans configurations inside my test. I tried using @ContextHierarchy but following usage example didn't…
Michael Hegner
  • 5,555
  • 9
  • 38
  • 64
1
vote
1 answer

Custom ContextConfiguration Loader issues when upgrading from Spring Framework 4.2.9 to 4.3+

I am having some issues running my integration tests after upgrading the Spring Framework spring-test dependency from 4.2.9 to 4.3.9. I am using a ContextConfiguration class which implements the spring test SmartContextLoader which allowed me to…
0
votes
1 answer

SpringBoot JUnit 4 test, Neither @ContextConfiguration nor @ContextHierarchy found

Here is my build.gradle file: plugins { id 'java' id 'org.springframework.boot' version '3.0.4' id 'io.spring.dependency-management' version '1.1.0' } group = 'com.kriegzeug' version = '0.0.1-SNAPSHOT' sourceCompatibility =…
OnlyDean
  • 1,025
  • 1
  • 13
  • 25
0
votes
0 answers

Documentation that describes the Spring ContextConfiguration Evaluation Order with Inheritance?

Lets say I have the following setup for 2 test classes in a SpringBoot Project class Config1 { @Bean public MyObject myObject() { return Mockito.mock(myObject.class); } } class Config2 { @Bean public MyObject myObject() { return…
Shane Gannon
  • 6,770
  • 7
  • 41
  • 64
1
2