}
PrimitiveArrayBean tb = new PrimitiveArrayBean();
BeanWrapper bw = new BeanWrapperImpl(tb);
int[] input = new int[1024];
StopWatch sw = new StopWatch();
sw.start("array1");
for (int i = 0; i < 1000; i++) {
bw.setPropertyValue("array", input);
}
sw.stop();
assertEquals(1024, tb.getArray().length);
assertEquals(0, tb.getArray()[0]);
long time1 = sw.getLastTaskTimeMillis();
assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);
bw.registerCustomEditor(String.class, new StringTrimmerEditor(false));
sw.start("array2");
for (int i = 0; i < 1000; i++) {
bw.setPropertyValue("array", input);
}
sw.stop();
assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);
bw.registerCustomEditor(int.class, "array.somePath", new CustomNumberEditor(Integer.class, false));
sw.start("array3");
for (int i = 0; i < 1000; i++) {
bw.setPropertyValue("array", input);
}
sw.stop();
assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);
bw.registerCustomEditor(int.class, "array[0].somePath", new CustomNumberEditor(Integer.class, false));
sw.start("array3");
for (int i = 0; i < 1000; i++) {
bw.setPropertyValue("array", input);
}
sw.stop();
assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);
bw.registerCustomEditor(int.class, new CustomNumberEditor(Integer.class, false));
sw.start("array4");
for (int i = 0; i < 100; i++) {
bw.setPropertyValue("array", input);
}
sw.stop();
assertEquals(1024, tb.getArray().length);
assertEquals(0, tb.getArray()[0]);
assertTrue("Took too long", sw.getLastTaskTimeMillis() > time1);
}