public void testConcurrentUsage() throws Exception {
final BeanWrapperFieldSetMapper<GreenBean> mapper = new BeanWrapperFieldSetMapper<GreenBean>();
mapper.setStrict(true);
mapper.setTargetType(GreenBean.class);
// mapper.setDistanceLimit(0);
final DelimitedLineTokenizer lineTokenizer = new DelimitedLineTokenizer();
String[] names = { "blue", "green" };
lineTokenizer.setNames(names);
ExecutorService executorService = Executors.newFixedThreadPool(5);
Collection<Future<Boolean>> results = new ArrayList<Future<Boolean>>();
for (int i = 0; i < 10; i++) {
Future<Boolean> result = executorService.submit(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
for (int i = 0; i < 10; i++) {
GreenBean bean = mapper.mapFieldSet(lineTokenizer.tokenize("blue,green"));
Assert.assertEquals("green", bean.getGreen());
}
return true;
}
});