Author: Alex.Kolonitsky
Date: 2009-11-01 11:27:54 -0500 (Sun, 01 Nov 2009)
New Revision: 15791
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/render/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/render/JavaClassRendererTest.java
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/TemplateReaderTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation2.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestInterfaceAnnotation.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestMethodAnnotation.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileManagerTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean2.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/UIComponent.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Id.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyMergeTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodySerializerTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XPathComparatorTest.java
root/cdk/trunk/plugins/generator/src/test/java/test/TestComponent.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestInterface.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestSubClass.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/UITestCommand.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/render/JavaClassRendererTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/render/JavaClassRendererTest.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/render/JavaClassRendererTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -0,0 +1,86 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+package org.richfaces.builder.render;
+
+import junit.framework.TestCase;
+
+import org.richfaces.builder.model.*;
+
+import javax.faces.component.UIComponentBase;
+
+import java.io.PrintWriter;
+
+/**
+ * @author akolonitsky
+ * @since Oct 30, 2009
+ */
+public class JavaClassRendererTest extends TestCase {
+ public void testMain() {
+ JavaClass javaClass = new JavaClass("MyClass", new
JavaPackage("mypackage"));
+ JavaField javaField = new JavaField(int.class, "count");
+
+ javaField.setValue(0);
+ javaField.getModifiers().add(JavaModifier.PRIVATE);
+ javaClass.addField(javaField);
+
+ JavaField field = new JavaField(UIComponentBase.class, "component",
"null");
+
+ field.addModifier(JavaModifier.PUBLIC);
+ field.addAnnotation(Deprecated.class);
+ javaClass.addField(field);
+ javaClass.addAnnotation(Deprecated.class);
+
+ JavaMethod accessor = new JavaMethod("getCount", int.class);
+
+ accessor.setMethodBody(new MethodBody(accessor) {
+ @Override
+ public String toCode() {
+ return "return count;";
+ }
+ });
+ accessor.getModifiers().add(JavaModifier.PUBLIC);
+ accessor.getModifiers().add(JavaModifier.FINAL);
+ javaClass.addMethod(accessor);
+
+ JavaMethod mutator = new JavaMethod("setCount", new
Argument("i", int.class));
+
+ mutator.setMethodBody(new MethodBody(mutator) {
+ @Override
+ public String toCode() {
+ return "count = i;";
+ }
+ });
+ mutator.addAnnotation(Tezt.class);
+ mutator.addModifier(JavaModifier.PUBLIC);
+ mutator.addModifier(JavaModifier.FINAL);
+ javaClass.addMethod(mutator);
+
+ PrintWriter printWriter = new PrintWriter(System.out);
+
+ new JavaClassRenderer().render(javaClass, printWriter);
+ printWriter.flush();
+ }
+
+ private @interface Tezt {}
+}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,14 +21,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+
import java.util.Collections;
import java.util.logging.LogManager;
@@ -41,41 +45,42 @@
*
*/
public class CdkTestBase {
+ protected Iterable<File> testSourceDirectory;
- protected Iterable<File> testSourceDirectory;
+ @Before
+ public void setUpSourceDirectory() throws Exception {
+ testSourceDirectory =
Collections.singleton(getJavaFile("test.source.properties").getParentFile());
- @Before
- public void setUpSourceDirectory() throws Exception {
- testSourceDirectory =
Collections.singleton(getJavaFile("test.source.properties")
- .getParentFile());
- InputStream stream = this.getClass().getResourceAsStream(
- "logging.properties");
- if (null != stream) {
- try {
- LogManager.getLogManager().readConfiguration(stream);
- } catch (Exception e) {
- // Ignore it.
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- // Ignore it.
- }
- }
- }
- }
+ InputStream stream =
this.getClass().getResourceAsStream("logging.properties");
- @After
- public void tearDownSourceDirectory() {
- testSourceDirectory = null;
- }
+ if (null != stream) {
+ try {
+ LogManager.getLogManager().readConfiguration(stream);
+ } catch (Exception e) {
- protected File getJavaFile(String name) throws URISyntaxException {
- ClassLoader classLoader = this.getClass().getClassLoader();
- URL testResource = classLoader.getResource(name);
- URI testUri = testResource.toURI();
- final File classFile = new File(testUri);
- return classFile;
- }
+ // Ignore it.
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // Ignore it.
+ }
+ }
+ }
+ }
+
+ @After
+ public void tearDownSourceDirectory() {
+ testSourceDirectory = null;
+ }
+
+ protected File getJavaFile(String name) throws URISyntaxException {
+ ClassLoader classLoader = this.getClass().getClassLoader();
+ URL testResource = classLoader.getResource(name);
+ URI testUri = testResource.toURI();
+ final File classFile = new File(testUri);
+
+ return classFile;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -1,5 +1,6 @@
+
/**
- *
+ *
*/
package org.richfaces.cdk;
@@ -17,6 +18,7 @@
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+
import org.richfaces.cdk.xmlutils.XMLBodyMergeTest;
import org.richfaces.cdk.xmlutils.XMLBodySerializerTest;
import org.richfaces.cdk.xmlutils.XMLBodyTest;
@@ -28,42 +30,35 @@
*/
@RunWith(Parameterized.class)
public class LibraryBuilderTest {
-
- private String param;
-
+ private String param;
- public LibraryBuilderTest(String param) {
- this.param=param;
- }
+ public LibraryBuilderTest(String param) {
+ this.param = param;
+ }
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- }
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {}
- /**
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- }
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {}
- /**
- * Test method for {@link org.richfaces.cdk.LibraryBuilder#createInstance()}.
- */
- @Test
- public void createInstance() {
-// assertEquals("Parameter match","Two", param);
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.LibraryBuilder#createInstance()}.
+ */
+ @Test
+ public void createInstance() {
-
- @Parameters
- public static Collection<String[]> values(){
- return Arrays.asList(new String[]{"One"},new String[]{"Two"},new
String[]{"Tree"});
- }
+// assertEquals("Parameter match","Two", param);
+ }
-
+ @Parameters
+ public static Collection<String[]> values() {
+ return Arrays.asList(new String[] {"One"}, new String[]
{"Two"}, new String[] {"Tree"});
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import static org.junit.Assert.*;
@@ -28,6 +30,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+
import org.richfaces.cdk.model.InvalidNameException;
/**
@@ -36,79 +39,80 @@
*
*/
public class NamingConventionsTest {
-
- private static final String BASE="foo.bar";
- private RichFacesConventions conventions;
-
- @Before
- public void createConventions() {
- conventions = new RichFacesConventions();
- }
-
- @After
- public void destroyConventions(){
- conventions = null;
- }
+ private static final String BASE = "foo.bar";
+ private RichFacesConventions conventions;
- /**
- * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testInferComponentTypeExplicit() throws Exception {
- assertEquals("foo.bar.Test",
conventions.inferComponentType("foo.bar.Test","foo.baz.UITest"));
- }
+ @Before
+ public void createConventions() {
+ conventions = new RichFacesConventions();
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testInferComponentTypeFromUIClass() throws Exception {
- assertEquals("foo.baz.Test",
conventions.inferComponentType("","foo.baz.component.UITest"));
- }
+ @After
+ public void destroyConventions() {
+ conventions = null;
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testInferComponentTypeFromAbstractClass() throws Exception {
- assertEquals("foo.baz.Test",
conventions.inferComponentType("","foo.baz.component.AbstractTest"));
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testInferComponentTypeExplicit() throws Exception {
+ assertEquals("foo.bar.Test",
conventions.inferComponentType("foo.bar.Test", "foo.baz.UITest"));
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testInferComponentTypeFromBaseClass() throws Exception {
- assertEquals("foo.baz.Test",
conventions.inferComponentType("","foo.baz.component.TestBase"));
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testInferComponentTypeFromUIClass() throws Exception {
+ assertEquals("foo.baz.Test",
conventions.inferComponentType("", "foo.baz.component.UITest"));
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testInferComponentTypeFromMarkupClass() throws Exception {
- assertEquals("foo.baz.HtmlTest",
conventions.inferComponentType("","foo.baz.component.html.HtmlTest"));
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testInferComponentTypeFromAbstractClass() throws Exception {
+ assertEquals("foo.baz.Test",
conventions.inferComponentType("",
"foo.baz.component.AbstractTest"));
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferUIComponentClass(java.lang.String,
java.lang.String, java.lang.String, boolean)}.
- */
- @Test
- public void testInferUIComponentClassFromExplicit() throws Exception {
- assertEquals("foo.bar.UITest",
conventions.inferUIComponentClass("foo.bar.Test", "foo.bar.UITest",
"foo.bar.AbstractClass", true));
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testInferComponentTypeFromBaseClass() throws Exception {
+ assertEquals("foo.baz.Test",
conventions.inferComponentType("", "foo.baz.component.TestBase"));
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferUIComponentClass(java.lang.String,
java.lang.String, java.lang.String, boolean)}.
- */
- @Test
- public void testInferUIComponentClassFromType() throws Exception {
- assertEquals("foo.bar.component.UITest",
conventions.inferUIComponentClass("foo.bar.Test", "",
"foo.bar.AbstractClass", true));
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testInferComponentTypeFromMarkupClass() throws Exception {
+ assertEquals("foo.baz.HtmlTest",
conventions.inferComponentType("",
"foo.baz.component.html.HtmlTest"));
+ }
+ /**
+ * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferUIComponentClass(java.lang.String,
java.lang.String, java.lang.String, boolean)}.
+ */
+ @Test
+ public void testInferUIComponentClassFromExplicit() throws Exception {
+ assertEquals("foo.bar.UITest",
+ conventions.inferUIComponentClass("foo.bar.Test",
"foo.bar.UITest", "foo.bar.AbstractClass",
+ true));
+ }
+
+ /**
+ * Test method for {@link
org.richfaces.cdk.RichFacesConventions#inferUIComponentClass(java.lang.String,
java.lang.String, java.lang.String, boolean)}.
+ */
+ @Test
+ public void testInferUIComponentClassFromType() throws Exception {
+ assertEquals("foo.bar.component.UITest",
+ conventions.inferUIComponentClass("foo.bar.Test",
"", "foo.bar.AbstractClass", true));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/TemplateReaderTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/TemplateReaderTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/TemplateReaderTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -1,6 +1,5 @@
package org.richfaces.cdk;
-
import static org.junit.Assert.*;
import java.io.IOException;
@@ -9,100 +8,114 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+
import org.richfaces.builder.model.JavaClass;
import org.richfaces.builder.model.JavaMethod;
import org.richfaces.builder.templates.TemplateReader;
public class TemplateReaderTest {
+ private static final String ENCODE_BEGIN_METHOD = "encodeBegin";
+ private static final String ENCODE_CHILDREN_METHOD = "encodeChildren";
+ private static final String ENCODE_END_METHOD = "encodeEnd";
+ private static final String END_DIV_FRAGMENT =
"responseWriter.endElement(\"div\");";
+ private static final String END_TABLE_FRAGMENT =
"responseWriter.endElement(\"table\");";
+ private static final String FULL_NAME =
"org.richfaces.renderkit.html.TabPanelRenderer";
+ private static final String IF_FRAGMENT = "if (";
+ private static final String PACKAGE = "org.richfaces.renderkit.html";
+ private static final String START_DIV_FRAGMENT =
"responseWriter.startElement(\"div\", component);";
+ private static final String START_TABLE_FRAGMENT =
"responseWriter.startElement(\"table\", component);";
+ private static final String SUPERCLASS = "javax.faces.render.Renderer";
+ private static final String TAB_PANEL_RENDERER = "TabPanelRenderer";
+ private static final String TEMPLATE_SIMPLE_XML = "template-simple.xml";
+ private static final String TEMPLATE_XML = "template.xml";
+ private static final String WRITE_ATTRIBBUTE_FRAGMENT =
+ "responseWriter.writeAttribute(\"id\",
component.getClientId(context), \"id\");";
+ InputStream stream = null;
- private static final String IF_FRAGMENT = "if (";
- private static final String START_DIV_FRAGMENT =
"responseWriter.startElement(\"div\", component);";
- private static final String START_TABLE_FRAGMENT =
"responseWriter.startElement(\"table\", component);";
- private static final String END_DIV_FRAGMENT =
"responseWriter.endElement(\"div\");";
- private static final String END_TABLE_FRAGMENT =
"responseWriter.endElement(\"table\");";
- private static final String WRITE_ATTRIBBUTE_FRAGMENT =
"responseWriter.writeAttribute(\"id\", component.getClientId(context),
\"id\");";
- private static final String TEMPLATE_XML = "template.xml";
- private static final String TEMPLATE_SIMPLE_XML = "template-simple.xml";
- private static final String FULL_NAME =
"org.richfaces.renderkit.html.TabPanelRenderer";
- private static final String SUPERCLASS = "javax.faces.render.Renderer";
- private static final String PACKAGE = "org.richfaces.renderkit.html";
- private static final String TAB_PANEL_RENDERER = "TabPanelRenderer";
- private static final String ENCODE_CHILDREN_METHOD = "encodeChildren";
- private static final String ENCODE_END_METHOD = "encodeEnd";
- private static final String ENCODE_BEGIN_METHOD = "encodeBegin";
- InputStream stream = null;
-
- @Before
- public void create() {
- }
-
- @After
- public void destroy(){
- try {
- stream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ @Before
+ public void create() {}
- @Test
- public void testSimpleTemplate() throws Exception {
- stream = this.getClass().getResourceAsStream(TEMPLATE_SIMPLE_XML);
- JavaClass claz = TemplateReader.parse(stream);
- /*JavaClassRenderer renderer = new JavaClassRenderer();
- renderer.render(claz, new PrintWriter(System.out));*/
- assertEquals(claz.getFullName(), FULL_NAME);
- assertEquals(claz.getName(), TAB_PANEL_RENDERER);
- assertEquals(claz.getPakg().getName(), PACKAGE);
- assertEquals(claz.getSuperClass().getFullName(), SUPERCLASS);
- assertTrue(containMethod(claz, ENCODE_BEGIN_METHOD));
- assertTrue(containMethod(claz, ENCODE_END_METHOD));
- assertTrue(containMethod(claz, ENCODE_CHILDREN_METHOD));
- }
-
- @Test
- public void testFullTemplate() throws Exception {
- stream = this.getClass().getResourceAsStream(TEMPLATE_XML);
- JavaClass claz = TemplateReader.parse(stream);
- /*JavaClassRenderer renderer = new JavaClassRenderer();
- renderer.render(claz, new PrintWriter(System.err));*/
- assertEquals(claz.getFullName(), FULL_NAME);
- assertEquals(claz.getName(), TAB_PANEL_RENDERER);
- assertEquals(claz.getPakg().getName(), PACKAGE);
- assertEquals(claz.getSuperClass().getFullName(), SUPERCLASS);
- assertTrue(containMethod(claz, ENCODE_BEGIN_METHOD));
- assertTrue(containMethod(claz, ENCODE_CHILDREN_METHOD));
- assertTrue(containMethod(claz, ENCODE_END_METHOD));
- JavaMethod method = getMethodByName(claz, ENCODE_CHILDREN_METHOD);
- assertNotNull(method);
- String code = method.getMethodBody().toCode();
- assertTrue(code.lastIndexOf(IF_FRAGMENT) != -1);
- assertTrue(code.lastIndexOf(START_TABLE_FRAGMENT) != -1);
- assertTrue(code.lastIndexOf(WRITE_ATTRIBBUTE_FRAGMENT) != -1);
- assertTrue(code.lastIndexOf(START_DIV_FRAGMENT) != -1);
- assertTrue(code.lastIndexOf(END_TABLE_FRAGMENT) != -1);
- assertTrue(code.lastIndexOf(END_DIV_FRAGMENT) != -1);
- assertTrue(code.lastIndexOf(START_TABLE_FRAGMENT) <
code.lastIndexOf(START_DIV_FRAGMENT));
- assertTrue(code.lastIndexOf(WRITE_ATTRIBBUTE_FRAGMENT) <
code.lastIndexOf(START_DIV_FRAGMENT));
- assertTrue(code.lastIndexOf(WRITE_ATTRIBBUTE_FRAGMENT) <
code.lastIndexOf(END_TABLE_FRAGMENT));
- assertTrue(code.lastIndexOf(END_TABLE_FRAGMENT) >
code.lastIndexOf(END_DIV_FRAGMENT));
- }
-
- private JavaMethod getMethodByName(JavaClass clazz, String name) {
- for(JavaMethod method : clazz.getMethods()){
- if(method.getName().equals(name)){
- return method;
- }
- }
- return null;
- }
+ @After
+ public void destroy() {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
- private boolean containMethod(JavaClass clazz, String name){
- for(JavaMethod method : clazz.getMethods()){
- if(method.getName().equals(name)){
- return true;
- }
- }
- return false;
- }
+ @Test
+ public void testSimpleTemplate() throws Exception {
+ stream = this.getClass().getResourceAsStream(TEMPLATE_SIMPLE_XML);
+
+ JavaClass claz = TemplateReader.parse(stream);
+
+ /*
+ * JavaClassRenderer renderer = new JavaClassRenderer();
+ * renderer.render(claz, new PrintWriter(System.out));
+ */
+ assertEquals(claz.getFullName(), FULL_NAME);
+ assertEquals(claz.getName(), TAB_PANEL_RENDERER);
+ assertEquals(claz.getPakg().getName(), PACKAGE);
+ assertEquals(claz.getSuperClass().getFullName(), SUPERCLASS);
+ assertTrue(containMethod(claz, ENCODE_BEGIN_METHOD));
+ assertTrue(containMethod(claz, ENCODE_END_METHOD));
+ assertTrue(containMethod(claz, ENCODE_CHILDREN_METHOD));
+ }
+
+ @Test
+ public void testFullTemplate() throws Exception {
+ stream = this.getClass().getResourceAsStream(TEMPLATE_XML);
+
+ JavaClass claz = TemplateReader.parse(stream);
+
+ /*
+ * JavaClassRenderer renderer = new JavaClassRenderer();
+ * renderer.render(claz, new PrintWriter(System.err));
+ */
+ assertEquals(claz.getFullName(), FULL_NAME);
+ assertEquals(claz.getName(), TAB_PANEL_RENDERER);
+ assertEquals(claz.getPakg().getName(), PACKAGE);
+ assertEquals(claz.getSuperClass().getFullName(), SUPERCLASS);
+ assertTrue(containMethod(claz, ENCODE_BEGIN_METHOD));
+ assertTrue(containMethod(claz, ENCODE_CHILDREN_METHOD));
+ assertTrue(containMethod(claz, ENCODE_END_METHOD));
+
+ JavaMethod method = getMethodByName(claz, ENCODE_CHILDREN_METHOD);
+
+ assertNotNull(method);
+
+ String code = method.getMethodBody().toCode();
+
+ assertTrue(code.lastIndexOf(IF_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(START_TABLE_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(WRITE_ATTRIBBUTE_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(START_DIV_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(END_TABLE_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(END_DIV_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(START_TABLE_FRAGMENT) <
code.lastIndexOf(START_DIV_FRAGMENT));
+ assertTrue(code.lastIndexOf(WRITE_ATTRIBBUTE_FRAGMENT) <
code.lastIndexOf(START_DIV_FRAGMENT));
+ assertTrue(code.lastIndexOf(WRITE_ATTRIBBUTE_FRAGMENT) <
code.lastIndexOf(END_TABLE_FRAGMENT));
+ assertTrue(code.lastIndexOf(END_TABLE_FRAGMENT) >
code.lastIndexOf(END_DIV_FRAGMENT));
+ }
+
+ private JavaMethod getMethodByName(JavaClass clazz, String name) {
+ for (JavaMethod method : clazz.getMethods()) {
+ if (method.getName().equals(name)) {
+ return method;
+ }
+ }
+
+ return null;
+ }
+
+ private boolean containMethod(JavaClass clazz, String name) {
+ for (JavaMethod method : clazz.getMethods()) {
+ if (method.getName().equals(name)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,14 +21,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
+
import static javax.lang.model.util.ElementFilter.*;
import java.io.File;
+
import java.net.URISyntaxException;
+
import java.util.Set;
import javax.annotation.processing.ProcessingEnvironment;
@@ -36,14 +42,18 @@
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
+
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
+
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import org.easymock.Capture;
import org.easymock.CaptureType;
+
import org.junit.Test;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
import org.richfaces.cdk.StandardOutputs;
@@ -61,229 +71,227 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class CdkProcessorTest extends CdkTestBase {
+ private static final String ANNOTATION2 = TestAnnotation2.class.getName();
+ private static final String CLASS_JAVA =
"org/richfaces/cdk/apt/TestClass.java";
+ private static final String COMPONENT_CLASS_JAVA =
"org/richfaces/cdk/test/component/AbstractTestComponent.java";
+ private static final String INTERFACE_JAVA =
"org/richfaces/cdk/apt/TestInterface.java";
+ private static final String SUB_CLASS_JAVA =
"org/richfaces/cdk/apt/TestSubClass.java";
+ private static final ImmutableSet<String> PROCESS_ANNOTATIONS =
ImmutableSet.of(TestAnnotation.class.getName());
+ private ClassLoader testLoader;
- private static final String ANNOTATION2 = TestAnnotation2.class.getName();
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testProcess() throws Exception {
- private static abstract class TestProcessor extends CdkProcessor {
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
- protected ComponentLibrary library;
+
expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType)
anyObject())).andStubReturn(null);
+
expect(cdkContext.getLoader()).andStubReturn(TestAnnotation.class.getClassLoader());
+ replay(cdkContext);
- protected int numOfComponents;
+ Processor processor = createMock(Processor.class);
- public TestProcessor(CdkContext context) {
- super(context);
- }
+ processor.init((ProcessingEnvironment) anyObject());
+
expect(processor.getSupportedOptions()).andReturn(ImmutableSet.<String>of());
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- }
+ // processor.process(null,null);
+ Capture<Set<? extends TypeElement>> capturedTypes = new
Capture<Set<? extends TypeElement>>();
- @Override
- public synchronized boolean isInitialized() {
- return super.isInitialized();
- }
+ expect(processor.process(capture(capturedTypes),
+ capture(new
Capture<RoundEnvironment>()))).andReturn(true).times(2);
+
expect(processor.getSupportedAnnotationTypes()).andReturn(ImmutableSet.of(TestAnnotation.class.getName()));
+
expect(processor.getSupportedSourceVersion()).andReturn(SourceVersion.RELEASE_6);
+ replay(processor);
- @Override
- public Set<String> getSupportedAnnotationTypes() {
- // Process all annotations
- return ImmutableSet.of("*");
- }
+ AptBuilder compiler = new AptBuilder();
- }
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(CLASS_JAVA)), processor);
+ verify(cdkContext, processor);
+ }
- private static final String INTERFACE_JAVA =
"org/richfaces/cdk/apt/TestInterface.java";
- private static final String SUB_CLASS_JAVA =
"org/richfaces/cdk/apt/TestSubClass.java";
- private static final String CLASS_JAVA =
"org/richfaces/cdk/apt/TestClass.java";
- private static final ImmutableSet<String> PROCESS_ANNOTATIONS = ImmutableSet
- .of(TestAnnotation.class.getName());
- private static final String COMPONENT_CLASS_JAVA =
"org/richfaces/cdk/test/component/AbstractTestComponent.java";
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testProcessSubClass() throws Exception {
- private ClassLoader testLoader;
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testProcess() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation.class.getClassLoader());
- replay(cdkContext);
+
expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType)
anyObject())).andStubReturn(null);
+
expect(cdkContext.getLoader()).andStubReturn(TestAnnotation2.class.getClassLoader());
+ replay(cdkContext);
- Processor processor = createMock(Processor.class);
- processor.init((ProcessingEnvironment) anyObject());
- expect(processor.getSupportedOptions()).andReturn(
- ImmutableSet.<String> of());
- // processor.process(null,null);
- Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<?
extends TypeElement>>();
- expect(
- processor.process(capture(capturedTypes),
- capture(new Capture<RoundEnvironment>()))).andReturn(
- true).times(2);
- expect(processor.getSupportedAnnotationTypes()).andReturn(
- ImmutableSet.of(TestAnnotation.class.getName()));
- expect(processor.getSupportedSourceVersion()).andReturn(
- SourceVersion.RELEASE_6);
- replay(processor);
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(CLASS_JAVA)), processor);
- verify(cdkContext, processor);
- }
+ Processor processor = createMock(Processor.class);
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testProcessSubClass() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation2.class.getClassLoader());
- replay(cdkContext);
+ processor.init((ProcessingEnvironment) anyObject());
+
expect(processor.getSupportedOptions()).andReturn(ImmutableSet.<String>of());
- Processor processor = createMock(Processor.class);
- processor.init((ProcessingEnvironment) anyObject());
- expect(processor.getSupportedOptions()).andReturn(
- ImmutableSet.<String> of());
- // processor.process(null,null);
- Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<?
extends TypeElement>>(
- CaptureType.FIRST);
- expect(
- processor.process(capture(capturedTypes),
- capture(new Capture<RoundEnvironment>()))).andReturn(
- true).times(2);
- expect(processor.getSupportedAnnotationTypes()).andReturn(
- ImmutableSet.of(TestAnnotation2.class.getName()));
- expect(processor.getSupportedSourceVersion()).andReturn(
- SourceVersion.RELEASE_6);
- replay(processor);
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(SUB_CLASS_JAVA),
- getJavaFile(CLASS_JAVA)), processor);
- verify(cdkContext, processor);
- Set<? extends TypeElement> elements = capturedTypes.getValue();
- assertFalse(elements.isEmpty());
- assertEquals("TestAnnotation2", elements.iterator().next()
- .getSimpleName().toString());
- }
+ // processor.process(null,null);
+ Capture<Set<? extends TypeElement>> capturedTypes = new
Capture<Set<? extends TypeElement>>(CaptureType.FIRST);
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment,
Class)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testGetClassesAnnotatedWith() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation2.class.getClassLoader());
- replay(cdkContext);
- TestProcessor processor = new TestProcessor(cdkContext) {
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
- if (!roundEnv.processingOver()) {
- this.numOfComponents = getClassesAnnotatedWith(
- roundEnv, Component.class).size();
+ expect(processor.process(capture(capturedTypes),
+ capture(new
Capture<RoundEnvironment>()))).andReturn(true).times(2);
+
expect(processor.getSupportedAnnotationTypes()).andReturn(ImmutableSet.of(TestAnnotation2.class.getName()));
+
expect(processor.getSupportedSourceVersion()).andReturn(SourceVersion.RELEASE_6);
+ replay(processor);
- }
- return true;
- }
- };
- // ComponentLibrary library = new
- // ComponentLibrary("org.richfaces.cdk.test");
- // processor.library = library;
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
- processor);
- verify(cdkContext);
- assertTrue(processor.isInitialized());
- assertEquals(1, processor.numOfComponents);
- }
+ AptBuilder compiler = new AptBuilder();
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment,
Class)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testGetPropertiesAnnotatedWith() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation2.class.getClassLoader());
- replay(cdkContext);
- TestProcessor processor = new TestProcessor(cdkContext) {
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
- if (!roundEnv.processingOver()) {
- TypeElement typeElement = getClassesAnnotatedWith(
- roundEnv, Component.class).iterator().next();
- Set<BeanProperty> beanProperties =
getBeanPropertiesAnnotatedWith(Attribute.class, typeElement);
- assertEquals(3, beanProperties.size());
- BeanProperty property = Iterables.get(beanProperties,2);
- assertEquals("foo", property.getName());
- assertEquals("int", property.getType().toString());
- assertNull(property.getDocComment());
-
- property = Iterables.get(beanProperties,1);
- assertEquals("testValue", property.getName());
- assertEquals("java.util.List<java.lang.String>",
property.getType().toString());
- assertEquals(" Test Attribute\n", property.getDocComment());
-
- property = Iterables.get(beanProperties,0);
- assertEquals("barValue", property.getName());
- assertEquals("java.util.List<M>", property.getType().toString());
- assertEquals(" Bar Attribute\n", property.getDocComment());
-// assertEquals("<M>" ,property.getTypeParameters());
-
- numOfComponents++;
- }
- return true;
- }
- };
- // ComponentLibrary library = new
- // ComponentLibrary("org.richfaces.cdk.test");
- // processor.library = library;
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
- processor);
- verify(cdkContext);
- assertTrue(processor.isInitialized());
- assertEquals(1, processor.numOfComponents);
- }
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(SUB_CLASS_JAVA),
getJavaFile(CLASS_JAVA)), processor);
+ verify(cdkContext, processor);
+ Set<? extends TypeElement> elements = capturedTypes.getValue();
+
+ assertFalse(elements.isEmpty());
+ assertEquals("TestAnnotation2",
elements.iterator().next().getSimpleName().toString());
+ }
+
+ /**
+ * Test method for
+ * {@link
org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment, Class)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetClassesAnnotatedWith() throws Exception {
+
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
+
+
expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType)
anyObject())).andStubReturn(null);
+
expect(cdkContext.getLoader()).andStubReturn(TestAnnotation2.class.getClassLoader());
+ replay(cdkContext);
+
+ TestProcessor processor = new TestProcessor(cdkContext) {
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
+ if (!roundEnv.processingOver()) {
+ this.numOfComponents = getClassesAnnotatedWith(roundEnv,
Component.class).size();
+ }
+
+ return true;
+ }
+ };
+
+ // ComponentLibrary library = new
+ // ComponentLibrary("org.richfaces.cdk.test");
+ // processor.library = library;
+ AptBuilder compiler = new AptBuilder();
+
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
processor);
+ verify(cdkContext);
+ assertTrue(processor.isInitialized());
+ assertEquals(1, processor.numOfComponents);
+ }
+
+ /**
+ * Test method for
+ * {@link
org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment, Class)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetPropertiesAnnotatedWith() throws Exception {
+
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
+
+
expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType)
anyObject())).andStubReturn(null);
+
expect(cdkContext.getLoader()).andStubReturn(TestAnnotation2.class.getClassLoader());
+ replay(cdkContext);
+
+ TestProcessor processor = new TestProcessor(cdkContext) {
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
+ if (!roundEnv.processingOver()) {
+ TypeElement typeElement = getClassesAnnotatedWith(roundEnv,
Component.class).iterator().next();
+ Set<BeanProperty> beanProperties =
getBeanPropertiesAnnotatedWith(Attribute.class, typeElement);
+
+ assertEquals(3, beanProperties.size());
+
+ BeanProperty property = Iterables.get(beanProperties, 2);
+
+ assertEquals("foo", property.getName());
+ assertEquals("int", property.getType().toString());
+ assertNull(property.getDocComment());
+ property = Iterables.get(beanProperties, 1);
+ assertEquals("testValue", property.getName());
+ assertEquals("java.util.List<java.lang.String>",
property.getType().toString());
+ assertEquals(" Test Attribute\n",
property.getDocComment());
+ property = Iterables.get(beanProperties, 0);
+ assertEquals("barValue", property.getName());
+ assertEquals("java.util.List<M>",
property.getType().toString());
+ assertEquals(" Bar Attribute\n",
property.getDocComment());
+
+// assertEquals("<M>" ,property.getTypeParameters());
+ numOfComponents++;
+ }
+
+ return true;
+ }
+ };
+
+ // ComponentLibrary library = new
+ // ComponentLibrary("org.richfaces.cdk.test");
+ // processor.library = library;
+ AptBuilder compiler = new AptBuilder();
+
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
processor);
+ verify(cdkContext);
+ assertTrue(processor.isInitialized());
+ assertEquals(1, processor.numOfComponents);
+ }
+
+ private static abstract class TestProcessor extends CdkProcessor {
+ protected ComponentLibrary library;
+ protected int numOfComponents;
+
+ public TestProcessor(CdkContext context) {
+ super(context);
+ }
+
+ @Override
+ public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ }
+
+ @Override
+ public synchronized boolean isInitialized() {
+ return super.isInitialized();
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+
+ // Process all annotations
+ return ImmutableSet.of("*");
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,26 +21,32 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
+
import static javax.lang.model.util.ElementFilter.*;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+
import java.util.Collection;
import java.util.Set;
import java.util.logging.LogManager;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkTestBase;
@@ -61,83 +67,97 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class ComponentProcessorTest extends CdkTestBase {
+ private static final String COMPONENT_CLASS_JAVA =
"org/richfaces/cdk/test/component/AbstractTestComponent.java";
+ private static final String FACES_COMPONENT_CLASS_JAVA =
"org/richfaces/cdk/test/component/UITestCommand.java";
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testProcess() throws Exception {
- private static final String COMPONENT_CLASS_JAVA =
"org/richfaces/cdk/test/component/AbstractTestComponent.java";
- private static final String FACES_COMPONENT_CLASS_JAVA =
"org/richfaces/cdk/test/component/UITestCommand.java";
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMockContext();
+ ComponentLibrary library = new ComponentLibrary();
+ ComponentProcessor processor = new ComponentProcessor(cdkContext, library);
+ AptBuilder compiler = new AptBuilder();
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
processor);
+ verify(cdkContext);
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testProcess() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- ComponentLibrary library = new ComponentLibrary();
- ComponentProcessor processor = new ComponentProcessor(cdkContext,library);
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)), processor);
- verify(cdkContext);
- Collection<Component> components = library.getComponents();
- assertEquals(1, components.size());
- Component component = Iterables.get(components, 0);
- Collection<Property> attributes = component.getAttributes();
- assertEquals(5, attributes.size());
- }
+ Collection<Component> components = library.getComponents();
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testProcessFacesComponent() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- ComponentLibrary library = new ComponentLibrary();
- ComponentProcessor processor = new ComponentProcessor(cdkContext,library);
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(FACES_COMPONENT_CLASS_JAVA)),
processor);
- verify(cdkContext);
- Collection<Component> components = library.getComponents();
- assertEquals(1, components.size());
- Component component = Iterables.get(components, 0);
- Collection<Property> attributes = component.getAttributes();
- assertEquals(2, attributes.size());
- }
+ assertEquals(1, components.size());
- private CdkContext createMockContext() throws Exception {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation.class.getClassLoader());
- RichFacesConventions richFacesConventions = new RichFacesConventions();
- expect(cdkContext.getWorkerInstance(NamingConventions.class)).andStubReturn(richFacesConventions);
- FragmentParser fragmentParser = new FragmentParser();
- expect(cdkContext.getWorkerInstance(FragmentParser.class)).andStubReturn(fragmentParser);
- JAXBBinding jaxbBinding = new JAXBBinding();
- expect(cdkContext.getWorkerInstance(JAXBBinding.class)).andStubReturn(jaxbBinding);
- replay(cdkContext);
- richFacesConventions.init(cdkContext);
- jaxbBinding.init(cdkContext);
- fragmentParser.init(cdkContext);
- return cdkContext;
- }
+ Component component = Iterables.get(components, 0);
+ Collection<Property> attributes = component.getAttributes();
+ assertEquals(5, attributes.size());
+ }
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testProcessFacesComponent() throws Exception {
+
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMockContext();
+ ComponentLibrary library = new ComponentLibrary();
+ ComponentProcessor processor = new ComponentProcessor(cdkContext, library);
+ AptBuilder compiler = new AptBuilder();
+
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(FACES_COMPONENT_CLASS_JAVA)),
processor);
+ verify(cdkContext);
+
+ Collection<Component> components = library.getComponents();
+
+ assertEquals(1, components.size());
+
+ Component component = Iterables.get(components, 0);
+ Collection<Property> attributes = component.getAttributes();
+
+ assertEquals(2, attributes.size());
+ }
+
+ private CdkContext createMockContext() throws Exception {
+ CdkContext cdkContext = createMock(CdkContext.class);
+
+
expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType)
anyObject())).andStubReturn(null);
+
expect(cdkContext.getLoader()).andStubReturn(TestAnnotation.class.getClassLoader());
+
+ RichFacesConventions richFacesConventions = new RichFacesConventions();
+
+
expect(cdkContext.getWorkerInstance(NamingConventions.class)).andStubReturn(richFacesConventions);
+
+ FragmentParser fragmentParser = new FragmentParser();
+
+
expect(cdkContext.getWorkerInstance(FragmentParser.class)).andStubReturn(fragmentParser);
+
+ JAXBBinding jaxbBinding = new JAXBBinding();
+
+
expect(cdkContext.getWorkerInstance(JAXBBinding.class)).andStubReturn(jaxbBinding);
+ replay(cdkContext);
+ richFacesConventions.init(cdkContext);
+ jaxbBinding.init(cdkContext);
+ fragmentParser.init(cdkContext);
+
+ return cdkContext;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.lang.annotation.Documented;
@@ -37,5 +39,5 @@
@Documented
@Target(ElementType.TYPE)
public @interface TestAnnotation {
- public String value();
+ public String value();
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation2.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation2.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation2.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.lang.annotation.Documented;
@@ -37,5 +39,5 @@
@Documented
@Target(ElementType.TYPE)
public @interface TestAnnotation2 {
- public String value();
+ public String value();
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestInterfaceAnnotation.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestInterfaceAnnotation.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestInterfaceAnnotation.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.lang.annotation.Documented;
@@ -36,6 +38,4 @@
@Inherited
@Documented
@Target(ElementType.TYPE)
-public @interface TestInterfaceAnnotation {
-
-}
+public @interface TestInterfaceAnnotation {}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestMethodAnnotation.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestMethodAnnotation.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestMethodAnnotation.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.lang.annotation.Documented;
@@ -37,5 +39,5 @@
@Documented
@Target(ElementType.METHOD)
public @interface TestMethodAnnotation {
- public String value();
+ public String value();
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileManagerTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileManagerTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileManagerTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -1,16 +1,19 @@
package org.richfaces.cdk.apt;
import static org.junit.Assert.*;
+
import static org.easymock.EasyMock.*;
+
import static org.hamcrest.CoreMatchers.*;
import java.io.File;
import java.io.IOException;
+
import java.net.URI;
import java.net.URL;
+
import java.util.ArrayList;
-
import javax.tools.FileObject;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
@@ -25,91 +28,122 @@
import com.google.common.collect.Lists;
public class VirtualFileManagerTest {
-
- private static final String TEST_PACKAGE = "org.richfaces.cdk.apt";
- private static final String TEST_CLASS = "TestClass";
- private static final String TEST_CLASS_NAME = TEST_PACKAGE + "." +
TEST_CLASS;
- private JavaFileManager mockFileManager;
- private File javaSourceDirectory;
+ private static final String TEST_CLASS = "TestClass";
+ private static final String TEST_PACKAGE = "org.richfaces.cdk.apt";
+ private static final String TEST_CLASS_NAME = TEST_PACKAGE + "." +
TEST_CLASS;
+ private File javaSourceDirectory;
+ private JavaFileManager mockFileManager;
- @Before
- public void setUp() throws Exception{
- mockFileManager = createMock(JavaFileManager.class);
- URL url = this.getClass().getResource(TEST_CLASS+".java");
- final File classFile = new File(url.toURI());
- javaSourceDirectory = classFile.getParentFile().getParentFile();
- }
+ @Before
+ public void setUp() throws Exception {
+ mockFileManager = createMock(JavaFileManager.class);
- @After
- public void tearDown() {
- mockFileManager = null;
- }
-
+ URL url = this.getClass().getResource(TEST_CLASS + ".java");
+ final File classFile = new File(url.toURI());
- @Test
- public void testGetJavaFileForInputSource() throws Exception {
- VirtualFileManager fileManager = new
VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- JavaFileObject fileObject =
fileManager.getJavaFileForInput(StandardLocation.SOURCE_PATH, "apt."+TEST_CLASS,
Kind.SOURCE);
- assertNotNull(fileObject);
- assertThat(fileObject,instanceOf(VirtualJavaFileObject.class) );
- JavaFileObject fileObject1 =
fileManager.getJavaFileForInput(StandardLocation.SOURCE_PATH, "apt."+TEST_CLASS,
Kind.SOURCE);
- assertSame(fileObject,fileObject1);
- }
+ javaSourceDirectory = classFile.getParentFile().getParentFile();
+ }
- @Test
- public void testHasLocationLocation() {
- VirtualFileManager fileManager = new
VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- assertTrue(fileManager.hasLocation(StandardLocation.SOURCE_PATH));
- }
+ @After
+ public void tearDown() {
+ mockFileManager = null;
+ }
- @Test
- public void testListLocationStringSetOfKindBoolean() throws Exception {
- VirtualFileManager fileManager = new
VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- ArrayList<JavaFileObject> list =
Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "apt",
ImmutableSet.of(Kind.HTML), false));
- assertEquals(1, list.size());
- }
+ @Test
+ public void testGetJavaFileForInputSource() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,
this.getClass().getClassLoader());
- @Test
- public void testListRecursive() throws Exception {
- VirtualFileManager fileManager = new
VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- ArrayList<JavaFileObject> list =
Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "",
ImmutableSet.of(Kind.HTML), true));
- assertEquals(1, list.size());
- }
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
- @Test
- public void testListRecursiveJava() throws Exception {
- VirtualFileManager fileManager = new
VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- ArrayList<JavaFileObject> list =
Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "",
ImmutableSet.of(Kind.HTML,Kind.SOURCE), true));
- assertEquals(6, list.size());
- }
- @Test
- public void testGetFileForInputLocationStringString() throws Exception {
- VirtualFileManager fileManager = new
VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- expect(mockFileManager.getFileForInput(StandardLocation.CLASS_PATH,
TestAnnotation.class.getPackage().getName(),
TestAnnotation.class.getSimpleName()+".class")).andReturn(new
VirtualJavaFileObject(new URI("file:/TestAnnotation.class"),Kind.CLASS));
- replay(mockFileManager);
- FileObject fileObject = fileManager.getFileForInput(StandardLocation.CLASS_PATH,
TestAnnotation.class.getPackage().getName(),
TestAnnotation.class.getSimpleName()+".class");
- assertNotNull(fileObject);
- assertThat(fileObject,instanceOf(VirtualJavaFileObject.class) );
- }
+ JavaFileObject fileObject =
fileManager.getJavaFileForInput(StandardLocation.SOURCE_PATH, "apt." +
TEST_CLASS,
+ Kind.SOURCE);
- @Test
- public void testGetFileForInputLocationFromSource() throws Exception {
- VirtualFileManager fileManager = new
VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- FileObject fileObject = fileManager.getFileForInput(StandardLocation.SOURCE_PATH,
"apt", TEST_CLASS+".java");
- assertNotNull(fileObject);
- assertThat(fileObject,instanceOf(VirtualJavaFileObject.class) );
- }
+ assertNotNull(fileObject);
+ assertThat(fileObject, instanceOf(VirtualJavaFileObject.class));
+ JavaFileObject fileObject1 =
fileManager.getJavaFileForInput(StandardLocation.SOURCE_PATH, "apt." +
TEST_CLASS,
+ Kind.SOURCE);
+
+ assertSame(fileObject, fileObject1);
+ }
+
+ @Test
+ public void testHasLocationLocation() {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,
this.getClass().getClassLoader());
+
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
+ assertTrue(fileManager.hasLocation(StandardLocation.SOURCE_PATH));
+ }
+
+ @Test
+ public void testListLocationStringSetOfKindBoolean() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,
this.getClass().getClassLoader());
+
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
+
+ ArrayList<JavaFileObject> list =
Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "apt",
+ ImmutableSet.of(Kind.HTML), false));
+
+ assertEquals(1, list.size());
+ }
+
+ @Test
+ public void testListRecursive() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,
this.getClass().getClassLoader());
+
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
+
+ ArrayList<JavaFileObject> list =
Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "",
+ ImmutableSet.of(Kind.HTML), true));
+
+ assertEquals(1, list.size());
+ }
+
+ @Test
+ public void testListRecursiveJava() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,
this.getClass().getClassLoader());
+
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
+
+ ArrayList<JavaFileObject> list =
Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "",
+ ImmutableSet.of(Kind.HTML, Kind.SOURCE),
true));
+
+ assertEquals(6, list.size());
+ }
+
+ @Test
+ public void testGetFileForInputLocationStringString() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,
this.getClass().getClassLoader());
+
+ expect(mockFileManager.getFileForInput(StandardLocation.CLASS_PATH,
+ TestAnnotation.class.getPackage().getName(),
+ TestAnnotation.class.getSimpleName()
+ + ".class")).andReturn(new VirtualJavaFileObject(new
URI("file:/TestAnnotation.class"), Kind.CLASS));
+ replay(mockFileManager);
+
+ FileObject fileObject = fileManager.getFileForInput(StandardLocation.CLASS_PATH,
+ TestAnnotation.class.getPackage().getName(),
+ TestAnnotation.class.getSimpleName() +
".class");
+
+ assertNotNull(fileObject);
+ assertThat(fileObject, instanceOf(VirtualJavaFileObject.class));
+ }
+
+ @Test
+ public void testGetFileForInputLocationFromSource() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,
this.getClass().getClassLoader());
+
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
+
+ FileObject fileObject = fileManager.getFileForInput(StandardLocation.SOURCE_PATH,
"apt", TEST_CLASS + ".java");
+
+ assertNotNull(fileObject);
+ assertThat(fileObject, instanceOf(VirtualJavaFileObject.class));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,18 +21,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.io.File;
import java.io.InputStream;
import java.io.Reader;
+
import java.net.URISyntaxException;
import java.net.URL;
+
import java.nio.charset.Charset;
import javax.tools.JavaFileObject.Kind;
-
import junit.framework.TestCase;
/**
@@ -41,84 +44,90 @@
*
*/
public class VirtualFileTest extends TestCase {
-
- private static final String
CONTENT="<html><body>test</body></html>\n";
+ private static final String CONTENT =
"<html><body>test</body></html>\n";
- /**
- * Test method for {@link
org.richfaces.cdk.apt.VirtualJavaFileObject#getLastModified()}.
- * @throws Exception
- */
- public void testGetLastModified() throws Exception {
- URL resource = getTestResource();
- File testFile = new File(resource.toURI());
- long lastModified = testFile.lastModified();
- assertEquals(lastModified, new
VirtualJavaClassPathObject(resource,Kind.HTML).getLastModified());
- assertEquals(lastModified, new
VirtualJavaFileSystemObject(testFile,Kind.HTML).getLastModified());
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.apt.VirtualJavaFileObject#getLastModified()}.
+ * @throws Exception
+ */
+ public void testGetLastModified() throws Exception {
+ URL resource = getTestResource();
+ File testFile = new File(resource.toURI());
+ long lastModified = testFile.lastModified();
- /**
- * <p class="changed_added_4_0"></p>
- * @return
- */
- protected URL getTestResource() {
- return this.getClass().getResource("test.html");
- }
+ assertEquals(lastModified, new VirtualJavaClassPathObject(resource,
Kind.HTML).getLastModified());
+ assertEquals(lastModified, new VirtualJavaFileSystemObject(testFile,
Kind.HTML).getLastModified());
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.apt.VirtualJavaFileObject#openInputStream()}.
- * @throws Exception
- */
- public void testOpenInputStream() throws Exception {
- VirtualJavaFileObject fileObject = createFileObject();
- InputStream inputStream = fileObject.openInputStream();
- byte buff[] = new byte[CONTENT.getBytes().length+10];
- int read = inputStream.read(buff,0,CONTENT.getBytes().length);
- inputStream.close();
- String result = new String(buff,0,read);
- assertEquals(CONTENT, result);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return
+ */
+ protected URL getTestResource() {
+ return this.getClass().getResource("test.html");
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.apt.VirtualJavaFileObject#getCharContent(boolean)}.
- * @throws Exception
- */
- public void testGetCharContentBoolean() throws Exception {
- VirtualJavaFileObject fileObject = createFileObject();
- CharSequence charContent = fileObject.getCharContent(true);
- assertEquals(CONTENT, charContent.toString());
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.apt.VirtualJavaFileObject#openInputStream()}.
+ * @throws Exception
+ */
+ public void testOpenInputStream() throws Exception {
+ VirtualJavaFileObject fileObject = createFileObject();
+ InputStream inputStream = fileObject.openInputStream();
+ byte buff[] = new byte[CONTENT.getBytes().length + 10];
+ int read = inputStream.read(buff, 0, CONTENT.getBytes().length);
- /**
- * Test method for {@link
org.richfaces.cdk.apt.VirtualJavaFileObject#openReader(boolean)}.
- * @throws Exception
- */
- public void testOpenReaderBoolean() throws Exception {
- VirtualJavaFileObject fileObject = createFileObject();
- Reader reader = fileObject.openReader(true);
- char buff[] = new char[CONTENT.length()+10];
- int read = reader.read(buff);
- reader.close();
- String result = new String(buff,0,read);
- assertEquals(CONTENT, result);
- }
+ inputStream.close();
- /**
- * <p class="changed_added_4_0"></p>
- * @return
- * @throws URISyntaxException
- */
- protected VirtualJavaFileObject createFileObject()
- throws URISyntaxException {
- return new VirtualJavaClassPathObject(getTestResource(),Kind.HTML);
- }
+ String result = new String(buff, 0, read);
- /**
- * Test method for {@link
org.richfaces.cdk.apt.VirtualJavaFileObject#setCharset(java.nio.charset.Charset)}.
- * @throws Exception
- */
- public void testSetCharset() throws Exception {
- VirtualJavaFileObject javaFileObject = createFileObject();
- javaFileObject.setCharset(Charset.forName("UTF-8"));
- }
+ assertEquals(CONTENT, result);
+ }
+ /**
+ * Test method for {@link
org.richfaces.cdk.apt.VirtualJavaFileObject#getCharContent(boolean)}.
+ * @throws Exception
+ */
+ public void testGetCharContentBoolean() throws Exception {
+ VirtualJavaFileObject fileObject = createFileObject();
+ CharSequence charContent = fileObject.getCharContent(true);
+
+ assertEquals(CONTENT, charContent.toString());
+ }
+
+ /**
+ * Test method for {@link
org.richfaces.cdk.apt.VirtualJavaFileObject#openReader(boolean)}.
+ * @throws Exception
+ */
+ public void testOpenReaderBoolean() throws Exception {
+ VirtualJavaFileObject fileObject = createFileObject();
+ Reader reader = fileObject.openReader(true);
+ char buff[] = new char[CONTENT.length() + 10];
+ int read = reader.read(buff);
+
+ reader.close();
+
+ String result = new String(buff, 0, read);
+
+ assertEquals(CONTENT, result);
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return
+ * @throws URISyntaxException
+ */
+ protected VirtualJavaFileObject createFileObject() throws URISyntaxException {
+ return new VirtualJavaClassPathObject(getTestResource(), Kind.HTML);
+ }
+
+ /**
+ * Test method for {@link
org.richfaces.cdk.apt.VirtualJavaFileObject#setCharset(java.nio.charset.Charset)}.
+ * @throws Exception
+ */
+ public void testSetCharset() throws Exception {
+ VirtualJavaFileObject javaFileObject = createFileObject();
+
+ javaFileObject.setCharset(Charset.forName("UTF-8"));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -1,6 +1,7 @@
package org.richfaces.cdk.freemarker;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
import java.io.File;
@@ -8,14 +9,17 @@
import java.io.InputStream;
import java.io.StringWriter;
import java.io.Writer;
+
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+
import java.util.logging.LogManager;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkTestBase;
@@ -27,58 +31,53 @@
import org.richfaces.cdk.model.Visitable;
public class FreeMarkerRendererTest extends CdkTestBase {
+ @Test
+ public void testRender() {
- @Test
- public void testRender() {
-// fail("Not yet implemented");
- }
+// fail("Not yet implemented");
+ }
- @Test
- public void testProcessComponent() throws Exception {
- final StringWriter output = new StringWriter();
- Component component = new Component(new Component.Type("foo.Bar"));
- FreeMarkerRenderer<Component, Boolean> renderer = new
FreeMarkerRenderer<Component, Boolean>(){
+ @Test
+ public void testProcessComponent() throws Exception {
+ final StringWriter output = new StringWriter();
+ Component component = new Component(new Component.Type("foo.Bar"));
+ FreeMarkerRenderer<Component, Boolean> renderer = new
FreeMarkerRenderer<Component, Boolean>() {
+ @Override
+ protected String getOutputFile(Component c) {
+ return null;
+ }
+ @Override
+ protected Writer getOutput(Component c) throws CdkException {
+ return output;
+ }
+ @Override
+ protected String getTemplateName() {
+ return "testComponent.ftl";
+ }
+ @Override
+ protected boolean isMyComponent(Visitable c) {
+ return true;
+ }
+ @Override
+ protected OutputType getOutputType() {
+ return null;
+ }
+ };
+ CdkContext cdkContext = createMockContext();
- @Override
- protected String getOutputFile(Component c) {
- return null;
- }
+ renderer.init(cdkContext);
+ renderer.processComponent(component, Boolean.TRUE);
+ assertEquals("foo.Bar", output.toString());
+ }
- @Override
- protected Writer getOutput(Component c) throws CdkException {
- return output;
- }
- @Override
- protected String getTemplateName() {
-
- return "testComponent.ftl";
- }
+ private CdkContext createMockContext() {
+ CdkContext cdkContext = createMock(CdkContext.class);
- @Override
- protected boolean isMyComponent(Visitable c) {
- return true;
- }
+
expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType)
anyObject())).andStubReturn(null);
+
expect(cdkContext.getLoader()).andStubReturn(FreeMarkerRendererTest.class.getClassLoader());
+ replay(cdkContext);
- @Override
- protected OutputType getOutputType() {
- return null;
- }
- };
- CdkContext cdkContext = createMockContext();
- renderer.init(cdkContext);
- renderer.processComponent(component, Boolean.TRUE);
- assertEquals("foo.Bar", output.toString());
- }
-
- private CdkContext createMockContext() {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- FreeMarkerRendererTest.class.getClassLoader());
- replay(cdkContext);
- return cdkContext;
- }
-
-
+ return cdkContext;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,18 +21,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.generate.java;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
import java.io.StringWriter;
import java.io.Writer;
+
import java.util.Set;
import javax.faces.component.UIOutput;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkTestBase;
@@ -52,57 +57,65 @@
*/
public class ComponentClassGeneratorTest extends CdkTestBase {
+ /**
+ * Test method for {@link
org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.Component)}.
+ * @throws Exception
+ */
+ @Test
+ public void testGetOutputFileComponent() throws Exception {
+ final StringWriter output = new StringWriter();
+ ComponentClassGenerator generator = new ComponentClassGenerator() {
+ @Override
+ protected Writer getOutput(Component c) throws CdkException {
+ return output;
+ }
+ };
+ CdkContext mockContext = createMockContext();
- /**
- * Test method for {@link
org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.Component)}.
- * @throws Exception
- */
- @Test
- public void testGetOutputFileComponent() throws Exception {
- final StringWriter output = new StringWriter();
- ComponentClassGenerator generator = new ComponentClassGenerator(){
- @Override
- protected Writer getOutput(Component c) throws CdkException {
- return output;
- }
- };
- CdkContext mockContext = createMockContext();
- generator.init(mockContext);
- ComponentLibrary library = new ComponentLibrary();
- Component component = library.findOrCreateComponent("foo.bar");
- component.setGenerate(true);
- component.setBaseClass(new ClassDescription(UIOutput.class));
- component.setComponentClass(new ClassDescription("foo.bar.UIBar"));
- Property attribute = component.findOrCreateAttribute("testValue");
- attribute.setType(new ClassDescription(Object.class));
- attribute.setGenerate(true);
- attribute = component.findOrCreateAttribute("testFlag");
- attribute.setType(new ClassDescription(boolean.class));
- attribute.setGenerate(true);
- attribute = component.findOrCreateAttribute("id");
- attribute.setType(new ClassDescription(String.class));
- Set<EventName> eventNames = attribute.getEventNames();
- EventName event = new EventName();
- event.setName("id");
- eventNames.add(event);
- event = new EventName();
- event.setName("action");
- event.setDefaultEvent(true);
- eventNames.add(event);
- attribute.setGenerate(false);
- generator.visit(component, library);
- System.out.println(output);
- verify(mockContext);
- // TODO - check generated file.
- }
+ generator.init(mockContext);
- private CdkContext createMockContext() {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- FreeMarkerRendererTest.class.getClassLoader());
- replay(cdkContext);
- return cdkContext;
- }
+ ComponentLibrary library = new ComponentLibrary();
+ Component component = library.findOrCreateComponent("foo.bar");
+
+ component.setGenerate(true);
+ component.setBaseClass(new ClassDescription(UIOutput.class));
+ component.setComponentClass(new ClassDescription("foo.bar.UIBar"));
+
+ Property attribute = component.findOrCreateAttribute("testValue");
+
+ attribute.setType(new ClassDescription(Object.class));
+ attribute.setGenerate(true);
+ attribute = component.findOrCreateAttribute("testFlag");
+ attribute.setType(new ClassDescription(boolean.class));
+ attribute.setGenerate(true);
+ attribute = component.findOrCreateAttribute("id");
+ attribute.setType(new ClassDescription(String.class));
+
+ Set<EventName> eventNames = attribute.getEventNames();
+ EventName event = new EventName();
+
+ event.setName("id");
+ eventNames.add(event);
+ event = new EventName();
+ event.setName("action");
+ event.setDefaultEvent(true);
+ eventNames.add(event);
+ attribute.setGenerate(false);
+ generator.visit(component, library);
+ System.out.println(output);
+ verify(mockContext);
+
+ // TODO - check generated file.
+ }
+
+ private CdkContext createMockContext() {
+ CdkContext cdkContext = createMock(CdkContext.class);
+
+
expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType)
anyObject())).andStubReturn(null);
+
expect(cdkContext.getLoader()).andStubReturn(FreeMarkerRendererTest.class.getClassLoader());
+ replay(cdkContext);
+
+ return cdkContext;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import static org.junit.Assert.*;
@@ -40,43 +42,46 @@
*/
@RunWith(Parameterized.class)
public class ClassDescriptionTest {
+ private final String className;
+ private final String expectedBoxedName;
+ private final String expectedCanonicalName;
+ private final String expectedTypeParameter;
+ private final String packageName;
+ private final String simpleName;
- private final String className;
- private final String expectedCanonicalName;
- private final String expectedBoxedName;
- private final String expectedTypeParameter;
- private final String packageName;
- private final String simpleName;
+ public ClassDescriptionTest(String className, String expectedCanonicalName, String
expectedBoxedName,
+ String expectedTypeParameter, String packageName, String
simpleName) {
+ this.className = className;
+ this.expectedCanonicalName = expectedCanonicalName;
+ this.expectedBoxedName = expectedBoxedName;
+ this.expectedTypeParameter = expectedTypeParameter;
+ this.packageName = packageName;
+ this.simpleName = simpleName;
+ }
- public ClassDescriptionTest(String className,String expectedCanonicalName,String
expectedBoxedName,String expectedTypeParameter, String packageName, String simpleName) {
- this.className = className;
- this.expectedCanonicalName = expectedCanonicalName;
- this.expectedBoxedName = expectedBoxedName;
- this.expectedTypeParameter = expectedTypeParameter;
- this.packageName = packageName;
- this.simpleName = simpleName;
+ /**
+ * Test method for {@link
org.richfaces.cdk.model.ClassDescription#ClassDescription(java.lang.String)}.
+ */
+ @Test
+ public void testClassDescription() {
+ ClassDescription description = new ClassDescription(className);
- }
- /**
- * Test method for {@link
org.richfaces.cdk.model.ClassDescription#ClassDescription(java.lang.String)}.
- */
- @Test
- public void testClassDescription() {
- ClassDescription description = new ClassDescription(className);
- assertEquals(className, description.toString());
- assertEquals(expectedCanonicalName, description.getName());
- assertEquals(expectedBoxedName, description.getBoxingName());
- assertEquals(expectedTypeParameter, description.getTypeParameters());
- assertEquals(packageName, description.getPackage());
- assertEquals(simpleName, description.getSimpleName());
-
- }
+ assertEquals(className, description.toString());
+ assertEquals(expectedCanonicalName, description.getName());
+ assertEquals(expectedBoxedName, description.getBoxingName());
+ assertEquals(expectedTypeParameter, description.getTypeParameters());
+ assertEquals(packageName, description.getPackage());
+ assertEquals(simpleName, description.getSimpleName());
+ }
- @Parameters
- public static Collection<String[]> values(){
- return Arrays.asList(new
String[]{int.class.getName(),"int","java.lang.Integer",null,null,"int"},
- new
String[]{"java.util.List<String>","java.util.List","java.util.List<String>","<String>","java.util","List"},
- new
String[]{double.class.getName(),"double","java.lang.Double",null,null,"double"});
- }
-
+ @Parameters
+ public static Collection<String[]> values() {
+ return Arrays.asList(new String[] {
+ int.class.getName(), "int", "java.lang.Integer", null,
null, "int"
+ }, new String[] {
+ "java.util.List<String>", "java.util.List",
"java.util.List<String>", "<String>",
"java.util", "List"
+ }, new String[] {
+ double.class.getName(), "double", "java.lang.Double",
null, null, "double"
+ });
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import static org.junit.Assert.*;
@@ -31,6 +33,7 @@
import javax.faces.render.RenderKitFactory;
import org.junit.Test;
+
import org.richfaces.cdk.CdkException;
/**
@@ -40,114 +43,126 @@
*/
public class ComponentLibraryTest {
- /**
- * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#merge(org.richfaces.cdk.model.ComponentLibrary)}.
- */
- @Test
- public void testMergeComponentLibrary() {
- ComponentLibrary lib = new ComponentLibrary();
- ComponentLibrary otherLib = new ComponentLibrary();
- Component component = lib.findOrCreateComponent("foo.Bar");
- Component component2 = otherLib.findOrCreateComponent("foo.Bar");
- otherLib.findOrCreateComponent("foo.baz");
- otherLib.findOrCreateRenderKit("foo.kit");
- lib.merge(otherLib);
- assertEquals(2, lib.getComponents().size());
- assertEquals(1, lib.getRenderKits().size());
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#merge(org.richfaces.cdk.model.ComponentLibrary)}.
+ */
+ @Test
+ public void testMergeComponentLibrary() {
+ ComponentLibrary lib = new ComponentLibrary();
+ ComponentLibrary otherLib = new ComponentLibrary();
+ Component component = lib.findOrCreateComponent("foo.Bar");
+ Component component2 = otherLib.findOrCreateComponent("foo.Bar");
- /**
- * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#accept(org.richfaces.cdk.model.LibraryVisitor,
java.lang.Object)}.
- * @throws Exception
- */
- @Test
- public void testAcceptLibraryVisitorOfRPP() throws Exception {
- ComponentLibrary lib = new ComponentLibrary();
- final Component component = lib.findOrCreateComponent("foo.Bar");
- LibraryVisitor<Boolean, Boolean> visitor = new LibraryVisitor<Boolean,
Boolean>() {
-
- @Override
- public Boolean visit(Visitable c, Boolean param) {
- return component == c?Boolean.TRUE:null;
- }
- };
- assertTrue(lib.accept(visitor, null));
- }
+ otherLib.findOrCreateComponent("foo.baz");
+ otherLib.findOrCreateRenderKit("foo.kit");
+ lib.merge(otherLib);
+ assertEquals(2, lib.getComponents().size());
+ assertEquals(1, lib.getRenderKits().size());
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#findOrCreateComponent(java.lang.String)}.
- */
- @Test
- public void testFindOrCreateComponent() {
- ComponentLibrary lib = new ComponentLibrary();
- Component component = lib.findOrCreateComponent("foo.Bar");
- assertNotNull(component);
- assertEquals(new Component.Type("foo.Bar"), component.getKey());
- assertSame(component, lib.findOrCreateComponent("foo.Bar"));
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#accept(org.richfaces.cdk.model.LibraryVisitor,
java.lang.Object)}.
+ * @throws Exception
+ */
+ @Test
+ public void testAcceptLibraryVisitorOfRPP() throws Exception {
+ ComponentLibrary lib = new ComponentLibrary();
+ final Component component = lib.findOrCreateComponent("foo.Bar");
+ LibraryVisitor<Boolean, Boolean> visitor = new LibraryVisitor<Boolean,
Boolean>() {
+ @Override
+ public Boolean visit(Visitable c, Boolean param) {
+ return component == c ? Boolean.TRUE : null;
+ }
+ };
- /**
- * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#findOrCreateRenderer(java.lang.String,
java.lang.String)}.
- */
- @Test
- public void testFindOrCreateRenderKit() {
- ComponentLibrary lib = new ComponentLibrary();
- RenderKit renderKit =
lib.findOrCreateRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT);
- assertNotNull(renderKit);
- assertSame(renderKit,
lib.findOrCreateRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT));
- }
+ assertTrue(lib.accept(visitor, null));
+ }
+ /**
+ * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#findOrCreateComponent(java.lang.String)}.
+ */
+ @Test
+ public void testFindOrCreateComponent() {
+ ComponentLibrary lib = new ComponentLibrary();
+ Component component = lib.findOrCreateComponent("foo.Bar");
- /**
- * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#merge(org.richfaces.cdk.model.Mergeable,
org.richfaces.cdk.model.Mergeable)}.
- */
- @Test
- public void testMergeTT() {
- ModelBean foo = new ModelBean("foo");
- foo.setResult("Result");
- foo.setDoNotReplace("Important");
- ModelBean bar = new ModelBean("bar");
- bar.setVizited(true);
- Object result = new Object();
- bar.setResult(result);
- bar.readOnly = "readOnly";
- bar.writeOnly = "writeOnly";
- bar.setDoNotReplace("Replaced");
- ComponentLibrary.merge(foo, bar);
- assertSame(result, foo.getResult());
- assertEquals(new ModelBean.Type("foo"), foo.getKey());
- assertTrue(foo.isVizited());
- assertEquals("Important", foo.getDoNotReplace());
- assertNull(foo.readOnly);
- assertNull(foo.writeOnly);
- }
+ assertNotNull(component);
+ assertEquals(new Component.Type("foo.Bar"), component.getKey());
+ assertSame(component, lib.findOrCreateComponent("foo.Bar"));
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#accept(java.lang.Iterable,
org.richfaces.cdk.model.LibraryVisitor, java.lang.Object, java.lang.Object)}.
- * @throws Exception
- */
- @Test
- public void testAcceptIterableOfTLibraryVisitorOfRPPR() throws Exception {
- List<ModelBean> beans = new ArrayList<ModelBean>();
- ModelBean foo = new ModelBean("foo");
- foo.setResult("foo");
- beans.add(foo);
- ModelBean bar = new ModelBean("bar");
- beans.add(bar);
- LibraryVisitor<Object, String> visitor = new LibraryVisitor<Object,
String>() {
-
- @Override
- public Object visit(Visitable c, String param) {
- ModelBean bean = (ModelBean) c;
- bean.setDoNotReplace(param);
- return bean.getResult();
- }
- };
- Object result = ComponentLibrary.accept(beans, visitor, "visited", null);
- assertTrue(foo.isVizited()||bar.isVizited());
- assertFalse(foo.isVizited()&&bar.isVizited());
- assertEquals("foo", result);
- assertEquals("visited", foo.getDoNotReplace());
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#findOrCreateRenderer(java.lang.String,
java.lang.String)}.
+ */
+ @Test
+ public void testFindOrCreateRenderKit() {
+ ComponentLibrary lib = new ComponentLibrary();
+ RenderKit renderKit =
lib.findOrCreateRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+ assertNotNull(renderKit);
+ assertSame(renderKit,
lib.findOrCreateRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT));
+ }
+
+ /**
+ * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#merge(org.richfaces.cdk.model.Mergeable,
org.richfaces.cdk.model.Mergeable)}.
+ */
+ @Test
+ public void testMergeTT() {
+ ModelBean foo = new ModelBean("foo");
+
+ foo.setResult("Result");
+ foo.setDoNotReplace("Important");
+
+ ModelBean bar = new ModelBean("bar");
+
+ bar.setVizited(true);
+
+ Object result = new Object();
+
+ bar.setResult(result);
+ bar.readOnly = "readOnly";
+ bar.writeOnly = "writeOnly";
+ bar.setDoNotReplace("Replaced");
+ ComponentLibrary.merge(foo, bar);
+ assertSame(result, foo.getResult());
+ assertEquals(new ModelBean.Type("foo"), foo.getKey());
+ assertTrue(foo.isVizited());
+ assertEquals("Important", foo.getDoNotReplace());
+ assertNull(foo.readOnly);
+ assertNull(foo.writeOnly);
+ }
+
+ /**
+ * Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#accept(java.lang.Iterable,
org.richfaces.cdk.model.LibraryVisitor, java.lang.Object, java.lang.Object)}.
+ * @throws Exception
+ */
+ @Test
+ public void testAcceptIterableOfTLibraryVisitorOfRPPR() throws Exception {
+ List<ModelBean> beans = new ArrayList<ModelBean>();
+ ModelBean foo = new ModelBean("foo");
+
+ foo.setResult("foo");
+ beans.add(foo);
+
+ ModelBean bar = new ModelBean("bar");
+
+ beans.add(bar);
+
+ LibraryVisitor<Object, String> visitor = new LibraryVisitor<Object,
String>() {
+ @Override
+ public Object visit(Visitable c, String param) {
+ ModelBean bean = (ModelBean) c;
+
+ bean.setDoNotReplace(param);
+
+ return bean.getResult();
+ }
+ };
+ Object result = ComponentLibrary.accept(beans, visitor, "visited",
null);
+
+ assertTrue(foo.isVizited() || bar.isVizited());
+ assertFalse(foo.isVizited() && bar.isVizited());
+ assertEquals("foo", result);
+ assertEquals("visited", foo.getDoNotReplace());
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,132 +33,114 @@
*
*/
@SuppressWarnings("serial")
-public class ModelBean implements ModelElement<ModelBean,ModelBean.Type> {
-
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = -4853397197172488116L;
+public class ModelBean implements ModelElement<ModelBean, ModelBean.Type> {
- @SuppressWarnings("serial")
- public static final class Type extends Key {
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private static final long serialVersionUID = -4853397197172488116L;
+ private boolean vizited = false;
+ private String doNotReplace;
+ String readOnly;
+ private Object result;
+ private Type type;
+ String writeOnly;
- public Type(String type) {
- super(type);
- }
-
- }
-
- private boolean vizited = false;
-
- private Type type;
-
- String readOnly;
-
- String writeOnly;
-
- private Object result;
-
- private String doNotReplace;
-
- public ModelBean() {
-
- }
-
- public ModelBean(String name) {
- this.type = new Type(name);
- }
+ public ModelBean() {}
- /**
- * <p class="changed_added_4_0"></p>
- * @return the vizited
- */
- @Merge
- public boolean isVizited() {
- return vizited;
- }
+ public ModelBean(String name) {
+ this.type = new Type(name);
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the vizited
+ */
+ @Merge
+ public boolean isVizited() {
+ return vizited;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param vizited the vizited to set
- */
- public void setVizited(boolean vizited) {
- this.vizited = vizited;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param vizited the vizited to set
+ */
+ public void setVizited(boolean vizited) {
+ this.vizited = vizited;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the result
+ */
+ @Merge
+ public Object getResult() {
+ return result;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the result
- */
- @Merge
- public Object getResult() {
- return result;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param result the result to set
+ */
+ public void setResult(Object result) {
+ this.result = result;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the readOnly
+ */
+ @Merge
+ public String getReadOnly() {
+ return readOnly;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param result the result to set
- */
- public void setResult(Object result) {
- this.result = result;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param writeOnly the writeOnly to set
+ */
+ public void setWriteOnly(String writeOnly) {
+ this.writeOnly = writeOnly;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the doNotReplace
+ */
+ @Merge(false)
+ public String getDoNotReplace() {
+ return doNotReplace;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the readOnly
- */
- @Merge
- public String getReadOnly() {
- return readOnly;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param doNotReplace the doNotReplace to set
+ */
+ public void setDoNotReplace(String doNotReplace) {
+ this.doNotReplace = doNotReplace;
+ }
+ @Override
+ public void merge(ModelBean other) {
+ ComponentLibrary.merge(this, other);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param writeOnly the writeOnly to set
- */
- public void setWriteOnly(String writeOnly) {
- this.writeOnly = writeOnly;
- }
+ @Override
+ public Type getKey() {
+ return type;
+ }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ vizited = true;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the doNotReplace
- */
- @Merge(false)
- public String getDoNotReplace() {
- return doNotReplace;
- }
+ return (R) visitor.visit(this, param);
+ }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param doNotReplace the doNotReplace to set
- */
- public void setDoNotReplace(String doNotReplace) {
- this.doNotReplace = doNotReplace;
- }
-
-
- @Override
- public void merge(ModelBean other) {
- ComponentLibrary.merge(this, other);
- }
-
- @Override
- public Type getKey() {
- return type;
- }
-
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- vizited = true;
- return (R) visitor.visit(this, param);
- }
-
+ @SuppressWarnings("serial")
+ public static final class Type extends Key {
+ public Type(String type) {
+ super(type);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import static org.junit.Assert.*;
@@ -36,127 +38,133 @@
*/
public class NameTest {
- /**
- * <p class="changed_added_4_0"></p>
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {}
- /**
- * <p class="changed_added_4_0"></p>
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {}
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString() throws Exception {
- Name name = Name.create("foo.bar.component.wml.WmlFoo");
- assertEquals("foo.bar", name.getPrefix());
- assertEquals(Name.Classifier.component, name.getClassifier());
- assertEquals("wml", name.getMarkup());
- assertEquals("WmlFoo", name.getSimpleName());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString() throws Exception {
+ Name name = Name.create("foo.bar.component.wml.WmlFoo");
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString1() throws Exception {
- Name name = Name.create("foo.bar.wml.WmlFoo");
- assertEquals("foo.bar.wml", name.getPrefix());
- assertNull(name.getClassifier());
- assertNull(name.getMarkup());
- assertEquals("WmlFoo", name.getSimpleName());
- }
+ assertEquals("foo.bar", name.getPrefix());
+ assertEquals(Name.Classifier.component, name.getClassifier());
+ assertEquals("wml", name.getMarkup());
+ assertEquals("WmlFoo", name.getSimpleName());
+ }
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString2() throws Exception {
- Name name = Name.create("foo.bar.component.Foo");
- assertEquals("foo.bar", name.getPrefix());
- assertEquals(Name.Classifier.component, name.getClassifier());
- assertNull( name.getMarkup());
- assertEquals("Foo", name.getSimpleName());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString1() throws Exception {
+ Name name = Name.create("foo.bar.wml.WmlFoo");
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString3() throws Exception {
- Name name = Name.create("Foo");
- assertNull(name.getPrefix());
- assertNull(name.getClassifier());
- assertNull( name.getMarkup());
- assertEquals("Foo", name.getSimpleName());
- }
+ assertEquals("foo.bar.wml", name.getPrefix());
+ assertNull(name.getClassifier());
+ assertNull(name.getMarkup());
+ assertEquals("WmlFoo", name.getSimpleName());
+ }
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString4() throws Exception {
- Name name = Name.create("component.Foo");
- assertNull(name.getPrefix());
- assertEquals(Name.Classifier.component, name.getClassifier());
- assertNull( name.getMarkup());
- assertEquals("Foo", name.getSimpleName());
- }
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString5() throws Exception {
- Name name = Name.create("component.wml.Foo");
- assertNull(name.getPrefix());
- assertEquals(Name.Classifier.component, name.getClassifier());
- assertEquals("wml", name.getMarkup());
- assertEquals("Foo", name.getSimpleName());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString2() throws Exception {
+ Name name = Name.create("foo.bar.component.Foo");
-
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString6() throws Exception {
- Name name = Name.create("bar.component.wml.Foo");
- assertEquals("bar",name.getPrefix());
- assertEquals(Name.Classifier.component, name.getClassifier());
- assertEquals("wml", name.getMarkup());
- assertEquals("Foo", name.getSimpleName());
- }
+ assertEquals("foo.bar", name.getPrefix());
+ assertEquals(Name.Classifier.component, name.getClassifier());
+ assertNull(name.getMarkup());
+ assertEquals("Foo", name.getSimpleName());
+ }
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String,
java.lang.String)}.
- */
- @Test
- public void testCreateStringString() {
-// fail("Not yet implemented");
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString3() throws Exception {
+ Name name = Name.create("Foo");
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String,
org.richfaces.cdk.model.Name.Classifier, java.lang.String)}.
- */
- @Test
- public void testCreateStringClassifierString() {
-// fail("Not yet implemented");
- }
+ assertNull(name.getPrefix());
+ assertNull(name.getClassifier());
+ assertNull(name.getMarkup());
+ assertEquals("Foo", name.getSimpleName());
+ }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString4() throws Exception {
+ Name name = Name.create("component.Foo");
+
+ assertNull(name.getPrefix());
+ assertEquals(Name.Classifier.component, name.getClassifier());
+ assertNull(name.getMarkup());
+ assertEquals("Foo", name.getSimpleName());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString5() throws Exception {
+ Name name = Name.create("component.wml.Foo");
+
+ assertNull(name.getPrefix());
+ assertEquals(Name.Classifier.component, name.getClassifier());
+ assertEquals("wml", name.getMarkup());
+ assertEquals("Foo", name.getSimpleName());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString6() throws Exception {
+ Name name = Name.create("bar.component.wml.Foo");
+
+ assertEquals("bar", name.getPrefix());
+ assertEquals(Name.Classifier.component, name.getClassifier());
+ assertEquals("wml", name.getMarkup());
+ assertEquals("Foo", name.getSimpleName());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String,
java.lang.String)}.
+ */
+ @Test
+ public void testCreateStringString() {
+
+// fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String,
org.richfaces.cdk.model.Name.Classifier, java.lang.String)}.
+ */
+ @Test
+ public void testCreateStringClassifierString() {
+
+// fail("Not yet implemented");
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -18,6 +18,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.test;
import java.util.ArrayList;
@@ -26,68 +29,61 @@
import java.util.Map;
public class Bean {
+ private UIComponent[] array = new UIComponent[] {new UIComponent()};
+ private List<UIComponent> components;
+ private Map<String, UIComponent> facets;
+ private boolean readOnly;
+ private Bean2 testBean2;
- public Bean(){
- facets = new HashMap<String, UIComponent>();
- UIComponent value = new UIComponent();
- facets.put("header", value);
- components = new ArrayList<UIComponent>();
- components.add(value);
- }
-
- private boolean readOnly;
-
- private Map<String, UIComponent> facets;
-
- private List<UIComponent> components;
-
- private Bean2 testBean2;
-
- private UIComponent[] array = new UIComponent[]{
- new UIComponent()
- };
-
- public Bean2 getTestBean2() {
- return testBean2;
- }
+ public Bean() {
+ facets = new HashMap<String, UIComponent>();
- public void setTestBean2(Bean2 testBean2) {
- this.testBean2 = testBean2;
- }
+ UIComponent value = new UIComponent();
- public void test(UIComponent comp, boolean test){
-
- }
-
- public UIComponent[] getArray() {
- return array;
- }
+ facets.put("header", value);
+ components = new ArrayList<UIComponent>();
+ components.add(value);
+ }
- public void setArray(UIComponent[] array) {
- this.array = array;
- }
+ public Bean2 getTestBean2() {
+ return testBean2;
+ }
- public List<UIComponent> getComponents() {
- return components;
- }
+ public void setTestBean2(Bean2 testBean2) {
+ this.testBean2 = testBean2;
+ }
- public void setComponents(List<UIComponent> components) {
- this.components = components;
- }
-
- public Map<String, UIComponent> getFacets() {
- return facets;
- }
+ public void test(UIComponent comp, boolean test) {}
- public void setFacets(Map<String, UIComponent> facets) {
- this.facets = facets;
- }
+ public UIComponent[] getArray() {
+ return array;
+ }
- public boolean isReadOnly() {
- return readOnly;
- }
+ public void setArray(UIComponent[] array) {
+ this.array = array;
+ }
- public void setReadOnly(boolean readOnly) {
- this.readOnly = readOnly;
- }
+ public List<UIComponent> getComponents() {
+ return components;
+ }
+
+ public void setComponents(List<UIComponent> components) {
+ this.components = components;
+ }
+
+ public Map<String, UIComponent> getFacets() {
+ return facets;
+ }
+
+ public void setFacets(Map<String, UIComponent> facets) {
+ this.facets = facets;
+ }
+
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean2.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean2.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean2.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -18,17 +18,19 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.test;
public class Bean2 {
+ private String string;
- private String string;
+ public String getString() {
+ return string;
+ }
- public String getString() {
- return string;
- }
-
- public void setString(String string) {
- this.string = string;
- }
+ public void setString(String string) {
+ this.string = string;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -18,6 +18,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.test;
import static org.junit.Assert.assertEquals;
@@ -27,260 +30,263 @@
import java.util.Map;
import org.junit.Test;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
public class ELParserTest {
-
- @Test
- public void testNull() throws Exception {
- assertEquals(resolveExpression("#{null}"), "null");
- }
-
- @Test
- public void testTrue() throws Exception {
- assertEquals(resolveExpression("#{true}"), "true");
- }
-
- @Test
- public void testFalse() throws Exception {
- assertEquals(resolveExpression("#{false}"), "false");
- }
-
- @Test
- public void testFloat() throws Exception {
- assertEquals(resolveExpression("#{5.0}"), "Double.valueOf(5.0)");
- }
-
- @Test
- public void testNegative() throws Exception {
- assertEquals(resolveExpression("#{-5}"), "-5");
- }
-
- @Test
- public void testNegativeFloat() throws Exception {
- assertEquals(resolveExpression("#{-5.0}"),
"-Double.valueOf(5.0)");
- }
-
- @Test
- public void testNotEqual() throws Exception {
- assertEquals(resolveExpression("#{1 ne 3}"), "(1 != 3)");
- assertEquals(resolveExpression("#{1 != 3}"), "(1 != 3)");
- }
-
- @Test
- public void testNot() throws Exception {
- assertEquals(resolveExpression("#{not 1}"), "(!1)");
- assertEquals(resolveExpression("#{!1}"), "(!1)");
- }
-
- @Test
- public void testPlus() throws Exception {
- assertEquals(resolveExpression("#{1+2}"), "(1 + 2)");
- }
-
- @Test
- public void testMinus() throws Exception {
- assertEquals(resolveExpression("#{1-2}"), "(1 - 2)");
- }
-
- @Test
- public void testDiv() throws Exception {
- assertEquals(resolveExpression("#{1/2}"), "(1 / 2)");
- }
-
- @Test
- public void testMult() throws Exception {
- assertEquals(resolveExpression("#{1*2}"), "(1 * 2)");
- }
-
- @Test
- public void testMod() throws Exception {
- assertEquals(resolveExpression("#{1%2}"), "(1 % 2)");
- }
-
- @Test
- public void testAnd() throws Exception {
- assertEquals(resolveExpression("#{1 and 2}"), "(1 && 2)");
- assertEquals(resolveExpression("#{1 && 2}"), "(1 &&
2)");
- }
-
- @Test
- public void testOr() throws Exception {
- assertEquals(resolveExpression("#{1 or 2}"), "(1 || 2)");
- assertEquals(resolveExpression("#{1 || 2}"), "(1 || 2)");
- }
-
- @Test
- public void testEquals() throws Exception {
- assertEquals(resolveExpression("#{1 eq 2}"), "(1 == 2)");
- assertEquals(resolveExpression("#{1 == 2}"), "(1 == 2)");
- }
-
- @Test
- public void testGreatThen() throws Exception {
- assertEquals(resolveExpression("#{1 gt 2}"), "(1 > 2)");
- assertEquals(resolveExpression("#{1 > 2}"), "(1 > 2)");
- }
-
- @Test
- public void testLessThen() throws Exception {
- assertEquals(resolveExpression("#{1 lt 2}"), "(1 < 2)");
- assertEquals(resolveExpression("#{1 < 2}"), "(1 < 2)");
- }
-
- @Test
- public void testLessThenEquals() throws Exception {
- assertEquals(resolveExpression("#{1 le 2}"), "(1 <= 2)");
- assertEquals(resolveExpression("#{1 <= 2}"), "(1 <= 2)");
- }
-
- @Test
- public void testGreatThenEquals() throws Exception {
- assertEquals(resolveExpression("#{1 ge 2}"), "(1 >= 2)");
- assertEquals(resolveExpression("#{1 >= 2}"), "(1 >= 2)");
- }
-
- @Test
- public void testChoice() throws Exception {
- assertEquals(resolveExpression("#{1 ? 2 : 3}"), "(1 ? 2 : 3)");
- }
-
- @Test
- public void testInteger() throws Exception {
- assertEquals(resolveExpression("#{152}"), "152");
- }
-
- @Test
- public void testString() throws Exception {
- assertEquals(resolveExpression("#{'nabc'}"),
"\"nabc\"");
- assertEquals(resolveExpression("#{'\tabc'}"),
"\" abc\"");
- assertEquals(resolveExpression("#{'/nabc'}"),
"\"/nabc\"");
- }
-
- @Test
- public void testIdentifier() throws Exception {
- assertEquals(resolveExpression("#{clientId}"),
"variables.getVariable(\"clientId\")");
- }
-
- @Test
- public void testLiteral() throws Exception {
- assertEquals(resolveExpression("clientId"),
"\"clientId\"");
- }
-
- @Test
- public void testMethodReturnMap() throws Exception {
- assertEquals(resolveExpression("#{action.facets}"),
"action.getFacets()");
- }
-
- @Test
- public void testMethodReturnMapElement() throws Exception {
- assertEquals(resolveExpression("#{action.facets['header']}"),
"action.getFacets().get(\"header\")");
- }
-
- @Test
- public void testMethodReturnMapElement2() throws Exception {
- assertEquals(resolveExpression("#{action.facets['header'].rendered}"),
"action.getFacets().get(\"header\").isRendered()");
- }
-
- @Test
- public void testMethod() throws Exception {
- assertEquals(resolveExpression("#{action.readOnly}"),
"action.isReadOnly()");
- }
-
- @Test
- public void testNestedMethod() throws Exception {
- assertEquals(resolveExpression("#{action.testBean2.string}"),
"action.getTestBean2().getString()");
- }
-
- @Test
- public void testMethodReturnList() throws Exception {
- assertEquals(resolveExpression("#{action.components}"),
"action.getComponents()");
- }
-
- @Test
- public void testMethodReturnListElement() throws Exception {
- assertEquals(resolveExpression("#{action.components[0]}"),
"action.getComponents().get(0)");
- }
-
- @Test
- public void testMethodReturnListElement2() throws Exception {
- assertEquals(resolveExpression("#{action.components[0].rendered}"),
"action.getComponents().get(0).isRendered()");
- }
-
- @Test
- public void testMethodReturnArray() throws Exception {
- assertEquals(resolveExpression("#{action.array}"),
"action.getArray()");
- }
-
- @Test
- public void testMethodReturnArrayElement() throws Exception {
- assertEquals(resolveExpression("#{action.array[0]}"),
"action.getArray()[0]");
- }
-
- @Test
- public void testMethodWithParam() throws Exception {
- assertEquals(resolveExpression("#{getType(action.array[0].rendered,
action.readOnly, true)}"),
"this.getType(action.getArray()[0].isRendered(),action.isReadOnly(),true)");
- }
-
- @Test
- public void testEmpty() throws Exception {
- assertEquals(resolveExpression("#{empty action.array}"),
"this.getUtils().isEmpty(action.getArray())");
- }
-
- @Test
- public void testFunction() throws Exception {
- assertEquals(resolveExpression("#{getType()}"), "this.getType()");
- }
-
- @Test
- public void testLiteralWithDeferred() throws Exception {
- assertEquals(resolveExpression("abs #{getType()}"), "\"abs \"
+ convertToString(this.getType())");
- }
-
- @Test
- public void testLiteralWithDeferred2() throws Exception {
- assertEquals(resolveExpression("#{getType()} abs "), "this.getType() +
\" abs \"");
- }
-
- @Test
- public void testThisFunction() throws Exception {
- assertEquals(resolveExpression("#{this.getType()}"),
"this.getType()");
- }
-
- @Test
- public void testUtilsFunction() throws Exception {
- assertEquals(resolveExpression("#{utils.getType()}"),
"this.getUtils().getType()");
- }
-
- @Test
- public void testWrongExpression() throws Exception {
- try{
- resolveExpression("#{bean.property}");
- fail("Parsing Exception is not thrown");
- }catch(ParsingException pe){
- assertEquals(pe.getMessage(), "No instance found in context for identifier
bean");
- }
-
- }
-
- @Test
- public void testWrongExpression2() throws Exception {
- try{
- resolveExpression("#{action.property}");
- fail("Parsing Exception is not thrown");
- }catch(ParsingException pe){
- assertEquals(pe.getMessage(), "property: property not found in class: class
org.richfaces.cdk.parser.el.test.Bean");
- }
-
- }
-
- private static String resolveExpression(String expression) throws ParsingException{
-
- Map<String, Class<?>> contextMap = new HashMap<String,
Class<?>>();
- contextMap.put("action", org.richfaces.cdk.parser.el.test.Bean.class);
- String code = ELVisitor.getInstance().parse(expression, contextMap);
- return code;
- }
+ @Test
+ public void testNull() throws Exception {
+ assertEquals(resolveExpression("#{null}"), "null");
+ }
+ @Test
+ public void testTrue() throws Exception {
+ assertEquals(resolveExpression("#{true}"), "true");
+ }
+
+ @Test
+ public void testFalse() throws Exception {
+ assertEquals(resolveExpression("#{false}"), "false");
+ }
+
+ @Test
+ public void testFloat() throws Exception {
+ assertEquals(resolveExpression("#{5.0}"),
"Double.valueOf(5.0)");
+ }
+
+ @Test
+ public void testNegative() throws Exception {
+ assertEquals(resolveExpression("#{-5}"), "-5");
+ }
+
+ @Test
+ public void testNegativeFloat() throws Exception {
+ assertEquals(resolveExpression("#{-5.0}"),
"-Double.valueOf(5.0)");
+ }
+
+ @Test
+ public void testNotEqual() throws Exception {
+ assertEquals(resolveExpression("#{1 ne 3}"), "(1 != 3)");
+ assertEquals(resolveExpression("#{1 != 3}"), "(1 != 3)");
+ }
+
+ @Test
+ public void testNot() throws Exception {
+ assertEquals(resolveExpression("#{not 1}"), "(!1)");
+ assertEquals(resolveExpression("#{!1}"), "(!1)");
+ }
+
+ @Test
+ public void testPlus() throws Exception {
+ assertEquals(resolveExpression("#{1+2}"), "(1 + 2)");
+ }
+
+ @Test
+ public void testMinus() throws Exception {
+ assertEquals(resolveExpression("#{1-2}"), "(1 - 2)");
+ }
+
+ @Test
+ public void testDiv() throws Exception {
+ assertEquals(resolveExpression("#{1/2}"), "(1 / 2)");
+ }
+
+ @Test
+ public void testMult() throws Exception {
+ assertEquals(resolveExpression("#{1*2}"), "(1 * 2)");
+ }
+
+ @Test
+ public void testMod() throws Exception {
+ assertEquals(resolveExpression("#{1%2}"), "(1 % 2)");
+ }
+
+ @Test
+ public void testAnd() throws Exception {
+ assertEquals(resolveExpression("#{1 and 2}"), "(1 &&
2)");
+ assertEquals(resolveExpression("#{1 && 2}"), "(1
&& 2)");
+ }
+
+ @Test
+ public void testOr() throws Exception {
+ assertEquals(resolveExpression("#{1 or 2}"), "(1 || 2)");
+ assertEquals(resolveExpression("#{1 || 2}"), "(1 || 2)");
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ assertEquals(resolveExpression("#{1 eq 2}"), "(1 == 2)");
+ assertEquals(resolveExpression("#{1 == 2}"), "(1 == 2)");
+ }
+
+ @Test
+ public void testGreatThen() throws Exception {
+ assertEquals(resolveExpression("#{1 gt 2}"), "(1 > 2)");
+ assertEquals(resolveExpression("#{1 > 2}"), "(1 >
2)");
+ }
+
+ @Test
+ public void testLessThen() throws Exception {
+ assertEquals(resolveExpression("#{1 lt 2}"), "(1 < 2)");
+ assertEquals(resolveExpression("#{1 < 2}"), "(1 <
2)");
+ }
+
+ @Test
+ public void testLessThenEquals() throws Exception {
+ assertEquals(resolveExpression("#{1 le 2}"), "(1 <= 2)");
+ assertEquals(resolveExpression("#{1 <= 2}"), "(1 <=
2)");
+ }
+
+ @Test
+ public void testGreatThenEquals() throws Exception {
+ assertEquals(resolveExpression("#{1 ge 2}"), "(1 >= 2)");
+ assertEquals(resolveExpression("#{1 >= 2}"), "(1 >=
2)");
+ }
+
+ @Test
+ public void testChoice() throws Exception {
+ assertEquals(resolveExpression("#{1 ? 2 : 3}"), "(1 ? 2 :
3)");
+ }
+
+ @Test
+ public void testInteger() throws Exception {
+ assertEquals(resolveExpression("#{152}"), "152");
+ }
+
+ @Test
+ public void testString() throws Exception {
+ assertEquals(resolveExpression("#{'nabc'}"),
"\"nabc\"");
+ assertEquals(resolveExpression("#{'\tabc'}"), "\"
abc\"");
+ assertEquals(resolveExpression("#{'/nabc'}"),
"\"/nabc\"");
+ }
+
+ @Test
+ public void testIdentifier() throws Exception {
+ assertEquals(resolveExpression("#{clientId}"),
"variables.getVariable(\"clientId\")");
+ }
+
+ @Test
+ public void testLiteral() throws Exception {
+ assertEquals(resolveExpression("clientId"),
"\"clientId\"");
+ }
+
+ @Test
+ public void testMethodReturnMap() throws Exception {
+ assertEquals(resolveExpression("#{action.facets}"),
"action.getFacets()");
+ }
+
+ @Test
+ public void testMethodReturnMapElement() throws Exception {
+ assertEquals(resolveExpression("#{action.facets['header']}"),
"action.getFacets().get(\"header\")");
+ }
+
+ @Test
+ public void testMethodReturnMapElement2() throws Exception {
+
assertEquals(resolveExpression("#{action.facets['header'].rendered}"),
+
"action.getFacets().get(\"header\").isRendered()");
+ }
+
+ @Test
+ public void testMethod() throws Exception {
+ assertEquals(resolveExpression("#{action.readOnly}"),
"action.isReadOnly()");
+ }
+
+ @Test
+ public void testNestedMethod() throws Exception {
+ assertEquals(resolveExpression("#{action.testBean2.string}"),
"action.getTestBean2().getString()");
+ }
+
+ @Test
+ public void testMethodReturnList() throws Exception {
+ assertEquals(resolveExpression("#{action.components}"),
"action.getComponents()");
+ }
+
+ @Test
+ public void testMethodReturnListElement() throws Exception {
+ assertEquals(resolveExpression("#{action.components[0]}"),
"action.getComponents().get(0)");
+ }
+
+ @Test
+ public void testMethodReturnListElement2() throws Exception {
+ assertEquals(resolveExpression("#{action.components[0].rendered}"),
+ "action.getComponents().get(0).isRendered()");
+ }
+
+ @Test
+ public void testMethodReturnArray() throws Exception {
+ assertEquals(resolveExpression("#{action.array}"),
"action.getArray()");
+ }
+
+ @Test
+ public void testMethodReturnArrayElement() throws Exception {
+ assertEquals(resolveExpression("#{action.array[0]}"),
"action.getArray()[0]");
+ }
+
+ @Test
+ public void testMethodWithParam() throws Exception {
+ assertEquals(resolveExpression("#{getType(action.array[0].rendered,
action.readOnly, true)}"),
+
"this.getType(action.getArray()[0].isRendered(),action.isReadOnly(),true)");
+ }
+
+ @Test
+ public void testEmpty() throws Exception {
+ assertEquals(resolveExpression("#{empty action.array}"),
"this.getUtils().isEmpty(action.getArray())");
+ }
+
+ @Test
+ public void testFunction() throws Exception {
+ assertEquals(resolveExpression("#{getType()}"),
"this.getType()");
+ }
+
+ @Test
+ public void testLiteralWithDeferred() throws Exception {
+ assertEquals(resolveExpression("abs #{getType()}"), "\"abs
\" + convertToString(this.getType())");
+ }
+
+ @Test
+ public void testLiteralWithDeferred2() throws Exception {
+ assertEquals(resolveExpression("#{getType()} abs "),
"this.getType() + \" abs \"");
+ }
+
+ @Test
+ public void testThisFunction() throws Exception {
+ assertEquals(resolveExpression("#{this.getType()}"),
"this.getType()");
+ }
+
+ @Test
+ public void testUtilsFunction() throws Exception {
+ assertEquals(resolveExpression("#{utils.getType()}"),
"this.getUtils().getType()");
+ }
+
+ @Test
+ public void testWrongExpression() throws Exception {
+ try {
+ resolveExpression("#{bean.property}");
+ fail("Parsing Exception is not thrown");
+ } catch (ParsingException pe) {
+ assertEquals(pe.getMessage(), "No instance found in context for
identifier bean");
+ }
+ }
+
+ @Test
+ public void testWrongExpression2() throws Exception {
+ try {
+ resolveExpression("#{action.property}");
+ fail("Parsing Exception is not thrown");
+ } catch (ParsingException pe) {
+ assertEquals(pe.getMessage(),
+ "property: property not found in class: class
org.richfaces.cdk.parser.el.test.Bean");
+ }
+ }
+
+ private static String resolveExpression(String expression) throws ParsingException {
+ Map<String, Class<?>> contextMap = new HashMap<String,
Class<?>>();
+
+ contextMap.put("action", org.richfaces.cdk.parser.el.test.Bean.class);
+
+ String code = ELVisitor.getInstance().parse(expression, contextMap);
+
+ return code;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/UIComponent.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/UIComponent.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/UIComponent.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -18,18 +18,19 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.test;
public class UIComponent {
+ private boolean rendered;
- private boolean rendered;
+ public boolean isRendered() {
+ return rendered;
+ }
- public boolean isRendered() {
- return rendered;
- }
-
- public void setRendered(boolean rendered) {
- this.rendered = rendered;
- }
-
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -1,6 +1,7 @@
package org.richfaces.cdk.xmlconfig;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
@@ -8,84 +9,99 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+
import java.util.logging.LogManager;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.apt.TestAnnotation2;
+
import org.xml.sax.InputSource;
public class CdkResolverTest extends CdkTestBase {
+ @Test
+ public void testResolveSystemIdSystem() throws Exception {
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMockContext();
- @Test
- public void testResolveSystemIdSystem() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- expect(cdkContext.getLoader()).andStubReturn(
- CdkEntityResolver.class.getClassLoader());
- replay(cdkContext);
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
- InputSource input =
entityResolver.resolveSystemId("http://java.sun.com/xml/ns/javaee/we...;
- assertNotNull(input);
- }
+
expect(cdkContext.getLoader()).andStubReturn(CdkEntityResolver.class.getClassLoader());
+ replay(cdkContext);
- @Test
- public void testResolveSystemIdResource() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- ClassLoader loader = new ClassLoader(CdkEntityResolver.class.getClassLoader()){
- @Override
- public InputStream getResourceAsStream(String name) {
- if("foo/bar.xml".equals(name)){
- return new ByteArrayInputStream("baz".getBytes());
- } else {
- return super.getResourceAsStream(name);
- }
- }
- };
- expect(cdkContext.getLoader()).andStubReturn(
- loader);
- replay(cdkContext);
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
- InputSource input =
entityResolver.resolveSystemId("urn:resource:foo/bar.xml");
- assertNotNull(input);
- }
+ CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
+ InputSource input =
entityResolver.resolveSystemId("http://java.sun.com/xml/ns/javaee/we...;
- @Test
- public void testResolveSystemIdAttributes() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- ClassLoader loader = CdkEntityResolver.class.getClassLoader();
- expect(cdkContext.getLoader()).andStubReturn(
- loader);
- replay(cdkContext);
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
- InputSource input =
entityResolver.resolveSystemId("urn:attributes:javax.faces.component.UIComponent.xml");
- assertNotNull(input);
- }
+ assertNotNull(input);
+ }
- private CdkContext createMockContext() {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- return cdkContext;
- }
+ @Test
+ public void testResolveSystemIdResource() throws Exception {
- @Test
- public void testGetProjectInputSource() throws Exception {
- CdkContext cdkContext = createMockContext();
- expect(cdkContext.getSourceFolders(StandardSources.FACES_CONFIGS)).andStubReturn(testSourceDirectory);
- replay(cdkContext);
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
- InputSource input = entityResolver.getProjectInputSource(StandardSources.FACES_CONFIGS,
"org/richfaces/cdk/apt/test.html");
- assertNotNull(input);
- verify(cdkContext);
- }
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMockContext();
+ ClassLoader loader = new ClassLoader(CdkEntityResolver.class.getClassLoader()) {
+ @Override
+ public InputStream getResourceAsStream(String name) {
+ if ("foo/bar.xml".equals(name)) {
+ return new ByteArrayInputStream("baz".getBytes());
+ } else {
+ return super.getResourceAsStream(name);
+ }
+ }
+ };
+ expect(cdkContext.getLoader()).andStubReturn(loader);
+ replay(cdkContext);
+
+ CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
+ InputSource input =
entityResolver.resolveSystemId("urn:resource:foo/bar.xml");
+
+ assertNotNull(input);
+ }
+
+ @Test
+ public void testResolveSystemIdAttributes() throws Exception {
+
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMockContext();
+ ClassLoader loader = CdkEntityResolver.class.getClassLoader();
+
+ expect(cdkContext.getLoader()).andStubReturn(loader);
+ replay(cdkContext);
+
+ CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
+ InputSource input =
entityResolver.resolveSystemId("urn:attributes:javax.faces.component.UIComponent.xml");
+
+ assertNotNull(input);
+ }
+
+ private CdkContext createMockContext() {
+ CdkContext cdkContext = createMock(CdkContext.class);
+
+
expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType)
anyObject())).andStubReturn(null);
+
+ return cdkContext;
+ }
+
+ @Test
+ public void testGetProjectInputSource() throws Exception {
+ CdkContext cdkContext = createMockContext();
+
+
expect(cdkContext.getSourceFolders(StandardSources.FACES_CONFIGS)).andStubReturn(testSourceDirectory);
+ replay(cdkContext);
+
+ CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
+ InputSource input =
entityResolver.getProjectInputSource(StandardSources.FACES_CONFIGS,
+ "org/richfaces/cdk/apt/test.html");
+
+ assertNotNull(input);
+ verify(cdkContext);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import static org.junit.Assert.*;
@@ -28,6 +30,7 @@
import java.util.Collection;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.CdkTestBase;
import org.richfaces.cdk.model.Component;
@@ -38,36 +41,43 @@
import com.google.common.collect.Iterables;
-
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
public class FacesConfigTest extends CdkTestBase {
+ @Test
+ public void testComponentUnmarshal() throws Exception {
+ CdkContextBase contextBase = new
CdkContextBase(this.getClass().getClassLoader());
+ JAXBBinding jaxbBinding = new JAXBBinding();
+ jaxbBinding.init(contextBase);
- @Test
- public void testComponentUnmarshal() throws Exception {
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- JAXBBinding jaxbBinding = new JAXBBinding();
- jaxbBinding.init(contextBase);
- FacesConfigBean library =
jaxbBinding.unmarshal("urn:resource:org/richfaces/cdk/xmlconfig/component.xml",
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION, FacesConfigBean.class);
- assertEquals(1,library.getComponents().size());
- Component component = library.getComponents().get(0);
- assertEquals("javax.faces.Panel", component.getType().toString());
- assertEquals("javax.faces.Panel", component.getFamily());
- assertEquals("javax.faces.component.UIPanel",
component.getComponentClass().getName());
- assertEquals("panel.gif", component.getIcon().getSmallIcon());
- assertEquals("panel-large.gif", component.getIcon().getLargeIcon());
- assertEquals("Panel component", component.getDescription());
- assertEquals("Panel", component.getDisplayname());
- assertTrue(component.isGenerate());
- Facet facet = Iterables.getOnlyElement(component.getFacets());
- assertEquals("header", facet.getName().toString());
- assertEquals("Header facet", facet.getDescription());
- assertTrue(facet.isGenerate());
- Collection<Property> attributes = component.getAttributes();
- assertEquals(3, attributes.size());
- }
+ FacesConfigBean library =
jaxbBinding.unmarshal("urn:resource:org/richfaces/cdk/xmlconfig/component.xml",
+ ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,
FacesConfigBean.class);
+
+ assertEquals(1, library.getComponents().size());
+
+ Component component = library.getComponents().get(0);
+
+ assertEquals("javax.faces.Panel", component.getType().toString());
+ assertEquals("javax.faces.Panel", component.getFamily());
+ assertEquals("javax.faces.component.UIPanel",
component.getComponentClass().getName());
+ assertEquals("panel.gif", component.getIcon().getSmallIcon());
+ assertEquals("panel-large.gif", component.getIcon().getLargeIcon());
+ assertEquals("Panel component", component.getDescription());
+ assertEquals("Panel", component.getDisplayname());
+ assertTrue(component.isGenerate());
+
+ Facet facet = Iterables.getOnlyElement(component.getFacets());
+
+ assertEquals("header", facet.getName().toString());
+ assertEquals("Header facet", facet.getDescription());
+ assertTrue(facet.isGenerate());
+
+ Collection<Property> attributes = component.getAttributes();
+
+ assertEquals(3, attributes.size());
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import static org.junit.Assert.*;
@@ -30,71 +32,92 @@
import java.util.Set;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.Property;
import com.google.common.collect.Iterables;
-
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
public class FragmentParserTest {
-
- @Test
- public void parserTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- parser.init(contextBase);
- Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
- assertEquals(3,properties.size());
- }
+ @Test
+ public void parserTest() throws Exception {
+ FragmentParser parser = new FragmentParser();
+ CdkContextBase contextBase = new
CdkContextBase(this.getClass().getClassLoader());
- @Test
- public void xincludeTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- parser.init(contextBase);
- Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent.xml");
- assertEquals(2,properties.size());
- }
+ parser.init(contextBase);
- @Test
- public void nestedXincludeTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- parser.init(contextBase);
- Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent2.xml");
- assertEquals(2,properties.size());
- }
+ Collection<Property> properties =
+
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
- @Test
- public void propertyTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- parser.init(contextBase);
- Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/properties.xml");
- assertEquals(1,properties.size());
- Property property = Iterables.getOnlyElement(properties);
- assertEquals("ontest2",property.getName().toString());
- assertEquals("int",property.getType().getName());
- assertEquals("test2 property",property.getDescription());
- assertEquals("ontest2.png",property.getIcon().getSmallIcon());
- assertEquals("test2 event property",property.getDisplayname());
- assertEquals("3",property.getDefaultValue());
- assertEquals("15",property.getSuggestedValue());
- // CDK extensions.
- assertTrue(property.isGenerate());
- assertTrue(property.isHidden());
- assertTrue(property.isLiteral());
- assertTrue(property.isPassThrough());
- assertTrue(property.isRequired());
- List<ClassDescription> signature = property.getSignature();
- assertEquals(2, signature.size());
- Set<String> aliases = property.getAliases();
- assertEquals(2, aliases.size());
- }
+ assertEquals(3, properties.size());
+ }
+
+ @Test
+ public void xincludeTest() throws Exception {
+ FragmentParser parser = new FragmentParser();
+ CdkContextBase contextBase = new
CdkContextBase(this.getClass().getClassLoader());
+
+ parser.init(contextBase);
+
+ Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent.xml");
+
+ assertEquals(2, properties.size());
+ }
+
+ @Test
+ public void nestedXincludeTest() throws Exception {
+ FragmentParser parser = new FragmentParser();
+ CdkContextBase contextBase = new
CdkContextBase(this.getClass().getClassLoader());
+
+ parser.init(contextBase);
+
+ Collection<Property> properties =
+
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent2.xml");
+
+ assertEquals(2, properties.size());
+ }
+
+ @Test
+ public void propertyTest() throws Exception {
+ FragmentParser parser = new FragmentParser();
+ CdkContextBase contextBase = new
CdkContextBase(this.getClass().getClassLoader());
+
+ parser.init(contextBase);
+
+ Collection<Property> properties =
+
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/properties.xml");
+
+ assertEquals(1, properties.size());
+
+ Property property = Iterables.getOnlyElement(properties);
+
+ assertEquals("ontest2", property.getName().toString());
+ assertEquals("int", property.getType().getName());
+ assertEquals("test2 property", property.getDescription());
+ assertEquals("ontest2.png", property.getIcon().getSmallIcon());
+ assertEquals("test2 event property", property.getDisplayname());
+ assertEquals("3", property.getDefaultValue());
+ assertEquals("15", property.getSuggestedValue());
+
+ // CDK extensions.
+ assertTrue(property.isGenerate());
+ assertTrue(property.isHidden());
+ assertTrue(property.isLiteral());
+ assertTrue(property.isPassThrough());
+ assertTrue(property.isRequired());
+
+ List<ClassDescription> signature = property.getSignature();
+
+ assertEquals(2, signature.size());
+
+ Set<String> aliases = property.getAliases();
+
+ assertEquals(2, aliases.size());
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -5,6 +5,7 @@
import java.util.List;
import org.junit.Test;
+
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.Component;
@@ -13,38 +14,45 @@
import org.richfaces.cdk.xmlconfig.model.ComponentBean.ComponentExtension;
public class JAXBCopyTest {
+ private static final String BAZ = "baz";
+ private static final String FOO_BAR = "foo.Bar";
+ private static final String FOO_DESCTIPTION = "foo.Desctiption";
+ private static final String FOO_FAMILY = "foo.Family";
+ private static final String FOO_UI_BAR = "foo.UIBar";
- private static final String FOO_FAMILY = "foo.Family";
- private static final String BAZ = "baz";
- private static final String FOO_DESCTIPTION = "foo.Desctiption";
- private static final String FOO_UI_BAR = "foo.UIBar";
- private static final String FOO_BAR = "foo.Bar";
+ @Test
+ public void testCreateAdapter() throws Exception {
+ Component component = new Component(new Component.Type(FOO_BAR));
- @Test
- public void testCreateAdapter() throws Exception {
- Component component = new Component(new Component.Type(FOO_BAR));
- component.setDescription(FOO_DESCTIPTION);
- component.setComponentClass(new ClassDescription(FOO_UI_BAR));
- component.findOrCreateAttribute(BAZ);
- component.setFamily(FOO_FAMILY);
- ComponentBean componentBean = JAXBBinding.createAdapter(ComponentBean.class,
component);
- assertEquals(FOO_BAR,componentBean.getType());
- List<Property> attributes = componentBean.getAttributes();
- assertEquals(1,attributes.size());
- assertEquals(BAZ,attributes.get(0).getName().toString());
- ComponentExtension extension = componentBean.getExtension();
- assertNotNull(extension);
- assertEquals(FOO_FAMILY, extension.getFamily());
- }
+ component.setDescription(FOO_DESCTIPTION);
+ component.setComponentClass(new ClassDescription(FOO_UI_BAR));
+ component.findOrCreateAttribute(BAZ);
+ component.setFamily(FOO_FAMILY);
- @Test
- public void testCopyExtensions() {
-// fail("Not yet implemented");
- }
+ ComponentBean componentBean = JAXBBinding.createAdapter(ComponentBean.class,
component);
- @Test
- public void testCopyProperties() {
-// fail("Not yet implemented");
- }
+ assertEquals(FOO_BAR, componentBean.getType());
+ List<Property> attributes = componentBean.getAttributes();
+
+ assertEquals(1, attributes.size());
+ assertEquals(BAZ, attributes.get(0).getName().toString());
+
+ ComponentExtension extension = componentBean.getExtension();
+
+ assertNotNull(extension);
+ assertEquals(FOO_FAMILY, extension.getFamily());
+ }
+
+ @Test
+ public void testCopyExtensions() {
+
+// fail("Not yet implemented");
+ }
+
+ @Test
+ public void testCopyProperties() {
+
+// fail("Not yet implemented");
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -7,6 +7,7 @@
import javax.xml.transform.stream.StreamResult;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.Component;
@@ -15,21 +16,24 @@
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
public class JaxbMarshalTest extends JaxbTestBase {
+ @Test
+ public void testMarshalResultStringT() throws Exception {
+ CdkContextBase contextBase = new
CdkContextBase(this.getClass().getClassLoader());
+ JAXBBinding jaxbBinding = new JAXBBinding();
- @Test
- public void testMarshalResultStringT() throws Exception {
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- JAXBBinding jaxbBinding = new JAXBBinding();
- jaxbBinding.init(contextBase);
- ComponentLibrary library = new ComponentLibrary();
- Component component = library.findOrCreateComponent("foo.bar");
- RenderKit renderKit = library.findOrCreateRenderKit("HTML");
- renderKit.findOrCreateRenderer("foo.Renderer");
- StringWriter writer = new StringWriter();
- StreamResult result = new StreamResult(writer);
- FacesConfigAdapter adapter = new FacesConfigAdapter();
- jaxbBinding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION,
adapter.marshal(library));
- System.out.println(writer.toString());
- }
+ jaxbBinding.init(contextBase);
+ ComponentLibrary library = new ComponentLibrary();
+ Component component = library.findOrCreateComponent("foo.bar");
+ RenderKit renderKit = library.findOrCreateRenderKit("HTML");
+
+ renderKit.findOrCreateRenderer("foo.Renderer");
+
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
+ FacesConfigAdapter adapter = new FacesConfigAdapter();
+
+ jaxbBinding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION,
adapter.marshal(library));
+ System.out.println(writer.toString());
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -9,40 +9,42 @@
import org.junit.Before;
public class JaxbTestBase {
+ protected static final String XML_PROLOG = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n";
- protected static final String XML_PROLOG = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n";
+ public JaxbTestBase() {
+ super();
+ }
- public JaxbTestBase() {
- super();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {}
- /**
- * <p class="changed_added_4_0"></p>
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {}
- /**
- * <p class="changed_added_4_0"></p>
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- }
+ protected <T> T unmarshal(Class<T> type, String src) {
+ StringBuilder xml = new StringBuilder(XML_PROLOG);
- protected <T> T unmarshal(Class<T> type, String src) {
- StringBuilder xml = new StringBuilder(XML_PROLOG);
- xml.append(src);
- StringReader reader = new StringReader(xml.toString());
- T result = JAXB.unmarshal(reader, type);
- return result;
- }
+ xml.append(src);
- protected <T> String marshal(T root){
- ByteArrayOutputStream xml = new ByteArrayOutputStream();
- JAXB.marshal(root, xml);
- return new String(xml.toByteArray());
- }
-}
\ No newline at end of file
+ StringReader reader = new StringReader(xml.toString());
+ T result = JAXB.unmarshal(reader, type);
+
+ return result;
+ }
+
+ protected <T> String marshal(T root) {
+ ByteArrayOutputStream xml = new ByteArrayOutputStream();
+
+ JAXB.marshal(root, xml);
+
+ return new String(xml.toByteArray());
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,61 +21,78 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
+
import static javax.lang.model.util.ElementFilter.*;
import java.io.StringReader;
+
import java.util.Set;
import javax.xml.bind.JAXB;
import org.junit.Test;
+
import org.richfaces.cdk.xmlconfig.testmodel.Child;
import org.richfaces.cdk.xmlconfig.testmodel.Root;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class JaxbUnmarshalTest extends JaxbTestBase {
+ @Test
+ public void testRootElement() throws Exception {
+ Root root =
+ unmarshal(
+ Root.class,
+ "<root-config xmlns='http://foo.bar/schema'
><name>foo</name><children><id>xxx</id><value>bar</value></children></root-config>");
- @Test
- public void testRootElement() throws Exception {
- Root root = unmarshal(
- Root.class,
- "<root-config xmlns='http://foo.bar/schema'
><name>foo</name><children><id>xxx</id><value>bar</value></children></root-config>");
- assertEquals("foo", root.getName());
- Set<Child> children = root.getChildren();
- assertEquals(1, children.size());
- assertEquals("xxx", children.iterator().next().getId());
- }
+ assertEquals("foo", root.getName());
- @Test
- public void testUniqueElement() throws Exception {
- Root root = unmarshal(
- Root.class,
- "<root-config xmlns='http://foo.bar/schema'
><name>foo</name><children><id>xxx</id><value>bar</value></children><children><id>xxx</id><value>baz</value></children></root-config>");
- assertEquals("foo", root.getName());
- Set<Child> children = root.getChildren();
- assertEquals(1, children.size());
- assertEquals("xxx", children.iterator().next().getId());
- }
-
- @Test
- public void testExtensions() throws Exception {
- Root root = unmarshal(
- Root.class,
- "<root-config xmlns='http://foo.bar/schema'
><name>foo</name><children><id>xxx</id><value>bar</value><extension><e:myExtension
xmlns:e=\"http://foo.bar/extensions\">eee</e:myExtension><s:foo
xmlns:s=\"urn:foo\">foo</s:foo></extension></children></root-config>");
- Set<Child> children = root.getChildren();
- assertEquals(1, children.size());
- Child child = children.iterator().next();
- assertEquals(1, child.getExtension().getExtensions().size());
- assertEquals("eee", child.getWrapped());
- }
+ Set<Child> children = root.getChildren();
+
+ assertEquals(1, children.size());
+ assertEquals("xxx", children.iterator().next().getId());
+ }
+
+ @Test
+ public void testUniqueElement() throws Exception {
+ Root root =
+ unmarshal(
+ Root.class,
+ "<root-config xmlns='http://foo.bar/schema'
><name>foo</name><children><id>xxx</id><value>bar</value></children><children><id>xxx</id><value>baz</value></children></root-config>");
+
+ assertEquals("foo", root.getName());
+
+ Set<Child> children = root.getChildren();
+
+ assertEquals(1, children.size());
+ assertEquals("xxx", children.iterator().next().getId());
+ }
+
+ @Test
+ public void testExtensions() throws Exception {
+ Root root =
+ unmarshal(
+ Root.class,
+ "<root-config xmlns='http://foo.bar/schema'
><name>foo</name><children><id>xxx</id><value>bar</value><extension><e:myExtension
xmlns:e=\"http://foo.bar/extensions\">eee</e:myExtension><s:foo
xmlns:s=\"urn:foo\">foo</s:foo></extension></children></root-config>");
+ Set<Child> children = root.getChildren();
+
+ assertEquals(1, children.size());
+
+ Child child = children.iterator().next();
+
+ assertEquals(1, child.getExtension().getExtensions().size());
+ assertEquals("eee", child.getWrapped());
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.testmodel;
import java.util.ArrayList;
@@ -39,172 +41,173 @@
* @author asmirnov(a)exadel.com
*
*/
-(a)XmlType(name="ChildType",namespace=Root.HTTP_FOO_BAR_SCHEMA)
+@XmlType(name = "ChildType", namespace = Root.HTTP_FOO_BAR_SCHEMA)
public class Child implements Id {
-
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static class Extension {
- private List<Element> extensions = new ArrayList<Element>();
-
- private Child parent;
+ private Extension extension;
+ private String id;
+ private String value;
+ private String wrapped;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the myExtension
- */
- @XmlElement(namespace = Root.EXTENSIONS_NAMESPACE)
- public String getMyExtension() {
- return parent.getWrapped();
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.xmlconfig.testmodel.Id#getId()
+ */
+ @Override
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
+ public String getId() {
+ return id;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param myExtension the myExtension to set
- */
- public void setMyExtension(String myExtension) {
- parent.setWrapped(myExtension);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extensions
- */
- @XmlAnyElement
- public List<Element> getExtensions() {
- return extensions;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the value
+ */
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
+ public String getValue() {
+ return value;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param extensions the extensions to set
- */
- public void setExtensions(List<Element> extensions) {
- this.extensions = extensions;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param value the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
- // This method is called immediately after the object is created and before the
unmarshalling of this
- // object begins. The callback provides an opportunity to initialize JavaBean
properties prior to unmarshalling.
- void beforeUnmarshal(Unmarshaller u, Object parent){
- this.parent = (Child) parent;
- }
-
- //This method is called after all the properties (except IDREF) are unmarshalled for
this object,
- //but before this object is set to the parent object.
- void afterUnmarshal(Unmarshaller u, Object parent){
-
- }
- }
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
+ public Extension getExtension() {
+ if (extension == null) {
+ extension = new Extension();
+ }
- private String id;
-
- private String value;
-
- private Extension extension;
-
- private String wrapped;
+ return extension;
+ }
+ public void setExtension(Extension extension) {
+ this.extension = extension;
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.xmlconfig.testmodel.Id#getId()
- */
- @Override
- @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
- public String getId() {
- return id;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the wrapped
+ */
+ public String getWrapped() {
+ return wrapped;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param id the id to set
- */
- public void setId(String id) {
- this.id = id;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param wrapped the wrapped to set
+ */
+ public void setWrapped(String wrapped) {
+ this.wrapped = wrapped;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the value
- */
- @XmlElement(namespace=Root.HTTP_FOO_BAR_SCHEMA)
- public String getValue() {
- return value;
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
- /**
- * <p class="changed_added_4_0"></p>
- * @param value the value to set
- */
- public void setValue(String value) {
- this.value = value;
- }
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
-
- @XmlElement(namespace=Root.HTTP_FOO_BAR_SCHEMA)
- public Extension getExtension(){
- if (extension == null) {
- extension = new Extension();
- }
- return extension;
- }
-
- public void setExtension(Extension extension) {
- this.extension = extension;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the wrapped
- */
- public String getWrapped() {
- return wrapped;
- }
+ return result;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param wrapped the wrapped to set
- */
- public void setWrapped(String wrapped) {
- this.wrapped = wrapped;
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
+ if (obj == null) {
+ return false;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof Child)) {
- return false;
- }
- Child other = (Child) obj;
- if (id == null) {
- if (other.id != null) {
- return false;
- }
- } else if (!id.equals(other.id)) {
- return false;
- }
- return true;
- }
+ if (!(obj instanceof Child)) {
+ return false;
+ }
+ Child other = (Child) obj;
+
+ if (id == null) {
+ if (other.id != null) {
+ return false;
+ }
+ } else if (!id.equals(other.id)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class Extension {
+ private List<Element> extensions = new ArrayList<Element>();
+ private Child parent;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the myExtension
+ */
+ @XmlElement(namespace = Root.EXTENSIONS_NAMESPACE)
+ public String getMyExtension() {
+ return parent.getWrapped();
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param myExtension the myExtension to set
+ */
+ public void setMyExtension(String myExtension) {
+ parent.setWrapped(myExtension);
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extensions
+ */
+ @XmlAnyElement
+ public List<Element> getExtensions() {
+ return extensions;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extensions the extensions to set
+ */
+ public void setExtensions(List<Element> extensions) {
+ this.extensions = extensions;
+ }
+
+ // This method is called immediately after the object is created and before the
unmarshalling of this
+ // object begins. The callback provides an opportunity to initialize JavaBean
properties prior to unmarshalling.
+ void beforeUnmarshal(Unmarshaller u, Object parent) {
+ this.parent = (Child) parent;
+ }
+
+ // This method is called after all the properties (except IDREF) are unmarshalled
for this object,
+ // but before this object is set to the parent object.
+ void afterUnmarshal(Unmarshaller u, Object parent) {}
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Id.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Id.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Id.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -4,11 +4,10 @@
public interface Id {
- /**
- * <p class="changed_added_4_0"></p>
- * @return the id
- */
- @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
- public String getId();
-
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the id
+ */
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
+ public String getId();
+}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.testmodel;
import java.util.Set;
@@ -35,48 +37,44 @@
* @author asmirnov(a)exadel.com
*
*/
-(a)XmlRootElement(name="root-config",namespace=Root.HTTP_FOO_BAR_SCHEMA)
+@XmlRootElement(name = "root-config", namespace = Root.HTTP_FOO_BAR_SCHEMA)
public class Root {
+ public static final String EXTENSIONS_NAMESPACE =
"http://foo.bar/extensions";
+ public static final String HTTP_FOO_BAR_SCHEMA = "http://foo.bar/schema";
+ private Set<Child> children = Sets.newHashSet();
+ private String name;
- public static final String HTTP_FOO_BAR_SCHEMA = "http://foo.bar/schema";
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlElement(namespace = HTTP_FOO_BAR_SCHEMA)
+ public String getName() {
+ return name;
+ }
- public static final String EXTENSIONS_NAMESPACE =
"http://foo.bar/extensions";
-
- private String name;
-
- private Set<Child> children = Sets.newHashSet();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlElement(namespace=HTTP_FOO_BAR_SCHEMA)
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the children
+ */
+ @XmlElement(namespace = HTTP_FOO_BAR_SCHEMA)
+ public Set<Child> getChildren() {
+ return children;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the children
- */
- @XmlElement(namespace=HTTP_FOO_BAR_SCHEMA)
- public Set<Child> getChildren() {
- return children;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param children the children to set
- */
- public void setChildren(Set<Child> children) {
- this.children = children;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param children the children to set
+ */
+ public void setChildren(Set<Child> children) {
+ this.children = children;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyMergeTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyMergeTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyMergeTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import junit.framework.TestCase;
@@ -29,54 +31,58 @@
*/
public class XMLBodyMergeTest extends TestCase {
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.xmlutils.XMLBodyMerge#add(org.w3c.dom.Node)}.
- */
- public void testAddNode() {
- XMLBodyMerge merge = new XMLBodyMerge("//node()");
-
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.xmlutils.XMLBodyMerge#add(org.w3c.dom.Node)}.
+ */
+ public void testAddNode() {
+ XMLBodyMerge merge = new XMLBodyMerge("//node()");
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.xmlutils.XMLBodyMerge#add(org.richfaces.cdk.xmlutils.XMLBody)}.
- */
- public void testAddXMLBody() {
- //fail("Not yet implemented");
- }
+ /**
+ * Test method for {@link
org.richfaces.cdk.xmlutils.XMLBodyMerge#add(org.richfaces.cdk.xmlutils.XMLBody)}.
+ */
+ public void testAddXMLBody() {
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#getLength()}.
- */
- public void testGetLength() {
- //fail("Not yet implemented");
- }
+ // fail("Not yet implemented");
+ }
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#item(int)}.
- */
- public void testItem() {
- //fail("Not yet implemented");
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#getLength()}.
+ */
+ public void testGetLength() {
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#getContent()}.
- */
- public void testGetContent() {
- //fail("Not yet implemented");
- }
+ // fail("Not yet implemented");
+ }
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#item(int)}.
+ */
+ public void testItem() {
+
+ // fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#getContent()}.
+ */
+ public void testGetContent() {
+
+ // fail("Not yet implemented");
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodySerializerTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodySerializerTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodySerializerTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.io.ByteArrayInputStream;
@@ -34,53 +36,62 @@
*
*/
public class XMLBodySerializerTest extends TestCase {
+ private XMLBodySerializer serializer;
- private XMLBodySerializer serializer;
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- serializer = new XMLBodySerializer();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ serializer = new XMLBodySerializer();
+ }
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- serializer = null;
- super.tearDown();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ serializer = null;
+ super.tearDown();
+ }
- /**
- * Test method for {@link
org.richfaces.cdk.xmlutils.XMLBodySerializer#serialize(org.w3c.dom.NodeList,
org.w3c.dom.Document)}.
- */
- public void testSerialize() throws ParsingException{
- String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN\"\n"
- + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n" +
" <component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
+ /**
+ * Test method for {@link
org.richfaces.cdk.xmlutils.XMLBodySerializer#serialize(org.w3c.dom.NodeList,
org.w3c.dom.Document)}.
+ */
+ public void testSerialize() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems,
Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n"
+ + "
<component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
+ + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
- NodeList singleElementList = body.getByXpath("/faces-config");
- assertEquals(1, singleElementList.getLength());
- Node node = singleElementList.item(0);
- assertNotNull(node);
- assertEquals("faces-config", node.getNodeName());
- String actual = serializer.serialize(singleElementList,
node.getOwnerDocument()).replaceAll("\\s", "");
- String expected =
"<faces-config><component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component></faces-config>";
- assertEquals(expected, actual);
-
- NodeList children = node.getChildNodes();
- actual = serializer.serialize(children,
node.getOwnerDocument()).replaceAll("\\s", "");
- expected =
"<component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>";
- assertEquals(expected, actual);
-
-
- }
+ body.loadXML(in);
+ NodeList singleElementList = body.getByXpath("/faces-config");
+
+ assertEquals(1, singleElementList.getLength());
+
+ Node node = singleElementList.item(0);
+
+ assertNotNull(node);
+ assertEquals("faces-config", node.getNodeName());
+
+ String actual = serializer.serialize(singleElementList,
node.getOwnerDocument()).replaceAll("\\s", "");
+ String expected =
+
"<faces-config><component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component></faces-config>";
+
+ assertEquals(expected, actual);
+
+ NodeList children = node.getChildNodes();
+
+ actual = serializer.serialize(children,
node.getOwnerDocument()).replaceAll("\\s", "");
+ expected =
+
"<component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>";
+ assertEquals(expected, actual);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -19,188 +19,196 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+
import java.util.HashSet;
import junit.framework.TestCase;
/**
* @author shura
- *
+ *
*/
public class XMLBodyTest extends TestCase {
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
- /**
- * Test method for
- * {@link org.richfaces.cdk.xmlutils.XMLBody#loadXML(java.io.InputStream)}.
- *
- * @throws ParsingException
- */
- public void testLoadXML() throws ParsingException {
- String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN\"\n"
- + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n"
- + " <component>\n"
- +
" <component-type>org.richfaces.ajax.Test</component-type>\n"
- +
" <component-class>org.richfaces.ajax.html.Test</component-class>\n"
- + "\n" + " <component-extension>\n"
- +
" <component-family>org.richfaces.Test</component-family>\n"
- + " <renderer-type>org.richfaces.Test</renderer-type>\n"
- + " </component-extension>\n" + " </component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- }
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.xmlutils.XMLBody#loadXML(java.io.InputStream)}.
+ *
+ * @throws ParsingException
+ */
+ public void testLoadXML() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems,
Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n" + " <component>\n" +
" <component-type>org.richfaces.ajax.Test</component-type>\n"
+ + "
<component-class>org.richfaces.ajax.html.Test</component-class>\n" +
"\n"
+ + " <component-extension>\n" + "
<component-family>org.richfaces.Test</component-family>\n"
+ + "
<renderer-type>org.richfaces.Test</renderer-type>\n" + "
</component-extension>\n"
+ + " </component>\n" + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
- /**
- * Test method for
- * {@link org.richfaces.cdk.xmlutils.XMLBody#isRootName(java.lang.String)}.
- *
- * @throws ParsingException
- */
- public void testIsRootName() throws ParsingException {
- String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN\"\n"
- + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n" + " <component>\n" +
" </component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- assertTrue(body.isRootName("faces-config"));
- assertEquals("faces-config", body.getDoctype());
- }
+ body.loadXML(in);
+ }
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBody#getDoctype()}.
- *
- * @throws ParsingException
- */
- public void testGetDoctype() throws ParsingException {
- String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN\"\n"
- + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n" + " <component>\n" +
" </component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- assertEquals(
- "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN",
- body.getPiblicId());
- }
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.xmlutils.XMLBody#isRootName(java.lang.String)}.
+ *
+ * @throws ParsingException
+ */
+ public void testIsRootName() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems,
Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n" + " <component>\n" +
" </component>\n" + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
- /**
- * Test method for
- * {@link org.richfaces.cdk.xmlutils.XMLBody#getRootNameSpace()}.
- *
- * @throws ParsingException
- */
- public void testGetRootNameSpace() throws ParsingException {
- String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
- + "<project
xmlns=\"http://maven.apache.org/POM/4.0.0\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd\">\n"
- + " <modelVersion>4.0.0</modelVersion>\n" +
"</project>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- assertNull( body.getRootTypeName());
- }
+ body.loadXML(in);
+ assertTrue(body.isRootName("faces-config"));
+ assertEquals("faces-config", body.getDoctype());
+ }
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBody#getContent()}.
- *
- * @throws ParsingException
- */
- public void testGetContent() throws ParsingException {
- String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
- + "<project
xmlns=\"http://maven.apache.org/POM/4.0.0\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd\">"
- + "<modelVersion>4.0.0</modelVersion></project>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- assertEquals("<modelVersion>4.0.0</modelVersion>",
body.getContent().trim());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBody#getDoctype()}.
+ *
+ * @throws ParsingException
+ */
+ public void testGetDoctype() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems,
Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n" + " <component>\n" +
" </component>\n" + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
- public void testGetContentXpath() throws ParsingException {
- String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN\"\n"
- + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n" +
" <component>blabla</component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- try {
- assertEquals(
- "<component>blabla</component>",
- body.getContent("/faces-config/component").trim());
- } catch (ParsingException e) {
- e.printStackTrace();
- assertTrue(e.getMessage(),false);
- }
- }
+ body.loadXML(in);
+ assertEquals("-//Sun Microsystems, Inc.//DTD JavaServer Faces Config
1.1//EN", body.getPiblicId());
+ }
- public void testGetContentUnique() throws ParsingException {
- String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN\"\n"
- + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n" +
" <component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- try {
- String expected =
"<component><test>blabla</test></component><component><test>blabla2</test></component>";
- String actual = body.getContentUnique("/faces-config/component",
"test/text()", new HashSet<String>()).replaceAll("\\s",
"");
-
- assertEquals(
- expected,
- actual);
- } catch (ParsingException e) {
- e.printStackTrace();
- assertTrue(e.getMessage(),false);
- }
- }
-
- public void testGetContentWithNS() throws Exception {
- String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
- + "<f:faces-config xmlns=\"http://foo.bar\"
xmlns:f=\"http://foo.baz\">"
- + "<f:component><test
f:foo=\"xxx\">blabla</test></f:component>"
- + "</f:faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in,true);
- try {
- assertEquals(
- "<f:component xmlns:f=\"http://foo.baz\"><test
f:foo=\"xxx\"
xmlns=\"http://foo.bar\">blabla</test></f:component>",
- body.getContent().replace("\r", "\n").replace("\n",
""));
- } catch (ParsingException e) {
- e.printStackTrace();
- assertTrue(e.getMessage(),false);
- }
-
- }
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.xmlutils.XMLBody#getRootNameSpace()}.
+ *
+ * @throws ParsingException
+ */
+ public void testGetRootNameSpace() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + "<project
xmlns=\"http://maven.apache.org/POM/4.0.0\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd\">\n"
+ + " <modelVersion>4.0.0</modelVersion>\n" +
"</project>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in);
+ assertNull(body.getRootTypeName());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBody#getContent()}.
+ *
+ * @throws ParsingException
+ */
+ public void testGetContent() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + "<project
xmlns=\"http://maven.apache.org/POM/4.0.0\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd\">"
+ +
"<modelVersion>4.0.0</modelVersion></project>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in);
+ assertEquals("<modelVersion>4.0.0</modelVersion>",
body.getContent().trim());
+ }
+
+ public void testGetContentXpath() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems,
Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n" + "
<component>blabla</component>\n" + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in);
+
+ try {
+ assertEquals("<component>blabla</component>",
body.getContent("/faces-config/component").trim());
+ } catch (ParsingException e) {
+ e.printStackTrace();
+ assertTrue(e.getMessage(), false);
+ }
+ }
+
+ public void testGetContentUnique() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems,
Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + "
\"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n"
+ + "
<component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
+ + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in);
+
+ try {
+ String expected =
"<component><test>blabla</test></component><component><test>blabla2</test></component>";
+ String actual = body.getContentUnique("/faces-config/component",
"test/text()",
+ new HashSet<String>()).replaceAll("\\s",
"");
+
+ assertEquals(expected, actual);
+ } catch (ParsingException e) {
+ e.printStackTrace();
+ assertTrue(e.getMessage(), false);
+ }
+ }
+
+ public void testGetContentWithNS() throws Exception {
+ String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + "<f:faces-config xmlns=\"http://foo.bar\"
xmlns:f=\"http://foo.baz\">"
+ + "<f:component><test
f:foo=\"xxx\">blabla</test></f:component>" +
"</f:faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in, true);
+
+ try {
+ assertEquals(
+ "<f:component xmlns:f=\"http://foo.baz\"><test
f:foo=\"xxx\"
xmlns=\"http://foo.bar\">blabla</test></f:component>",
+ body.getContent().replace("\r",
"\n").replace("\n", ""));
+ } catch (ParsingException e) {
+ e.printStackTrace();
+ assertTrue(e.getMessage(), false);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XPathComparatorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XPathComparatorTest.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XPathComparatorTest.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.io.ByteArrayInputStream;
@@ -35,59 +37,62 @@
*/
public class XPathComparatorTest extends TestCase {
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
- public void testCompare() throws Exception{
- String xml = "<faces-config>" +
- "<component><test>blabla1</test></component>" +
- "<component><test>blabla</test></component>" +
- "<renderer><foo>blabla2</foo></renderer>" +
- "<component><test>blabla2</test></component>"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- NodeList list = body.getByXpath("//component|//renderer");
- assertEquals(4, list.getLength());
- Node node0 = list.item(0);
- Node node1 = list.item(1);
- Node node2 = list.item(2);
- Node node3 = list.item(3);
-
- XPathComparator dummyComparator = new XPathComparator();
- assertEquals(0, dummyComparator.compare(node0, node1));
- assertEquals(0, dummyComparator.compare(node1, node2));
- assertEquals(0, dummyComparator.compare(node0, node2));
- assertEquals(0, dummyComparator.compare(node0, node3));
- assertEquals(0, dummyComparator.compare(node2, node3));
- assertEquals(0, dummyComparator.compare(node1, node0));
- assertEquals(0, dummyComparator.compare(node2, node1));
- assertEquals(0, dummyComparator.compare(node2, node0));
-
- XPathComparator simpleComparator = new XPathComparator("local-name()");
- assertEquals(0, simpleComparator.compare(node0, node1));
- assertEquals(0, simpleComparator.compare(node0, node3));
- assertTrue(simpleComparator.compare(node0, node2) < 0);
- assertTrue(simpleComparator.compare(node2, node1) > 0);
-
- XPathComparator advancedComparator = new XPathComparator("local-name()",
"test/text()", "foo/text()");
- assertTrue(advancedComparator.compare(node0, node2) < 0);
- assertTrue(advancedComparator.compare(node2, node1) > 0);
- assertTrue(advancedComparator.compare(node0, node1) > 0);
- assertTrue(advancedComparator.compare(node1, node0) < 0);
-
-
- }
+ public void testCompare() throws Exception {
+ String xml = "<faces-config>" +
"<component><test>blabla1</test></component>"
+ +
"<component><test>blabla</test></component>" +
"<renderer><foo>blabla2</foo></renderer>"
+ +
"<component><test>blabla2</test></component>" +
"</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in);
+
+ NodeList list = body.getByXpath("//component|//renderer");
+
+ assertEquals(4, list.getLength());
+
+ Node node0 = list.item(0);
+ Node node1 = list.item(1);
+ Node node2 = list.item(2);
+ Node node3 = list.item(3);
+ XPathComparator dummyComparator = new XPathComparator();
+
+ assertEquals(0, dummyComparator.compare(node0, node1));
+ assertEquals(0, dummyComparator.compare(node1, node2));
+ assertEquals(0, dummyComparator.compare(node0, node2));
+ assertEquals(0, dummyComparator.compare(node0, node3));
+ assertEquals(0, dummyComparator.compare(node2, node3));
+ assertEquals(0, dummyComparator.compare(node1, node0));
+ assertEquals(0, dummyComparator.compare(node2, node1));
+ assertEquals(0, dummyComparator.compare(node2, node0));
+
+ XPathComparator simpleComparator = new
XPathComparator("local-name()");
+
+ assertEquals(0, simpleComparator.compare(node0, node1));
+ assertEquals(0, simpleComparator.compare(node0, node3));
+ assertTrue(simpleComparator.compare(node0, node2) < 0);
+ assertTrue(simpleComparator.compare(node2, node1) > 0);
+
+ XPathComparator advancedComparator = new
XPathComparator("local-name()", "test/text()",
"foo/text()");
+
+ assertTrue(advancedComparator.compare(node0, node2) < 0);
+ assertTrue(advancedComparator.compare(node2, node1) > 0);
+ assertTrue(advancedComparator.compare(node0, node1) > 0);
+ assertTrue(advancedComparator.compare(node1, node0) < 0);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/test/TestComponent.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/test/TestComponent.java 2009-11-01
16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/test/TestComponent.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -19,33 +19,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package test;
-
-import javax.faces.component.UIInput;
+package test;
-
+import javax.faces.component.UIInput;
-/**
+/**
+ *
+ * @author shura (latest modification by $Author$)
+ *
+ * @version $Revision$ $Date$
+ *
+ *
+ *
+ */
+public abstract class TestComponent extends UIInput {
+ public abstract String getMyProperty();
- * @author shura (latest modification by $Author$)
-
- * @version $Revision$ $Date$
-
- *
-
- */
-
-public abstract class TestComponent extends UIInput {
-
-
-
- public abstract String getMyProperty();
-
-
-
- public abstract void setMyProperty(String myProperty);
-
-}
-
+ public abstract void setMyProperty(String myProperty);
+}
Modified:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
/**
@@ -29,6 +31,4 @@
*
*/
@TestAnnotation("foo")
-public class TestClass {
-
-}
+public class TestClass {}
Modified:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestInterface.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestInterface.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestInterface.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
/**
@@ -30,10 +32,8 @@
*/
@TestInterfaceAnnotation
public interface TestInterface {
-
- @TestMethodAnnotation("baz")
- public String getValue();
-
- public void setValue(String value);
+ @TestMethodAnnotation("baz")
+ public String getValue();
+ public void setValue(String value);
}
Modified:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestSubClass.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestSubClass.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestSubClass.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
/**
@@ -30,23 +32,22 @@
*/
@TestAnnotation2("subclass")
public class TestSubClass extends TestClass implements TestInterface {
+ private String value;
- private String value;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param value the value to set
+ */
+ @TestMethodAnnotation("setter")
+ public void setValue(String value) {
+ this.value = value;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param value the value to set
- */
- @TestMethodAnnotation("setter")
- public void setValue(String value) {
- this.value = value;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the value
- */
- public String getValue() {
- return value;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,12 +21,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.test.component;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Component;
import java.util.List;
+
import javax.faces.component.UIComponent;
import javax.faces.component.ValueHolder;
@@ -36,24 +39,20 @@
*
*/
@Component("org.richfaces.cdk.test.TestComponent")
-public abstract class AbstractTestComponent extends UIComponent implements
- ValueHolder {
-
-
- private static final String COMPONENT_FAMILY="org.richfaces.Test";
-
- @Attribute
- private int foo;
-
- /**
- * Test Attribute
- */
- @Attribute
- public abstract List<String> getTestValue();
+public abstract class AbstractTestComponent extends UIComponent implements ValueHolder {
+ private static final String COMPONENT_FAMILY = "org.richfaces.Test";
+ @Attribute
+ private int foo;
- /**
- * Bar Attribute
- */
- @Attribute
- public abstract <M> void setBarValue(List<M> bar);
+ /**
+ * Test Attribute
+ */
+ @Attribute
+ public abstract List<String> getTestValue();
+
+ /**
+ * Bar Attribute
+ */
+ @Attribute
+ public abstract <M> void setBarValue(List<M> bar);
}
Modified:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/UITestCommand.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/UITestCommand.java 2009-11-01
16:21:55 UTC (rev 15790)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/UITestCommand.java 2009-11-01
16:27:54 UTC (rev 15791)
@@ -21,9 +21,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.test.component;
import javax.el.MethodExpression;
+
import javax.faces.component.ActionSource2;
import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;
@@ -37,96 +40,110 @@
*/
@FacesComponent("cdk.TestCommand")
public class UITestCommand extends UIComponentBase implements ActionSource2 {
-
- private static final String COMPONENT_FAMILY="cdk.TestFamily";
+ private static final String COMPONENT_FAMILY = "cdk.TestFamily";
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponent#getFamily()
- */
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
- /* (non-Javadoc)
- * @see
javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
- */
- public void addActionListener(ActionListener listener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see
javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
+ */
+ public void addActionListener(ActionListener listener) {
- }
+ // TODO Auto-generated method stub
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getAction()
- */
- public MethodBinding getAction() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getAction()
+ */
+ public MethodBinding getAction() {
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getActionListener()
- */
- public MethodBinding getActionListener() {
- // TODO Auto-generated method stub
- return null;
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getActionListeners()
- */
- public ActionListener[] getActionListeners() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getActionListener()
+ */
+ public MethodBinding getActionListener() {
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#isImmediate()
- */
- public boolean isImmediate() {
- // TODO Auto-generated method stub
- return false;
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see
javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
- */
- public void removeActionListener(ActionListener listener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getActionListeners()
+ */
+ public ActionListener[] getActionListeners() {
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
- */
- public void setAction(MethodBinding action) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#isImmediate()
+ */
+ public boolean isImmediate() {
- }
+ // TODO Auto-generated method stub
+ return false;
+ }
- /* (non-Javadoc)
- * @see
javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
- */
- public void setActionListener(MethodBinding actionListener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see
javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
+ */
+ public void removeActionListener(ActionListener listener) {
- }
+ // TODO Auto-generated method stub
+ }
- public void setActionExpression(MethodExpression action) {
- // TODO Auto-generated method stub
-
- }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#setImmediate(boolean)
- */
- public void setImmediate(boolean immediate) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
+ */
+ public void setAction(MethodBinding action) {
- }
+ // TODO Auto-generated method stub
+ }
- public MethodExpression getActionExpression() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see
javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
+ */
+ public void setActionListener(MethodBinding actionListener) {
+ // TODO Auto-generated method stub
+ }
+
+ public void setActionExpression(MethodExpression action) {
+
+ // TODO Auto-generated method stub
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#setImmediate(boolean)
+ */
+ public void setImmediate(boolean immediate) {
+
+ // TODO Auto-generated method stub
+ }
+
+ public MethodExpression getActionExpression() {
+
+ // TODO Auto-generated method stub
+ return null;
+ }
}