You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by li...@apache.org on 2012/01/18 00:19:58 UTC
[8/14] git commit: Revert "[DELTASPIKE-46] Adding tests for
AnnotatedTypeBuilder"
Revert "[DELTASPIKE-46] Adding tests for AnnotatedTypeBuilder"
This reverts commit c7a5550121b0de0597fb41f7c6b8311b3c7aac7b.
Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/d5d730a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/d5d730a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/d5d730a3
Branch: refs/heads/master
Commit: d5d730a3c7557800dc2e1c82231a1cd9c0930468
Parents: d908fa2
Author: Jason Porter <li...@apache.org>
Authored: Tue Jan 17 16:13:13 2012 -0700
Committer: Jason Porter <li...@apache.org>
Committed: Tue Jan 17 16:13:13 2012 -0700
----------------------------------------------------------------------
.../core/api/literal/AlternativeLiteral.java | 31 -----
.../core/api/literal/ApplicationScopedLiteral.java | 31 -----
.../deltaspike/core/api/literal/ModelLiteral.java | 31 -----
.../deltaspike/core/api/literal/TypedLiteral.java | 46 -------
.../api/metadata/AnnotatedTypeBuilderTest.java | 106 ---------------
.../apache/deltaspike/test/api/metadata/Cat.java | 67 ---------
.../api/metadata/NamedAnnotationRedefiner.java | 51 -------
7 files changed, 0 insertions(+), 363 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/d5d730a3/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/AlternativeLiteral.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/AlternativeLiteral.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/AlternativeLiteral.java
deleted file mode 100644
index 3e29100..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/AlternativeLiteral.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.deltaspike.core.api.literal;
-
-import javax.enterprise.inject.Alternative;
-import javax.enterprise.util.AnnotationLiteral;
-
-/**
- * Literal for {@link javax.enterprise.inject.Alternative}.
- */
-public class AlternativeLiteral extends AnnotationLiteral<Alternative> implements Alternative
-{
- private static final long serialVersionUID = -4865048799125718216L;
-}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/d5d730a3/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/ApplicationScopedLiteral.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/ApplicationScopedLiteral.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/ApplicationScopedLiteral.java
deleted file mode 100644
index cd6e99d..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/ApplicationScopedLiteral.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.deltaspike.core.api.literal;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.util.AnnotationLiteral;
-
-/**
- * Literal for {@link ApplicationScoped}
- */
-public class ApplicationScopedLiteral extends AnnotationLiteral<ApplicationScoped> implements ApplicationScoped
-{
- private static final long serialVersionUID = 6582580975876369665L;
-}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/d5d730a3/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/ModelLiteral.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/ModelLiteral.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/ModelLiteral.java
deleted file mode 100644
index b9eb07e..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/ModelLiteral.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.deltaspike.core.api.literal;
-
-import javax.enterprise.inject.Model;
-import javax.enterprise.util.AnnotationLiteral;
-
-/**
- * Literal for {@link javax.enterprise.inject.Model} annotation.
- */
-public class ModelLiteral extends AnnotationLiteral<Model> implements Model
-{
- private static final long serialVersionUID = -1828119201454843678L;
-}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/d5d730a3/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/TypedLiteral.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/TypedLiteral.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/TypedLiteral.java
deleted file mode 100644
index 990354e..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/TypedLiteral.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.deltaspike.core.api.literal;
-
-import javax.enterprise.inject.Typed;
-import javax.enterprise.util.AnnotationLiteral;
-
-/**
- *
- */
-public class TypedLiteral extends AnnotationLiteral<Typed> implements Typed
-{
- final private Class<?>[] value;
-
- public TypedLiteral()
- {
- value = new Class<?>[0];
- }
-
- public TypedLiteral(Class<?>[] value)
- {
- this.value = value;
- }
-
- @Override public Class<?>[] value()
- {
- return value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/d5d730a3/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/AnnotatedTypeBuilderTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/AnnotatedTypeBuilderTest.java b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/AnnotatedTypeBuilderTest.java
deleted file mode 100644
index 5bf2949..0000000
--- a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/AnnotatedTypeBuilderTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.deltaspike.test.api.metadata;
-
-import org.apache.deltaspike.core.api.literal.AnyLiteral;
-import org.apache.deltaspike.core.api.literal.TypedLiteral;
-import org.apache.deltaspike.core.api.metadata.builder.AnnotatedTypeBuilder;
-import org.junit.Test;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Alternative;
-import javax.enterprise.inject.Default;
-import javax.enterprise.inject.Typed;
-import javax.enterprise.inject.spi.AnnotatedConstructor;
-import javax.enterprise.inject.spi.AnnotatedParameter;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.inject.Named;
-import java.util.List;
-import java.util.Set;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-public class AnnotatedTypeBuilderTest
-{
-
- @Test
- public void testTypeLevelAnnotationRedefinition()
- {
- AnnotatedTypeBuilder<Cat> builder = new AnnotatedTypeBuilder<Cat>();
- builder.readFromType(Cat.class);
- builder.redefine(Named.class, new NamedAnnotationRedefiner());
-
- final AnnotatedType<Cat> cat = builder.create();
- assertEquals(3, cat.getAnnotations().size());
- assertTrue(cat.isAnnotationPresent(Named.class));
- assertTrue(cat.isAnnotationPresent(Alternative.class));
- assertTrue(cat.isAnnotationPresent(ApplicationScoped.class));
- assertEquals("tomcat", cat.getAnnotation(Named.class).value());
-
- builder = new AnnotatedTypeBuilder<Cat>();
- builder.readFromType(cat);
- builder.removeFromAll(Named.class);
-
- final AnnotatedType<Cat> noNameCat = builder.create();
- assertFalse(noNameCat.isAnnotationPresent(Named.class));
- assertEquals(2, noNameCat.getAnnotations().size());
- }
-
- @Test
- public void testAdditionOfAnnotation()
- {
- final AnnotatedTypeBuilder<Cat> builder = new AnnotatedTypeBuilder<Cat>();
- builder.readFromType(Cat.class, true);
- builder.addToClass(new TypedLiteral());
-
- final AnnotatedType<Cat> catAnnotatedType = builder.create();
- assertThat(catAnnotatedType.isAnnotationPresent(Typed.class), is(true));
- }
-
- @Test
- public void modifyAnnotationsOnConstructorParameter() throws NoSuchMethodException
- {
- final AnnotatedTypeBuilder<Cat> builder = new AnnotatedTypeBuilder<Cat>();
- builder.readFromType(Cat.class, true);
- builder.removeFromConstructorParameter(Cat.class.getConstructor(String.class, String.class), 1, Default.class);
- builder.addToConstructorParameter(Cat.class.getConstructor(String.class, String.class), 1, new AnyLiteral());
-
- final AnnotatedType<Cat> catAnnotatedType = builder.create();
- Set<AnnotatedConstructor<Cat>> catCtors = catAnnotatedType.getConstructors();
-
- assertThat(catCtors.size(), is(2));
-
- for (AnnotatedConstructor<Cat> ctor : catCtors)
- {
- if (ctor.getParameters().size() == 2)
- {
- List<AnnotatedParameter<Cat>> ctorParams = ctor.getParameters();
-
- assertThat(ctorParams.get(1).getAnnotations().size(), is(1));
- assertThat((AnyLiteral) ctorParams.get(1).getAnnotations().toArray()[0], is(new AnyLiteral()));
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/d5d730a3/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/Cat.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/Cat.java b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/Cat.java
deleted file mode 100644
index 4a21cff..0000000
--- a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/Cat.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.deltaspike.test.api.metadata;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-@Named("cat")
-public class Cat
-{
- private String color;
- private String gender;
-
- public Cat()
- {
- }
-
- @Inject
- public Cat(String color, String gender)
- {
- this.color = color;
- this.gender = gender;
- }
-
- @PostConstruct
- public void setup()
- {
- }
-
- public String getColor()
- {
- return color;
- }
-
- public void setColor(String color)
- {
- this.color = color;
- }
-
- public String getGender()
- {
- return gender;
- }
-
- public void setGender(String gender)
- {
- this.gender = gender;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/d5d730a3/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/NamedAnnotationRedefiner.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/NamedAnnotationRedefiner.java b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/NamedAnnotationRedefiner.java
deleted file mode 100644
index ddf9003..0000000
--- a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/NamedAnnotationRedefiner.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.deltaspike.test.api.metadata;
-
-import org.apache.deltaspike.core.api.literal.AlternativeLiteral;
-import org.apache.deltaspike.core.api.literal.ApplicationScopedLiteral;
-import org.apache.deltaspike.core.api.metadata.AnnotationRedefiner;
-import org.apache.deltaspike.core.api.metadata.RedefinitionContext;
-import org.apache.deltaspike.core.api.metadata.builder.AnnotationBuilder;
-import org.apache.webbeans.annotation.NamedLiteral;
-
-import javax.inject.Named;
-
-/**
- *
- */
-public class NamedAnnotationRedefiner implements AnnotationRedefiner<Named>
-{
- @Override
- public void redefine(RedefinitionContext<Named> ctx)
- {
- Named named = ctx.getAnnotatedElement().getAnnotation(Named.class);
- if ("cat".equals(named.value()))
- {
- AnnotationBuilder builder = ctx.getAnnotationBuilder();
- // add two annotations
- builder.add(new AlternativeLiteral());
- builder.add(new ApplicationScopedLiteral());
- // change the value of @Named
- builder.remove(Named.class);
- builder.add(new NamedLiteral("tomcat"));
- }
- }
-}