Hallo zusammen,
hab’ ich Tomaten auf den Augen? Was läuft denn in diesem “Hallo-Welt”-Unit-Test für Apache Commons BeanUtils schief? Läuft das bei Euch durch? Bei mir knallt es mit Oracle JDK 1.7.0.45, 1.7.0.51 mit Beanutils 1.8.1 sowohl unter Mac OS X als auch unter Linux (beides 64bit).
import static org.junit.Assert.assertEquals;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import org.apache.commons.beanutils.PropertyUtils;
import org.junit.Test;
class MyBean implements Serializable {
private static final long serialVersionUID = -2186779570411846625L;
private String string;
public String getString() {
return string;
}
public void setString(String string) {
this.string = string;
}
}
public class AppTest {
@Test
public void test() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
MyBean myBean = new MyBean();
myBean.setString("Hallo");
MyBean myBean2 = new MyBean();
PropertyUtils.copyProperties(myBean2, myBean);
assertEquals("Hallo", myBean2.getString());
}
}