r1608 - in trunk/guix-compiler-gwt: . src/main/java/org/nuiton/guix/generator src/test/java/org/nuiton/guix/generator
Author: kmorin Date: 2009-08-27 10:39:49 +0200 (Thu, 27 Aug 2009) New Revision: 1608 Modified: trunk/guix-compiler-gwt/pom.xml trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtAbstractClassGenerator.java trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtJavaFileGenerator.java trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/generator/GwtGeneratorTest.java Log: Correction in the javadoc + clean imports Correction in the tests Modified: trunk/guix-compiler-gwt/pom.xml =================================================================== --- trunk/guix-compiler-gwt/pom.xml 2009-08-27 08:39:26 UTC (rev 1607) +++ trunk/guix-compiler-gwt/pom.xml 2009-08-27 08:39:49 UTC (rev 1608) @@ -120,7 +120,31 @@ </build> <profiles> + <profile> + <id>gwt-dev-windows</id> + <properties> + <platform>windows</platform> + </properties> + <activation> + <activeByDefault>false</activeByDefault> + <os> + <family>windows</family> + </os> + </activation> + </profile> <profile> + <id>gwt-dev-mac</id> + <properties> + <platform>mac</platform> + </properties> + <activation> + <activeByDefault>false</activeByDefault> + <os> + <family>mac</family> + </os> + </activation> + </profile> + <profile> <id>gwt-dev-linux</id> <activation> <activeByDefault>true</activeByDefault> Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtAbstractClassGenerator.java =================================================================== --- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtAbstractClassGenerator.java 2009-08-27 08:39:26 UTC (rev 1607) +++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtAbstractClassGenerator.java 2009-08-27 08:39:49 UTC (rev 1608) @@ -20,7 +20,6 @@ import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.MenuBar; -import com.google.gwt.user.client.ui.TabPanel; import java.beans.IntrospectionException; import java.io.File; import java.io.FileInputStream; Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java =================================================================== --- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java 2009-08-27 08:39:26 UTC (rev 1607) +++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java 2009-08-27 08:39:49 UTC (rev 1608) @@ -166,7 +166,6 @@ catch(Exception eee) { if(log.isErrorEnabled()) { log.error(eee); - eee.printStackTrace(); } } Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtJavaFileGenerator.java =================================================================== --- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtJavaFileGenerator.java 2009-08-27 08:39:26 UTC (rev 1607) +++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtJavaFileGenerator.java 2009-08-27 08:39:49 UTC (rev 1608) @@ -23,10 +23,7 @@ import org.nuiton.guix.model.GuixModelObject; //~--- JDK imports ------------------------------------------------------------ -import java.util.List; import java.util.Map; -import org.nuiton.guix.tags.TagHandler; -import org.nuiton.guix.tags.TagManager; /** * Modified: trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/generator/GwtGeneratorTest.java =================================================================== --- trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/generator/GwtGeneratorTest.java 2009-08-27 08:39:26 UTC (rev 1607) +++ trunk/guix-compiler-gwt/src/test/java/org/nuiton/guix/generator/GwtGeneratorTest.java 2009-08-27 08:39:49 UTC (rev 1608) @@ -18,19 +18,16 @@ */ package org.nuiton.guix.generator; +import com.google.gwt.event.dom.client.ClickHandler; import org.nuiton.guix.*; import com.google.gwt.user.client.ui.ToggleButton; +import java.beans.PropertyChangeListener; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.List; import java.util.Map; import org.junit.Test; -import org.nuiton.guix.generator.GwtGenerator; import org.junit.Assert; -import org.nuiton.guix.generator.GuixGenerator; -import org.nuiton.guix.generator.JavaField; -import org.nuiton.guix.generator.JavaFile; -import org.nuiton.guix.generator.JavaMethod; import org.nuiton.guix.tags.gwt.ToggleButtonHandler; /** @@ -48,117 +45,142 @@ @Test public void testGenerateBinding() { -// GwtGuixInitializer.initialize(); -// GwtGenerator gg = new GwtGenerator(); -// //tests the not null condition for the parameters that needs to be not null -// List<Class> l = gg.generateBindings(null, new StringBuffer(), null, null, Class.class, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(), 0); -// l = gg.generateBindings(new StringBuffer(), null, null, null, Class.class, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(), 0); -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, null, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(), 0); -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], -1, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(), 0); -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], -1, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(), 0); -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], 0, null, null, new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(), 0); -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], 0, null, "", null); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(), 0); -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, null, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(), 0); -// //tests with a class parameter not null -// //tests if a null listener as result returns null -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, ToggleButton.class, new String[]{"isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNull(l); -// //tests a successful generation with a method as a binding -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(),1); -// Assert.assertNotNull(l.get(0)); -// Assert.assertEquals(l.get(0),ClickHandler.class); -// //tests a successful generation with an attribute as a binding -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(),1); -// Assert.assertNotNull(l.get(0)); -// Assert.assertEquals(l.get(0),ClickHandler.class); -// //tests a successful generation with a method with the generic name as a binding -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(),1); -// Assert.assertNotNull(l.get(0)); -// Assert.assertEquals(l.get(0),ClickHandler.class); -// //tests a successful generation with an attribute with the generic name as a binding -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"selected"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(),1); -// Assert.assertNotNull(l.get(0)); -// Assert.assertEquals(l.get(0),ClickHandler.class); -// -// //tests with a javafile parameter not null -// //tests if the result is null without the taghandler associated to the field -// JavaFile jf = new JavaFile(); -// jf.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null)); -// jf.addMethod(new JavaMethod(Modifier.PUBLIC, "com.google.gwt.user.client.ui.ToggleButton", "getButton", null, null, "", null)); -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNull(l); -// //tests a successful generation with a method as a binding -// jf = new JavaFile(); -// jf.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null, new ToggleButtonHandler())); -// jf.addMethod(new JavaMethod(Modifier.PUBLIC, "com.google.gwt.user.client.ui.ToggleButton", "getButton", null, null, "", null)); -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(),1); -// Assert.assertNotNull(l.get(0)); -// Assert.assertEquals(l.get(0),ClickHandler.class); -// //tests a successful generation with an attribute as a binding -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"button","down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(),1); -// Assert.assertNotNull(l.get(0)); -// Assert.assertEquals(l.get(0),ClickHandler.class); -// -// //tests with a javafile parameter not null with an attribute whose type is another generated file -// //tests if the result is null without the taghandler associated to the field -// jf = new JavaFile(); -// jf.addField(new JavaField(Modifier.PRIVATE, "test.Test", "test", null)); -// jf.addMethod(new JavaMethod(Modifier.PUBLIC, "test.Test", "getTest", null, null, "", null)); -// JavaFile jf2 = new JavaFile(Modifier.PUBLIC, JavaFile.CLASS, "test", "Test", null, null); -// jf2.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null)); -// jf2.addMethod(new JavaMethod(Modifier.PUBLIC, "com.google.gwt.user.client.ui.ToggleButton", "getButton", null, null, "", null)); -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()","isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(), 0); -// //test without jf2 in the map of generators with JavaFile -// jf2 = new JavaFile(Modifier.PUBLIC, JavaFile.CLASS, "test", "Test", null, null); -// jf2.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null, new ToggleButtonHandler())); -// jf2.addMethod(new JavaMethod(Modifier.PUBLIC, "com.google.gwt.user.client.ui.ToggleButton", "getButton", null, null, "", null)); -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()","isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(), 0); -// Map<GuixGenerator,JavaFile> map = new HashMap<GuixGenerator, JavaFile>(); -// map.put(gg, jf2); -// //tests a successful generation with a method as a binding -// l =gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()", "isDown()"}, 0, null, "", map); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(),1); -// Assert.assertNotNull(l.get(0)); -// Assert.assertEquals(l.get(0),ClickHandler.class); -// //tests a successful generation with an attribute as a binding -// l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"test","button","down"}, 0, null, "", map); -// Assert.assertNotNull(l); -// Assert.assertEquals(l.size(),1); -// Assert.assertNotNull(l.get(0)); -// Assert.assertEquals(l.get(0),ClickHandler.class); + GwtGuixInitializer.initialize(); + GwtGenerator gg = new GwtGenerator(); + JavaMethod addPropertyChangeListener = new JavaMethod(Modifier.PUBLIC, "void", "addPropertyChangeListener", new JavaArgument[]{new JavaArgument("java.beans.PropertyChangeListener", "listener")}, null, "", null); + + //tests the not null condition for the parameters that needs to be not null + List<Class> l = gg.generateBindings(null, new StringBuffer(), null, null, Class.class, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 0); + l = gg.generateBindings(new StringBuffer(), null, null, null, Class.class, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 0); + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, null, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 0); + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], -1, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 0); + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], -1, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 0); + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], 0, null, null, new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 0); + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, Class.class, new String[0], 0, null, "", null); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 0); + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, null, new String[0], 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 0); + //tests with a class parameter not null + //tests if a null listener as result returns an empty result + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, null, ToggleButton.class, new String[]{"isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 0); + //tests a successful generation with a method as a binding + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(),1); + Assert.assertNotNull(l.get(0)); + Assert.assertEquals(l.get(0),ClickHandler.class); + //tests a successful generation with an attribute as a binding + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(),1); + Assert.assertNotNull(l.get(0)); + Assert.assertEquals(l.get(0),ClickHandler.class); + //tests a successful generation with a method with the generic name as a binding + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"isSelected()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(),1); + Assert.assertNotNull(l.get(0)); + Assert.assertEquals(l.get(0),ClickHandler.class); + //tests a successful generation with an attribute with the generic name as a binding + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), new ToggleButtonHandler(), null, ToggleButton.class, new String[]{"selected"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(),1); + Assert.assertNotNull(l.get(0)); + Assert.assertEquals(l.get(0),ClickHandler.class); + + //tests with a javafile parameter not null + //tests if the result is empty without the addPropertyChangeListener method + JavaFile jf = new JavaFile(); + jf.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null)); + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 0); + //tests if the result contains only a PropertyChangeListener without the taghandler associated to the field + jf = new JavaFile(); + jf.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null)); + jf.addMethod(addPropertyChangeListener); + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 1); + Assert.assertNotNull(l.get(0)); + Assert.assertEquals(l.get(0),PropertyChangeListener.class); + //tests a successful generation with a method as a binding + jf = new JavaFile(); + jf.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null, new ToggleButtonHandler())); + jf.addMethod(addPropertyChangeListener); + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getButton()", "isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(),2); + Assert.assertNotNull(l.get(0)); + Assert.assertEquals(l.get(0),ClickHandler.class); + Assert.assertNotNull(l.get(1)); + Assert.assertEquals(l.get(1),PropertyChangeListener.class); + //tests a successful generation with an attribute as a binding + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"button","down"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(),2); + Assert.assertNotNull(l.get(0)); + Assert.assertEquals(l.get(0),ClickHandler.class); + Assert.assertNotNull(l.get(1)); + Assert.assertEquals(l.get(1),PropertyChangeListener.class); + + //tests with a javafile parameter not null with an attribute whose type is another generated file + //tests if the result is only a PropertyChangeListener without the taghandler associated to the field + jf = new JavaFile(); + jf.addField(new JavaField(Modifier.PRIVATE, "test.Test", "test", null)); + jf.addMethod(addPropertyChangeListener); + JavaFile jf2 = new JavaFile(Modifier.PUBLIC, JavaFile.CLASS, "test", "Test", null, null); + jf2.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null)); + jf2.addMethod(addPropertyChangeListener); + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()","isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 1); + Assert.assertNotNull(l.get(0)); + Assert.assertEquals(l.get(0),PropertyChangeListener.class); + //test without jf2 in the map of generators with JavaFile + jf2 = new JavaFile(Modifier.PUBLIC, JavaFile.CLASS, "test", "Test", null, null); + jf2.addField(new JavaField(Modifier.PRIVATE, "com.google.gwt.user.client.ui.ToggleButton", "button", null, new ToggleButtonHandler())); + jf2.addMethod(addPropertyChangeListener); + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()","isDown()"}, 0, null, "", new HashMap<GuixGenerator, JavaFile>()); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(), 1); + Assert.assertNotNull(l.get(0)); + Assert.assertEquals(l.get(0),PropertyChangeListener.class); + + Map<GuixGenerator,JavaFile> map = new HashMap<GuixGenerator, JavaFile>(); + map.put(gg, jf2); + //tests a successful generation with a method as a binding + l =gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"getTest()","getButton()", "isDown()"}, 0, null, "", map); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(),2); + Assert.assertNotNull(l.get(0)); + Assert.assertEquals(l.get(0),ClickHandler.class); + Assert.assertNotNull(l.get(1)); + Assert.assertEquals(l.get(1),PropertyChangeListener.class); + //tests a successful generation with an attribute as a binding + l = gg.generateBindings(new StringBuffer(), new StringBuffer(), null, jf, null, new String[]{"test","button","down"}, 0, null, "", map); + Assert.assertNotNull(l); + Assert.assertEquals(l.size(),2); + Assert.assertNotNull(l.get(0)); + Assert.assertEquals(l.get(0),ClickHandler.class); + Assert.assertNotNull(l.get(1)); + Assert.assertEquals(l.get(1),PropertyChangeListener.class); } }
participants (1)
-
kmorin@users.nuiton.org