Author: athimel Date: 2011-08-25 19:46:56 +0200 (Thu, 25 Aug 2011) New Revision: 2191 Url: http://nuiton.org/repositories/revision/nuiton-utils/2191 Log: Fix #1713 - BinderModelBuilder was using source instead of target Added: trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/Destination.java trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/Source.java Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderModelBuilderTest.java Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java 2011-08-25 14:18:52 UTC (rev 2190) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java 2011-08-25 17:46:56 UTC (rev 2191) @@ -444,7 +444,7 @@ model.getTargetType()); } // check dstProperty is writable - Method writeMethod = sourceDescriptor.getWriteMethod(); + Method writeMethod = targetDescriptor.getWriteMethod(); if (writeMethod == null) { throw new IllegalArgumentException("property '" + targetProperty + "' " + "is not writable on type " + model.getTargetType()); Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderModelBuilderTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderModelBuilderTest.java 2011-08-25 14:18:52 UTC (rev 2190) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BinderModelBuilderTest.java 2011-08-25 17:46:56 UTC (rev 2191) @@ -540,4 +540,24 @@ Assert.assertEquals(targetType, builder.getModel().getTargetType()); } + @Test + public void testBug1713() throws Exception { + + // This is test for http://nuiton.org/issues/1713 + + BinderModelBuilder<Source, Destination> builder = + BinderModelBuilder.newDefaultBuilder(Source.class, Destination.class); + builder.addProperty("salutationCode", "gender"); + + Binder<Source, Destination> binder = builder.toBinder(); + + String salutationCode = "youhou"; + + Source source = new Source(salutationCode); + Destination destination = new Destination(); + binder.copy(source, destination); + + Assert.assertEquals(salutationCode, destination.getGender()); + } + } Added: trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/Destination.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/Destination.java (rev 0) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/Destination.java 2011-08-25 17:46:56 UTC (rev 2191) @@ -0,0 +1,42 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2011 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.beans; + +/** + * Destination bean used to fix http://nuiton.org/issues/1713 + */ +public class Destination { + + private String gender; + + public String getGender() { + return gender; + } + + public void setGender(String gender) { + this.gender = gender; + } + +} Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/Destination.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/Source.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/Source.java (rev 0) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/Source.java 2011-08-25 17:46:56 UTC (rev 2191) @@ -0,0 +1,42 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2011 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.beans; + +/** + * Source bean used to fix http://nuiton.org/issues/1713 + */ +public class Source { + + private String salutationCode; + + public Source(String salutationCode) { + this.salutationCode = salutationCode; + } + + public String getSalutationCode() { + return salutationCode; + } + +} Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/Source.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native