Skip to content

Commit

Permalink
need to explicitly call after properties in bean initialization #EA-3597
Browse files Browse the repository at this point in the history
  • Loading branch information
gsergiu committed Nov 10, 2023
1 parent 65caf19 commit d12815c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
Expand Down Expand Up @@ -44,16 +45,32 @@ public class TranslationRestIT extends BaseTranslationTest {
@Autowired
RedisCacheService redisCacheService;

private static RedisServer redisServer = startRedisService();

@Autowired
@Qualifier(BeanNames.BEAN_GOOGLE_TRANSLATION_CLIENT_WRAPPER)
GoogleTranslationServiceClientWrapper clientWrapper;

@BeforeAll
void mockGoogleTranslate() throws IOException {
void startMockServers() throws IOException {
TranslationServiceClient googleClient = new MockGClient(new MockGServiceStub());
clientWrapper.setClient(googleClient);
googleTranslationService.init(clientWrapper);
}

static RedisServer startRedisService() {
//start redis server
RedisServer redisServer = new RedisServer(redisPort);
redisServer.start();
return redisServer;
}

@AfterAll void stopRedis() {
if(redisServer != null) {
redisServer.stop();
}
}


@Test
void translationGoogle() throws Exception {
Expand Down Expand Up @@ -101,8 +118,6 @@ void translationPangeanic() throws Exception {

@Test
void translationWithCaching() throws Exception {
RedisServer redisServer = new RedisServer(redisPort);
redisServer.start();

String requestJson = getJsonStringInput(TRANSLATION_REQUEST_CACHING);
JSONObject reqJsonObj = new JSONObject(requestJson);
Expand Down Expand Up @@ -143,7 +158,6 @@ void translationWithCaching() throws Exception {
assertTrue(translations.length()>0);

redisCacheService.deleteAll();
redisServer.stop();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ private RedisTemplate<String, RedisCacheTranslation> getRedisTemplate(
@ConditionalOnProperty(name = "redis.connection.url")
public RedisCacheService getRedisCacheService() throws IOException {
LettuceConnectionFactory redisConnectionFactory = getRedisConnectionFactory();
redisConnectionFactory.afterPropertiesSet();
RedisTemplate<String, RedisCacheTranslation> redisTemplate =
getRedisTemplate(redisConnectionFactory);

Expand Down

0 comments on commit d12815c

Please sign in to comment.