/
SpringJarHelsingTest.java
45 lines (35 loc) · 1.3 KB
/
SpringJarHelsingTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.github.springjarhelsing;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.concurrent.*;
import static org.junit.Assert.assertEquals;
public class SpringJarHelsingTest {
ClassPathXmlApplicationContext applicationContext;
TestContext testContext;
@Before
public void init() {
applicationContext = new ClassPathXmlApplicationContext("test-main-context.xml");
testContext = (TestContext) applicationContext.getBean("testContext");
}
@After
public void shutdown() {
applicationContext.close();
}
@Test
public void test() throws ExecutionException, InterruptedException {
Callable<Integer> task = new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return 42;
}
};
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Integer> future = executor.submit(task);
int result09 = testContext.getGuava09UninterpretableFutureGetter().get(future);
int result17 = testContext.getGuava17UninterpretableFutureGetter().get(future);
assertEquals(result09, result17);
}
}