Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-10-19 22:55:02 +0000
committerRoberto E. Escobar2012-10-19 22:56:14 +0000
commita32311fc44430fb21bebd794086d8606c312c951 (patch)
treee78042bbb8e597ce9f6695770945388f37695a3b /plugins/org.eclipse.osee.framework.jdk.core.test
parentaafe7f0fe15d13e2e79391c1e5866f1a92c75342 (diff)
downloadorg.eclipse.osee-a32311fc44430fb21bebd794086d8606c312c951.tar.gz
org.eclipse.osee-a32311fc44430fb21bebd794086d8606c312c951.tar.xz
org.eclipse.osee-a32311fc44430fb21bebd794086d8606c312c951.zip
feature: Create AnnotationProcessor
Diffstat (limited to 'plugins/org.eclipse.osee.framework.jdk.core.test')
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/rules/JdkCoreRuleTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/JdkCoreUtilTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/Annotation1.java22
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/Annotation2.java22
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/AnnotationProcessorTest.java87
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/AnnotationTestSuite.java23
6 files changed, 156 insertions, 2 deletions
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/rules/JdkCoreRuleTestSuite.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/rules/JdkCoreRuleTestSuite.java
index 7714c48a486..5f3f4f698d3 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/rules/JdkCoreRuleTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/rules/JdkCoreRuleTestSuite.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.framework.jdk.core.rules;
-import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
-import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/JdkCoreUtilTestSuite.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/JdkCoreUtilTestSuite.java
index 9d02d53f0af..0c30753d021 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/JdkCoreUtilTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/JdkCoreUtilTestSuite.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.framework.jdk.core.util;
+import org.eclipse.osee.framework.jdk.core.util.annotation.AnnotationTestSuite;
import org.eclipse.osee.framework.jdk.core.util.io.IoTestSuite;
import org.eclipse.osee.framework.jdk.core.util.xml.XmlTestSuite;
import org.junit.runner.RunWith;
@@ -20,6 +21,7 @@ import org.junit.runners.Suite;
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
+ AnnotationTestSuite.class,
DateIteratorTest.class,
IoTestSuite.class,
XmlTestSuite.class,
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/Annotation1.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/Annotation1.java
new file mode 100644
index 00000000000..3d21caf97ca
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/Annotation1.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.jdk.core.util.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Annotation1 {
+ //
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/Annotation2.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/Annotation2.java
new file mode 100644
index 00000000000..bdcffd16c1f
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/Annotation2.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.jdk.core.util.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Annotation2 {
+ //
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/AnnotationProcessorTest.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/AnnotationProcessorTest.java
new file mode 100644
index 00000000000..9341e6a51ac
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/AnnotationProcessorTest.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.jdk.core.util.annotation;
+
+import static org.junit.Assert.assertEquals;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link AnnotationProcessor}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AnnotationProcessorTest {
+
+ private Map<Class<? extends Annotation>, FieldAnnotationHandler<?>> annotationHandlers;
+ private AnnotationProcessor processor;
+
+ @Before
+ public void setup() {
+ annotationHandlers = new HashMap<Class<? extends Annotation>, FieldAnnotationHandler<?>>();
+
+ annotationHandlers.put(Annotation1.class, new Handler1());
+ annotationHandlers.put(Annotation2.class, new Handler2());
+
+ processor = new AnnotationProcessor(annotationHandlers);
+ }
+
+ @Test
+ public void testFieldInjection() throws Exception {
+ Child child = new Child();
+ processor.initAnnotations(child);
+
+ assertEquals("Handler1", child.getField1());
+ assertEquals("Handler2", child.getField2());
+ }
+
+ private class Base {
+
+ @Annotation2
+ private String field2;
+
+ public String getField2() {
+ return field2;
+ }
+ };
+
+ private class Child extends Base {
+
+ @Annotation1
+ private String field1;
+
+ public String getField1() {
+ return field1;
+ }
+ }
+
+ private class Handler1 extends AbstractFieldAnnotationHandler<Annotation1> {
+
+ @Override
+ public void handleAnnotation(Annotation1 annotation, Object object, Field field) throws Exception {
+ injectToFields(annotation, object, field, "Handler1");
+ }
+ }
+
+ private class Handler2 extends AbstractFieldAnnotationHandler<Annotation2> {
+
+ @Override
+ public void handleAnnotation(Annotation2 annotation, Object object, Field field) throws Exception {
+ injectToFields(annotation, object, field, "Handler2");
+ }
+
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/AnnotationTestSuite.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/AnnotationTestSuite.java
new file mode 100644
index 00000000000..642db8c879c
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/annotation/AnnotationTestSuite.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.jdk.core.util.annotation;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({})
+public class AnnotationTestSuite {
+ // Test Suite
+}

Back to the top