Author: alexsmirnov
Date: 2010-07-28 19:37:11 -0400 (Wed, 28 Jul 2010)
New Revision: 18271
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestSubClass.java
Removed:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.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/TaskFactoryTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java
Log:
https://jira.jboss.org/browse/RF-8975
work in progress: unit tests
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -236,6 +236,12 @@
}
@Override
+ public boolean isDefaultValue(AnnotationMirror annotation, String propertyName) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
public <T> T getAnnotationValue(AnnotationMirror annotation, String
propertyName, Class<T> expectedType) {
Map<? extends ExecutableElement, ? extends AnnotationValue> elements =
processingEnv.getElementUtils().getElementValuesWithDefaults(annotation);
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue>
attributeEntry : elements.entrySet()) {
@@ -246,6 +252,9 @@
Object constantValue = variable.getConstantValue();
// TODO - properly convert into enum value.
return (T) Enum.valueOf((Class<? extends Enum>) expectedType,
(String)constantValue);
+ } else if(ClassName.class.equals(expectedType)){
+ TypeMirror value = (TypeMirror) annotationValue.getValue();
+ return (T) ClassName.get(value.toString());
}
return (T) annotationValue.getValue();
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -108,5 +108,11 @@
return null;
}
+ @Override
+ public boolean isDefaultValue(AnnotationMirror annotation, String propertyName) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -172,6 +172,13 @@
<T> List<T> getAnnotationValues(AnnotationMirror annotation, String
propertyName, Class<T> expectedType);
/**
+ * <p class="changed_added_4_0">Check annotation proprrty for default
value.</p>
+ * @param annotation
+ * @param propertyName
+ * @return true if property has its default value.
+ */
+ boolean isDefaultValue(AnnotationMirror annotation, String propertyName);
+ /**
* <p class="changed_added_4_0">
* </p>
*
Copied:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTestBase.java
(from rev 18270,
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java)
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTestBase.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTestBase.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -0,0 +1,151 @@
+/**
+ * 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.cdk.apt;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.el.ELContext;
+import javax.faces.component.UIComponent;
+import javax.lang.model.element.Name;
+
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Generator;
+import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.MockController;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.SourceFileManagerImpl;
+import org.richfaces.cdk.SourceImpl;
+import org.richfaces.cdk.Sources;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.apt.processors.ComponentProcessor;
+import org.richfaces.cdk.model.ComponentModel;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+/**
+ * @author akolonitsky
+ * @since Jan 14, 2010
+ */
+public abstract class AnnotationProcessorTestBase extends CdkTestBase {
+
+ protected static final class TestName implements Name {
+
+ private final String name;
+
+ public TestName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public char charAt(int index) {
+ return name.charAt(index);
+ }
+
+ @Override
+ public boolean contentEquals(CharSequence cs) {
+ // TODO Auto-generated method stub
+ return name.equals(cs);
+ }
+
+ @Override
+ public int length() {
+ return name.length();
+ }
+
+ @Override
+ public CharSequence subSequence(int start, int end) {
+ return name.substring(start, end);
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+ }
+
+ protected static final String FOO_BAR = "foo.Bar";
+
+ @Inject
+ protected Logger log;
+
+ @Inject
+ @Source(Sources.JAVA_SOURCES)
+ protected FileManager sources;
+
+ @Inject
+ protected MockController mockController;
+
+ @Inject
+ private Injector injector;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ try {
+ CdkClassLoader cdkClassLoader = createClassLoader();
+ binder.bind(CdkClassLoader.class).toInstance(cdkClassLoader);
+ List<File> sourceFiles = new ArrayList<File>();
+ for (String src : sources()) {
+ sourceFiles.add(getJavaFile(src));
+ }
+ binder.bind(FileManager.class).annotatedWith(new
SourceImpl(Sources.JAVA_SOURCES)).toInstance(
+ new SourceFileManagerImpl(sourceFiles, this.testSourceDirectory));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ @Override
+ protected CdkClassLoader createClassLoader() {
+ try {
+ return new
CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
+ getLibraryFile(ComponentModel.class), getLibraryFile(ELContext.class),
+ getLibraryFile(JsfComponent.class), getLibraryFile(UIComponent.class)),
this.getClass()
+ .getClassLoader());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void process(String javaFilePath) throws Exception {
+ Generator generator = new Generator();
+ generator.setLoader(createClassLoader());
+ generator.addSources(Sources.JAVA_SOURCES,
ImmutableList.of(getJavaFile(javaFilePath)), null);
+
+ generator.init();
+ injector.injectMembers(new ComponentProcessor());
+
+ LibraryBuilder builder = injector.getInstance(LibraryBuilder.class);
+ builder.build();
+ }
+
+ protected abstract Iterable<String> sources();
+}
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -0,0 +1,71 @@
+package org.richfaces.cdk.apt;
+
+import static org.junit.Assert.*;
+
+import java.util.Set;
+
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.Element;
+
+import org.junit.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+
+public class AptSourceUtilsAnnotationsTest extends SourceUtilsTestBase {
+
+ private static final String ANNOTATIONS_TEST_SUB_CLASS =
"AnnotationsTestSubClass";
+ private static final String ANNOTATIONS_TEST_CLASS =
"AnnotationsTestClass";
+ private static final String PACKAGE_PATH = "org/richfaces/cdk/apt/";
+ private static final String CLASS_JAVA = PACKAGE_PATH + ANNOTATIONS_TEST_CLASS +
".java";
+ private static final String SUB_CLASS_JAVA = PACKAGE_PATH +
ANNOTATIONS_TEST_SUB_CLASS + ".java";
+
+ @Test
+ public void testGetAnnotationMirror() {
+ fail("Not yet implemented");
+ }
+
+ @Test
+ public void testIsAnnotationPresent() {
+ setCallback(new SourceUtilsCallback() {
+
+ @Override
+ public void process(SourceUtils utils, RoundEnvironment roundEnv) {
+ assertTrue(utils.isAnnotationPresent(findElement(roundEnv,
ANNOTATIONS_TEST_CLASS), TestAnnotation.class));
+ }
+ });
+ execute();
+ }
+
+ @Test
+ public void testIsDefaultValue() {
+ fail("Not yet implemented");
+ }
+
+ @Test
+ public void testGetAnnotationValue() {
+ fail("Not yet implemented");
+ }
+
+ @Test
+ public void testGetAnnotationValues() {
+ fail("Not yet implemented");
+ }
+
+ @Override
+ protected Iterable<String> sources() {
+ return ImmutableList.of(CLASS_JAVA, SUB_CLASS_JAVA);
+ }
+
+ private Element findElement(RoundEnvironment roundEnvironment, final String name){
+ Set<? extends Element> elements = roundEnvironment.getRootElements();
+ return Iterables.find(elements, new Predicate<Element>() {
+
+ @Override
+ public boolean apply(Element input) {
+ return name.equals(input.getSimpleName().toString());
+ }
+ });
+ }
+}
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 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -44,7 +44,6 @@
import org.richfaces.cdk.Output;
import org.richfaces.cdk.Outputs;
import org.richfaces.cdk.Stub;
-import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
import org.richfaces.cdk.apt.processors.CdkAnnotationProcessor;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -63,7 +62,7 @@
*
*/
@RunWith(CdkTestRunner.class)
-public class CdkProcessorTest extends AnnotationProcessorTest {
+public class CdkProcessorTest extends AnnotationProcessorTestBase {
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";
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -0,0 +1,126 @@
+/*
+ * $Id$
+ *
+ * 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.cdk.apt;
+
+import static junit.framework.Assert.*;
+
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
+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 org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Output;
+import org.richfaces.cdk.Outputs;
+import org.richfaces.cdk.Stub;
+
+import com.google.inject.Binder;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)RunWith(CdkTestRunner.class)
+public abstract class SourceUtilsTestBase extends AnnotationProcessorTestBase {
+
+ @Inject
+ protected CdkProcessor processor;
+
+ @Inject
+ protected TaskFactoryImpl factory;
+
+ @Stub
+ @Output(Outputs.JAVA_CLASSES)
+ protected FileManager output;
+
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(CdkProcessor.class).to(TestProcessor.class).in(Singleton.class);
+ }
+
+ protected void setCallback(SourceUtilsCallback callback){
+ ((TestProcessor)processor).callback = callback;
+ }
+
+ protected void execute(){
+ assertTrue("Compilation error",factory.get().call());
+ }
+
+ /**
+ * <p class="changed_added_4_0">Interface to call back test method
from APT</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public interface SourceUtilsCallback {
+ void process(SourceUtils utils, RoundEnvironment roundEnv);
+ }
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @SupportedSourceVersion(SourceVersion.RELEASE_6)
+ @SupportedAnnotationTypes("*")
+ public static class TestProcessor extends AbstractProcessor implements CdkProcessor
{
+
+ @Inject
+ protected SourceUtilsProvider sourceUtilsProvider;
+
+ SourceUtilsCallback callback;
+
+ @Override
+ public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ sourceUtilsProvider.setProcessingEnv(processingEnv);
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
+ if(!roundEnv.processingOver()){
+ callback.process(sourceUtilsProvider.get(), roundEnv);
+ }
+ return false;
+ }
+
+ @Override
+ public void processNonJavaSources() {
+ // do nothing
+ }
+
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -46,7 +46,6 @@
import org.richfaces.cdk.Output;
import org.richfaces.cdk.Outputs;
import org.richfaces.cdk.Stub;
-import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
@@ -59,7 +58,7 @@
*
*/
@RunWith(CdkTestRunner.class)
-public class TaskFactoryTest extends AnnotationProcessorTest {
+public class TaskFactoryTest extends AnnotationProcessorTestBase {
private static final String CLASS_JAVA =
"org/richfaces/cdk/apt/TestClass.java";
private static final String INTERFACE_JAVA =
"org/richfaces/cdk/apt/TestInterface.java";
Deleted:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -1,146 +0,0 @@
-/**
- * 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.cdk.apt.processors;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.el.ELContext;
-import javax.faces.component.UIComponent;
-import javax.lang.model.element.Name;
-
-import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.Generator;
-import org.richfaces.cdk.LibraryBuilder;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.Source;
-import org.richfaces.cdk.SourceFileManagerImpl;
-import org.richfaces.cdk.SourceImpl;
-import org.richfaces.cdk.Sources;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.model.ComponentModel;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Binder;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-
-/**
- * @author akolonitsky
- * @since Jan 14, 2010
- */
-public abstract class AnnotationProcessorTest extends CdkTestBase {
-
- protected static final class TestName implements Name {
-
- private final String name;
-
- public TestName(String name) {
- this.name = name;
- }
-
- @Override
- public char charAt(int index) {
- return name.charAt(index);
- }
-
- @Override
- public boolean contentEquals(CharSequence cs) {
- // TODO Auto-generated method stub
- return name.equals(cs);
- }
-
- @Override
- public int length() {
- return name.length();
- }
-
- @Override
- public CharSequence subSequence(int start, int end) {
- return name.substring(start, end);
- }
-
- @Override
- public String toString() {
- return name;
- }
- }
-
- protected static final String FOO_BAR = "foo.Bar";
-
- @Inject
- protected Logger log;
-
- @Inject
- @Source(Sources.JAVA_SOURCES)
- protected FileManager sources;
-
- @Inject
- private Injector injector;
-
- @Override
- public void configure(Binder binder) {
- super.configure(binder);
- try {
- CdkClassLoader cdkClassLoader = createClassLoader();
- binder.bind(CdkClassLoader.class).toInstance(cdkClassLoader);
- List<File> sourceFiles = new ArrayList<File>();
- for (String src : sources()) {
- sourceFiles.add(getJavaFile(src));
- }
- binder.bind(FileManager.class).annotatedWith(new
SourceImpl(Sources.JAVA_SOURCES)).toInstance(
- new SourceFileManagerImpl(sourceFiles, this.testSourceDirectory));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- }
-
- @Override
- protected CdkClassLoader createClassLoader() {
- try {
- return new
CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
- getLibraryFile(ComponentModel.class), getLibraryFile(ELContext.class),
- getLibraryFile(JsfComponent.class), getLibraryFile(UIComponent.class)),
this.getClass()
- .getClassLoader());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- protected void process(String javaFilePath) throws Exception {
- Generator generator = new Generator();
- generator.setLoader(createClassLoader());
- generator.addSources(Sources.JAVA_SOURCES,
ImmutableList.of(getJavaFile(javaFilePath)), null);
-
- generator.init();
- injector.injectMembers(new ComponentProcessor());
-
- LibraryBuilder builder = injector.getInstance(LibraryBuilder.class);
- builder.build();
- }
-
- protected abstract Iterable<String> sources();
-}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -36,8 +36,8 @@
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.Mock;
-import org.richfaces.cdk.MockController;
import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
@@ -58,7 +58,7 @@
*
*/
@RunWith(CdkTestRunner.class)
-public class AttributesProcessorTest extends AnnotationProcessorTest {
+public class AttributesProcessorTest extends AnnotationProcessorTestBase {
private static final String FOO = "foo";
@@ -68,9 +68,6 @@
private DescriptionProcessor descriptionProcessor;
@Inject
- private MockController mockController;
-
- @Inject
private AttributesProcessorImpl processor;
@Mock
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -43,6 +43,7 @@
import org.richfaces.cdk.annotations.Description;
import org.richfaces.cdk.annotations.JsfBehavior;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
@@ -58,7 +59,7 @@
* @since Jan 21, 2010
*/
@RunWith(CdkTestRunner.class)
-public class BehaviorProcessorTest extends AnnotationProcessorTest {
+public class BehaviorProcessorTest extends AnnotationProcessorTestBase {
private static final String BEHAVIOR_CLASS_JAVA =
"org/richfaces/cdk/test/component/MyBehavior.java";
private static final String MY_BEHAVIOR = "my_behavior";
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -43,6 +43,7 @@
import org.richfaces.cdk.annotations.Description;
import org.richfaces.cdk.annotations.Facet;
import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -62,7 +63,7 @@
*
*/
@RunWith(CdkTestRunner.class)
-public class ComponentProcessorTest extends AnnotationProcessorTest {
+public class ComponentProcessorTest extends AnnotationProcessorTestBase {
public static final String LARGE_GIF = "/icons/Large.gif";
public static final String SMALL_JPG = "/icons/Small.jpg";
private static final String COMPONENT_CLASS_JAVA =
"org/richfaces/cdk/test/component/AbstractTestComponent.java";
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -30,6 +30,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
@@ -42,7 +43,7 @@
* @since Jan 14, 2010
*/
@RunWith(CdkTestRunner.class)
-public class ConverterProcessorTest extends AnnotationProcessorTest {
+public class ConverterProcessorTest extends AnnotationProcessorTestBase {
private static final String COMPONENT_CLASS_JAVA =
"org/richfaces/cdk/test/component/MyConverter.java";
@Inject
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -31,8 +31,8 @@
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.Mock;
-import org.richfaces.cdk.MockController;
import org.richfaces.cdk.annotations.Description;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.model.DescriptionGroup;
import com.google.inject.Inject;
@@ -45,7 +45,7 @@
*
*/
@RunWith(CdkTestRunner.class)
-public class DescriptionProcessorTest extends AnnotationProcessorTest {
+public class DescriptionProcessorTest extends AnnotationProcessorTestBase {
private static final String FOO_BAR_ELEMENT = "Foo bar element";
@@ -60,9 +60,6 @@
@Inject
private DescriptionProcessorImpl descriptionProcessor;
- @Inject
- private MockController mockController;
-
/**
* Test method for
* {@link
org.richfaces.cdk.apt.processors.DescriptionProcessorImpl#processDescription(org.richfaces.cdk.model.DescriptionGroup,
org.richfaces.cdk.annotations.Description, java.lang.String)}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java 2010-07-28
23:36:46 UTC (rev 18270)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -39,6 +39,7 @@
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.annotations.JsfValidator;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.ValidatorModel;
@@ -50,7 +51,7 @@
* @since Jan 14, 2010
*/
@RunWith(CdkTestRunner.class)
-public class ValidatorProcessorTest extends AnnotationProcessorTest {
+public class ValidatorProcessorTest extends AnnotationProcessorTestBase {
private static class MyName implements Name {
private final String toString;
Added:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -0,0 +1,34 @@
+/*
+ * $Id$
+ *
+ * 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.cdk.apt;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@TestAnnotation("foo")
+public class AnnotationsTestClass {}
Added:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestSubClass.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestSubClass.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestSubClass.java 2010-07-28
23:37:11 UTC (rev 18271)
@@ -0,0 +1,54 @@
+/*
+ * $Id$
+ *
+ * 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.cdk.apt;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@TestAnnotation2("subclass")
+public class AnnotationsTestSubClass extends TestClass implements TestInterface {
+
+ 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>
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+}