From 594327bf71d2cd681085ea6894bab057ffa52bf8 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Thu, 18 Aug 2011 10:48:23 +1000 Subject: [PATCH 01/16] SOLDER-112 Fix disposal methods on default beans --- .../seam/solder/reflection/Reflections.java | 526 +++++++++++++++++- .../jboss/seam/solder/reflection/Types.java | 100 ++++ .../defaultbean/DefaultBeanExtension.java | 82 ++- .../test/defaultbean/HardDriveFactory.java | 10 +- 4 files changed, 690 insertions(+), 28 deletions(-) create mode 100644 api/src/main/java/org/jboss/seam/solder/reflection/Types.java diff --git a/api/src/main/java/org/jboss/seam/solder/reflection/Reflections.java b/api/src/main/java/org/jboss/seam/solder/reflection/Reflections.java index bda6d619..53049bdc 100644 --- a/api/src/main/java/org/jboss/seam/solder/reflection/Reflections.java +++ b/api/src/main/java/org/jboss/seam/solder/reflection/Reflections.java @@ -16,27 +16,35 @@ */ package org.jboss.seam.solder.reflection; +import javax.enterprise.inject.spi.Annotated; +import javax.enterprise.inject.spi.AnnotatedField; +import javax.enterprise.inject.spi.AnnotatedType; +import javax.enterprise.inject.spi.BeanManager; +import javax.inject.Qualifier; +import java.beans.Introspector; import java.io.Serializable; import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Member; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.lang.reflect.WildcardType; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; -import javax.enterprise.inject.spi.Annotated; -import javax.enterprise.inject.spi.AnnotatedField; -import javax.enterprise.inject.spi.AnnotatedType; -import javax.enterprise.inject.spi.BeanManager; - /** * Utility class for working with JDK Reflection and also CDI's * {@link Annotated} metadata. @@ -58,6 +66,10 @@ public class Reflections { */ public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0]; + public static final Type[] EMPTY_TYPES = {}; + + public static final Class[] EMPTY_CLASSES = new Class[0]; + /** *

* Perform a runtime cast. Similar to {@link Class#cast(Object)}, but useful @@ -622,6 +634,510 @@ public static boolean isSerializable(Class clazz) { return clazz.isPrimitive() || Serializable.class.isAssignableFrom(clazz); } + + public static Map, Type> buildTypeMap(Set types) { + Map, Type> map = new HashMap, Type>(); + for (Type type : types) { + if (type instanceof Class) { + map.put((Class) type, type); + } else if (type instanceof ParameterizedType) { + if (((ParameterizedType) type).getRawType() instanceof Class) { + map.put((Class) ((ParameterizedType) type).getRawType(), type); + } + } else if (type instanceof TypeVariable) { + + } + } + return map; + } + + public static boolean isCacheable(Set annotations) { + for (Annotation qualifier : annotations) { + Class clazz = qualifier.getClass(); + if (clazz.isAnonymousClass() || (clazz.isMemberClass() && isStatic(clazz))) { + return false; + } + } + return true; + } + + public static boolean isCacheable(Annotation[] annotations) { + for (Annotation qualifier : annotations) { + Class clazz = qualifier.getClass(); + if (clazz.isAnonymousClass() || (clazz.isMemberClass() && isStatic(clazz))) { + return false; + } + } + return true; + } + + /** + * Gets the property name from a getter method. + *

+ * We extend JavaBean conventions, allowing the getter method to have parameters + * + * @param method The getter method + * @return The name of the property. Returns null if method wasn't JavaBean + * getter-styled + */ + public static String getPropertyName(Method method) { + String methodName = method.getName(); + if (methodName.matches("^(get).*")) { + return Introspector.decapitalize(methodName.substring(3)); + } else if (methodName.matches("^(is).*")) { + return Introspector.decapitalize(methodName.substring(2)); + } else { + return null; + } + + } + + /** + * Checks if class is final + * + * @param clazz The class to check + * @return True if final, false otherwise + */ + public static boolean isFinal(Class clazz) { + return Modifier.isFinal(clazz.getModifiers()); + } + + public static int getNesting(Class clazz) { + if (clazz.isMemberClass() && !isStatic(clazz)) { + return 1 + getNesting(clazz.getDeclaringClass()); + } else { + return 0; + } + } + + /** + * Checks if member is final + * + * @param member The member to check + * @return True if final, false otherwise + */ + public static boolean isFinal(Member member) { + return Modifier.isFinal(member.getModifiers()); + } + + /** + * Checks if member is private + * + * @param member The member to check + * @return True if final, false otherwise + */ + public static boolean isPrivate(Member member) { + return Modifier.isPrivate(member.getModifiers()); + } + + /** + * Checks if type or member is final + * + * @param type Type or member + * @return True if final, false otherwise + */ + public static boolean isTypeOrAnyMethodFinal(Class type) { + return getNonPrivateFinalMethodOrType(type) != null; + } + + public static Object getNonPrivateFinalMethodOrType(Class type) { + if (isFinal(type)) { + return type; + } + for (Method method : type.getDeclaredMethods()) { + if (isFinal(method) && !isPrivate(method)) { + return method; + } + } + return null; + } + + public static boolean isPackagePrivate(int mod) { + return !(Modifier.isPrivate(mod) || Modifier.isProtected(mod) || Modifier.isPublic(mod)); + } + + /** + * Checks if type is static + * + * @param type Type to check + * @return True if static, false otherwise + */ + public static boolean isStatic(Class type) { + return Modifier.isStatic(type.getModifiers()); + } + + /** + * Checks if member is static + * + * @param member Member to check + * @return True if static, false otherwise + */ + public static boolean isStatic(Member member) { + return Modifier.isStatic(member.getModifiers()); + } + + public static boolean isTransient(Member member) { + return Modifier.isTransient(member.getModifiers()); + } + + /** + * Checks if a method is abstract + * + * @param method + * @return + */ + public static boolean isAbstract(Method method) { + return Modifier.isAbstract(method.getModifiers()); + } + + /** + * Gets the actual type arguments of a class + * + * @param clazz The class to examine + * @return The type arguments + */ + public static Type[] getActualTypeArguments(Class clazz) { + Type type = new HierarchyDiscovery(clazz).getResolvedType(); + if (type instanceof ParameterizedType) { + return ((ParameterizedType) type).getActualTypeArguments(); + } else { + return EMPTY_TYPES; + } + } + + /** + * Gets the actual type arguments of a Type + * + * @param type The type to examine + * @return The type arguments + */ + public static Type[] getActualTypeArguments(Type type) { + Type resolvedType = new HierarchyDiscovery(type).getResolvedType(); + if (resolvedType instanceof ParameterizedType) { + return ((ParameterizedType) resolvedType).getActualTypeArguments(); + } else { + return EMPTY_TYPES; + } + } + + /** + * Checks if raw type is array type + * + * @param rawType The raw type to check + * @return True if array, false otherwise + */ + public static boolean isArrayType(Class rawType) { + return rawType.isArray(); + } + + /** + * Checks if type is parameterized type + * + * @param type The type to check + * @return True if parameterized, false otherwise + */ + public static boolean isParameterizedType(Class type) { + return type.getTypeParameters().length > 0; + } + + public static boolean isParamerterizedTypeWithWildcard(Class type) { + if (isParameterizedType(type)) { + return containsWildcards(type.getTypeParameters()); + } else { + return false; + } + } + + public static boolean containsWildcards(Type[] types) { + for (Type type : types) { + if (type instanceof WildcardType) { + return true; + } + } + return false; + } + + /** + * Checks the bindingType to make sure the annotation was declared properly + * as a binding type (annotated with @BindingType) and that it has a runtime + * retention policy. + * + * @param binding The binding type to check + * @return true only if the annotation is really a binding type + */ + @Deprecated + // TODO Replace usage of this with metadatacache + public static boolean isBindings(Annotation binding) { + boolean isBindingAnnotation = false; + if (binding.annotationType().isAnnotationPresent(Qualifier.class) && binding.annotationType().isAnnotationPresent(Retention.class) && binding.annotationType().getAnnotation(Retention.class).value().equals(RetentionPolicy.RUNTIME)) { + isBindingAnnotation = true; + } + return isBindingAnnotation; + } + + /** + * Check the assignability of one type to another, taking into account the + * actual type arguements + * + * @param rawType1 the raw type of the class to check + * @param actualTypeArguments1 the actual type arguements to check, or an + * empty array if not a parameterized type + * @param rawType2 the raw type of the class to check + * @param actualTypeArguments2 the actual type arguements to check, or an + * empty array if not a parameterized type + * @return + */ + public static boolean isAssignableFrom(Class rawType1, Type[] actualTypeArguments1, Class rawType2, Type[] actualTypeArguments2) { + return Types.boxedClass(rawType1).isAssignableFrom(Types.boxedClass(rawType2)) && isAssignableFrom(actualTypeArguments1, actualTypeArguments2); + } + + public static boolean matches(Class rawType1, Type[] actualTypeArguments1, Class rawType2, Type[] actualTypeArguments2) { + return Types.boxedClass(rawType1).equals(Types.boxedClass(rawType2)) && isAssignableFrom(actualTypeArguments1, actualTypeArguments2); + } + + public static boolean isAssignableFrom(Type[] actualTypeArguments1, Type[] actualTypeArguments2) { + for (int i = 0; i < actualTypeArguments1.length; i++) { + Type type1 = actualTypeArguments1[i]; + Type type2 = Object.class; + if (actualTypeArguments2.length > i) { + type2 = actualTypeArguments2[i]; + } + if (!isAssignableFrom(type1, type2)) { + return false; + } + } + return true; + } + + public static boolean isAssignableFrom(Type type1, Set types2) { + for (Type type2 : types2) { + if (isAssignableFrom(type1, type2)) { + return true; + } + } + return false; + } + + public static boolean matches(Type type1, Set types2) { + for (Type type2 : types2) { + if (matches(type1, type2)) { + return true; + } + } + return false; + } + + public static boolean isAssignableFrom(Type type1, Type[] types2) { + for (Type type2 : types2) { + if (isAssignableFrom(type1, type2)) { + return true; + } + } + return false; + } + + public static boolean isAssignableFrom(Type type1, Type type2) { + if (type1 instanceof Class) { + Class clazz = (Class) type1; + if (isAssignableFrom(clazz, EMPTY_TYPES, type2)) { + return true; + } + } + if (type1 instanceof ParameterizedType) { + ParameterizedType parameterizedType1 = (ParameterizedType) type1; + if (parameterizedType1.getRawType() instanceof Class) { + if (isAssignableFrom((Class) parameterizedType1.getRawType(), parameterizedType1.getActualTypeArguments(), type2)) { + return true; + } + } + } + if (type1 instanceof WildcardType) { + WildcardType wildcardType = (WildcardType) type1; + if (isTypeBounded(type2, wildcardType.getLowerBounds(), wildcardType.getUpperBounds())) { + return true; + } + } + if (type2 instanceof WildcardType) { + WildcardType wildcardType = (WildcardType) type2; + if (isTypeBounded(type1, wildcardType.getUpperBounds(), wildcardType.getLowerBounds())) { + return true; + } + } + if (type1 instanceof TypeVariable) { + TypeVariable typeVariable = (TypeVariable) type1; + if (isTypeBounded(type2, EMPTY_TYPES, typeVariable.getBounds())) { + return true; + } + } + if (type2 instanceof TypeVariable) { + TypeVariable typeVariable = (TypeVariable) type2; + if (isTypeBounded(type1, typeVariable.getBounds(), EMPTY_TYPES)) { + return true; + } + } + return false; + } + + public static boolean matches(Type type1, Type type2) { + if (type1 instanceof Class) { + Class clazz = (Class) type1; + if (matches(clazz, EMPTY_TYPES, type2)) { + return true; + } + } + if (type1 instanceof ParameterizedType) { + ParameterizedType parameterizedType1 = (ParameterizedType) type1; + if (parameterizedType1.getRawType() instanceof Class) { + if (matches((Class) parameterizedType1.getRawType(), parameterizedType1.getActualTypeArguments(), type2)) { + return true; + } + } + } + if (type1 instanceof WildcardType) { + WildcardType wildcardType = (WildcardType) type1; + if (isTypeBounded(type2, wildcardType.getLowerBounds(), wildcardType.getUpperBounds())) { + return true; + } + } + if (type2 instanceof WildcardType) { + WildcardType wildcardType = (WildcardType) type2; + if (isTypeBounded(type1, wildcardType.getUpperBounds(), wildcardType.getLowerBounds())) { + return true; + } + } + if (type1 instanceof TypeVariable) { + TypeVariable typeVariable = (TypeVariable) type1; + if (isTypeBounded(type2, EMPTY_TYPES, typeVariable.getBounds())) { + return true; + } + } + if (type2 instanceof TypeVariable) { + TypeVariable typeVariable = (TypeVariable) type2; + if (isTypeBounded(type1, typeVariable.getBounds(), EMPTY_TYPES)) { + return true; + } + } + return false; + } + + public static boolean isTypeBounded(Type type, Type[] lowerBounds, Type[] upperBounds) { + if (lowerBounds.length > 0) { + if (!isAssignableFrom(type, lowerBounds)) { + return false; + } + } + if (upperBounds.length > 0) { + if (!isAssignableFrom(upperBounds, type)) { + return false; + } + } + return true; + } + + public static boolean isAssignableFrom(Class rawType1, Type[] actualTypeArguments1, Type type2) { + if (type2 instanceof ParameterizedType) { + ParameterizedType parameterizedType = (ParameterizedType) type2; + if (parameterizedType.getRawType() instanceof Class) { + if (isAssignableFrom(rawType1, actualTypeArguments1, (Class) parameterizedType.getRawType(), parameterizedType.getActualTypeArguments())) { + return true; + } + } + } else if (type2 instanceof Class) { + Class clazz = (Class) type2; + if (isAssignableFrom(rawType1, actualTypeArguments1, clazz, EMPTY_TYPES)) { + return true; + } + } else if (type2 instanceof TypeVariable) { + TypeVariable typeVariable = (TypeVariable) type2; + if (isTypeBounded(rawType1, actualTypeArguments1, typeVariable.getBounds())) { + return true; + } + } + return false; + } + + public static boolean matches(Class rawType1, Type[] actualTypeArguments1, Type type2) { + if (type2 instanceof ParameterizedType) { + ParameterizedType parameterizedType = (ParameterizedType) type2; + if (parameterizedType.getRawType() instanceof Class) { + if (matches(rawType1, actualTypeArguments1, (Class) parameterizedType.getRawType(), parameterizedType.getActualTypeArguments())) { + return true; + } + } + } else if (type2 instanceof Class) { + Class clazz = (Class) type2; + if (matches(rawType1, actualTypeArguments1, clazz, EMPTY_TYPES)) { + return true; + } + } + return false; + } + + /** + * Check the assiginability of a set of flattened types. This + * algorithm will check whether any of the types1 matches a type in types2 + * + * @param types1 + * @param types2 + * @return + */ + public static boolean isAssignableFrom(Set types1, Set types2) { + for (Type type : types1) { + if (isAssignableFrom(type, types2)) { + return true; + } + } + return false; + } + + /** + * Check whether whether any of the types1 matches a type in types2 + * + * @param types1 + * @param types2 + * @return + */ + public static boolean matches(Set types1, Set types2) { + for (Type type : types1) { + if (matches(type, types2)) { + return true; + } + } + return false; + } + + /** + * Check the assiginability of a set of flattened types. This + * algorithm will check whether any of the types1 matches a type in types2 + * + * @param types1 + * @param type2 + * @return + */ + public static boolean isAssignableFrom(Set types1, Type type2) { + for (Type type : types1) { + if (isAssignableFrom(type, type2)) { + return true; + } + } + return false; + } + + public static boolean isAssignableFrom(Type[] types1, Type type2) { + for (Type type : types1) { + if (isAssignableFrom(type, type2)) { + return true; + } + } + return false; + } + + public static boolean isPrimitive(Type type) { + Class rawType = getRawType(type); + return rawType == null ? false : rawType.isPrimitive(); + } + + private Reflections() { } diff --git a/api/src/main/java/org/jboss/seam/solder/reflection/Types.java b/api/src/main/java/org/jboss/seam/solder/reflection/Types.java new file mode 100644 index 00000000..5c679c3f --- /dev/null +++ b/api/src/main/java/org/jboss/seam/solder/reflection/Types.java @@ -0,0 +1,100 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.seam.solder.reflection; + +import java.lang.reflect.Type; + +/** + * Utility class for Types + * + * @author Pete Muir + */ +public class Types +{ + + /** + * Gets the boxed type of a class + * + * @param type The type + * @return The boxed type + */ + public static Type boxedType(Type type) + { + if (type instanceof Class) + { + return boxedClass((Class) type); + } + else + { + return type; + } + } + + public static Class boxedClass(Class type) + { + if (!type.isPrimitive()) + { + return type; + } + else if (type.equals(Boolean.TYPE)) + { + return Boolean.class; + } + else if (type.equals(Character.TYPE)) + { + return Character.class; + } + else if (type.equals(Byte.TYPE)) + { + return Byte.class; + } + else if (type.equals(Short.TYPE)) + { + return Short.class; + } + else if (type.equals(Integer.TYPE)) + { + return Integer.class; + } + else if (type.equals(Long.TYPE)) + { + return Long.class; + } + else if (type.equals(Float.TYPE)) + { + return Float.class; + } + else if (type.equals(Double.TYPE)) + { + return Double.class; + } + else if (type.equals(Void.TYPE)) + { + return Void.class; + } + else + { + // Vagaries of if/else statement, can't be reached ;-) + return type; + } + } +} \ No newline at end of file diff --git a/impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultBeanExtension.java b/impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultBeanExtension.java index 0924cfac..9753bcdd 100644 --- a/impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultBeanExtension.java +++ b/impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultBeanExtension.java @@ -16,21 +16,18 @@ */ package org.jboss.seam.solder.bean.defaultbean; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; +import org.jboss.seam.solder.bean.Beans; +import org.jboss.seam.solder.literal.DefaultLiteral; +import org.jboss.seam.solder.logging.Logger; +import org.jboss.seam.solder.reflection.HierarchyDiscovery; +import org.jboss.seam.solder.reflection.Reflections; +import org.jboss.seam.solder.reflection.Synthetic; +import org.jboss.seam.solder.reflection.annotated.AnnotatedTypeBuilder; +import org.jboss.seam.solder.util.collections.SetMultimap; +import org.jboss.seam.solder.util.collections.Supplier; import javax.enterprise.event.Observes; +import javax.enterprise.inject.Disposes; import javax.enterprise.inject.Produces; import javax.enterprise.inject.spi.AfterBeanDiscovery; import javax.enterprise.inject.spi.AfterDeploymentValidation; @@ -47,14 +44,19 @@ import javax.enterprise.inject.spi.ProcessObserverMethod; import javax.enterprise.inject.spi.ProcessProducerField; import javax.enterprise.inject.spi.ProcessProducerMethod; - -import org.jboss.seam.solder.bean.Beans; -import org.jboss.seam.solder.literal.DefaultLiteral; -import org.jboss.seam.solder.logging.Logger; -import org.jboss.seam.solder.reflection.Synthetic; -import org.jboss.seam.solder.reflection.annotated.AnnotatedTypeBuilder; -import org.jboss.seam.solder.util.collections.SetMultimap; -import org.jboss.seam.solder.util.collections.Supplier; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; import static org.jboss.seam.solder.util.collections.Multimaps.newSetMultimap; @@ -192,6 +194,7 @@ void processAnnotatedType(@Observes ProcessAnnotatedType event, BeanManag } } } + final Set producers = new HashSet(); // now look for producer methods // if this bean is a default bean then all producers are default beans // otherwise the annotation needs to be present @@ -229,6 +232,43 @@ void processAnnotatedType(@Observes ProcessAnnotatedType event, BeanManag beanTypeInformation.put(syntheticQualifier, new DefaultBeanType(qualifiers, type)); builder.addToMethod(m, syntheticQualifier); producerToDeclaringDefaultBean.put(syntheticQualifier, new DefaultBeanQualifiers(declaringBeanSyntheticQualifier, declaringBeanQualifiers)); + producers.add(syntheticQualifier); + } + } + + //now look for disposer methods + if (!producers.isEmpty()) { + + for (AnnotatedMethod m : tp.getMethods()) { + for (AnnotatedParameter p : m.getParameters()) { + if (p.isAnnotationPresent(Disposes.class)) { + Set type = p.getTypeClosure(); + Set qualifiers = new HashSet(); + for (final Annotation annotation : p.getAnnotations()) { + if (beanManager.isQualifier(annotation.annotationType())) { + qualifiers.add(annotation); + } + } + if(qualifiers.isEmpty()) { + qualifiers.add(DefaultLiteral.INSTANCE); + } + + for (final Synthetic producer : producers) { + final DefaultBeanType beanType = beanTypeInformation.get(producer); + Set types = new HierarchyDiscovery(beanType.getType()).getTypeClosure(); + if (Reflections.matches(type, types)) { + if (beanType.getQualifiers().equals(qualifiers)) { + for (final Annotation annotation : p.getAnnotations()) { + if (beanManager.isQualifier(annotation.annotationType())) { + builder.removeFromMethodParameter(m.getJavaMember(), p.getPosition(), annotation.annotationType()); + } + } + builder.addToMethodParameter(m.getJavaMember(), p.getPosition(), producer); + } + } + } + } + } } } diff --git a/impl/src/test/java/org/jboss/seam/solder/test/defaultbean/HardDriveFactory.java b/impl/src/test/java/org/jboss/seam/solder/test/defaultbean/HardDriveFactory.java index 86ed8739..a7e00ff3 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/defaultbean/HardDriveFactory.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/defaultbean/HardDriveFactory.java @@ -16,11 +16,12 @@ */ package org.jboss.seam.solder.test.defaultbean; +import org.jboss.seam.solder.bean.defaultbean.DefaultBean; + import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Disposes; import javax.enterprise.inject.Produces; -import org.jboss.seam.solder.bean.defaultbean.DefaultBean; - /** * test that producer methods are read from the installed default bean and not * the synthetic delegate @@ -43,6 +44,11 @@ public String size() { } + public void disposeHardDrive(final @Disposes HardDrive hardDrive) { + + } + + public String getSize() { return size; } From 8385ea997a0b41fd7f78ffb407dec066e8754bdd Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sat, 20 Aug 2011 22:05:02 +1000 Subject: [PATCH 02/16] refactored logging api into org.jboss.seam.logging package, added manifest entries required for logging in as7 --- .../seam/solder/core/VersionLoggerUtil.java | 2 +- .../jboss/seam/solder/logging/Category.java | 59 - .../org/jboss/seam/solder/logging/Log.java | 46 - .../org/jboss/seam/solder/logging/Logger.java | 2125 ----------------- .../seam/solder/logging/MessageLogger.java | 43 - .../MessageLoggerInvocationHandler.java | 91 - .../org/jboss/seam/solder/logging/Suffix.java | 53 - .../seam/solder/logging/TypedCategory.java | 58 - .../seam/solder/logging/package-info.java | 106 - .../jboss/seam/solder/messages/Locale.java | 4 +- .../jboss/seam/solder/messages/Messages.java | 2 +- .../solder/util/service/ServiceLoader.java | 2 +- impl/pom.xml | 147 +- .../solder/bean/AbstractImmutableBean.java | 2 +- .../defaultbean/DefaultBeanExtension.java | 6 +- .../jboss/seam/solder/core/CoreExtension.java | 2 +- .../seam/solder/logging/LoggerProducer.java | 7 +- .../logging/TypedMessageLoggerExtension.java | 1 + .../logging/TypedMessageLoggerProducer.java | 6 +- .../ClasspathResourceLoader.java | 2 +- .../DelegatingResourceLoader.java | 2 +- .../ServiceHandlerExtension.java | 6 +- .../seam/solder/unwraps/UnwrapsExtension.java | 3 +- .../bean/defaultbean/DefaultBeanTest.java | 2 +- .../seam/solder/test/logging/BaldEagle.java | 2 +- .../seam/solder/test/logging/BirdLogger.java | 4 +- .../jboss/seam/solder/test/logging/Finch.java | 4 +- .../jboss/seam/solder/test/logging/Hawk.java | 2 +- .../seam/solder/test/logging/NonBean.java | 2 +- .../jboss/seam/solder/test/logging/Raven.java | 4 +- .../seam/solder/test/logging/Sparrow.java | 2 +- .../jboss/seam/solder/test/logging/Wren.java | 4 +- pom.xml | 2 +- .../solder/tooling/SolderAnnotations.java | 6 +- .../seam/solder/tooling/SolderLoggers.java | 2 +- 35 files changed, 129 insertions(+), 2682 deletions(-) delete mode 100644 api/src/main/java/org/jboss/seam/solder/logging/Category.java delete mode 100644 api/src/main/java/org/jboss/seam/solder/logging/Log.java delete mode 100644 api/src/main/java/org/jboss/seam/solder/logging/Logger.java delete mode 100644 api/src/main/java/org/jboss/seam/solder/logging/MessageLogger.java delete mode 100644 api/src/main/java/org/jboss/seam/solder/logging/MessageLoggerInvocationHandler.java delete mode 100644 api/src/main/java/org/jboss/seam/solder/logging/Suffix.java delete mode 100644 api/src/main/java/org/jboss/seam/solder/logging/TypedCategory.java delete mode 100644 api/src/main/java/org/jboss/seam/solder/logging/package-info.java diff --git a/api/src/main/java/org/jboss/seam/solder/core/VersionLoggerUtil.java b/api/src/main/java/org/jboss/seam/solder/core/VersionLoggerUtil.java index b9e0796c..6a331370 100644 --- a/api/src/main/java/org/jboss/seam/solder/core/VersionLoggerUtil.java +++ b/api/src/main/java/org/jboss/seam/solder/core/VersionLoggerUtil.java @@ -16,7 +16,7 @@ */ package org.jboss.seam.solder.core; -import org.jboss.seam.solder.logging.Logger; +import org.jboss.seam.logging.Logger; /** * Utility class for logging the version number of class based on package. diff --git a/api/src/main/java/org/jboss/seam/solder/logging/Category.java b/api/src/main/java/org/jboss/seam/solder/logging/Category.java deleted file mode 100644 index 7fa7e7d4..00000000 --- a/api/src/main/java/org/jboss/seam/solder/logging/Category.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * Licensed 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.jboss.seam.solder.logging; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import org.jboss.seam.solder.logging.Logger; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - *

- * Specifies a string category for the injected logger. - *

- *

- *

- * A category must be specified for a typed logger. - *

- *

- *

- * For a non-typed logger, if no category annotation is specified at a - * {@link Logger} injection point, the fully qualified name of the bean - * implementation class is used as the category. - *

- * - * @author Pete Muir - * @see MessageLogger - * @see Logger#getLogger(String) - */ -@Target({METHOD, FIELD, PARAMETER, TYPE}) -@Retention(RUNTIME) -@Documented -public @interface Category { - - /** - * The category of the logger. - */ - String value(); -} diff --git a/api/src/main/java/org/jboss/seam/solder/logging/Log.java b/api/src/main/java/org/jboss/seam/solder/logging/Log.java deleted file mode 100644 index 0bc249c0..00000000 --- a/api/src/main/java/org/jboss/seam/solder/logging/Log.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * Licensed 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.jboss.seam.solder.logging; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.jboss.seam.solder.logging.Logger; -import org.jboss.seam.solder.messages.Message; - -/** - * A typed logger method. Indicates that this method will log the associated {@link Message} to the logger system, as - * opposed to being a simple message lookup. - * - * @author David M. Lloyd - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -@Documented -public @interface Log { - - /** - * The log level at which this message should be logged. Defaults to {@code INFO}. - * - * @return the log level - */ - Logger.Level level() default Logger.Level.INFO; -} diff --git a/api/src/main/java/org/jboss/seam/solder/logging/Logger.java b/api/src/main/java/org/jboss/seam/solder/logging/Logger.java deleted file mode 100644 index ea6c02f7..00000000 --- a/api/src/main/java/org/jboss/seam/solder/logging/Logger.java +++ /dev/null @@ -1,2125 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2011, Red Hat, Inc., and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * Licensed 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.jboss.seam.solder.logging; - -import java.io.Serializable; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Proxy; -import java.util.Locale; - -/** - * A Logger implementation that forwards all calls to the {@link #delegate()}. - * - * @author Ken Finnigan - */ -public class Logger implements Serializable { - - private static final long serialVersionUID = 2699068144024070551L; - - private final org.jboss.seam.solder.logging.internal.Logger delegate; - - /** - * Levels used by this logging API. - */ - public enum Level { - FATAL, ERROR, WARN, INFO, DEBUG, TRACE, - } - - Logger(String name) { - this.delegate = org.jboss.seam.solder.logging.internal.Logger.getLogger(name); - } - - /** - * Return the name of this logger. - * - * @return The name of this logger. - */ - public String getName() { - return delegate.getName(); - } - - /** - * Check to see if the specified level is enabled for this logger. - * - * @param level the level - * @return {@code true} if messages logged at {@link Level#level} may be accepted, {@code false} otherwise - */ - public boolean isEnabled(Level level) { - return delegate.isEnabled(translate(level)); - } - - /** - * Check to see if the {@code TRACE} level is enabled for this logger. - * - * @return {@code true} if messages logged at {@link Level#TRACE} may be accepted, {@code false} otherwise - */ - public boolean isTraceEnabled() { - return delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE); - } - - /** - * Issue a log message with a level of TRACE. - * - * @param message the message - */ - public void trace(Object message) { - delegate.trace(message); - } - - /** - * Issue a log message and throwable with a level of TRACE. - * - * @param message the message - * @param t the throwable - */ - public void trace(Object message, Throwable t) { - delegate.trace(message, t); - } - - /** - * Issue a log message and throwable with a level of TRACE and a specific logger class name. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param t the throwable - */ - public void trace(String loggerFqcn, Object message, Throwable t) { - delegate.trace(loggerFqcn, message, t); - } - - /** - * Issue a log message with parameters and a throwable with a level of TRACE. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param params the message parameters - * @param t the throwable - */ - public void trace(String loggerFqcn, Object message, Object[] params, Throwable t) { - delegate.trace(loggerFqcn, message, params, t); - } - - /** - * Issue a log message with a level of TRACE using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param params the parameters - */ - public void tracev(String format, Object... params) { - delegate.tracev(format, params); - } - - /** - * Issue a log message with a level of TRACE using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the sole parameter - */ - public void tracev(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(format, param1); - } - } - - /** - * Issue a log message with a level of TRACE using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void tracev(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(format, param1, param2); - } - } - - /** - * Issue a log message with a level of TRACE using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void tracev(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(format, param1, param2, param3); - } - } - - /** - * Issue a log message with a level of TRACE using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param params the parameters - */ - public void tracev(Throwable t, String format, Object... params) { - delegate.tracev(t, format, params); - } - - /** - * Issue a log message with a level of TRACE using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the sole parameter - */ - public void tracev(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(t, format, param1); - } - } - - /** - * Issue a log message with a level of TRACE using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void tracev(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(t, format, param1, param2); - } - } - - /** - * Issue a log message with a level of TRACE using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void tracev(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(t, format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of TRACE. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param params the parameters - */ - public void tracef(String format, Object... params) { - delegate.tracev(format, params); - } - - /** - * Issue a formatted log message with a level of TRACE. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the sole parameter - */ - public void tracef(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(format, param1); - } - } - - /** - * Issue a formatted log message with a level of TRACE. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void tracef(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of TRACE. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void tracef(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of TRACE. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param params the parameters - */ - public void tracef(Throwable t, String format, Object... params) { - delegate.tracev(t, format, params); - } - - /** - * Issue a formatted log message with a level of TRACE. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the sole parameter - */ - public void tracef(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(t, format, param1); - } - } - - /** - * Issue a formatted log message with a level of TRACE. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void tracef(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(t, format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of TRACE. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void tracef(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.TRACE)) { - delegate.tracev(t, format, param1, param2, param3); - } - } - - /** - * Check to see if the {@code DEBUG} level is enabled for this logger. - * - * @return {@code true} if messages logged at {@link Level#DEBUG} may be accepted, {@code false} otherwise - */ - public boolean isDebugEnabled() { - return delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG); - } - - /** - * Issue a log message with a level of DEBUG. - * - * @param message the message - */ - public void debug(Object message) { - delegate.debug(message); - } - - /** - * Issue a log message and throwable with a level of DEBUG. - * - * @param message the message - * @param t the throwable - */ - public void debug(Object message, Throwable t) { - delegate.debug(message, t); - } - - /** - * Issue a log message and throwable with a level of DEBUG and a specific logger class name. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param t the throwable - */ - public void debug(String loggerFqcn, Object message, Throwable t) { - delegate.debug(loggerFqcn, message, t); - } - - /** - * Issue a log message with parameters and a throwable with a level of DEBUG. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param params the message parameters - * @param t the throwable - */ - public void debug(String loggerFqcn, Object message, Object[] params, Throwable t) { - delegate.debug(loggerFqcn, message, params, t); - } - - /** - * Issue a log message with a level of DEBUG using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param params the parameters - */ - public void debugv(String format, Object... params) { - delegate.debugv(format, params); - } - - /** - * Issue a log message with a level of DEBUG using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the sole parameter - */ - public void debugv(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugv(format, param1); - } - } - - /** - * Issue a log message with a level of DEBUG using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void debugv(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugv(format, param1, param2); - } - } - - /** - * Issue a log message with a level of DEBUG using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void debugv(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugv(format, param1, param2, param3); - } - } - - /** - * Issue a log message with a level of DEBUG using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param params the parameters - */ - public void debugv(Throwable t, String format, Object... params) { - delegate.debugv(t, format, params); - } - - /** - * Issue a log message with a level of DEBUG using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the sole parameter - */ - public void debugv(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugv(t, format, param1); - } - } - - /** - * Issue a log message with a level of DEBUG using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void debugv(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugv(t, format, param1, param2); - } - } - - /** - * Issue a log message with a level of DEBUG using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void debugv(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugv(t, format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of DEBUG. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param params the parameters - */ - public void debugf(String format, Object... params) { - delegate.debugf(format, params); - } - - /** - * Issue a formatted log message with a level of DEBUG. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the sole parameter - */ - public void debugf(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugf(format, param1); - } - } - - /** - * Issue a formatted log message with a level of DEBUG. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void debugf(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugf(format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of DEBUG. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void debugf(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugf(format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of DEBUG. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param params the parameters - */ - public void debugf(Throwable t, String format, Object... params) { - delegate.debugf(t, format, params); - } - - /** - * Issue a formatted log message with a level of DEBUG. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the sole parameter - */ - public void debugf(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugf(t, format, param1); - } - } - - /** - * Issue a formatted log message with a level of DEBUG. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void debugf(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugf(t, format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of DEBUG. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void debugf(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG)) { - delegate.debugf(t, format, param1, param2, param3); - } - } - - /** - * Check to see if the {@code INFO} level is enabled for this logger. - * - * @return {@code true} if messages logged at {@link Level#INFO} may be accepted, {@code false} otherwise - */ - public boolean isInfoEnabled() { - return delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO); - } - - /** - * Issue a log message with a level of INFO. - * - * @param message the message - */ - public void info(Object message) { - delegate.info(message); - } - - /** - * Issue a log message and throwable with a level of INFO. - * - * @param message the message - * @param t the throwable - */ - public void info(Object message, Throwable t) { - delegate.info(message, t); - } - - /** - * Issue a log message and throwable with a level of INFO and a specific logger class name. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param t the throwable - */ - public void info(String loggerFqcn, Object message, Throwable t) { - delegate.info(loggerFqcn, message, t); - } - - /** - * Issue a log message with parameters and a throwable with a level of INFO. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param params the message parameters - * @param t the throwable - */ - public void info(String loggerFqcn, Object message, Object[] params, Throwable t) { - delegate.info(loggerFqcn, message, params, t); - } - - /** - * Issue a log message with a level of INFO using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param params the parameters - */ - public void infov(String format, Object... params) { - delegate.infov(format, params); - } - - /** - * Issue a log message with a level of INFO using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the sole parameter - */ - public void infov(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infov(format, param1); - } - } - - /** - * Issue a log message with a level of INFO using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void infov(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infov(format, param1, param2); - } - } - - /** - * Issue a log message with a level of INFO using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void infov(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infov(format, param1, param2, param3); - } - } - - /** - * Issue a log message with a level of INFO using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param params the parameters - */ - public void infov(Throwable t, String format, Object... params) { - delegate.infov(t, format, params); - } - - /** - * Issue a log message with a level of INFO using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the sole parameter - */ - public void infov(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infov(t, format, param1); - } - } - - /** - * Issue a log message with a level of INFO using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void infov(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infov(t, format, param1, param2); - } - } - - /** - * Issue a log message with a level of INFO using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void infov(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infov(t, format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of INFO. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param params the parameters - */ - public void infof(String format, Object... params) { - delegate.infof(format, params); - } - - /** - * Issue a formatted log message with a level of INFO. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the sole parameter - */ - public void infof(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infof(format, param1); - } - } - - /** - * Issue a formatted log message with a level of INFO. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void infof(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infof(format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of INFO. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void infof(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infof(format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of INFO. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param params the parameters - */ - public void infof(Throwable t, String format, Object... params) { - delegate.infof(t, format, params); - } - - /** - * Issue a formatted log message with a level of INFO. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the sole parameter - */ - public void infof(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infof(t, format, param1); - } - } - - /** - * Issue a formatted log message with a level of INFO. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void infof(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infof(t, format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of INFO. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void infof(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.INFO)) { - delegate.infof(t, format, param1, param2, param3); - } - } - - /** - * Issue a log message with a level of WARN. - * - * @param message the message - */ - public void warn(Object message) { - delegate.warn(message); - } - - /** - * Issue a log message and throwable with a level of WARN. - * - * @param message the message - * @param t the throwable - */ - public void warn(Object message, Throwable t) { - delegate.warn(message, t); - } - - /** - * Issue a log message and throwable with a level of WARN and a specific logger class name. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param t the throwable - */ - public void warn(String loggerFqcn, Object message, Throwable t) { - delegate.warn(loggerFqcn, message, t); - } - - /** - * Issue a log message with parameters and a throwable with a level of WARN. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param params the message parameters - * @param t the throwable - */ - public void warn(String loggerFqcn, Object message, Object[] params, Throwable t) { - delegate.warn(loggerFqcn, message, params, t); - } - - /** - * Issue a log message with a level of WARN using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param params the parameters - */ - public void warnv(String format, Object... params) { - delegate.warnv(format, params); - } - - /** - * Issue a log message with a level of WARN using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the sole parameter - */ - public void warnv(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnv(format, param1); - } - } - - /** - * Issue a log message with a level of WARN using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void warnv(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnv(format, param1, param2); - } - } - - /** - * Issue a log message with a level of WARN using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void warnv(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnv(format, param1, param2, param3); - } - } - - /** - * Issue a log message with a level of WARN using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param params the parameters - */ - public void warnv(Throwable t, String format, Object... params) { - delegate.warnv(t, format, params); - } - - /** - * Issue a log message with a level of WARN using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the sole parameter - */ - public void warnv(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnv(t, format, param1); - } - } - - /** - * Issue a log message with a level of WARN using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void warnv(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnv(t, format, param1, param2); - } - } - - /** - * Issue a log message with a level of WARN using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void warnv(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnv(t, format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of WARN. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param params the parameters - */ - public void warnf(String format, Object... params) { - delegate.warnf(format, params); - } - - /** - * Issue a formatted log message with a level of WARN. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the sole parameter - */ - public void warnf(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnf(format, param1); - } - } - - /** - * Issue a formatted log message with a level of WARN. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void warnf(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnf(format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of WARN. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void warnf(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnf(format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of WARN. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param params the parameters - */ - public void warnf(Throwable t, String format, Object... params) { - delegate.warnf(t, format, params); - } - - /** - * Issue a formatted log message with a level of WARN. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the sole parameter - */ - public void warnf(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnf(t, format, param1); - } - } - - /** - * Issue a formatted log message with a level of WARN. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void warnf(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnf(t, format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of WARN. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void warnf(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.WARN)) { - delegate.warnf(t, format, param1, param2, param3); - } - } - - /** - * Issue a log message with a level of ERROR. - * - * @param message the message - */ - public void error(Object message) { - delegate.error(message); - } - - /** - * Issue a log message and throwable with a level of ERROR. - * - * @param message the message - * @param t the throwable - */ - public void error(Object message, Throwable t) { - delegate.error(message, t); - } - - /** - * Issue a log message and throwable with a level of ERROR and a specific logger class name. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param t the throwable - */ - public void error(String loggerFqcn, Object message, Throwable t) { - delegate.error(loggerFqcn, message, t); - } - - /** - * Issue a log message with parameters and a throwable with a level of ERROR. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param params the message parameters - * @param t the throwable - */ - public void error(String loggerFqcn, Object message, Object[] params, Throwable t) { - delegate.error(loggerFqcn, message, params, t); - } - - /** - * Issue a log message with a level of ERROR using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param params the parameters - */ - public void errorv(String format, Object... params) { - delegate.errorv(format, params); - } - - /** - * Issue a log message with a level of ERROR using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the sole parameter - */ - public void errorv(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorv(format, param1); - } - } - - /** - * Issue a log message with a level of ERROR using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void errorv(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorv(format, param1, param2); - } - } - - /** - * Issue a log message with a level of ERROR using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void errorv(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorv(format, param1, param2, param3); - } - } - - /** - * Issue a log message with a level of ERROR using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param params the parameters - */ - public void errorv(Throwable t, String format, Object... params) { - delegate.errorv(t, format, params); - } - - /** - * Issue a log message with a level of ERROR using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the sole parameter - */ - public void errorv(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorv(t, format, param1); - } - } - - /** - * Issue a log message with a level of ERROR using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void errorv(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorv(t, format, param1, param2); - } - } - - /** - * Issue a log message with a level of ERROR using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void errorv(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorv(t, format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of ERROR. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param params the parameters - */ - public void errorf(String format, Object... params) { - delegate.errorf(format, params); - } - - /** - * Issue a formatted log message with a level of ERROR. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the sole parameter - */ - public void errorf(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorf(format, param1); - } - } - - /** - * Issue a formatted log message with a level of ERROR. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void errorf(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorf(format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of ERROR. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void errorf(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorf(format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of ERROR. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param params the parameters - */ - public void errorf(Throwable t, String format, Object... params) { - delegate.errorf(t, format, params); - } - - /** - * Issue a formatted log message with a level of ERROR. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the sole parameter - */ - public void errorf(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorf(t, format, param1); - } - } - - /** - * Issue a formatted log message with a level of ERROR. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void errorf(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorf(t, format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of ERROR. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void errorf(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.ERROR)) { - delegate.errorf(t, format, param1, param2, param3); - } - } - - /** - * Issue a log message with a level of FATAL. - * - * @param message the message - */ - public void fatal(Object message) { - delegate.fatal(message); - } - - /** - * Issue a log message and throwable with a level of FATAL. - * - * @param message the message - * @param t the throwable - */ - public void fatal(Object message, Throwable t) { - delegate.fatal(message, t); - } - - /** - * Issue a log message and throwable with a level of FATAL and a specific logger class name. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param t the throwable - */ - public void fatal(String loggerFqcn, Object message, Throwable t) { - delegate.fatal(loggerFqcn, message, t); - } - - /** - * Issue a log message with parameters and a throwable with a level of FATAL. - * - * @param loggerFqcn the logger class name - * @param message the message - * @param params the message parameters - * @param t the throwable - */ - public void fatal(String loggerFqcn, Object message, Object[] params, Throwable t) { - delegate.fatal(loggerFqcn, message, params, t); - } - - /** - * Issue a log message with a level of FATAL using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param params the parameters - */ - public void fatalv(String format, Object... params) { - delegate.fatalv(format, params); - } - - /** - * Issue a log message with a level of FATAL using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the sole parameter - */ - public void fatalv(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalv(format, param1); - } - } - - /** - * Issue a log message with a level of FATAL using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void fatalv(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalv(format, param1, param2); - } - } - - /** - * Issue a log message with a level of FATAL using {@link java.text.MessageFormat}-style formatting. - * - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void fatalv(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalv(format, param1, param2, param3); - } - } - - /** - * Issue a log message with a level of FATAL using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param params the parameters - */ - public void fatalv(Throwable t, String format, Object... params) { - delegate.fatalv(t, format, params); - } - - /** - * Issue a log message with a level of FATAL using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the sole parameter - */ - public void fatalv(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalv(t, format, param1); - } - } - - /** - * Issue a log message with a level of FATAL using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void fatalv(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalv(t, format, param1, param2); - } - } - - /** - * Issue a log message with a level of FATAL using {@link java.text.MessageFormat}-style formatting. - * - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void fatalv(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalv(t, format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of FATAL. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param params the parameters - */ - public void fatalf(String format, Object... params) { - delegate.fatalf(format, params); - } - - /** - * Issue a formatted log message with a level of FATAL. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the sole parameter - */ - public void fatalf(String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalf(format, param1); - } - } - - /** - * Issue a formatted log message with a level of FATAL. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void fatalf(String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalf(format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of FATAL. - * - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void fatalf(String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalf(format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message with a level of FATAL. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param params the parameters - */ - public void fatalf(Throwable t, String format, Object... params) { - delegate.fatalf(t, format, params); - } - - /** - * Issue a formatted log message with a level of FATAL. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the sole parameter - */ - public void fatalf(Throwable t, String format, Object param1) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalf(t, format, param1); - } - } - - /** - * Issue a formatted log message with a level of FATAL. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void fatalf(Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalf(t, format, param1, param2); - } - } - - /** - * Issue a formatted log message with a level of FATAL. - * - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void fatalf(Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(org.jboss.seam.solder.logging.internal.Logger.Level.FATAL)) { - delegate.fatalf(t, format, param1, param2, param3); - } - } - - /** - * Log a message at the given level. - * - * @param level the level - * @param message the message - */ - public void log(Level level, Object message) { - delegate.log(translate(level), message); - } - - /** - * Issue a log message and throwable at the given log level. - * - * @param level the level - * @param message the message - * @param t the throwable - */ - public void log(Level level, Object message, Throwable t) { - delegate.log(translate(level), message, t); - } - - /** - * Issue a log message and throwable at the given log level and a specific logger class name. - * - * @param level the level - * @param loggerFqcn the logger class name - * @param message the message - * @param t the throwable - */ - public void log(Level level, String loggerFqcn, Object message, Throwable t) { - delegate.log(translate(level), loggerFqcn, message, t); - } - - /** - * Issue a log message with parameters and a throwable at the given log level. - * - * @param loggerFqcn the logger class name - * @param level the level - * @param message the message - * @param params the message parameters - * @param t the throwable - */ - public void log(String loggerFqcn, Level level, Object message, Object[] params, Throwable t) { - delegate.log(loggerFqcn, translate(level), message, params, t); - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param level the level - * @param format the message format string - * @param params the parameters - */ - public void logv(Level level, String format, Object... params) { - delegate.logv(translate(level), format, params); - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param level the level - * @param format the message format string - * @param param1 the sole parameter - */ - public void logv(Level level, String format, Object param1) { - if (delegate.isEnabled(translate(level))) { - delegate.logv(translate(level), format, param1); - } - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param level the level - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void logv(Level level, String format, Object param1, Object param2) { - if (delegate.isEnabled(translate(level))) { - delegate.logv(translate(level), format, param1, param2); - } - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param level the level - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void logv(Level level, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(translate(level))) { - delegate.logv(translate(level), format, param1, param2, param3); - } - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param level the level - * @param t the throwable - * @param format the message format string - * @param params the parameters - */ - public void logv(Level level, Throwable t, String format, Object... params) { - delegate.logv(translate(level), t, format, params); - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param level the level - * @param t the throwable - * @param format the message format string - * @param param1 the sole parameter - */ - public void logv(Level level, Throwable t, String format, Object param1) { - if (delegate.isEnabled(translate(level))) { - delegate.logv(translate(level), t, format, param1); - } - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param level the level - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void logv(Level level, Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(translate(level))) { - delegate.logv(translate(level), t, format, param1, param2); - } - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param level the level - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void logv(Level level, Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(translate(level))) { - delegate.logv(translate(level), t, format, param1, param2, param3); - } - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param loggerFqcn the logger class name - * @param level the level - * @param t the throwable - * @param format the message format string - * @param params the parameters - */ - public void logv(String loggerFqcn, Level level, Throwable t, String format, Object... params) { - delegate.logv(loggerFqcn, translate(level), t, format, params); - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param loggerFqcn the logger class name - * @param level the level - * @param t the throwable - * @param format the message format string - * @param param1 the sole parameter - */ - public void logv(String loggerFqcn, Level level, Throwable t, String format, Object param1) { - if (delegate.isEnabled(translate(level))) { - delegate.logv(loggerFqcn, translate(level), t, format, param1); - } - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param loggerFqcn the logger class name - * @param level the level - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void logv(String loggerFqcn, Level level, Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(translate(level))) { - delegate.logv(loggerFqcn, translate(level), t, format, param1, param2); - } - } - - /** - * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting. - * - * @param loggerFqcn the logger class name - * @param level the level - * @param t the throwable - * @param format the message format string - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void logv(String loggerFqcn, Level level, Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(translate(level))) { - delegate.logv(loggerFqcn, translate(level), t, format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message at the given log level. - * - * @param level the level - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param params the parameters - */ - public void logf(Level level, String format, Object... params) { - delegate.logf(translate(level), format, params); - } - - /** - * Issue a formatted log message at the given log level. - * - * @param level the level - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the sole parameter - */ - public void logf(Level level, String format, Object param1) { - if (delegate.isEnabled(translate(level))) { - delegate.logf(translate(level), format, param1); - } - } - - /** - * Issue a formatted log message at the given log level. - * - * @param level the level - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void logf(Level level, String format, Object param1, Object param2) { - if (delegate.isEnabled(translate(level))) { - delegate.logf(translate(level), format, param1, param2); - } - } - - /** - * Issue a formatted log message at the given log level. - * - * @param level the level - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void logf(Level level, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(translate(level))) { - delegate.logf(translate(level), format, param1, param2, param3); - } - } - - /** - * Issue a formatted log message at the given log level. - * - * @param level the level - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param params the parameters - */ - public void logf(Level level, Throwable t, String format, Object... params) { - delegate.logf(translate(level), t, format, params); - } - - /** - * Issue a formatted log message at the given log level. - * - * @param level the level - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the sole parameter - */ - public void logf(Level level, Throwable t, String format, Object param1) { - if (delegate.isEnabled(translate(level))) { - delegate.logf(translate(level), t, format, param1); - } - } - - /** - * Issue a formatted log message at the given log level. - * - * @param level the level - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void logf(Level level, Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(translate(level))) { - delegate.logf(translate(level), t, format, param1, param2); - } - } - - /** - * Issue a formatted log message at the given log level. - * - * @param level the level - * @param t the throwable - * @param format the format string, as per {@link String#format(String, Object...)} - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void logf(Level level, Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(translate(level))) { - delegate.logf(translate(level), t, format, param1, param2, param3); - } - } - - /** - * Log a message at the given level. - * - * @param loggerFqcn the logger class name - * @param level the level - * @param t the throwable cause - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the sole parameter - */ - public void logf(String loggerFqcn, Level level, Throwable t, String format, Object param1) { - if (delegate.isEnabled(translate(level))) { - delegate.logf(loggerFqcn, translate(level), t, format, param1); - } - } - - /** - * Log a message at the given level. - * - * @param loggerFqcn the logger class name - * @param level the level - * @param t the throwable cause - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - */ - public void logf(String loggerFqcn, Level level, Throwable t, String format, Object param1, Object param2) { - if (delegate.isEnabled(translate(level))) { - delegate.logf(loggerFqcn, translate(level), t, format, param1, param2); - } - } - - /** - * Log a message at the given level. - * - * @param loggerFqcn the logger class name - * @param level the level - * @param t the throwable cause - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param param1 the first parameter - * @param param2 the second parameter - * @param param3 the third parameter - */ - public void logf(String loggerFqcn, Level level, Throwable t, String format, Object param1, Object param2, Object param3) { - if (delegate.isEnabled(translate(level))) { - delegate.logf(loggerFqcn, translate(level), t, format, param1, param2, param3); - } - } - - /** - * Log a message at the given level. - * - * @param loggerFqcn the logger class name - * @param level the level - * @param t the throwable cause - * @param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor - * @param params the message parameters - */ - public void logf(String loggerFqcn, Level level, Throwable t, String format, Object... params) { - delegate.logf(loggerFqcn, translate(level), t, format, params); - } - - /** - * Get a Logger instance given the logger name. - * - * @param name the logger name - * - * @return the logger - */ - public static Logger getLogger(String name) { - return new Logger(name); - } - - /** - * Get a Logger instance given the logger name with the given suffix. - *

- *

- * This will include a logger separator between logger name and suffix. - * - * @param name the logger name - * @param suffix a suffix to append to the logger name - * - * @return the logger - */ - public static Logger getLogger(String name, String suffix) { - return getLogger(name == null || name.length() == 0 ? suffix : name + "." + suffix); - } - - /** - * Get a Logger instance given the name of a class. This simply calls create(clazz.getName()). - * - * @param clazz the Class whose name will be used as the logger name - * - * @return the logger - */ - public static Logger getLogger(Class clazz) { - return getLogger(clazz.getName()); - } - - /** - * Get a Logger instance given the name of a class with the given suffix. - *

- *

- * This will include a logger separator between logger name and suffix - * - * @param clazz the Class whose name will be used as the logger name - * @param suffix a suffix to append to the logger name - * - * @return the logger - */ - public static Logger getLogger(Class clazz, String suffix) { - return getLogger(clazz.getName(), suffix); - } - - /** - * Get a typed logger which implements the given interface. The current default locale will be used for the new logger. - * - * @param type the interface to implement - * @param category the logger category - * @param the logger type - * @return the typed logger - */ - public static T getMessageLogger(Class type, String category) { - return getMessageLogger(type, category, Locale.getDefault()); - } - - /** - * Get a typed logger which implements the given interface. The given locale will be used for the new logger. - * - * @param type the interface to implement - * @param category the logger category - * @param locale the locale for the new logger - * @param the logger type - * @return the typed logger - */ - public static T getMessageLogger(Class type, String category, Locale locale) { - String language = locale.getLanguage(); - String country = locale.getCountry(); - String variant = locale.getVariant(); - - Class loggerClass = null; - if (variant != null && variant.length() > 0) - try { - loggerClass = Class.forName(join(type.getName(), "$logger", language, country, variant), true, - type.getClassLoader()).asSubclass(type); - } catch (ClassNotFoundException e) { - // ignore - } - if (loggerClass == null && country != null && country.length() > 0) - try { - loggerClass = Class.forName(join(type.getName(), "$logger", language, country, null), true, - type.getClassLoader()).asSubclass(type); - } catch (ClassNotFoundException e) { - // ignore - } - if (loggerClass == null && language != null && language.length() > 0) - try { - loggerClass = Class.forName(join(type.getName(), "$logger", language, null, null), true, type.getClassLoader()) - .asSubclass(type); - } catch (ClassNotFoundException e) { - // ignore - } - if (loggerClass == null) - try { - loggerClass = Class.forName(join(type.getName(), "$logger", null, null, null), true, type.getClassLoader()) - .asSubclass(type); - } catch (ClassNotFoundException e) { - Logger thisLogger = Logger.getLogger(Logger.class); - thisLogger - .warn("Generating proxy for type-safe logger " - + type - + ". You should generate a concrete implementation using the jboss-logging-tools annotation processor before deploying to production!!"); - return type.cast(Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, - new MessageLoggerInvocationHandler(type, category))); - } - final Constructor constructor; - try { - constructor = loggerClass.getConstructor(Logger.class); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException("Logger implementation " + loggerClass + " has no matching constructor"); - } - try { - return constructor.newInstance(Logger.getLogger(category)); - } catch (InstantiationException e) { - throw new IllegalArgumentException("Logger implementation " + loggerClass + " could not be instantiated", e); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException("Logger implementation " + loggerClass + " could not be instantiated", e); - } catch (InvocationTargetException e) { - throw new IllegalArgumentException("Logger implementation " + loggerClass + " could not be instantiated", - e.getCause()); - } - } - - private static String join(String interfaceName, String a, String b, String c, String d) { - final StringBuilder build = new StringBuilder(); - build.append(interfaceName).append('_').append(a); - if (b != null && b.length() > 0) { - build.append('_'); - build.append(b); - } - if (c != null && c.length() > 0) { - build.append('_'); - build.append(c); - } - if (d != null && d.length() > 0) { - build.append('_'); - build.append(d); - } - return build.toString(); - } - - private static org.jboss.seam.solder.logging.internal.Logger.Level translate(final Level level) { - if (level != null) - switch (level) { - case FATAL: - return org.jboss.seam.solder.logging.internal.Logger.Level.FATAL; - case ERROR: - return org.jboss.seam.solder.logging.internal.Logger.Level.ERROR; - case WARN: - return org.jboss.seam.solder.logging.internal.Logger.Level.WARN; - case INFO: - return org.jboss.seam.solder.logging.internal.Logger.Level.INFO; - case DEBUG: - return org.jboss.seam.solder.logging.internal.Logger.Level.DEBUG; - case TRACE: - return org.jboss.seam.solder.logging.internal.Logger.Level.TRACE; - } - return null; - } - -} \ No newline at end of file diff --git a/api/src/main/java/org/jboss/seam/solder/logging/MessageLogger.java b/api/src/main/java/org/jboss/seam/solder/logging/MessageLogger.java deleted file mode 100644 index 2ba2c077..00000000 --- a/api/src/main/java/org/jboss/seam/solder/logging/MessageLogger.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * Licensed 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.jboss.seam.solder.logging; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.jboss.seam.solder.messages.MessageBundle; - -/** - * Signify that an interface is a typed logger interface. A message logger interface may optionally extend other message logger - * interfaces and message bundle interfaces (see {@link MessageBundle}, as well as the {@link org.jboss.logging.BasicLogger} interface. - * - * @author David M. Lloyd - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface MessageLogger { - - /** - * Get the project code for messages that have an associated code. - * - * @return the project code - */ - String projectCode() default ""; -} diff --git a/api/src/main/java/org/jboss/seam/solder/logging/MessageLoggerInvocationHandler.java b/api/src/main/java/org/jboss/seam/solder/logging/MessageLoggerInvocationHandler.java deleted file mode 100644 index a6338008..00000000 --- a/api/src/main/java/org/jboss/seam/solder/logging/MessageLoggerInvocationHandler.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * Licensed 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.jboss.seam.solder.logging; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.ArrayList; - -import org.jboss.seam.solder.messages.Message; -import org.jboss.seam.solder.messages.MessageBundleInvocationHandler; - -/** - * @author David M. Lloyd - */ -public class MessageLoggerInvocationHandler extends MessageBundleInvocationHandler { - - private final Logger logger; - - public MessageLoggerInvocationHandler(final Class type, final String category) { - this(type.getAnnotation(MessageLogger.class), category); - } - - private MessageLoggerInvocationHandler(final MessageLogger messageLogger, final String category) { - super(messageLogger.projectCode()); - logger = Logger.getLogger(category); - } - - public Object invoke(final Object proxy, final Method method, Object[] args) throws Throwable { - final Message message = method.getAnnotation(Message.class); - if (message == null) { - // nothing to do... - return null; - } - final Annotation[][] parameterAnnotations = method.getParameterAnnotations(); - final Log logMessage = method.getAnnotation(Log.class); - if (logMessage != null) { - - try { - // See if it's a basic logger method - if (method.getDeclaringClass().equals(org.jboss.seam.solder.logging.internal.BasicLogger.class)) { - // doesn't cover overrides though! - return method.invoke(logger, args); - } - - // it's a log message - final Logger.Level level = logMessage.level(); - if (logger.isEnabled(level)) { - String formatString = getFormatString(message); - if (formatString == null) { - return null; - } - ArrayList newArgs = new ArrayList(); - Throwable cause = extractCause(parameterAnnotations, args, newArgs); - final Message.Format format = message.format(); - switch (format) { - case PRINTF: { - logger.logf(level, cause, formatString, newArgs.toArray()); - return null; - } - case MESSAGE_FORMAT: { - logger.logv(level, cause, formatString, newArgs.toArray()); - return null; - } - default: { - return null; - } - } - } - } catch (Throwable ignored) { - } - } else { - return super.invoke(proxy, method, args); - } - return null; - } -} diff --git a/api/src/main/java/org/jboss/seam/solder/logging/Suffix.java b/api/src/main/java/org/jboss/seam/solder/logging/Suffix.java deleted file mode 100644 index 81cc75ee..00000000 --- a/api/src/main/java/org/jboss/seam/solder/logging/Suffix.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * Licensed 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.jboss.seam.solder.logging; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import org.jboss.seam.solder.logging.Logger; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - *

- * A suffix to use on the specified category (or fully qualified name of the - * injection point type if no category is specified). The category and suffix - * will be separated by a logger separator. - *

- *

- *

- * Suffixes are not supported by typed loggers. - *

- * - * @author Pete Muir - * @see Logger#getLogger(String, String) - */ -@Target({METHOD, FIELD, PARAMETER, TYPE}) -@Retention(RUNTIME) -@Documented -public @interface Suffix { - /** - * The suffix to use - */ - String value(); -} diff --git a/api/src/main/java/org/jboss/seam/solder/logging/TypedCategory.java b/api/src/main/java/org/jboss/seam/solder/logging/TypedCategory.java deleted file mode 100644 index bed3c6e3..00000000 --- a/api/src/main/java/org/jboss/seam/solder/logging/TypedCategory.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * Licensed 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.jboss.seam.solder.logging; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import org.jboss.seam.solder.logging.Logger; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - *

- * Specifies a typed category for the injected logger. - *

- *

- *

- * A category is required for a typed logger. - *

- *

- *

- * For a non-typed logger, if no category annotation is specified at a - * {@link Logger} injection point, the fully qualified name of the bean - * implementation class is used as the category. - *

- * - * @author Dan Allen - * @see MessageLogger - * @see Logger#getLogger(String) - */ -@Target({METHOD, FIELD, PARAMETER, TYPE}) -@Retention(RUNTIME) -@Documented -public @interface TypedCategory { - /** - * The category of the logger. - */ - Class value(); -} diff --git a/api/src/main/java/org/jboss/seam/solder/logging/package-info.java b/api/src/main/java/org/jboss/seam/solder/logging/package-info.java deleted file mode 100644 index 9ec8ceb1..00000000 --- a/api/src/main/java/org/jboss/seam/solder/logging/package-info.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2010, Red Hat, Inc., and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * Licensed 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. - */ - -/** - * Seam Solder integrates with JBoss Logging 3 to provide injectable native - * loggers or typed message loggers (suitable for internationalization and - * localization) while still offering a choice of logging backend - * - *

Solder builds on its typed message bundles support combined with JBoss - * Logging 3 to provide the following feature set:

- * - *
    - *
  • An abstraction over common logging backends and frameworks (such as JDK Logging, log4j and slf4j)
  • - *
  • An innovative, typed message logger (and bundle) defined using an interface (see below for examples)
  • - *
  • Full support for internationalization and localization
  • - *
  • Build time tooling to generate typed loggers for production, and runtime generation of typed loggers for development
  • - *
  • Access to MDC and NDC (if underlying logger supports it)
  • - *
  • Serializable loggers
  • - *
- * - *

To define a typed message logger, first create an annotated interface - * with methods configured as log commands. The log messages to use - * printf-style interpolations of parameters (%s).

- * - *
- * @MessageLogger
- * public interface TrainSpotterLog {
- *
- *    @Log @Message("Spotted %s diesel trains")
- *    void dieselTrainsSpotted(int number);
- *
- * }
- * 
- * - *

You can then inject the typed logger with no further configuration - * necessary. You use another annotation to set the category of the logger to - * "trains" at the injection point:

- * - *
- *    @Inject @Category("trains") TrainSpotterLog log;
- * 
- * - *

You log a message by simply invoking a method of the message logger - * interface:

- * - *
- *    log.dieselTrainsSpotted(7);
- * 
- * - *

The default locale will be used unless overridden. Here we configure the - * logger to use the UK locale.

- * - *
- *    @Inject @Category("trains") @Locale("en_GB") TrainSpotterLog log;
- * 
- * - *

You can also log exceptions:

- * - *
- * @MessageLogger
- * public interface TrainSpotterLog {
- *
- *    @Log @Message("Failed to spot train %s")
- *    void missedTrain(String trainNumber, @Cause Exception exception);
- *
- * }
- * 
- * - *

You can then log a message with exception:

- * - *
- *    log.missedTrain("RH1", cause);
- * 
- * - *

- * You can also inject a native Logger from the JBoss Logging 3 API: - *

- * - *
- *    @Inject Logger log;
- * 
- * - * @see org.jboss.seam.solder.logging.Log - * @see org.jboss.seam.solder.logging.Category - * @see org.jboss.seam.solder.logging.TypedCategory - * @see org.jboss.seam.solder.logging.Suffix - * @see org.jboss.seam.solder.messages.Cause - * @see org.jboss.seam.solder.messages.Message - * @see org.jboss.seam.solder.messages.Locale - * @see org.jboss.seam.solder.messages.Formatter - */ -package org.jboss.seam.solder.logging; diff --git a/api/src/main/java/org/jboss/seam/solder/messages/Locale.java b/api/src/main/java/org/jboss/seam/solder/messages/Locale.java index cc38f50e..564489b4 100644 --- a/api/src/main/java/org/jboss/seam/solder/messages/Locale.java +++ b/api/src/main/java/org/jboss/seam/solder/messages/Locale.java @@ -20,8 +20,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import org.jboss.seam.solder.logging.Logger; -import org.jboss.seam.solder.logging.MessageLogger; +import org.jboss.seam.logging.MessageLogger; +import org.jboss.seam.logging.Logger; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; diff --git a/api/src/main/java/org/jboss/seam/solder/messages/Messages.java b/api/src/main/java/org/jboss/seam/solder/messages/Messages.java index 637d7c64..ce90693a 100644 --- a/api/src/main/java/org/jboss/seam/solder/messages/Messages.java +++ b/api/src/main/java/org/jboss/seam/solder/messages/Messages.java @@ -21,7 +21,7 @@ import java.lang.reflect.Proxy; import java.util.Locale; -import org.jboss.seam.solder.logging.Logger; +import org.jboss.seam.logging.Logger; /** * A factory class to produce message bundle implementations. diff --git a/api/src/main/java/org/jboss/seam/solder/util/service/ServiceLoader.java b/api/src/main/java/org/jboss/seam/solder/util/service/ServiceLoader.java index f869e28e..c3e4c91f 100644 --- a/api/src/main/java/org/jboss/seam/solder/util/service/ServiceLoader.java +++ b/api/src/main/java/org/jboss/seam/solder/util/service/ServiceLoader.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Set; -import org.jboss.seam.solder.logging.Logger; +import org.jboss.seam.logging.Logger; /** * This class handles looking up service providers on the class path. It diff --git a/impl/pom.xml b/impl/pom.xml index 7ad42021..4a07ecb6 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -32,10 +32,6 @@ ${project.parent.url} - - 1.0.0.Alpha5 - - @@ -78,13 +74,13 @@ true - + log4j @@ -97,7 +93,6 @@ org.slf4j slf4j-api - 1.5.8 provided true @@ -118,16 +113,11 @@ junit junit-dep - - 4.8.1 - test org.jboss.arquillian arquillian-junit - ${version.arquillian} - test @@ -139,9 +129,6 @@ org.hamcrest hamcrest-core - - 1.3.RC2 - test @@ -168,6 +155,21 @@ + + + + org.apache.maven.plugins + maven-war-plugin + + + + org.jboss.logging,org.jboss.logmanager + + + + + @@ -181,31 +183,36 @@ + org.jboss.arquillian.container arquillian-weld-ee-embedded-1.1 - ${version.arquillian} + org.jboss.spec.javax.transaction jboss-transaction-api_1.1_spec test + org.hibernate.javax.persistence hibernate-jpa-2.0-api test + javax.validation validation-api test + org.jboss.weld weld-core test + @@ -234,59 +241,72 @@ + org.jboss.arquillian.container arquillian-openwebbeans-embedded-1 ${version.arquillian} - - org.apache.openwebbeans - openwebbeans-spi - - - org.apache.openwebbeans - openwebbeans-impl - - - org.apache.geronimo.specs - geronimo-el_2.2_spec - - - org.apache.geronimo.specs - geronimo-jta_1.1_spec - - - org.apache.geronimo.specs - geronimo-validation_1.0_spec - - - org.apache.geronimo.specs - geronimo-interceptor_1.1_spec - - - org.apache.geronimo.specs - geronimo-jcdi_1.0_spec - - - org.apache.geronimo.specs - geronimo-atinject_1.0_spec - - - org.apache.geronimo.specs - geronimo-servlet_2.5_spec - + + + org.apache.openwebbeans + openwebbeans-spi + + + + org.apache.openwebbeans + openwebbeans-impl + + + + org.apache.geronimo.specs + geronimo-el_2.2_spec + + + + org.apache.geronimo.specs + geronimo-jta_1.1_spec + + + + org.apache.geronimo.specs + geronimo-validation_1.0_spec + + + + org.apache.geronimo.specs + geronimo-interceptor_1.1_spec + + + + org.apache.geronimo.specs + geronimo-jcdi_1.0_spec + + + + org.apache.geronimo.specs + geronimo-atinject_1.0_spec + + + + org.apache.geronimo.specs + geronimo-servlet_2.5_spec + + + + + + + + org.apache.openwebbeans + openwebbeans + 1.0.0 + pom + import + - - - - org.apache.openwebbeans - openwebbeans - 1.0.0 - pom - import - - - + + @@ -305,6 +325,7 @@ + incontainer diff --git a/impl/src/main/java/org/jboss/seam/solder/bean/AbstractImmutableBean.java b/impl/src/main/java/org/jboss/seam/solder/bean/AbstractImmutableBean.java index 298847be..73ff88f5 100644 --- a/impl/src/main/java/org/jboss/seam/solder/bean/AbstractImmutableBean.java +++ b/impl/src/main/java/org/jboss/seam/solder/bean/AbstractImmutableBean.java @@ -28,8 +28,8 @@ import javax.enterprise.inject.spi.Bean; import javax.enterprise.inject.spi.InjectionPoint; +import org.jboss.seam.logging.Logger; import org.jboss.seam.solder.literal.DefaultLiteral; -import org.jboss.seam.solder.logging.Logger; import org.jboss.seam.solder.util.collections.Arrays2; /** diff --git a/impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultBeanExtension.java b/impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultBeanExtension.java index 0924cfac..0079d540 100644 --- a/impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultBeanExtension.java +++ b/impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultBeanExtension.java @@ -16,6 +16,8 @@ */ package org.jboss.seam.solder.bean.defaultbean; +import static org.jboss.seam.solder.util.collections.Multimaps.newSetMultimap; + import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.lang.reflect.Type; @@ -48,16 +50,14 @@ import javax.enterprise.inject.spi.ProcessProducerField; import javax.enterprise.inject.spi.ProcessProducerMethod; +import org.jboss.seam.logging.Logger; import org.jboss.seam.solder.bean.Beans; import org.jboss.seam.solder.literal.DefaultLiteral; -import org.jboss.seam.solder.logging.Logger; import org.jboss.seam.solder.reflection.Synthetic; import org.jboss.seam.solder.reflection.annotated.AnnotatedTypeBuilder; import org.jboss.seam.solder.util.collections.SetMultimap; import org.jboss.seam.solder.util.collections.Supplier; -import static org.jboss.seam.solder.util.collections.Multimaps.newSetMultimap; - /** * Registers beans annotated @DefaultBean *

diff --git a/impl/src/main/java/org/jboss/seam/solder/core/CoreExtension.java b/impl/src/main/java/org/jboss/seam/solder/core/CoreExtension.java index 6f5961d8..19a4259e 100644 --- a/impl/src/main/java/org/jboss/seam/solder/core/CoreExtension.java +++ b/impl/src/main/java/org/jboss/seam/solder/core/CoreExtension.java @@ -39,8 +39,8 @@ import javax.enterprise.inject.spi.ProcessAnnotatedType; import javax.inject.Named; +import org.jboss.seam.logging.Logger; import org.jboss.seam.solder.literal.NamedLiteral; -import org.jboss.seam.solder.logging.Logger; import org.jboss.seam.solder.properties.Properties; import org.jboss.seam.solder.reflection.Reflections; import org.jboss.seam.solder.reflection.annotated.AnnotatedTypeBuilder; diff --git a/impl/src/main/java/org/jboss/seam/solder/logging/LoggerProducer.java b/impl/src/main/java/org/jboss/seam/solder/logging/LoggerProducer.java index 86386cfc..72f7b9ac 100644 --- a/impl/src/main/java/org/jboss/seam/solder/logging/LoggerProducer.java +++ b/impl/src/main/java/org/jboss/seam/solder/logging/LoggerProducer.java @@ -17,14 +17,17 @@ package org.jboss.seam.solder.logging; -import static org.jboss.seam.solder.logging.Logger.getLogger; +import static org.jboss.seam.logging.Logger.getLogger; import static org.jboss.seam.solder.reflection.Reflections.getRawType; import javax.enterprise.inject.Produces; import javax.enterprise.inject.spi.Annotated; import javax.enterprise.inject.spi.InjectionPoint; -import org.jboss.seam.solder.logging.Logger; +import org.jboss.seam.logging.Category; +import org.jboss.seam.logging.Logger; +import org.jboss.seam.logging.Suffix; +import org.jboss.seam.logging.TypedCategory; /** * The LoggerProducer provides a producer method for all injected loggers that use the JBoss Logging API diff --git a/impl/src/main/java/org/jboss/seam/solder/logging/TypedMessageLoggerExtension.java b/impl/src/main/java/org/jboss/seam/solder/logging/TypedMessageLoggerExtension.java index fb3226be..1937bbd2 100644 --- a/impl/src/main/java/org/jboss/seam/solder/logging/TypedMessageLoggerExtension.java +++ b/impl/src/main/java/org/jboss/seam/solder/logging/TypedMessageLoggerExtension.java @@ -30,6 +30,7 @@ import javax.enterprise.inject.spi.ProcessAnnotatedType; import javax.enterprise.inject.spi.ProcessProducerMethod; +import org.jboss.seam.logging.MessageLogger; import org.jboss.seam.solder.bean.NarrowingBeanBuilder; /** diff --git a/impl/src/main/java/org/jboss/seam/solder/logging/TypedMessageLoggerProducer.java b/impl/src/main/java/org/jboss/seam/solder/logging/TypedMessageLoggerProducer.java index ef9c0c86..93dbc886 100644 --- a/impl/src/main/java/org/jboss/seam/solder/logging/TypedMessageLoggerProducer.java +++ b/impl/src/main/java/org/jboss/seam/solder/logging/TypedMessageLoggerProducer.java @@ -17,9 +17,9 @@ package org.jboss.seam.solder.logging; -import static org.jboss.seam.solder.logging.Logger.getMessageLogger; -import static org.jboss.seam.solder.reflection.Reflections.getRawType; +import static org.jboss.seam.logging.Logger.getMessageLogger; import static org.jboss.seam.solder.logging.LoggerProducer.getDeclaringRawType; +import static org.jboss.seam.solder.reflection.Reflections.getRawType; import static org.jboss.seam.solder.util.Locales.toLocale; import java.io.Serializable; @@ -28,6 +28,8 @@ import javax.enterprise.inject.spi.Annotated; import javax.enterprise.inject.spi.InjectionPoint; +import org.jboss.seam.logging.Category; +import org.jboss.seam.logging.TypedCategory; import org.jboss.seam.solder.messages.Locale; /** diff --git a/impl/src/main/java/org/jboss/seam/solder/resourceLoader/ClasspathResourceLoader.java b/impl/src/main/java/org/jboss/seam/solder/resourceLoader/ClasspathResourceLoader.java index ba004a19..8a0a6d39 100644 --- a/impl/src/main/java/org/jboss/seam/solder/resourceLoader/ClasspathResourceLoader.java +++ b/impl/src/main/java/org/jboss/seam/solder/resourceLoader/ClasspathResourceLoader.java @@ -24,7 +24,7 @@ import java.util.HashSet; import java.util.Set; -import org.jboss.seam.solder.logging.Logger; +import org.jboss.seam.logging.Logger; class ClasspathResourceLoader implements ResourceLoader { diff --git a/impl/src/main/java/org/jboss/seam/solder/resourceLoader/DelegatingResourceLoader.java b/impl/src/main/java/org/jboss/seam/solder/resourceLoader/DelegatingResourceLoader.java index 04d5560e..1b9308e4 100644 --- a/impl/src/main/java/org/jboss/seam/solder/resourceLoader/DelegatingResourceLoader.java +++ b/impl/src/main/java/org/jboss/seam/solder/resourceLoader/DelegatingResourceLoader.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Set; -import org.jboss.seam.solder.logging.Logger; +import org.jboss.seam.logging.Logger; /** * Resource loader that delegates to a static list of resource loaders. diff --git a/impl/src/main/java/org/jboss/seam/solder/serviceHandler/ServiceHandlerExtension.java b/impl/src/main/java/org/jboss/seam/solder/serviceHandler/ServiceHandlerExtension.java index 591d22eb..1cbc4333 100644 --- a/impl/src/main/java/org/jboss/seam/solder/serviceHandler/ServiceHandlerExtension.java +++ b/impl/src/main/java/org/jboss/seam/solder/serviceHandler/ServiceHandlerExtension.java @@ -16,6 +16,8 @@ */ package org.jboss.seam.solder.serviceHandler; +import static org.jboss.seam.solder.reflection.AnnotationInspector.getMetaAnnotation; + import java.util.HashSet; import java.util.Set; @@ -27,12 +29,10 @@ import javax.enterprise.inject.spi.Extension; import javax.enterprise.inject.spi.ProcessAnnotatedType; +import org.jboss.seam.logging.Logger; import org.jboss.seam.solder.bean.BeanBuilder; -import org.jboss.seam.solder.logging.Logger; import org.jboss.seam.solder.reflection.Reflections; -import static org.jboss.seam.solder.reflection.AnnotationInspector.getMetaAnnotation; - /** * This extension automatically implements interfaces and abstract classes. * diff --git a/impl/src/main/java/org/jboss/seam/solder/unwraps/UnwrapsExtension.java b/impl/src/main/java/org/jboss/seam/solder/unwraps/UnwrapsExtension.java index caa0d000..ecefdee4 100644 --- a/impl/src/main/java/org/jboss/seam/solder/unwraps/UnwrapsExtension.java +++ b/impl/src/main/java/org/jboss/seam/solder/unwraps/UnwrapsExtension.java @@ -27,7 +27,8 @@ import javax.enterprise.inject.spi.BeanManager; import javax.enterprise.inject.spi.Extension; import javax.enterprise.inject.spi.ProcessAnnotatedType; -import org.jboss.seam.solder.logging.Logger; + +import org.jboss.seam.logging.Logger; import org.jboss.seam.solder.reflection.Reflections; /** diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java index 4fad5246..fc442428 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java @@ -23,6 +23,7 @@ import org.jboss.arquillian.api.Deployment; import org.jboss.arquillian.junit.Arquillian; +import org.jboss.seam.logging.Category; import org.jboss.seam.solder.logging.internal.Logger; import org.jboss.seam.solder.bean.Beans; import org.jboss.seam.solder.bean.defaultbean.DefaultBeanExtension; @@ -32,7 +33,6 @@ import org.jboss.seam.solder.core.CoreExtension; import org.jboss.seam.solder.el.Resolver; import org.jboss.seam.solder.literal.DefaultLiteral; -import org.jboss.seam.solder.logging.Category; import org.jboss.seam.solder.logging.TypedMessageLoggerExtension; import org.jboss.seam.solder.messages.Messages; import org.jboss.seam.solder.reflection.Synthetic; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/logging/BaldEagle.java b/impl/src/test/java/org/jboss/seam/solder/test/logging/BaldEagle.java index ecbe0c9a..9a483d14 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/logging/BaldEagle.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/logging/BaldEagle.java @@ -5,7 +5,7 @@ import javax.enterprise.context.SessionScoped; import javax.inject.Inject; -import org.jboss.seam.solder.logging.Category; +import org.jboss.seam.logging.Category; @SessionScoped public class BaldEagle implements Serializable { diff --git a/impl/src/test/java/org/jboss/seam/solder/test/logging/BirdLogger.java b/impl/src/test/java/org/jboss/seam/solder/test/logging/BirdLogger.java index ace00f1f..03b2e841 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/logging/BirdLogger.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/logging/BirdLogger.java @@ -16,8 +16,8 @@ */ package org.jboss.seam.solder.test.logging; -import org.jboss.seam.solder.logging.Log; -import org.jboss.seam.solder.logging.MessageLogger; +import org.jboss.seam.logging.Log; +import org.jboss.seam.logging.MessageLogger; import org.jboss.seam.solder.messages.Message; @MessageLogger diff --git a/impl/src/test/java/org/jboss/seam/solder/test/logging/Finch.java b/impl/src/test/java/org/jboss/seam/solder/test/logging/Finch.java index 04663892..929b4d76 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/logging/Finch.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/logging/Finch.java @@ -18,8 +18,8 @@ import javax.inject.Inject; -import org.jboss.seam.solder.logging.Category; -import org.jboss.seam.solder.logging.Logger; +import org.jboss.seam.logging.Category; +import org.jboss.seam.logging.Logger; public class Finch { @Inject diff --git a/impl/src/test/java/org/jboss/seam/solder/test/logging/Hawk.java b/impl/src/test/java/org/jboss/seam/solder/test/logging/Hawk.java index 5663cbbf..34e60195 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/logging/Hawk.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/logging/Hawk.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.seam.solder.logging.Category; +import org.jboss.seam.logging.Category; public class Hawk { @Inject diff --git a/impl/src/test/java/org/jboss/seam/solder/test/logging/NonBean.java b/impl/src/test/java/org/jboss/seam/solder/test/logging/NonBean.java index 47ccd7f0..62ce4631 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/logging/NonBean.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/logging/NonBean.java @@ -19,7 +19,7 @@ import javax.enterprise.inject.Alternative; import javax.inject.Inject; -import org.jboss.seam.solder.logging.Logger; +import org.jboss.seam.logging.Logger; @Alternative public class NonBean { diff --git a/impl/src/test/java/org/jboss/seam/solder/test/logging/Raven.java b/impl/src/test/java/org/jboss/seam/solder/test/logging/Raven.java index 5173c601..25a858a1 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/logging/Raven.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/logging/Raven.java @@ -18,8 +18,8 @@ import javax.inject.Inject; -import org.jboss.seam.solder.logging.Logger; -import org.jboss.seam.solder.logging.Suffix; +import org.jboss.seam.logging.Suffix; +import org.jboss.seam.logging.Logger; class Raven { @Inject diff --git a/impl/src/test/java/org/jboss/seam/solder/test/logging/Sparrow.java b/impl/src/test/java/org/jboss/seam/solder/test/logging/Sparrow.java index 11b12681..ba63cb82 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/logging/Sparrow.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/logging/Sparrow.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.seam.solder.logging.Logger; +import org.jboss.seam.logging.Logger; class Sparrow { diff --git a/impl/src/test/java/org/jboss/seam/solder/test/logging/Wren.java b/impl/src/test/java/org/jboss/seam/solder/test/logging/Wren.java index 12b8d0b7..72f49705 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/logging/Wren.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/logging/Wren.java @@ -18,8 +18,8 @@ import javax.inject.Inject; -import org.jboss.seam.solder.logging.Logger; -import org.jboss.seam.solder.logging.TypedCategory; +import org.jboss.seam.logging.TypedCategory; +import org.jboss.seam.logging.Logger; public class Wren { @Inject diff --git a/pom.xml b/pom.xml index 78f49a6f..c3826d6f 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.jboss.seam seam-parent - 12 + 13-SNAPSHOT org.jboss.seam.solder diff --git a/tooling/src/main/java/org/jboss/seam/solder/tooling/SolderAnnotations.java b/tooling/src/main/java/org/jboss/seam/solder/tooling/SolderAnnotations.java index 911e01e2..31b26981 100644 --- a/tooling/src/main/java/org/jboss/seam/solder/tooling/SolderAnnotations.java +++ b/tooling/src/main/java/org/jboss/seam/solder/tooling/SolderAnnotations.java @@ -22,9 +22,9 @@ import javax.lang.model.element.TypeElement; import org.jboss.logging.Annotations; -import org.jboss.seam.solder.logging.Log; -import org.jboss.seam.solder.logging.Logger; -import org.jboss.seam.solder.logging.MessageLogger; +import org.jboss.seam.logging.Log; +import org.jboss.seam.logging.Logger; +import org.jboss.seam.logging.MessageLogger; import org.jboss.seam.solder.messages.Cause; import org.jboss.seam.solder.messages.Formatter; import org.jboss.seam.solder.messages.Message; diff --git a/tooling/src/main/java/org/jboss/seam/solder/tooling/SolderLoggers.java b/tooling/src/main/java/org/jboss/seam/solder/tooling/SolderLoggers.java index 91554e70..890354b3 100644 --- a/tooling/src/main/java/org/jboss/seam/solder/tooling/SolderLoggers.java +++ b/tooling/src/main/java/org/jboss/seam/solder/tooling/SolderLoggers.java @@ -22,8 +22,8 @@ import java.util.List; import org.jboss.logging.Loggers; +import org.jboss.seam.logging.Logger; import org.jboss.seam.solder.logging.internal.BasicLogger; -import org.jboss.seam.solder.logging.Logger; /** * @author James R. Perkins (jrp) - 20.Feb.2011 From 9f186c6d6ecda9fe424f6f7743d7cb32a2acb070 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 21 Aug 2011 00:57:52 +1000 Subject: [PATCH 03/16] added testsuite --- testsuite/common/pom.xml | 37 ++++ testsuite/internals/base/pom.xml | 76 ++++++++ .../base/src/main/java/NoPackageClass.java | 11 ++ .../test/bean/defaultbean/Airplane.java | 29 +++ .../bean/defaultbean/DefaultBeanTest.java | 110 ++++++++++++ .../bean/defaultbean/DefaultProducers.java | 35 ++++ .../bean/defaultbean/NonDefaultProducers.java | 26 +++ .../solder/test/bean/defaultbean/Vehicle.java | 29 +++ .../test/bean/generic/alternative/Bam.java | 39 ++++ .../test/bean/generic/alternative/Big.java | 36 ++++ .../test/bean/generic/alternative/Boom.java | 33 ++++ .../test/bean/generic/alternative/Bop.java | 36 ++++ .../DisabledAlternativeProducer.java | 37 ++++ .../EnabledAlternativeProducer.java | 37 ++++ .../GenericBeanAlternativeTest.java | 67 +++++++ .../alternative/OnomatopoeiaProducer.java | 40 +++++ .../test/bean/generic/alternative/Pow.java | 39 ++++ .../test/bean/generic/alternative/Small.java | 36 ++++ .../solder/test/bean/generic/field/Bar.java | 58 ++++++ .../solder/test/bean/generic/field/Baz.java | 93 ++++++++++ .../solder/test/bean/generic/field/Burt.java | 21 +++ .../test/bean/generic/field/BurtSubclass.java | 24 +++ .../solder/test/bean/generic/field/Corge.java | 34 ++++ .../solder/test/bean/generic/field/Foo.java | 41 +++++ .../test/bean/generic/field/FooLiteral.java | 33 ++++ .../solder/test/bean/generic/field/Fred.java | 35 ++++ .../test/bean/generic/field/Garply.java | 61 +++++++ .../generic/field/GenericBeanProducer.java | 66 +++++++ .../bean/generic/field/GenericBeanTest.java | 114 ++++++++++++ .../generic/field/GenericBeanUnwrapTest.java | 52 ++++++ .../generic/field/GenericProductTest.java | 93 ++++++++++ .../test/bean/generic/field/Message.java | 41 +++++ .../bean/generic/field/MessageLiteral.java | 33 ++++ .../field/ObserversOnGenericBeanTest.java | 63 +++++++ .../solder/test/bean/generic/field/Plugh.java | 31 ++++ .../field/ProducersOnGenericBeanTest.java | 87 +++++++++ .../solder/test/bean/generic/field/Qux.java | 41 +++++ .../test/bean/generic/field/Service.java | 43 +++++ .../solder/test/bean/generic/field/Waldo.java | 40 +++++ .../test/bean/generic/field/WaldoName.java | 41 +++++ .../test/bean/generic/field/Wibble.java | 41 +++++ .../test/bean/generic/field/Wobble.java | 30 ++++ .../solder/test/bean/generic/method/Bar.java | 53 ++++++ .../solder/test/bean/generic/method/Baz.java | 55 ++++++ .../solder/test/bean/generic/method/Burt.java | 26 +++ .../test/bean/generic/method/Corge.java | 30 ++++ .../solder/test/bean/generic/method/Foo.java | 41 +++++ .../test/bean/generic/method/FooLiteral.java | 33 ++++ .../test/bean/generic/method/Formatted.java | 41 +++++ .../test/bean/generic/method/Garply.java | 83 +++++++++ .../generic/method/GenericBeanProducer.java | 55 ++++++ .../bean/generic/method/GenericBeanTest.java | 79 ++++++++ .../generic/method/GenericProductTest.java | 119 +++++++++++++ .../test/bean/generic/method/Kitchen.java | 30 ++++ .../bean/generic/method/KitchenProducer.java | 42 +++++ .../test/bean/generic/method/Message.java | 41 +++++ .../method/ProducersOnGenericBeanTest.java | 86 +++++++++ .../method/QualifierOnlyGenericBeanTest.java | 72 ++++++++ .../solder/test/bean/generic/method/Qux.java | 41 +++++ .../solder/test/bean/generic/method/Room.java | 35 ++++ .../test/bean/generic/method/Service.java | 43 +++++ .../solder/test/bean/generic/method/Sink.java | 33 ++++ .../test/bean/generic/method/Waldo.java | 41 +++++ .../test/bean/generic/method/WaldoName.java | 41 +++++ .../tooManyGenericConfigurations/Bar.java | 30 ++++ .../tooManyGenericConfigurations/Baz.java | 28 +++ .../tooManyGenericConfigurations/Corge.java | 30 ++++ .../tooManyGenericConfigurations/Foo.java | 41 +++++ .../GenericBeanProducer.java | 52 ++++++ .../GenericBeanTest.java | 34 ++++ .../tooManyGenericConfigurations/Message.java | 41 +++++ .../seam/solder/test/core/BorderCollie.java | 21 +++ .../jboss/seam/solder/test/core/CoreTest.java | 123 +++++++++++++ .../org/jboss/seam/solder/test/core/Dog.java | 21 +++ .../core/FullyQualifiedCustomNamedBean.java | 26 +++ .../test/core/FullyQualifiedModelBean.java | 46 +++++ .../test/core/FullyQualifiedNamedBean.java | 26 +++ .../core/FullyQualifiedToTargetNamedBean.java | 27 +++ .../seam/solder/test/core/Greyhound.java | 21 +++ .../solder/test/core/InstalledService.java | 24 +++ .../seam/solder/test/core/NamedBean.java | 23 +++ .../seam/solder/test/core/RaceTrack.java | 32 ++++ .../FullyQualifiedFromPackageNamedBean.java | 23 +++ .../core/fullyqualified/package-info.java | 20 +++ .../seam/solder/test/core/package-info.java | 20 +++ .../test/core/requires/CommonInterface.java | 21 +++ .../solder/test/core/requires/Jaguar.java | 32 ++++ .../seam/solder/test/core/requires/Lion.java | 26 +++ .../test/core/requires/RequiresTest.java | 95 ++++++++++ .../seam/solder/test/core/requires/Tiger.java | 25 +++ .../requires/beans/DisabledOptionalBean.java | 28 +++ ...sabledOptionalBeanWithFieldDependency.java | 33 ++++ ...dOptionalBeanWithReturnTypeDependency.java | 33 ++++ ...edOptionalBeanWithSupertypeDependency.java | 32 ++++ .../requires/beans/EnabledOptionalBean.java | 28 +++ ...nabledOptionalBeanWithFieldDependency.java | 32 ++++ ...dOptionalBeanWithReturnTypeDependency.java | 32 ++++ ...edOptionalBeanWithSupertypeDependency.java | 31 ++++ .../core/requires/beans/package-info.java | 22 +++ ...ionalBeanWithPackageLevelDependencies.java | 21 +++ .../core/requires/beans/pkg/package-info.java | 23 +++ .../seam/solder/test/core/veto/Tiger.java | 21 +++ .../solder/test/core/veto/package-info.java | 21 +++ .../test/defaultbean/BigLaptopHardDrive.java | 26 +++ .../seam/solder/test/defaultbean/CDDrive.java | 29 +++ .../seam/solder/test/defaultbean/CPU.java | 21 +++ .../test/defaultbean/ChipManufacturer.java | 47 +++++ .../solder/test/defaultbean/DVDDrive.java | 21 +++ .../test/defaultbean/DefaultBeanTest.java | 99 +++++++++++ .../solder/test/defaultbean/FloppyDrive.java | 29 +++ .../seam/solder/test/defaultbean/GPU.java | 21 +++ .../solder/test/defaultbean/HardDrive.java | 21 +++ .../test/defaultbean/HardDriveFactory.java | 61 +++++++ .../test/defaultbean/HardDriveImpl.java | 31 ++++ .../test/defaultbean/LaptopHardDrive.java | 31 ++++ .../test/defaultbean/MagneticDrive.java | 21 +++ .../solder/test/defaultbean/OpticalDrive.java | 21 +++ .../solder/test/defaultbean/SASHardDrive.java | 31 ++++ .../defaultbean/SmallHardDriveFactory.java | 36 ++++ .../test/defaultbean/SuperChargedCPU.java | 25 +++ .../solder/test/defaultbean/WriteEvent.java | 30 ++++ .../seam/solder/test/el/CustomELResolver.java | 69 +++++++ .../org/jboss/seam/solder/test/el/ElTest.java | 69 +++++++ .../org/jboss/seam/solder/test/el/Ute.java | 37 ++++ .../test/interceptor/BarInterceptor.java | 32 ++++ .../seam/solder/test/interceptor/Foo.java | 21 +++ .../test/interceptor/FooInterceptor.java | 32 ++++ .../test/interceptor/InterceptorTest.java | 38 ++++ .../PrimaryInterceptionBinding.java | 38 ++++ .../seam/solder/test/logging/BaldEagle.java | 19 ++ .../seam/solder/test/logging/BirdLogger.java | 36 ++++ .../solder/test/logging/BirdMessages.java | 26 +++ .../jboss/seam/solder/test/logging/Finch.java | 36 ++++ .../jboss/seam/solder/test/logging/Hawk.java | 31 ++++ .../test/logging/LoggerInjectionTest.java | 88 +++++++++ .../seam/solder/test/logging/NonBean.java | 32 ++++ .../jboss/seam/solder/test/logging/Owl.java | 28 +++ .../jboss/seam/solder/test/logging/Raven.java | 36 ++++ .../seam/solder/test/logging/Sparrow.java | 35 ++++ .../TypedMessageLoggerInjectionTest.java | 69 +++++++ .../jboss/seam/solder/test/logging/Wren.java | 36 ++++ .../solder/test/messages/BirdMessages.java | 26 +++ .../seam/solder/test/messages/FrenchJay.java | 35 ++++ .../jboss/seam/solder/test/messages/Jay.java | 33 ++++ .../TypedMessageBundleInjectionTest.java | 52 ++++++ .../test/properties/ClassToIntrospect.java | 73 ++++++++ .../properties/PropertyFromMethodTest.java | 110 ++++++++++++ .../solder/test/properties/query/Person.java | 38 ++++ .../properties/query/PropertyQueryTest.java | 77 ++++++++ .../test/reflection/PrimitiveTypesTest.java | 54 ++++++ .../test/reflection/ReflectionsTest.java | 117 ++++++++++++ .../solder/test/reflection/model/Cat.java | 44 +++++ .../test/resourceLoader/ResourceClient.java | 34 ++++ .../resourceLoader/ResourceLoaderTest.java | 140 +++++++++++++++ .../serviceHandler/DecoratedEchoService.java | 31 ++++ .../DecoratedEchoServiceHandler.java | 32 ++++ .../serviceHandler/DecoratedHelloWorld.java | 22 +++ .../test/serviceHandler/EchoDecorator.java | 23 +++ .../test/serviceHandler/EchoService.java | 28 +++ .../serviceHandler/EchoServiceHandler.java | 27 +++ .../test/serviceHandler/GoodbyeWorld.java | 27 +++ .../test/serviceHandler/HelloWorld.java | 22 +++ .../serviceHandler/ServiceHandlerTest.java | 66 +++++++ .../solder/test/unwraps/BeanProducer.java | 30 ++++ .../jboss/seam/solder/test/unwraps/Lion.java | 36 ++++ .../seam/solder/test/unwraps/LionTamer.java | 55 ++++++ .../seam/solder/test/unwraps/MPType.java | 25 +++ .../solder/test/unwraps/ManagedReceiver.java | 38 ++++ .../solder/test/unwraps/ProducedBean.java | 32 ++++ .../test/unwraps/ProducedInterface.java | 23 +++ .../seam/solder/test/unwraps/UnwrapsTest.java | 61 +++++++ .../jboss/seam/solder/test/util/Animal.java | 27 +++ .../jboss/seam/solder/test/util/Animals.java | 31 ++++ .../seam/solder/test/util/AnnotatedClass.java | 24 +++ .../test/util/AnnotationInspectorTest.java | 109 ++++++++++++ .../util/AnnotationInstanceProviderTest.java | 129 ++++++++++++++ .../org/jboss/seam/solder/test/util/Cat.java | 32 ++++ .../seam/solder/test/util/Deployments.java | 39 ++++ .../solder/test/util/IntMemberAnnotation.java | 27 +++ .../util/MavenArtifactPathResolverTest.java | 145 +++++++++++++++ .../test/util/MavenArtifactResolver.java | 148 +++++++++++++++ .../solder/test/util/MultipleMembers.java | 41 +++++ .../solder/test/util/SimpleAnnotation.java | 25 +++ .../util/collections/CompilerBugTest.java | 32 ++++ .../services/javax.el.ExpressionFactory | 1 + .../base/src/main/resources/arquillian.xml | 26 +++ .../base/src/main/resources/com/acme/foo1 | 1 + .../main/resources/com/acme/foo2.properties | 2 + .../base/src/main/resources/jndi.properties | 4 + .../test/bean/generic/alternative/beans.xml | 8 + .../messages/BirdMessages.i18n_fr.properties | 1 + testsuite/internals/jbossas/pom.xml | 168 ++++++++++++++++++ .../jbossas/src/test/resources/arquillian.xml | 37 ++++ testsuite/internals/pom.xml | 22 +++ testsuite/pom.xml | 80 +++++++++ 195 files changed, 8333 insertions(+) create mode 100644 testsuite/common/pom.xml create mode 100644 testsuite/internals/base/pom.xml create mode 100644 testsuite/internals/base/src/main/java/NoPackageClass.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/Airplane.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultProducers.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/NonDefaultProducers.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/Vehicle.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Bam.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Big.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Boom.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Bop.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/DisabledAlternativeProducer.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/EnabledAlternativeProducer.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/OnomatopoeiaProducer.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Pow.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Small.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Bar.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Baz.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Burt.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/BurtSubclass.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Corge.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Foo.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/FooLiteral.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Fred.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Garply.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanProducer.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Message.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/MessageLiteral.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Plugh.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Qux.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Service.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Waldo.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/WaldoName.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Wibble.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Wobble.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Bar.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Baz.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Burt.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Corge.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Foo.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/FooLiteral.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Formatted.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Garply.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanProducer.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Kitchen.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/KitchenProducer.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Message.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Qux.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Room.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Service.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Sink.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Waldo.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/WaldoName.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Bar.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Baz.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Corge.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Foo.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/GenericBeanProducer.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/GenericBeanTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Message.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/BorderCollie.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/CoreTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/Dog.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedCustomNamedBean.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedModelBean.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedNamedBean.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedToTargetNamedBean.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/Greyhound.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/InstalledService.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/NamedBean.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/RaceTrack.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/fullyqualified/FullyQualifiedFromPackageNamedBean.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/fullyqualified/package-info.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/package-info.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/CommonInterface.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Jaguar.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Lion.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Tiger.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBean.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithFieldDependency.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithReturnTypeDependency.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithSupertypeDependency.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBean.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithFieldDependency.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithReturnTypeDependency.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithSupertypeDependency.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/package-info.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/pkg/OptionalBeanWithPackageLevelDependencies.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/pkg/package-info.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/veto/Tiger.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/veto/package-info.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/BigLaptopHardDrive.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/CDDrive.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/CPU.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/ChipManufacturer.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DVDDrive.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/FloppyDrive.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/GPU.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDrive.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDriveFactory.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDriveImpl.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/LaptopHardDrive.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/MagneticDrive.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/OpticalDrive.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SASHardDrive.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SmallHardDriveFactory.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SuperChargedCPU.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/WriteEvent.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/CustomELResolver.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/ElTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/Ute.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/BarInterceptor.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/Foo.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/FooInterceptor.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/InterceptorTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/PrimaryInterceptionBinding.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BaldEagle.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BirdLogger.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BirdMessages.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Finch.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Hawk.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/NonBean.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Owl.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Raven.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Sparrow.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Wren.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/BirdMessages.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/FrenchJay.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/Jay.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/ClassToIntrospect.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/PropertyFromMethodTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/query/Person.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/query/PropertyQueryTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/PrimitiveTypesTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/ReflectionsTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/model/Cat.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceClient.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedEchoService.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedEchoServiceHandler.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedHelloWorld.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoDecorator.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoService.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoServiceHandler.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/GoodbyeWorld.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/HelloWorld.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/BeanProducer.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/Lion.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/LionTamer.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/MPType.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ManagedReceiver.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ProducedBean.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ProducedInterface.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Animal.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Animals.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotatedClass.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInstanceProviderTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Cat.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Deployments.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/IntMemberAnnotation.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MavenArtifactPathResolverTest.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MavenArtifactResolver.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MultipleMembers.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/SimpleAnnotation.java create mode 100644 testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/collections/CompilerBugTest.java create mode 100644 testsuite/internals/base/src/main/resources/META-INF/services/javax.el.ExpressionFactory create mode 100644 testsuite/internals/base/src/main/resources/arquillian.xml create mode 100644 testsuite/internals/base/src/main/resources/com/acme/foo1 create mode 100644 testsuite/internals/base/src/main/resources/com/acme/foo2.properties create mode 100644 testsuite/internals/base/src/main/resources/jndi.properties create mode 100644 testsuite/internals/base/src/main/resources/org/jboss/seam/solder/test/bean/generic/alternative/beans.xml create mode 100644 testsuite/internals/base/src/main/resources/org/jboss/seam/solder/test/messages/BirdMessages.i18n_fr.properties create mode 100644 testsuite/internals/jbossas/pom.xml create mode 100644 testsuite/internals/jbossas/src/test/resources/arquillian.xml create mode 100644 testsuite/internals/pom.xml create mode 100644 testsuite/pom.xml diff --git a/testsuite/common/pom.xml b/testsuite/common/pom.xml new file mode 100644 index 00000000..7406ff1e --- /dev/null +++ b/testsuite/common/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + + org.jboss.seam.solder + seam-solder-testsuite + 3.1.0-SNAPSHOT + ../pom.xml + + + seam-solder-testsuite-common + Seam Solder Test Suite Common + jar + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-api-maven + provided + + + diff --git a/testsuite/internals/base/pom.xml b/testsuite/internals/base/pom.xml new file mode 100644 index 00000000..858f473f --- /dev/null +++ b/testsuite/internals/base/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + + + org.jboss.seam.solder + seam-solder-testsuite-integration-internals + 3.1.0-SNAPSHOT + ../pom.xml + + + seam-solder-testsuite-integration-internals-base + Seam Solder Test Suite: Internals Integration Tests Base + jar + + + + + org.jboss.seam.solder + seam-solder-testsuite-common + provided + + + + org.jboss.arquillian.junit + arquillian-junit-container + provided + + + + + org.glassfish.web + el-impl + compile + + + + org.jboss.seam.solder + seam-solder-api + + + + org.jboss.seam.solder + seam-solder + provided + + + + org.jboss.spec + jboss-javaee-6.0 + pom + provided + + + + junit + junit + provided + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + diff --git a/testsuite/internals/base/src/main/java/NoPackageClass.java b/testsuite/internals/base/src/main/java/NoPackageClass.java new file mode 100644 index 00000000..4da16092 --- /dev/null +++ b/testsuite/internals/base/src/main/java/NoPackageClass.java @@ -0,0 +1,11 @@ +import org.jboss.seam.solder.test.core.CoreTest; + +/** + * Used by {@link CoreTest} to verify that Seam Solder does not fail with NPE when + * a BDA contains a no-package class. + * + * @author Jozef Hartinger + * @see https://issues.jboss.org/browse/SOLDER-80 + */ +public class NoPackageClass { +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/Airplane.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/Airplane.java new file mode 100644 index 00000000..f180ccd5 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/Airplane.java @@ -0,0 +1,29 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.defaultbean; + +public class Airplane { + private String name; + + public Airplane(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java new file mode 100644 index 00000000..fc442428 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java @@ -0,0 +1,110 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.defaultbean; + +import static org.junit.Assert.assertEquals; + +import javax.enterprise.inject.spi.Extension; +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.seam.logging.Category; +import org.jboss.seam.solder.logging.internal.Logger; +import org.jboss.seam.solder.bean.Beans; +import org.jboss.seam.solder.bean.defaultbean.DefaultBeanExtension; +import org.jboss.seam.solder.bean.generic.GenericBeanExtension; +import org.jboss.seam.solder.beanManager.BeanManagerAware; +import org.jboss.seam.solder.core.Client; +import org.jboss.seam.solder.core.CoreExtension; +import org.jboss.seam.solder.el.Resolver; +import org.jboss.seam.solder.literal.DefaultLiteral; +import org.jboss.seam.solder.logging.TypedMessageLoggerExtension; +import org.jboss.seam.solder.messages.Messages; +import org.jboss.seam.solder.reflection.Synthetic; +import org.jboss.seam.solder.resourceLoader.ResourceLoader; +import org.jboss.seam.solder.serviceHandler.ServiceHandlerExtension; +import org.jboss.seam.solder.support.SolderMessages; +import org.jboss.seam.solder.test.properties.ClassToIntrospect; +import org.jboss.seam.solder.unwraps.UnwrapsExtension; +import org.jboss.seam.solder.util.Sortable; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * This test verifies that {@link @GenericBean} works as expected. + * + * @author Jozef Hartinger + */ +@RunWith(Arquillian.class) +public class DefaultBeanTest { + @Inject + private Airplane airplane; + @Inject + private Vehicle vehicle; + + @Deployment + public static WebArchive createDeployment() { + WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war"); + war.addPackage(DefaultBeanTest.class.getPackage()); + war.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + war.addAsLibrary(createSeamSolder()); + return war; + } + + /** + * Seam Solder TODO: there must be a better way to get Solder jar + */ + public static JavaArchive createSeamSolder() { + JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "solder.jar"); + + jar.addPackages(true, Beans.class.getPackage()); // .bean + jar.addPackages(true, BeanManagerAware.class.getPackage()); // .beanManager + jar.addPackages(true, Client.class.getPackage()); // .core + jar.addPackages(true, Resolver.class.getPackage()); // .el + jar.addPackages(true, DefaultLiteral.class.getPackage()); // .literal + jar.addPackages(true, Category.class.getPackage()); // .log + jar.addPackages(true, Messages.class.getPackage()); // .logging + jar.addPackages(true, ClassToIntrospect.class.getPackage()); // .properties + jar.addPackages(true, SolderMessages.class.getPackage()); // .messages + jar.addPackages(true, Synthetic.class.getPackage()); // .reflection + jar.addPackages(true, ResourceLoader.class.getPackage()); // .resourceLoader + jar.addPackages(true, ServiceHandlerExtension.class.getPackage()); // .serviceHandler + jar.addPackages(true, UnwrapsExtension.class.getPackage()); // .unwraps + jar.addPackages(true, Sortable.class.getPackage()); // .util + jar.addPackages(false, Logger.class.getPackage()); // org.jboss.seam.solder.logging.internal + + jar.addAsServiceProvider(Extension.class, GenericBeanExtension.class, DefaultBeanExtension.class, CoreExtension.class, + UnwrapsExtension.class, TypedMessageLoggerExtension.class, ServiceHandlerExtension.class); + jar.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + return jar; + } + + @Test + public void testDefaultProducerUsed() { + assertEquals("Cessna 172", airplane.getName()); + } + + @Test + public void testDefaultProducerNotUsed() { + assertEquals("Seat Ibiza", vehicle.getName()); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultProducers.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultProducers.java new file mode 100644 index 00000000..d55c130e --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultProducers.java @@ -0,0 +1,35 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.defaultbean; + +import javax.enterprise.inject.Produces; + +import org.jboss.seam.solder.bean.defaultbean.DefaultBean; + +public class DefaultProducers { + @Produces + @DefaultBean(Airplane.class) + public Airplane createAirplane() { + return new Airplane("Cessna 172"); + } + + @Produces + @DefaultBean(Vehicle.class) + public Vehicle createVehicle() { + return new Vehicle("Honda Civic"); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/NonDefaultProducers.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/NonDefaultProducers.java new file mode 100644 index 00000000..1e3c38c1 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/NonDefaultProducers.java @@ -0,0 +1,26 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.defaultbean; + +import javax.enterprise.inject.Produces; + +public class NonDefaultProducers { + @Produces + public Vehicle createVehicle() { + return new Vehicle("Seat Ibiza"); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/Vehicle.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/Vehicle.java new file mode 100644 index 00000000..989d9564 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/Vehicle.java @@ -0,0 +1,29 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.defaultbean; + +public class Vehicle { + private String name; + + public Vehicle(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Bam.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Bam.java new file mode 100644 index 00000000..d2a70e03 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Bam.java @@ -0,0 +1,39 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.alternative; + + +public class Bam { + private String name; + + public Bam() { + + } + + public Bam(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Big.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Big.java new file mode 100644 index 00000000..a21ed714 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Big.java @@ -0,0 +1,36 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.alternative; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * a qualifier + * + * @author stuart + */ +@Retention(RetentionPolicy.RUNTIME) +@Qualifier +@Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD, ElementType.TYPE}) +public @interface Big { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Boom.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Boom.java new file mode 100644 index 00000000..04008ebf --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Boom.java @@ -0,0 +1,33 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.alternative; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import org.jboss.seam.solder.bean.generic.GenericType; + +/** + * Generic config annotation + * + * @author stuart + */ +@GenericType(Bam.class) +@Retention(RetentionPolicy.RUNTIME) +public @interface Boom { + String value(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Bop.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Bop.java new file mode 100644 index 00000000..27590426 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Bop.java @@ -0,0 +1,36 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.alternative; + +/** + * class that is created by a generic producer method + * + * @author Stuart Douglas + */ +public class Bop { + private final String name; + + public Bop(String name) { + super(); + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/DisabledAlternativeProducer.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/DisabledAlternativeProducer.java new file mode 100644 index 00000000..160320c9 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/DisabledAlternativeProducer.java @@ -0,0 +1,37 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.alternative; + +import javax.enterprise.inject.Alternative; +import javax.enterprise.inject.Produces; + +/** + * Produces the disabled alternative generic beans + * + * @author stuart + */ +@Alternative +public class DisabledAlternativeProducer { + + @Boom("Alternative Small") + @Small + @Alternative + @Produces + public Bam getSmallBam() { + return new Bam("Alternative Small Bam"); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/EnabledAlternativeProducer.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/EnabledAlternativeProducer.java new file mode 100644 index 00000000..6a71c9ff --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/EnabledAlternativeProducer.java @@ -0,0 +1,37 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.alternative; + +import javax.enterprise.inject.Alternative; +import javax.enterprise.inject.Produces; + +/** + * Produces the enabled alternative generic beans + * + * @author stuart + */ +@Alternative +public class EnabledAlternativeProducer { + @Boom("Alternative Big") + @Big + @Alternative + @Produces + public Bam getBigBam() { + return new Bam("Alternative Big Bam"); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java new file mode 100644 index 00000000..66fb3f39 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java @@ -0,0 +1,67 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.alternative; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; + +import javax.inject.Inject; + +import junit.framework.Assert; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +public class GenericBeanAlternativeTest { + @Deployment + public static WebArchive deployment() { + return baseDeployment().addPackage(GenericBeanAlternativeTest.class.getPackage()).addAsWebInfResource( + "org/jboss/seam/solder/test/bean/generic/alternative/beans.xml", "beans.xml"); + } + + @Inject + @Big + Pow bigPow; + + @Inject + @Small + Pow smallPow; + + @Inject + @Big + Bop bigBop; + + @Inject + @Small + Bop smallBop; + + @Test + public void testGenericAlternatives() { + Assert.assertEquals("Alternative Big Bam", bigPow.getName()); + Assert.assertEquals("Small Bam", smallPow.getName()); + } + + @Test + public void testGenericProducerMethodAlternatives() { + Assert.assertEquals("Alternative Big Bam", bigBop.getName()); + Assert.assertEquals("Small Bam", smallBop.getName()); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/OnomatopoeiaProducer.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/OnomatopoeiaProducer.java new file mode 100644 index 00000000..e0d683ac --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/OnomatopoeiaProducer.java @@ -0,0 +1,40 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.alternative; + +import javax.enterprise.inject.Produces; + +/** + * Produces the default non-alternative generic beans + * + * @author stuart + */ +public class OnomatopoeiaProducer { + @Boom("Big") + @Big + @Produces + public Bam getBigBam() { + return new Bam("Big Bam"); + } + + @Boom("Small") + @Small + @Produces + public Bam getSmallBam() { + return new Bam("Small Bam"); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Pow.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Pow.java new file mode 100644 index 00000000..5ed16064 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Pow.java @@ -0,0 +1,39 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.alternative; + +import javax.enterprise.inject.Produces; +import javax.inject.Inject; + +import org.jboss.seam.solder.bean.generic.Generic; +import org.jboss.seam.solder.bean.generic.GenericConfiguration; + +@GenericConfiguration(Boom.class) +public class Pow { + @Inject + @Generic + Bam bam; + + public String getName() { + return bam.getName(); + } + + @Produces + public Bop createBop() { + return new Bop(bam.getName()); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Small.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Small.java new file mode 100644 index 00000000..9b0695f8 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/Small.java @@ -0,0 +1,36 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.alternative; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * a qualifier + * + * @author stuart + */ +@Retention(RetentionPolicy.RUNTIME) +@Qualifier +@Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD, ElementType.TYPE}) +public @interface Small { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Bar.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Bar.java new file mode 100644 index 00000000..2617b3c1 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Bar.java @@ -0,0 +1,58 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import java.io.Serializable; + +import javax.enterprise.inject.Produces; +import javax.inject.Inject; + +import org.jboss.seam.solder.bean.generic.Generic; +import org.jboss.seam.solder.bean.generic.GenericConfiguration; + +/** + * A generic bean for the config annotation Message + * + * @author pmuir + */ + +@GenericConfiguration(Message.class) +public class Bar implements Serializable { + + private static final long serialVersionUID = -6679070875886826999L; + + @Inject + @Generic + private Message injectedMessage; + + // A Message with no @Inject + private Message message; + + public Message getInjectedMessage() { + return injectedMessage; + } + + public Message getMessage() { + return message; + } + + @Produces + @Qux + public String getBarMessage() { + return "bar" + getInjectedMessage().value(); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Baz.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Baz.java new file mode 100644 index 00000000..096af14e --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Baz.java @@ -0,0 +1,93 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import java.io.Serializable; + +import javax.enterprise.event.Observes; +import javax.enterprise.inject.Any; +import javax.enterprise.inject.Produces; +import javax.inject.Inject; + +import org.jboss.seam.solder.bean.generic.ApplyScope; +import org.jboss.seam.solder.bean.generic.Generic; +import org.jboss.seam.solder.bean.generic.GenericConfiguration; +import org.jboss.seam.solder.unwraps.Unwraps; + +/** + * A generic bean for the config annotation Message + * + * @author pmuir + */ + +@GenericConfiguration(Message.class) +@ApplyScope +public class Baz implements Serializable { + + private static final long serialVersionUID = 6807449196645110050L; + + private Fred fred = new Fred("Hello Fred"); + + @Inject + @Generic + private Bar bar; + + @Inject + private Corge corge; + + @Inject + @Generic + private Message message; + + public Bar getBar() { + return bar; + } + + public Corge getCorge() { + return corge; + } + + public Message getMessage() { + return message; + } + + @Produces + @Wibble + public String getCorge(Wobble wobble) { + return wobble.getName() + message.value(); + } + + @Unwraps + public Fred getFred() { + return fred; + } + + public void observe(@Observes @Any Plugh event) { + // Set the message if we are in a generic bean + if (message != null) { + event.setMessage(message); + } + // Set the message if not previously + else if (event.getMessage() == null) { + event.setMessage(new MessageLiteral("base")); + } + } + + public void setFred(Fred fred) { + this.fred = fred; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Burt.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Burt.java new file mode 100644 index 00000000..ccb6c282 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Burt.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +public class Burt { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/BurtSubclass.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/BurtSubclass.java new file mode 100644 index 00000000..4ddd75f3 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/BurtSubclass.java @@ -0,0 +1,24 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + + +@Foo(5) +@Message("hello5") +public class BurtSubclass extends Burt { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Corge.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Corge.java new file mode 100644 index 00000000..b71f2a88 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Corge.java @@ -0,0 +1,34 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import java.io.Serializable; + +/** + * A normal bean + * + * @author pmuir + */ +public class Corge implements Serializable { + + private static final long serialVersionUID = 8211199638181988551L; + + public String getName() { + return "fred"; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Foo.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Foo.java new file mode 100644 index 00000000..9efebd25 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Foo.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * A qualifier + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@Qualifier +public @interface Foo { + int value(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/FooLiteral.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/FooLiteral.java new file mode 100644 index 00000000..161f0db0 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/FooLiteral.java @@ -0,0 +1,33 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import javax.enterprise.util.AnnotationLiteral; + +public class FooLiteral extends AnnotationLiteral implements Foo { + + private final int value; + + public FooLiteral(int value) { + this.value = value; + } + + public int value() { + return value; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Fred.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Fred.java new file mode 100644 index 00000000..d00e35c5 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Fred.java @@ -0,0 +1,35 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +public class Fred { + private final String value; + + // need to make fred proxiable + public Fred() { + value = null; + } + + public Fred(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Garply.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Garply.java new file mode 100644 index 00000000..e6008aec --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Garply.java @@ -0,0 +1,61 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + + +import javax.enterprise.inject.Produces; +import javax.enterprise.inject.spi.AnnotatedMember; +import javax.inject.Inject; + +import org.jboss.seam.solder.bean.generic.Generic; +import org.jboss.seam.solder.bean.generic.GenericConfiguration; + +/** + * A generic bean for the config annotation Message + * + * @author pmuir + */ + +@GenericConfiguration(Service.class) +public class Garply { + + @Inject + @Generic + private Waldo waldo; + + @Inject + @Generic + private AnnotatedMember annotatedMember; + + + @Produces + @WaldoName + public String getWaldoName() { + return waldo.getName(); + } + + + public Waldo getWaldo() { + return waldo; + } + + public AnnotatedMember getAnnotatedMember() { + return annotatedMember; + } + + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanProducer.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanProducer.java new file mode 100644 index 00000000..9eaffdae --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanProducer.java @@ -0,0 +1,66 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import javax.enterprise.context.SessionScoped; +import javax.enterprise.inject.Produces; + +/** + * A producer of generic beans + * + * @author pmuir + */ +public class GenericBeanProducer { + @SuppressWarnings("unused") + @Foo(1) + @Produces + @Message("hello1") + private Burt burt1; + + @SuppressWarnings("unused") + @Foo(2) + @Produces + @Message("hello2") + private Burt burt2; + + @SuppressWarnings("unused") + @Foo(3) + @Produces + @Message("hello3") + @SessionScoped + private Burt baz3; + + @SuppressWarnings("unused") + @Foo(4) + @Produces + @Message("hello4") + @SessionScoped + private Burt baz4; + + @SuppressWarnings("unused") + @Foo(1) + @Produces + @Service(1) + private Waldo waldo1 = new Waldo("Pete"); + + @SuppressWarnings("unused") + @Foo(2) + @Produces + @Service(2) + private Waldo waldo2 = new Waldo("Stuart"); + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java new file mode 100644 index 00000000..32d3925c --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java @@ -0,0 +1,114 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; + +@RunWith(Arquillian.class) +public class GenericBeanTest { + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(GenericBeanTest.class.getPackage()); + } + + @Inject + @Foo(1) + private Baz baz1; + + @Inject + @Foo(2) + private Baz baz2; + + @Inject + @Foo(1) + private Bar bar1; + + @Inject + @Foo(2) + private Bar bar2; + + @Inject + @Foo(3) + private Baz baz3; + + @Inject + @Foo(3) + private Baz baz3a; + + @Inject + @Foo(4) + private Baz baz4; + + @Inject + @Foo(4) + private Baz baz4a; + + @Inject + @Foo(5) + private Baz baz5; + + @Test + public void testGeneric() { + // Check that normal bean injection is working correctly! + assertNotNull(baz2.getCorge()); + assertEquals(baz2.getCorge().getName(), "fred"); + + // Test that the generic configuration injection wiring is working for bar + assertNotNull(bar1.getInjectedMessage()); + assertEquals(bar1.getInjectedMessage().value(), "hello1"); + assertNotNull(bar2.getInjectedMessage()); + assertEquals(bar2.getInjectedMessage().value(), "hello2"); + + // Check that the generic configuration injection wiring is working for baz + assertNotNull(baz1.getMessage()); + assertEquals(baz1.getMessage().value(), "hello1"); + assertNotNull(baz2.getMessage()); + assertEquals(baz2.getMessage().value(), "hello2"); + + assertNotNull(baz5.getMessage()); + assertEquals(baz5.getMessage().value(), "hello5"); + + // Check that this isn't affecting annotations on the generic bean without @Inject + assertNull(baz1.getBar().getMessage()); + assertNull(baz2.getBar().getMessage()); + + } + + @Test + public void testScope() { + assertNotSame(baz1.getCorge(), baz2.getCorge()); + assertNotNull(baz3); + assertNotNull(baz3a); + assertEquals(baz3.getCorge(), baz3a.getCorge()); + assertNotNull(baz4); + assertNotNull(baz4a); + assertEquals(baz4.getCorge(), baz4a.getCorge()); + assertNotSame(baz3.getCorge(), baz4.getCorge()); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java new file mode 100644 index 00000000..c43d86fe --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java @@ -0,0 +1,52 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import javax.inject.Inject; + +import junit.framework.Assert; +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; + +@RunWith(Arquillian.class) +public class GenericBeanUnwrapTest { + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(GenericBeanUnwrapTest.class.getPackage()); + } + + @Inject + @Foo(3) + private Baz baz3; + + @Inject + @Foo(3) + private Fred fred; + + + @Test + public void testGenericUnwrap() { + Assert.assertEquals("Hello Fred", fred.getValue()); + baz3.setFred(new Fred("Goodbye Fred")); + Assert.assertEquals("Goodbye Fred", fred.getValue()); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java new file mode 100644 index 00000000..3db1a45d --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java @@ -0,0 +1,93 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +@RunWith(Arquillian.class) +public class GenericProductTest { + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(GenericProductTest.class.getPackage()); + } + + @Inject + @Foo(1) + private Garply garply1; + + @Inject + @Foo(2) + private Garply garply2; + + @Inject + @Foo(1) + private Waldo waldo1; + + @Inject + @Foo(2) + private Waldo waldo2; + + @Inject + @Foo(1) + @WaldoName + private String waldoName1; + + @Inject + @Foo(2) + @WaldoName + private String waldoName2; + + @Test + public void testGeneric() { + + // Check injection of product + assertNotNull(waldo1); + assertNotNull(waldo2); + assertEquals("Pete", waldo1.getName()); + assertEquals("Stuart", waldo2.getName()); + + assertNotNull(garply1); + assertNotNull(garply2); + + assertEquals("Pete", garply1.getWaldo().getName()); + assertEquals("Stuart", garply2.getWaldo().getName()); + + assertEquals("Pete", waldoName1); + assertEquals("Stuart", waldoName2); + + // Check injection of generic product injection point + assertNotNull(garply1.getAnnotatedMember()); + assertTrue(garply1.getAnnotatedMember().isAnnotationPresent(Service.class)); + assertEquals(1, garply1.getAnnotatedMember().getAnnotation(Service.class).value()); + + assertNotNull(garply2.getAnnotatedMember()); + assertTrue(garply2.getAnnotatedMember().isAnnotationPresent(Service.class)); + assertEquals(2, garply2.getAnnotatedMember().getAnnotation(Service.class).value()); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Message.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Message.java new file mode 100644 index 00000000..f11d978a --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Message.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.jboss.seam.solder.bean.generic.GenericType; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * The annotation used to configure a generic bean + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@GenericType(Burt.class) +public @interface Message { + String value(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/MessageLiteral.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/MessageLiteral.java new file mode 100644 index 00000000..7f54fe97 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/MessageLiteral.java @@ -0,0 +1,33 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import javax.enterprise.util.AnnotationLiteral; + +public class MessageLiteral extends AnnotationLiteral implements Message { + + private final String value; + + public MessageLiteral(String value) { + this.value = value; + } + + public String value() { + return value; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java new file mode 100644 index 00000000..7e21b75a --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java @@ -0,0 +1,63 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import javax.enterprise.event.Event; +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(Arquillian.class) +public class ObserversOnGenericBeanTest { + + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(ObserversOnGenericBeanTest.class.getPackage()); + } + + @Inject + private Event plughEvent; + + @Test + public void testGeneric() { + + + // Check specific observers are invoked + Plugh plugh1 = new Plugh(); + plughEvent.select(new FooLiteral(1)).fire(plugh1); + assertEquals("hello1", plugh1.getMessage().value()); + + Plugh plugh2 = new Plugh(); + plughEvent.select(new FooLiteral(2)).fire(plugh2); + assertEquals("hello2", plugh2.getMessage().value()); + + // Check that the base observer is invoked + Plugh basePlugh = new Plugh(); + plughEvent.fire(basePlugh); + assertNotNull(basePlugh.getMessage()); + assertEquals("base", basePlugh.getMessage().value()); + + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Plugh.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Plugh.java new file mode 100644 index 00000000..88b73cfc --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Plugh.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +public class Plugh { + + private Message message; + + public Message getMessage() { + return message; + } + + public void setMessage(Message message) { + this.message = message; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java new file mode 100644 index 00000000..10148385 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java @@ -0,0 +1,87 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(Arquillian.class) +public class ProducersOnGenericBeanTest { + + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(ProducersOnGenericBeanTest.class.getPackage()); + } + + @Inject + @Qux + @Foo(1) + private String bar1Message; + + @Inject + @Qux + @Foo(2) + private String bar2Message; + + @Inject + @Foo(1) + private Message baz1Message; + + @Inject + @Foo(2) + private Message baz2Message; + + @Inject + @Foo(1) + @Wibble + private String wibble1; + + @Inject + @Foo(2) + @Wibble + private String wibble2; + + @Test + public void testGeneric() { + + // Check that producer methods on generic beans are working + assertNotNull(bar1Message); + assertEquals("barhello1", bar1Message); + assertNotNull(bar2Message); + assertEquals("barhello2", bar2Message); + + assertNotNull(baz1Message); + assertEquals("hello1", baz1Message.value()); + assertNotNull(baz2Message); + assertEquals("hello2", baz2Message.value()); + + assertNotNull(wibble1); + assertEquals("billhello1", wibble1); + assertNotNull(wibble2); + assertEquals("billhello2", wibble2); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Qux.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Qux.java new file mode 100644 index 00000000..9ff46648 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Qux.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * A qualifier + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@Qualifier +public @interface Qux { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Service.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Service.java new file mode 100644 index 00000000..e24f1bbb --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Service.java @@ -0,0 +1,43 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.jboss.seam.solder.bean.generic.GenericType; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * An annotation used to configure a generic bean + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@GenericType(Waldo.class) +public @interface Service { + + int value(); + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Waldo.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Waldo.java new file mode 100644 index 00000000..1b812aa0 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Waldo.java @@ -0,0 +1,40 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + + +/** + * The configuration class for the config annotation Message + * + * @author pmuir + */ +public class Waldo { + + private String name; + + public Waldo() { + } + + public Waldo(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/WaldoName.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/WaldoName.java new file mode 100644 index 00000000..78e15bac --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/WaldoName.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * A qualifier + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@Qualifier +public @interface WaldoName { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Wibble.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Wibble.java new file mode 100644 index 00000000..ea5d2cc6 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Wibble.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * A qualifier + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@Qualifier +public @interface Wibble { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Wobble.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Wobble.java new file mode 100644 index 00000000..70a68e62 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/Wobble.java @@ -0,0 +1,30 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.field; + +/** + * A normal bean + * + * @author pmuir + */ +public class Wobble { + + public String getName() { + return "bill"; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Bar.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Bar.java new file mode 100644 index 00000000..778fb5d1 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Bar.java @@ -0,0 +1,53 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import javax.enterprise.inject.Produces; +import javax.inject.Inject; + +import org.jboss.seam.solder.bean.generic.Generic; +import org.jboss.seam.solder.bean.generic.GenericConfiguration; + +/** + * A generic bean for the config annotation Message + * + * @author pmuir + */ + +@GenericConfiguration(Message.class) +public class Bar { + @Inject + @Generic + private Message injectedMessage; + + // A Message with no @Inject + private Message message; + + public Message getInjectedMessage() { + return injectedMessage; + } + + public Message getMessage() { + return message; + } + + @Produces + @Qux + public String getBarMessage() { + return "bar" + getInjectedMessage().value(); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Baz.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Baz.java new file mode 100644 index 00000000..19307d13 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Baz.java @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import javax.inject.Inject; + +import org.jboss.seam.solder.bean.generic.Generic; +import org.jboss.seam.solder.bean.generic.GenericConfiguration; + +/** + * A generic bean for the config annotation Message + * + * @author pmuir + */ + +@GenericConfiguration(Message.class) +public class Baz { + + @Inject + @Generic + private Bar bar; + + @Inject + private Corge corge; + + @Inject + @Generic + private Message message; + + public Bar getBar() { + return bar; + } + + public Corge getCorge() { + return corge; + } + + public Message getMessage() { + return message; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Burt.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Burt.java new file mode 100644 index 00000000..50e8f538 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Burt.java @@ -0,0 +1,26 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +/** + * The config type for the @Service annotation + * + * @author stuart + */ +public class Burt { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Corge.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Corge.java new file mode 100644 index 00000000..0bd437c8 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Corge.java @@ -0,0 +1,30 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +/** + * A normal bean + * + * @author pmuir + */ +public class Corge { + + public String getName() { + return "fred"; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Foo.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Foo.java new file mode 100644 index 00000000..012a0f0b --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Foo.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * A qualifier + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@Qualifier +public @interface Foo { + int value(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/FooLiteral.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/FooLiteral.java new file mode 100644 index 00000000..287b51c7 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/FooLiteral.java @@ -0,0 +1,33 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import javax.enterprise.util.AnnotationLiteral; + +public class FooLiteral extends AnnotationLiteral implements Foo { + + private final int value; + + public FooLiteral(int value) { + this.value = value; + } + + public int value() { + return value; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Formatted.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Formatted.java new file mode 100644 index 00000000..d3fb30b0 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Formatted.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * A qualifier + * + * @author Stuart Douglas + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@Qualifier +public @interface Formatted { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Garply.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Garply.java new file mode 100644 index 00000000..7ddf697e --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Garply.java @@ -0,0 +1,83 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import java.util.HashMap; + +import javax.enterprise.inject.Disposes; +import javax.enterprise.inject.Produces; +import javax.inject.Inject; + +import junit.framework.Assert; +import org.jboss.seam.solder.bean.generic.Generic; +import org.jboss.seam.solder.bean.generic.GenericConfiguration; + +/** + * A generic bean for the config annotation Message + * + * @author pmuir + */ + +@GenericConfiguration(Service.class) +public class Garply { + + static boolean disposerCalled = false; + static boolean mapDisposerCalled = false; + + @Inject + @Generic + private Waldo waldo; + + @Produces + public HashMap getMap() { + return new HashMap(); + } + + @Produces + @WaldoName + public String getWaldoName() { + return waldo.getName(); + } + + @Produces + @Formatted + public String getFormattedWaldoName(@Generic Waldo waldo) { + return "[" + waldo.getName() + "]"; + } + + public void dispose(@Disposes @WaldoName String waldoName, @Generic Waldo waldo) { + disposerCalled = true; + Assert.assertEquals(waldo.getName(), waldoName); + } + + public void dispose(@Disposes HashMap map) { + mapDisposerCalled = true; + } + + public Waldo getWaldo() { + return waldo; + } + + public static boolean isDisposerCalled() { + return disposerCalled; + } + + public static boolean isMapDisposerCalled() { + return mapDisposerCalled; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanProducer.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanProducer.java new file mode 100644 index 00000000..a920e123 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanProducer.java @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import javax.enterprise.inject.Produces; + +/** + * A producer of generic beans + * + * @author pmuir + */ +public class GenericBeanProducer { + @Foo(1) + @Produces + @Message("hello1") + public Burt getBurt1() { + return null; + } + + @Foo(2) + @Produces + @Message("hello2") + public Burt getBurt2() { + return null; + } + + @Foo(1) + @Produces + @Service(1) + public Waldo getWaldo1() { + return new Waldo("Pete"); + } + + @Foo(2) + @Produces + @Service(2) + public Waldo getWaldo2() { + return new Waldo("Stuart"); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java new file mode 100644 index 00000000..4c0c6854 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java @@ -0,0 +1,79 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +@RunWith(Arquillian.class) +public class GenericBeanTest { + + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(GenericBeanTest.class.getPackage()); + } + + @Inject + @Foo(1) + private Baz baz1; + + @Inject + @Foo(2) + private Baz baz2; + + @Inject + @Foo(1) + private Bar bar1; + + @Inject + @Foo(2) + private Bar bar2; + + @Test + public void testGeneric() { + // Check that normal bean injection is working correctly! + assertNotNull(baz2.getCorge()); + assertEquals(baz2.getCorge().getName(), "fred"); + + // Test that the generic configuration injection wiring is working for bar + assertNotNull(bar1.getInjectedMessage()); + assertEquals(bar1.getInjectedMessage().value(), "hello1"); + assertNotNull(bar2.getInjectedMessage()); + assertEquals(bar2.getInjectedMessage().value(), "hello2"); + + // Check that the generic configuration injection wiring is working for baz + assertNotNull(baz1.getMessage()); + assertEquals(baz1.getMessage().value(), "hello1"); + assertNotNull(baz2.getMessage()); + assertEquals(baz2.getMessage().value(), "hello2"); + + // Check that this isn't affecting annotations on the generic bean without @Inject + assertNull(baz1.getBar().getMessage()); + assertNull(baz2.getBar().getMessage()); + + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java new file mode 100644 index 00000000..5ca76fd4 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java @@ -0,0 +1,119 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import java.util.HashMap; + +import javax.enterprise.context.spi.CreationalContext; +import javax.enterprise.inject.spi.Bean; +import javax.enterprise.inject.spi.BeanManager; +import javax.enterprise.util.AnnotationLiteral; +import javax.inject.Inject; + +import junit.framework.Assert; +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(Arquillian.class) +public class GenericProductTest { + + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(GenericProductTest.class.getPackage()); + } + + @Inject + @Foo(1) + private Garply garply1; + + @Inject + @Foo(2) + private Garply garply2; + + @Inject + @Foo(1) + private Waldo waldo1; + + @Inject + @Foo(2) + private Waldo waldo2; + + @Inject + @Foo(1) + @WaldoName + private String waldoName1; + + @Inject + @Foo(2) + @WaldoName + private String waldoName2; + + @Inject + @Foo(1) + @Formatted + private String formattedWaldoName1; + + @Inject + @Foo(2) + @Formatted + private String formattedWaldoName2; + + @Test + public void testGeneric() { + + // Check injection of product + assertNotNull(waldo1); + assertNotNull(waldo2); + assertEquals("Pete", waldo1.getName()); + assertEquals("Stuart", waldo2.getName()); + + assertNotNull(garply1); + assertNotNull(garply2); + + assertEquals("Pete", garply1.getWaldo().getName()); + assertEquals("Stuart", garply2.getWaldo().getName()); + + assertEquals("Pete", waldoName1); + assertEquals("Stuart", waldoName2); + + assertEquals("[Pete]", formattedWaldoName1); + assertEquals("[Stuart]", formattedWaldoName2); + } + + @Test + public void testDisposerCalled(BeanManager manager) { + Bean bean = manager.resolve(manager.getBeans(String.class, new AnnotationLiteral() { + }, new FooLiteral(1))); + CreationalContext ctx = manager.createCreationalContext(bean); + manager.getReference(bean, String.class, ctx); + ctx.release(); + Assert.assertTrue(Garply.disposerCalled); + + bean = manager.resolve(manager.getBeans(HashMap.class, new FooLiteral(1))); + ctx = manager.createCreationalContext(bean); + manager.getReference(bean, String.class, ctx); + ctx.release(); + Assert.assertTrue(Garply.isMapDisposerCalled()); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Kitchen.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Kitchen.java new file mode 100644 index 00000000..78a61728 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Kitchen.java @@ -0,0 +1,30 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +public class Kitchen { + private final String size; + + public Kitchen(String size) { + this.size = size; + } + + public String getSize() { + return size; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/KitchenProducer.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/KitchenProducer.java new file mode 100644 index 00000000..da82ae74 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/KitchenProducer.java @@ -0,0 +1,42 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import javax.enterprise.inject.Produces; + +/** + * configures the {@link Room} generic beans + * + * @author stuart + */ +public class KitchenProducer { + + @Foo(1) + @Produces + @Room + public Kitchen getBigKitchen() { + return new Kitchen("big"); + } + + @Foo(2) + @Produces + @Room + public Kitchen getSmallKitchen() { + return new Kitchen("small"); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Message.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Message.java new file mode 100644 index 00000000..7d09de14 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Message.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.jboss.seam.solder.bean.generic.GenericType; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * The annotation used to configure a generic bean + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@GenericType(Burt.class) +public @interface Message { + String value(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java new file mode 100644 index 00000000..1b237151 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java @@ -0,0 +1,86 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import java.util.HashMap; +import java.util.Map; + +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +@RunWith(Arquillian.class) +public class ProducersOnGenericBeanTest { + + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(ProducersOnGenericBeanTest.class.getPackage()); + } + + @Inject + @Qux + @Foo(1) + private String bar1Message; + + @Inject + @Qux + @Foo(2) + private String bar2Message; + + @Inject + @Foo(1) + private Message baz1Message; + + @Inject + @Foo(2) + private Message baz2Message; + + @Inject + @Foo(1) + private Map map; + + @Test + public void testGeneric() { + + // Check that producer methods on generic beans are working + assertNotNull(bar1Message); + assertEquals("barhello1", bar1Message); + assertNotNull(bar2Message); + assertEquals("barhello2", bar2Message); + + assertNotNull(baz1Message); + assertEquals("hello1", baz1Message.value()); + assertNotNull(baz2Message); + assertEquals("hello2", baz2Message.value()); + } + + @Test + // WELDX-133 + public void testProducerSuperclass() { + assertTrue(map instanceof HashMap); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java new file mode 100644 index 00000000..caed6203 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java @@ -0,0 +1,72 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(Arquillian.class) +public class QualifierOnlyGenericBeanTest { + + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(QualifierOnlyGenericBeanTest.class.getPackage()); + } + + @Inject + @Foo(1) + private Kitchen kitchen1; + + @Inject + @Foo(2) + private Kitchen kitchen2; + + @Inject + @Foo(1) + private Sink sink1; + + @Inject + @Foo(2) + private Sink sink2; + + + @Test + public void testGeneric() { + + // Check that producer methods on generic beans are working + assertNotNull(kitchen1); + assertEquals("big", kitchen1.getSize()); + assertNotNull(kitchen2); + assertEquals("small", kitchen2.getSize()); + + assertNotNull(sink1); + assertEquals("big", sink1.getKitchen().getSize()); + assertNotNull(sink2); + assertEquals("small", sink2.getKitchen().getSize()); + } + + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Qux.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Qux.java new file mode 100644 index 00000000..12c3692e --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Qux.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * A qualifier + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@Qualifier +public @interface Qux { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Room.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Room.java new file mode 100644 index 00000000..cbf41fd2 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Room.java @@ -0,0 +1,35 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.jboss.seam.solder.bean.generic.GenericType; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@GenericType(Kitchen.class) +public @interface Room { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Service.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Service.java new file mode 100644 index 00000000..042bac7d --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Service.java @@ -0,0 +1,43 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.jboss.seam.solder.bean.generic.GenericType; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * An annotation used to configure a generic bean + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@GenericType(Waldo.class) +public @interface Service { + + int value(); + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Sink.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Sink.java new file mode 100644 index 00000000..50c08648 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Sink.java @@ -0,0 +1,33 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import javax.inject.Inject; + +import org.jboss.seam.solder.bean.generic.Generic; +import org.jboss.seam.solder.bean.generic.GenericConfiguration; + +@GenericConfiguration(Room.class) +public class Sink { + @Inject + @Generic + private Kitchen kitchen; + + public Kitchen getKitchen() { + return kitchen; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Waldo.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Waldo.java new file mode 100644 index 00000000..6c5e80ba --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/Waldo.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +/** + * The config type for the config annotation Message + * + * @author pmuir + */ + + +public class Waldo { + + private String name; + + public Waldo() { + } + + public Waldo(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/WaldoName.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/WaldoName.java new file mode 100644 index 00000000..5a4c9ce3 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/WaldoName.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.method; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * A qualifier + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@Qualifier +public @interface WaldoName { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Bar.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Bar.java new file mode 100644 index 00000000..faa5ba8c --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Bar.java @@ -0,0 +1,30 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.tooManyGenericConfigurations; + +import org.jboss.seam.solder.bean.generic.GenericConfiguration; + +/** + * A generic bean for the config annotation Message + * + * @author pmuir + */ + +@GenericConfiguration(Message.class) +public class Bar { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Baz.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Baz.java new file mode 100644 index 00000000..1e020d10 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Baz.java @@ -0,0 +1,28 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.tooManyGenericConfigurations; + + +/** + * The config type for the config annotation Message + * + * @author pmuir + */ + +public class Baz { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Corge.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Corge.java new file mode 100644 index 00000000..874f8c5f --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Corge.java @@ -0,0 +1,30 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.tooManyGenericConfigurations; + +/** + * A normal bean + * + * @author pmuir + */ +public class Corge { + + public String getName() { + return "fred"; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Foo.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Foo.java new file mode 100644 index 00000000..158b8e5b --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Foo.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.tooManyGenericConfigurations; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * A qualifier + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@Qualifier +public @interface Foo { + int value(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/GenericBeanProducer.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/GenericBeanProducer.java new file mode 100644 index 00000000..942421f2 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/GenericBeanProducer.java @@ -0,0 +1,52 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.tooManyGenericConfigurations; + +import javax.enterprise.inject.Produces; + +/** + * A producer of generic beans + * + * @author pmuir + */ +public class GenericBeanProducer { + @SuppressWarnings("unused") + @Foo(1) + @Produces + @Message("hello1") + private Baz baz1; + + @SuppressWarnings("unused") + @Foo(2) + @Produces + @Message("hello2") + private Baz baz2; + + @SuppressWarnings("unused") + @Foo(1) + @Produces + @Message("hello1") + private Bar bar1; + + @SuppressWarnings("unused") + @Foo(2) + @Produces + @Message("hello2") + private Bar bar2; + + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/GenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/GenericBeanTest.java new file mode 100644 index 00000000..75d8be4f --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/GenericBeanTest.java @@ -0,0 +1,34 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.tooManyGenericConfigurations; + + +//@RunWith(Arquillian.class) +//public class GenericBeanTest +//{ +// @Deployment +// public static Archive deploy() +// { +// return ShrinkWrap.create("test.jar", JavaArchive.class).addPackage(GenericBeanTest.class.getPackage()); +// } +// +// //@Test(expected=Exception.class ) +// public void testGeneric() +// { +// assertFalse(true); +// } +//} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Message.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Message.java new file mode 100644 index 00000000..098ac72a --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/tooManyGenericConfigurations/Message.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.bean.generic.tooManyGenericConfigurations; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.jboss.seam.solder.bean.generic.GenericType; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * The annotation used to configure a generic bean + * + * @author pmuir + */ + +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +@GenericType(Baz.class) +public @interface Message { + String value(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/BorderCollie.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/BorderCollie.java new file mode 100644 index 00000000..37d1f347 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/BorderCollie.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core; + +public class BorderCollie extends Dog { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/CoreTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/CoreTest.java new file mode 100644 index 00000000..d2db84a0 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/CoreTest.java @@ -0,0 +1,123 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core; + +import java.beans.Introspector; +import java.util.Set; + +import javax.enterprise.context.spi.CreationalContext; +import javax.enterprise.inject.spi.Bean; +import javax.enterprise.inject.spi.BeanManager; +import javax.inject.Inject; + +import junit.framework.Assert; +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.seam.solder.core.CoreExtension; +import org.jboss.seam.solder.core.VersionLoggerUtil; +import org.jboss.seam.solder.literal.DefaultLiteral; +import org.jboss.seam.solder.test.core.fullyqualified.FullyQualifiedFromPackageNamedBean; +import org.jboss.seam.solder.test.core.requires.Lion; +import org.jboss.seam.solder.test.core.veto.Tiger; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; + +/** + * @author Stuart Douglas + */ +@RunWith(Arquillian.class) +public class CoreTest { + + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(CoreTest.class.getPackage()) + .addPackage(FullyQualifiedFromPackageNamedBean.class.getPackage()) + .addPackage(Lion.class.getPackage()) + .addPackage(Tiger.class.getPackage()) + .addClass("NoPackageClass"); + } + + @Inject + RaceTrack raceTrack; + + @Test + public void testExact() { + assert raceTrack.getDog() instanceof Greyhound; + } + + @Test + public void testBeanInstalled(BeanManager manager) { + Set> beans = manager.getBeans(InstalledService.class, DefaultLiteral.INSTANCE); + Bean bean = manager.resolve(beans); + CreationalContext ctx = manager.createCreationalContext(bean); + manager.getReference(bean, InstalledService.class, ctx); + } + + @Test + public void testPackageLevelVeto(BeanManager manager) { + Set> beans = manager.getBeans(Tiger.class, DefaultLiteral.INSTANCE); + Assert.assertEquals(0, beans.size()); + } + + @Test + public void testNamedPackages(BeanManager manager) { + Set> beans = manager.getBeans("raceTrack"); + Assert.assertEquals(1, beans.size()); + } + + @Test + public void testFullyQualifiedBeanNames(BeanManager manager) { + assertEquals(1, manager.getBeans(getBeanNameForType(NamedBean.class)).size()); + assertEquals(1, manager.getBeans(getQualifiedBeanNameForType(FullyQualifiedNamedBean.class)).size()); + assertEquals(1, manager.getBeans(getQualifiedBeanNameForType(FullyQualifiedModelBean.class)).size()); + assertEquals(1, manager.getBeans(qualifyBeanName("wordOfTheDay", FullyQualifiedModelBean.class.getPackage())).size()); + assertEquals(1, manager.getBeans(qualifyBeanName("model", FullyQualifiedModelBean.class.getPackage())).size()); + assertEquals(1, manager.getBeans(qualifyBeanName("size", FullyQualifiedModelBean.class.getPackage())).size()); + assertEquals(1, manager.getBeans(qualifyBeanName("custom", FullyQualifiedCustomNamedBean.class.getPackage())).size()); + assertEquals(1, manager.getBeans(getQualifiedBeanNameForType(FullyQualifiedToTargetNamedBean.class, CoreExtension.class.getPackage())).size()); + assertEquals(1, manager.getBeans(getQualifiedBeanNameForType(FullyQualifiedFromPackageNamedBean.class)).size()); + } + + @Test + public void testVersionInformation() { + String expected = String.format("a %s b %s", + CoreExtension.class.getPackage().getSpecificationVersion(), + CoreExtension.class.getPackage().getImplementationVersion()); + String actual = VersionLoggerUtil.createVersionMessage(CoreExtension.class, "a %s b %s"); + assertEquals(expected, actual); + } + + private String getQualifiedBeanNameForType(Class type, Package targetPackage) { + return targetPackage.getName() + "." + getBeanNameForType(type); + } + + private String getQualifiedBeanNameForType(Class type) { + return qualifyBeanName(getBeanNameForType(type), type.getPackage()); + } + + private String getBeanNameForType(Class type) { + return Introspector.decapitalize(type.getSimpleName()); + } + + private String qualifyBeanName(String name, Package pkg) { + return pkg.getName() + "." + name; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/Dog.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/Dog.java new file mode 100644 index 00000000..79328807 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/Dog.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core; + +public class Dog { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedCustomNamedBean.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedCustomNamedBean.java new file mode 100644 index 00000000..14ccff56 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedCustomNamedBean.java @@ -0,0 +1,26 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core; + +import javax.inject.Named; + +import org.jboss.seam.solder.core.FullyQualified; + +@FullyQualified +@Named("custom") +public class FullyQualifiedCustomNamedBean { +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedModelBean.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedModelBean.java new file mode 100644 index 00000000..813a1426 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedModelBean.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core; + +import javax.enterprise.inject.Model; +import javax.enterprise.inject.Produces; +import javax.inject.Named; + +import org.jboss.seam.solder.core.FullyQualified; + +@FullyQualified +@Model +public class FullyQualifiedModelBean { + @Produces + @FullyQualified + @Named + private boolean model = true; + + @Produces + @FullyQualified + @Named + public String getWordOfTheDay() { + return "Dragon"; + } + + @Produces + @FullyQualified + @Named + public Integer size() { + return 0; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedNamedBean.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedNamedBean.java new file mode 100644 index 00000000..04847264 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedNamedBean.java @@ -0,0 +1,26 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core; + +import javax.inject.Named; + +import org.jboss.seam.solder.core.FullyQualified; + +@FullyQualified +@Named +public class FullyQualifiedNamedBean { +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedToTargetNamedBean.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedToTargetNamedBean.java new file mode 100644 index 00000000..7542e7e8 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/FullyQualifiedToTargetNamedBean.java @@ -0,0 +1,27 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core; + +import javax.inject.Named; + +import org.jboss.seam.solder.core.CoreExtension; +import org.jboss.seam.solder.core.FullyQualified; + +@FullyQualified(CoreExtension.class) +@Named +public class FullyQualifiedToTargetNamedBean { +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/Greyhound.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/Greyhound.java new file mode 100644 index 00000000..76fc92e9 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/Greyhound.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core; + +public class Greyhound extends Dog { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/InstalledService.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/InstalledService.java new file mode 100644 index 00000000..8afc0c08 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/InstalledService.java @@ -0,0 +1,24 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core; + +import org.jboss.seam.solder.core.Requires; + +@Requires({"org.jboss.seam.solder.test.core.Greyhound", "org.jboss.seam.solder.test.core.CoreTest"}) +public class InstalledService { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/NamedBean.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/NamedBean.java new file mode 100644 index 00000000..687286a3 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/NamedBean.java @@ -0,0 +1,23 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core; + +import javax.inject.Named; + +@Named +public class NamedBean { +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/RaceTrack.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/RaceTrack.java new file mode 100644 index 00000000..ad27fbe8 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/RaceTrack.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core; + +import javax.inject.Inject; + +import org.jboss.seam.solder.core.Exact; + +public class RaceTrack { + @Inject + @Exact(Greyhound.class) + private Dog dog; + + public Dog getDog() { + return dog; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/fullyqualified/FullyQualifiedFromPackageNamedBean.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/fullyqualified/FullyQualifiedFromPackageNamedBean.java new file mode 100644 index 00000000..6d230823 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/fullyqualified/FullyQualifiedFromPackageNamedBean.java @@ -0,0 +1,23 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.fullyqualified; + +import javax.inject.Named; + +@Named +public class FullyQualifiedFromPackageNamedBean { +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/fullyqualified/package-info.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/fullyqualified/package-info.java new file mode 100644 index 00000000..954b599a --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/fullyqualified/package-info.java @@ -0,0 +1,20 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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. + */ +@FullyQualified package org.jboss.seam.solder.test.core.fullyqualified; + +import org.jboss.seam.solder.core.FullyQualified; + diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/package-info.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/package-info.java new file mode 100644 index 00000000..3d60d479 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/package-info.java @@ -0,0 +1,20 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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. + */ +@Named package org.jboss.seam.solder.test.core; + +import javax.inject.Named; + diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/CommonInterface.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/CommonInterface.java new file mode 100644 index 00000000..7d90ed31 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/CommonInterface.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires; + +public interface CommonInterface { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Jaguar.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Jaguar.java new file mode 100644 index 00000000..85a3cb6d --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Jaguar.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires; + +/** + * This class is never deployed to a standalone container. To prevent the class from being picked up in an embedded test run, + * its static initializer throws an exception. + * + * @author Jozef Hartinger + */ +public class Jaguar { + + static { + if (true) { + throw new RuntimeException(); + } + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Lion.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Lion.java new file mode 100644 index 00000000..56123b1f --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Lion.java @@ -0,0 +1,26 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires; + +/** + * The entire "beans" package depends on this class. + * + * @author Jozef Hartinger + */ +public class Lion { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java new file mode 100644 index 00000000..87c4b456 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java @@ -0,0 +1,95 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires; + +import javax.enterprise.inject.spi.BeanManager; +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.seam.solder.test.core.requires.beans.EnabledOptionalBean; +import org.jboss.seam.solder.test.core.requires.beans.pkg.OptionalBeanWithPackageLevelDependencies; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; + +@RunWith(Arquillian.class) +public class RequiresTest { + + @Inject + private BeanManager manager; + + @Deployment + public static WebArchive getDeployment() { + return baseDeployment().addClasses(CommonInterface.class, Tiger.class, Lion.class) + .addPackage(EnabledOptionalBean.class.getPackage()) + .addPackage(OptionalBeanWithPackageLevelDependencies.class.getPackage()); + } + + @Test + public void testEnabledOptionalBean() { + assertEquals(1, manager.getBeans("enabledOptionalBean").size()); + } + + @Test + public void testDisabledOptionalBean() { + assertEquals(0, manager.getBeans("disabledOptionalBean").size()); + } + + @Test + public void testEnabledOptionalBeanWithFieldDependency() { + assertEquals(1, manager.getBeans("enabledOptionalBeanWithFieldDependency").size()); + } + + @Test + public void testDisabledOptionalBeanWithFieldDependency() { + assertEquals(0, manager.getBeans("disabledOptionalBeanWithFieldDependency").size()); + } + + @Test + public void testEnabledOptionalBeanWithReturnTypeDependency() { + assertEquals(1, manager.getBeans("enabledOptionalBeanWithReturnTypeDependency").size()); + } + + @Test + public void testDisabledOptionalBeanWithReturnTypeDependency() { + assertEquals(0, manager.getBeans("disabledOptionalBeanWithReturnTypeDependency").size()); + } + + @Test + public void testEnabledOptionalBeanWithSupertypeDependency() { + assertEquals(1, manager.getBeans("enabledOptionalBeanWithSupertypeDependency").size()); + } + + @Test + public void testDisabledOptionalBeanWithSupertypeDependency() { + assertEquals(0, manager.getBeans("disabledOptionalBeanWithSupertypeDependency").size()); + } + + @Test + public void testEnabledPackageLevelRequires() { + assertEquals(4, manager.getBeans(CommonInterface.class).size()); + } + + @Test + public void testDisabledPackageLevelRequires() { + assertEquals(0, manager.getBeans(OptionalBeanWithPackageLevelDependencies.class).size()); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Tiger.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Tiger.java new file mode 100644 index 00000000..e2f90e45 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/Tiger.java @@ -0,0 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires; + +/** + * Every bean in the "beans" package depends on this class. + * + * @author Jozef Hartinger + */ +public class Tiger { +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBean.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBean.java new file mode 100644 index 00000000..949e41f9 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBean.java @@ -0,0 +1,28 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires.beans; + +import javax.inject.Named; + +import org.jboss.seam.solder.core.Requires; +import org.jboss.seam.solder.test.core.requires.CommonInterface; + +@Requires({"org.jboss.seam.solder.test.core.requires.Tiger", "org.jboss.seam.solder.test.core.requires.Jaguar", "java.lang.Integer"}) +@Named +public class DisabledOptionalBean implements CommonInterface { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithFieldDependency.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithFieldDependency.java new file mode 100644 index 00000000..76247a1b --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithFieldDependency.java @@ -0,0 +1,33 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires.beans; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.jboss.seam.solder.core.Requires; +import org.jboss.seam.solder.test.core.requires.CommonInterface; +import org.jboss.seam.solder.test.core.requires.Jaguar; + +@Requires({"org.jboss.seam.solder.test.core.requires.Tiger", "org.jboss.seam.solder.test.core.requires.Jaguar", + "java.lang.Integer"}) +@Named +public class DisabledOptionalBeanWithFieldDependency implements CommonInterface { + + @Inject + public Jaguar tiger; +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithReturnTypeDependency.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithReturnTypeDependency.java new file mode 100644 index 00000000..cd0b4827 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithReturnTypeDependency.java @@ -0,0 +1,33 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires.beans; + +import javax.inject.Named; + +import org.jboss.seam.solder.core.Requires; +import org.jboss.seam.solder.test.core.requires.CommonInterface; +import org.jboss.seam.solder.test.core.requires.Jaguar; + +@Requires({"org.jboss.seam.solder.test.core.requires.Tiger", "org.jboss.seam.solder.test.core.requires.Jaguar", + "java.lang.Integer"}) +@Named +public class DisabledOptionalBeanWithReturnTypeDependency implements CommonInterface { + + public Jaguar getJaguar() { + return new Jaguar(); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithSupertypeDependency.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithSupertypeDependency.java new file mode 100644 index 00000000..cbe1eeea --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/DisabledOptionalBeanWithSupertypeDependency.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires.beans; + +import javax.enterprise.inject.Typed; +import javax.inject.Named; + +import org.jboss.seam.solder.core.Requires; +import org.jboss.seam.solder.test.core.requires.CommonInterface; +import org.jboss.seam.solder.test.core.requires.Jaguar; + +@Requires({"org.jboss.seam.solder.test.core.requires.Tiger", "org.jboss.seam.solder.test.core.requires.Jaguar", + "java.lang.Integer"}) +@Typed({CommonInterface.class, DisabledOptionalBeanWithSupertypeDependency.class}) +@Named +public class DisabledOptionalBeanWithSupertypeDependency extends Jaguar implements CommonInterface { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBean.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBean.java new file mode 100644 index 00000000..65d873e0 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBean.java @@ -0,0 +1,28 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires.beans; + +import javax.inject.Named; + +import org.jboss.seam.solder.core.Requires; +import org.jboss.seam.solder.test.core.requires.CommonInterface; + +@Requires({"org.jboss.seam.solder.test.core.requires.Tiger", "java.lang.Integer"}) +@Named +public class EnabledOptionalBean implements CommonInterface { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithFieldDependency.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithFieldDependency.java new file mode 100644 index 00000000..5c1a3d1f --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithFieldDependency.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires.beans; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.jboss.seam.solder.core.Requires; +import org.jboss.seam.solder.test.core.requires.CommonInterface; +import org.jboss.seam.solder.test.core.requires.Tiger; + +@Requires({"org.jboss.seam.solder.test.core.requires.Tiger", "java.lang.Integer"}) +@Named +public class EnabledOptionalBeanWithFieldDependency implements CommonInterface { + + @Inject + public Tiger tiger; +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithReturnTypeDependency.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithReturnTypeDependency.java new file mode 100644 index 00000000..4648594a --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithReturnTypeDependency.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires.beans; + +import javax.inject.Named; + +import org.jboss.seam.solder.core.Requires; +import org.jboss.seam.solder.test.core.requires.CommonInterface; +import org.jboss.seam.solder.test.core.requires.Tiger; + +@Requires({"org.jboss.seam.solder.test.core.requires.Tiger", "java.lang.Integer"}) +@Named +public class EnabledOptionalBeanWithReturnTypeDependency implements CommonInterface { + + public Tiger getTiger() { + return new Tiger(); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithSupertypeDependency.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithSupertypeDependency.java new file mode 100644 index 00000000..d690ff2a --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/EnabledOptionalBeanWithSupertypeDependency.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires.beans; + +import javax.enterprise.inject.Typed; +import javax.inject.Named; + +import org.jboss.seam.solder.core.Requires; +import org.jboss.seam.solder.test.core.requires.CommonInterface; +import org.jboss.seam.solder.test.core.requires.Tiger; + +@Requires({"org.jboss.seam.solder.test.core.requires.Tiger", "java.lang.Integer"}) +@Typed({CommonInterface.class, EnabledOptionalBeanWithSupertypeDependency.class}) +@Named +public class EnabledOptionalBeanWithSupertypeDependency extends Tiger implements CommonInterface { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/package-info.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/package-info.java new file mode 100644 index 00000000..c1b49c05 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/package-info.java @@ -0,0 +1,22 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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. + */ +@Requires({"org.jboss.seam.solder.test.core.requires.Lion", "java.lang.RuntimeException"}) package org.jboss.seam.solder.test.core.requires.beans; + +import org.jboss.seam.solder.core.Requires; + diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/pkg/OptionalBeanWithPackageLevelDependencies.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/pkg/OptionalBeanWithPackageLevelDependencies.java new file mode 100644 index 00000000..371e9e74 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/pkg/OptionalBeanWithPackageLevelDependencies.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.requires.beans.pkg; + +public class OptionalBeanWithPackageLevelDependencies { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/pkg/package-info.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/pkg/package-info.java new file mode 100644 index 00000000..772d5f3a --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/beans/pkg/package-info.java @@ -0,0 +1,23 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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. + */ +@Requires({"org.jboss.seam.solder.test.core.requires.Lion", "java.lang.RuntimeException", + "org.jboss.seam.solder.test.core.requires.Jaguar"}) package org.jboss.seam.solder.test.core.requires.beans.pkg; + +import org.jboss.seam.solder.core.Requires; + diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/veto/Tiger.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/veto/Tiger.java new file mode 100644 index 00000000..a76d983d --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/veto/Tiger.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.core.veto; + +public class Tiger { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/veto/package-info.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/veto/package-info.java new file mode 100644 index 00000000..a27f6f7a --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/veto/package-info.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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. + */ +@Veto package org.jboss.seam.solder.test.core.veto; + +import org.jboss.seam.solder.core.Veto; diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/BigLaptopHardDrive.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/BigLaptopHardDrive.java new file mode 100644 index 00000000..4e355735 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/BigLaptopHardDrive.java @@ -0,0 +1,26 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +@LaptopHardDrive +public class BigLaptopHardDrive implements HardDrive { + + public String size() { + return "200MB"; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/CDDrive.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/CDDrive.java new file mode 100644 index 00000000..ec011c18 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/CDDrive.java @@ -0,0 +1,29 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +import javax.enterprise.event.Observes; +import javax.enterprise.inject.Default; + +import org.jboss.seam.solder.bean.defaultbean.DefaultBean; + +@DefaultBean(OpticalDrive.class) +public class CDDrive implements OpticalDrive { + public void write(@Observes @Default WriteEvent event) { + event.increment(); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/CPU.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/CPU.java new file mode 100644 index 00000000..bdabba1a --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/CPU.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +public interface CPU { + public String getSpeed(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/ChipManufacturer.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/ChipManufacturer.java new file mode 100644 index 00000000..c825e7c1 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/ChipManufacturer.java @@ -0,0 +1,47 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +import javax.enterprise.inject.Produces; + +import org.jboss.seam.solder.bean.defaultbean.DefaultBean; + +public class ChipManufacturer { + public ChipManufacturer() { + } + + @DefaultBean(CPU.class) + @Produces + public CPU createChip() { + return new CPU() { + public String getSpeed() { + return "slow"; + } + }; + } + + @DefaultBean(GPU.class) + @Produces + public GPU createGPU() { + return new GPU() { + + public String getSpeed() { + return "slow"; + } + }; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DVDDrive.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DVDDrive.java new file mode 100644 index 00000000..4688d687 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DVDDrive.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +public class DVDDrive implements OpticalDrive { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java new file mode 100644 index 00000000..0a7796e9 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java @@ -0,0 +1,99 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +import javax.enterprise.inject.spi.BeanManager; +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.seam.solder.literal.DefaultLiteral; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; + +@RunWith(Arquillian.class) +public class DefaultBeanTest { + @Inject + OpticalDrive opticalDrive; + + @Inject + MagneticDrive magneticDrive; + + @Inject + CPU cpu; + + @Inject + GPU gpu; + + @Inject + HardDrive hardDrive; + + @Inject + HardDriveFactory factory; + + @Inject + BeanManager manager; + + @Inject + @SASHardDrive + HardDrive sasHardDrive; + + @Inject + @LaptopHardDrive + HardDrive laptopHardDrive; + + @Deployment + public static WebArchive deployment() { + return baseDeployment().addPackage(DefaultBeanTest.class.getPackage()); + } + + @Test + public void testDefaultBean() { + Assert.assertTrue(opticalDrive instanceof DVDDrive); + Assert.assertTrue(magneticDrive instanceof FloppyDrive); + } + + @Test + public void testDefaultProducerMethod() { + Assert.assertEquals("fast", cpu.getSpeed()); + Assert.assertEquals("slow", gpu.getSpeed()); + } + + @Test + public void testDefaultProducerUsesCorrectDelegate() { + factory.setSize("big"); + Assert.assertEquals("big", hardDrive.size()); + } + + @Test + public void testDefaultProducerFields() { + Assert.assertEquals("100MB", sasHardDrive.size()); + Assert.assertEquals("200MB", laptopHardDrive.size()); + } + + @Test + public void testDefaultBeanObserverMethods() { + WriteEvent event = new WriteEvent(); + manager.fireEvent(event, DefaultLiteral.INSTANCE); + Assert.assertEquals(1, event.getCount()); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/FloppyDrive.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/FloppyDrive.java new file mode 100644 index 00000000..7af32234 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/FloppyDrive.java @@ -0,0 +1,29 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +import javax.enterprise.event.Observes; +import javax.enterprise.inject.Default; + +import org.jboss.seam.solder.bean.defaultbean.DefaultBean; + +@DefaultBean(MagneticDrive.class) +public class FloppyDrive implements MagneticDrive { + public void write(@Observes @Default WriteEvent event) { + event.increment(); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/GPU.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/GPU.java new file mode 100644 index 00000000..cf3c9484 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/GPU.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +public interface GPU { + public String getSpeed(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDrive.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDrive.java new file mode 100644 index 00000000..7e223ac5 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDrive.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +public interface HardDrive { + public String size(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDriveFactory.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDriveFactory.java new file mode 100644 index 00000000..a7e00ff3 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDriveFactory.java @@ -0,0 +1,61 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +import org.jboss.seam.solder.bean.defaultbean.DefaultBean; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Disposes; +import javax.enterprise.inject.Produces; + +/** + * test that producer methods are read from the installed default bean and not + * the synthetic delegate + * + * @author stuart + */ +@ApplicationScoped +@DefaultBean(HardDriveFactory.class) +public class HardDriveFactory { + private String size = "small"; + + @DefaultBean(HardDrive.class) + @Produces + public HardDrive getHardDrive() { + return new HardDrive() { + public String size() { + return size; + } + }; + } + + + public void disposeHardDrive(final @Disposes HardDrive hardDrive) { + + } + + + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } + + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDriveImpl.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDriveImpl.java new file mode 100644 index 00000000..86b7fd77 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/HardDriveImpl.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +public class HardDriveImpl implements HardDrive { + + public HardDriveImpl(String size) { + this.size = size; + } + + private final String size; + + public String size() { + return size; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/LaptopHardDrive.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/LaptopHardDrive.java new file mode 100644 index 00000000..8e17ba80 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/LaptopHardDrive.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD, ElementType.TYPE}) +public @interface LaptopHardDrive { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/MagneticDrive.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/MagneticDrive.java new file mode 100644 index 00000000..93949022 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/MagneticDrive.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +public interface MagneticDrive { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/OpticalDrive.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/OpticalDrive.java new file mode 100644 index 00000000..a8e01f5e --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/OpticalDrive.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +public interface OpticalDrive { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SASHardDrive.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SASHardDrive.java new file mode 100644 index 00000000..a9667007 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SASHardDrive.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface SASHardDrive { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SmallHardDriveFactory.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SmallHardDriveFactory.java new file mode 100644 index 00000000..a0c1d864 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SmallHardDriveFactory.java @@ -0,0 +1,36 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; + +import org.jboss.seam.solder.bean.defaultbean.DefaultBean; + +@DefaultBean(SmallHardDriveFactory.class) +public class SmallHardDriveFactory { + @Produces + @SASHardDrive + @ApplicationScoped + private HardDrive sasHardDrive = new HardDriveImpl("100MB"); + + @Produces + @LaptopHardDrive + @ApplicationScoped + private HardDrive laptopHardDrive = new HardDriveImpl("100MB"); + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SuperChargedCPU.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SuperChargedCPU.java new file mode 100644 index 00000000..bd67c606 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/SuperChargedCPU.java @@ -0,0 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +public class SuperChargedCPU implements CPU { + + public String getSpeed() { + return "fast"; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/WriteEvent.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/WriteEvent.java new file mode 100644 index 00000000..83300b81 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/WriteEvent.java @@ -0,0 +1,30 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.defaultbean; + +public class WriteEvent { + private int count = 0; + + public void increment() { + count++; + } + + public int getCount() { + return count; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/CustomELResolver.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/CustomELResolver.java new file mode 100644 index 00000000..dbcd430b --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/CustomELResolver.java @@ -0,0 +1,69 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.el; + +import java.beans.FeatureDescriptor; +import java.util.Iterator; + +import javax.el.ELContext; +import javax.el.ELResolver; + +import org.jboss.seam.solder.el.Resolver; + +@Resolver +public class CustomELResolver extends ELResolver { + + @Override + public Object getValue(ELContext context, Object base, Object property) { + if ("foo".equals(property)) { + context.setPropertyResolved(true); + return "baz"; + } else { + return null; + } + } + + @Override + public Class getType(ELContext context, Object base, Object property) { + if ("foo".equals(property)) { + return String.class; + } else { + return null; + } + } + + @Override + public void setValue(ELContext context, Object base, Object property, Object value) { + + } + + @Override + public boolean isReadOnly(ELContext context, Object base, Object property) { + return false; + } + + @Override + public Iterator getFeatureDescriptors(ELContext context, Object base) { + return null; + } + + @Override + public Class getCommonPropertyType(ELContext context, Object base) { + return null; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/ElTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/ElTest.java new file mode 100644 index 00000000..bf5f9bbd --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/ElTest.java @@ -0,0 +1,69 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.el; + +import javax.el.ExpressionFactory; +import javax.inject.Inject; + +import com.sun.el.ExpressionFactoryImpl; +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.seam.solder.el.ELResolverProducer; +import org.jboss.seam.solder.el.Expressions; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.jboss.seam.solder.test.util.Deployments.targetContainerAdapterClass; + +@RunWith(Arquillian.class) +public class ElTest { + @Inject + Expressions expressions; + + @Deployment + public static Archive deployment() { + // hack to work around container differences atm + boolean isEmbedded = targetContainerAdapterClass().getName().contains(".embedded"); + + WebArchive war = baseDeployment().addPackage(ElTest.class.getPackage()); + if (isEmbedded) { + war.addPackage(ELResolverProducer.class.getPackage()) + // set proper EL implementation using META-INF/services/javax.el.ExpressionFactory for Weld embedded + .addAsServiceProvider(ExpressionFactory.class, ExpressionFactoryImpl.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + return war; + } + + @Test + public void testElResolver() { + Assert.assertTrue(expressions.evaluateValueExpression("#{ute.speed}").equals("fast")); + Assert.assertTrue(expressions.evaluateMethodExpression("#{ute.go}").equals(Ute.GO_STRING)); + } + + @Test + public void testCustomElResolver() { + Assert.assertTrue(expressions.evaluateValueExpression("#{foo}").equals("baz")); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/Ute.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/Ute.java new file mode 100644 index 00000000..cba34f68 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/Ute.java @@ -0,0 +1,37 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.el; + +import javax.inject.Named; + +@Named +public class Ute { + public static String GO_STRING = "Vroom Vroom"; + public String speed = "fast"; + + public String go() { + return GO_STRING; + } + + public String getSpeed() { + return speed; + } + + public void setSpeed(String speed) { + this.speed = speed; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/BarInterceptor.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/BarInterceptor.java new file mode 100644 index 00000000..7bc8106f --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/BarInterceptor.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.interceptor; + +import javax.interceptor.AroundInvoke; +import javax.interceptor.Interceptor; +import javax.interceptor.InvocationContext; + +@Interceptor +@PrimaryInterceptionBinding +public class BarInterceptor { + + @AroundInvoke + public void aroundInvoke(InvocationContext ctx) throws Exception { + + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/Foo.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/Foo.java new file mode 100644 index 00000000..7013664e --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/Foo.java @@ -0,0 +1,21 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.interceptor; + +public class Foo { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/FooInterceptor.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/FooInterceptor.java new file mode 100644 index 00000000..643f95f5 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/FooInterceptor.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.interceptor; + +import javax.interceptor.AroundInvoke; +import javax.interceptor.Interceptor; +import javax.interceptor.InvocationContext; + +@Interceptor +@PrimaryInterceptionBinding +public class FooInterceptor { + + @AroundInvoke + public void aroundInvoke(InvocationContext ctx) throws Exception { + + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/InterceptorTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/InterceptorTest.java new file mode 100644 index 00000000..8bd7f1d8 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/InterceptorTest.java @@ -0,0 +1,38 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.interceptor; + +import org.junit.Test; + +//@Artifact +//@Classes(Interceptors.class) +public class InterceptorTest // extends AbstractWeldTest +{ + + // Disabled, needs a snapshot of Weld to work + // @Test(enabled=false) + @Test + public void testInterceptorResolvable() { + // assert + // getReference(Interceptors.class).isInterceptorEnabled(FooInterceptor.class); + // Waiting on WELD-503 + // assert + // !getReference(Interceptors.class).isInterceptorEnabled(BarInterceptor.class); + // + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/PrimaryInterceptionBinding.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/PrimaryInterceptionBinding.java new file mode 100644 index 00000000..436a8ea7 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/interceptor/PrimaryInterceptionBinding.java @@ -0,0 +1,38 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.interceptor; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.interceptor.InterceptorBinding; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * @author Marius Bogoevici + */ +@InterceptorBinding +@Documented +@Retention(RUNTIME) +@Target({METHOD, TYPE}) +public @interface PrimaryInterceptionBinding { +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BaldEagle.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BaldEagle.java new file mode 100644 index 00000000..9a483d14 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BaldEagle.java @@ -0,0 +1,19 @@ +package org.jboss.seam.solder.test.logging; + +import java.io.Serializable; + +import javax.enterprise.context.SessionScoped; +import javax.inject.Inject; + +import org.jboss.seam.logging.Category; + +@SessionScoped +public class BaldEagle implements Serializable { + @Inject + @Category("Birds") + private BirdLogger logger; + + public void generateLogMessage() { + logger.logBaldEaglesSpotted(2); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BirdLogger.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BirdLogger.java new file mode 100644 index 00000000..03b2e841 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BirdLogger.java @@ -0,0 +1,36 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.logging; + +import org.jboss.seam.logging.Log; +import org.jboss.seam.logging.MessageLogger; +import org.jboss.seam.solder.messages.Message; + +@MessageLogger +public interface BirdLogger extends BirdMessages { + @Log + @Message("Spotted %s Hawks") + void logHawksSpotted(int number); + + @Log + @Message("Spotted %s Owls") + void logOwlsSpotted(int number); + + @Log + @Message("Spotted %s Bald Eagles") + void logBaldEaglesSpotted(int number); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BirdMessages.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BirdMessages.java new file mode 100644 index 00000000..ab1753fd --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/BirdMessages.java @@ -0,0 +1,26 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.logging; + +import org.jboss.seam.solder.messages.Message; +import org.jboss.seam.solder.messages.MessageBundle; + +@MessageBundle +public interface BirdMessages { + @Message("Spotted %s jays") + String numberOfJaysSpotted(int number); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Finch.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Finch.java new file mode 100644 index 00000000..929b4d76 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Finch.java @@ -0,0 +1,36 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.logging; + +import javax.inject.Inject; + +import org.jboss.seam.logging.Category; +import org.jboss.seam.logging.Logger; + +public class Finch { + @Inject + @Category("Finch") + private Logger log; + + public void generateLogMessage() { + log.info("Finch"); + } + + public Logger getLogger() { + return log; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Hawk.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Hawk.java new file mode 100644 index 00000000..34e60195 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Hawk.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.logging; + +import javax.inject.Inject; + +import org.jboss.seam.logging.Category; + +public class Hawk { + @Inject + @Category("Birds") + private BirdLogger logger; + + public void generateLogMessage() { + logger.logHawksSpotted(3); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java new file mode 100644 index 00000000..34c2bd04 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java @@ -0,0 +1,88 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.logging; + +import javax.enterprise.context.spi.CreationalContext; +import javax.enterprise.inject.spi.BeanManager; +import javax.enterprise.inject.spi.InjectionTarget; + +import junit.framework.Assert; +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.seam.solder.test.util.Deployments; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * Tests injection of native JBoss Logging API + *

+ *

+ * NOTE: Some of these tests must be verified manually as we have no way to plug + * in a mock logger. + *

+ * + * @author David Allen + * @author Dan Allen + */ +@RunWith(Arquillian.class) +public class LoggerInjectionTest { + @Deployment + public static Archive createDeployment() { + return Deployments.baseDeployment() + .addClasses(Sparrow.class, Finch.class, Wren.class, Raven.class, NonBean.class); + } + + @Test + public void testLoggerInjection(Sparrow sparrow) { + sparrow.generateLogMessage(); + Assert.assertEquals(Sparrow.class.getName(), sparrow.getLogger().getName()); + } + + @Test + public void testLoggerInjectionWithCategory(Finch finch) { + finch.generateLogMessage(); + Assert.assertEquals("Finch", finch.getLogger().getName()); + } + + @Test + public void testLoggerInjectionWithTypedCategory(Wren wren) { + wren.generateLogMessage(); + Assert.assertEquals(LoggerInjectionTest.class.getName(), wren.getLogger().getName()); + } + + @Test + public void testLoggerInjectionWithSuffix(Raven raven) { + raven.generateLogMessage(); + Assert.assertEquals(Raven.class.getName() + ".log", raven.getLogger().getName()); + } + + @Test + public void testLoggerInjectionIntoNonBean(BeanManager bm) { + NonBean nonBean = new NonBean(); + InjectionTarget target = bm.createInjectionTarget(bm.createAnnotatedType(NonBean.class)); + CreationalContext cc = bm.createCreationalContext(null); + try { + target.inject(nonBean, cc); + // this will cause a NullPointerException if the injection does not occur + nonBean.logMessage(); + } finally { + cc.release(); + } + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/NonBean.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/NonBean.java new file mode 100644 index 00000000..62ce4631 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/NonBean.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.logging; + +import javax.enterprise.inject.Alternative; +import javax.inject.Inject; + +import org.jboss.seam.logging.Logger; + +@Alternative +public class NonBean { + @Inject + private Logger log; + + void logMessage() { + log.info("Log message from non-bean"); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Owl.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Owl.java new file mode 100644 index 00000000..edc3ac25 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Owl.java @@ -0,0 +1,28 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.logging; + +import javax.inject.Inject; + +public class Owl { + @Inject + private BirdLogger logger; + + public void generateLogMessage() { + logger.logOwlsSpotted(5); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Raven.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Raven.java new file mode 100644 index 00000000..25a858a1 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Raven.java @@ -0,0 +1,36 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.logging; + +import javax.inject.Inject; + +import org.jboss.seam.logging.Suffix; +import org.jboss.seam.logging.Logger; + +class Raven { + @Inject + @Suffix("log") + private Logger log; + + public void generateLogMessage() { + log.info("Raven"); + } + + public Logger getLogger() { + return log; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Sparrow.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Sparrow.java new file mode 100644 index 00000000..ba63cb82 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Sparrow.java @@ -0,0 +1,35 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.logging; + +import javax.inject.Inject; + +import org.jboss.seam.logging.Logger; + + +class Sparrow { + @Inject + private Logger log; + + public void generateLogMessage() { + log.info("Sparrow"); + } + + public Logger getLogger() { + return log; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java new file mode 100644 index 00000000..248f1e03 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java @@ -0,0 +1,69 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.logging; + +import javax.enterprise.inject.Instance; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; + +/** + * Tests injection of typed message logger injections. + *

+ * Also verifies that a typed message logger is permitted to extend a typed message bundle. + *

+ *

+ * NOTE: Some of these tests must be verified manually as we have no way to plug + * in a mock logger. + *

+ * + * @author David Allen + * @author Dan Allen + */ +@RunWith(Arquillian.class) +public class TypedMessageLoggerInjectionTest { + @Deployment + public static Archive createDeployment() { + return baseDeployment() + .addPackage(TypedMessageLoggerInjectionTest.class.getPackage()); + } + + @Test + public void testMessageLoggerInjectionWithCategoryDefaulted(Instance owlResolver) { + owlResolver.get().generateLogMessage(); + } + + @Test + public void testMessageLoggerInjectionWithExplicitCategory(Hawk hawk) { + hawk.generateLogMessage(); + } + + /** + * BaldEagle declares a passivating scope and therefore must not have any non-serializable dependencies. This test will fail + * deployment if the type-safe logger producer is not serializable. (see SOLDER-81) + */ + @Test + public void testMessageLoggerInjectionOnPassivatingBean(BaldEagle baldEagle) { + baldEagle.generateLogMessage(); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Wren.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Wren.java new file mode 100644 index 00000000..72f49705 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/Wren.java @@ -0,0 +1,36 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.logging; + +import javax.inject.Inject; + +import org.jboss.seam.logging.TypedCategory; +import org.jboss.seam.logging.Logger; + +public class Wren { + @Inject + @TypedCategory(LoggerInjectionTest.class) + private Logger log; + + public void generateLogMessage() { + log.info("Wren"); + } + + public Logger getLogger() { + return log; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/BirdMessages.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/BirdMessages.java new file mode 100644 index 00000000..f63d5459 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/BirdMessages.java @@ -0,0 +1,26 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.messages; + +import org.jboss.seam.solder.messages.Message; +import org.jboss.seam.solder.messages.MessageBundle; + +@MessageBundle +public interface BirdMessages { + @Message("Spotted %s jays") + String numberOfJaysSpotted(int number); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/FrenchJay.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/FrenchJay.java new file mode 100644 index 00000000..bfa6b7dc --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/FrenchJay.java @@ -0,0 +1,35 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.messages; + +import javax.inject.Inject; + +import org.jboss.seam.solder.messages.Locale; +import org.jboss.seam.solder.messages.MessageBundle; + +public class FrenchJay { + + @Inject + @MessageBundle + @Locale("fr") + BirdMessages messages; + + String getMessage() { + return messages.numberOfJaysSpotted(4); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/Jay.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/Jay.java new file mode 100644 index 00000000..d687d1fe --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/Jay.java @@ -0,0 +1,33 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.messages; + +import javax.inject.Inject; + +import org.jboss.seam.solder.messages.MessageBundle; + +public class Jay { + + @Inject + @MessageBundle + BirdMessages messages; + + String getMessage() { + return messages.numberOfJaysSpotted(8); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java new file mode 100644 index 00000000..958d6099 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java @@ -0,0 +1,52 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.messages; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; + +/** + * Tests injection of typed message bundle injections. + * + * @author David Allen + * @author Dan Allen + */ +@RunWith(Arquillian.class) +public class TypedMessageBundleInjectionTest { + @Deployment + public static Archive createDeployment() { + return baseDeployment() + .addPackage(TypedMessageBundleInjectionTest.class.getPackage()); + } + + @Test + public void testMessageBundleInjection(Jay jay) { + assertEquals("Spotted 8 jays", jay.getMessage()); + } + + @Test + public void testMessageBundleLocaleInjection(FrenchJay jay) { + assertEquals("Spotted 4 geais", jay.getMessage()); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/ClassToIntrospect.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/ClassToIntrospect.java new file mode 100644 index 00000000..aca4665e --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/ClassToIntrospect.java @@ -0,0 +1,73 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.properties; + +import java.net.URL; + +public class ClassToIntrospect { + private String name; + + private String p; + + private URL URL; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getP() { + return p; + } + + public void setP(String p) { + this.p = p; + } + + public String getTitle() { + return "Hero"; + } + + public String get() { + return null; + } + + public boolean is() { + return false; + } + + public void getFooBar() { + } + + public void setSalary(Double base, Double bonus) { + } + + public URL getURL() { + return URL; + } + + public void setURL(URL URL) { + this.URL = URL; + } + + public Boolean isValid() { + return false; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/PropertyFromMethodTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/PropertyFromMethodTest.java new file mode 100644 index 00000000..72610ddb --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/PropertyFromMethodTest.java @@ -0,0 +1,110 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.properties; + +import java.lang.reflect.Method; +import java.net.URL; + +import org.jboss.seam.solder.properties.Properties; +import org.jboss.seam.solder.properties.Property; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * Verify that only valid properties are permitted, as per the JavaBean specification. + * + * @author Dan Allen + * @see http://www.oracle.com/technetwork/java/javase/documentation/spec-136004.html + */ +public class PropertyFromMethodTest { + @Test + public void testValidPropertyGetterMethod() throws Exception { + Method getter = ClassToIntrospect.class.getMethod("getName"); + Property p = Properties.createProperty(getter); + assertNotNull(p); + assertEquals("name", p.getName()); + assertEquals(getter, p.getMember()); + } + + @Test + public void testValidPropertySetterMethod() throws Exception { + Property p = Properties.createProperty(ClassToIntrospect.class.getMethod("setName", String.class)); + assertNotNull(p); + assertEquals("name", p.getName()); + } + + @Test + public void testReadOnlyProperty() throws Exception { + Property p = Properties.createProperty(ClassToIntrospect.class.getMethod("getTitle")); + assertNotNull(p); + assertEquals("title", p.getName()); + assertTrue(p.isReadOnly()); + } + + @Test(expected = IllegalArgumentException.class) + public void testEmptyPropertyGetterMethod() throws Exception { + Properties.createProperty(ClassToIntrospect.class.getMethod("get")); + } + + @Test(expected = IllegalArgumentException.class) + public void testEmptyBooleanPropertyGetterMethod() throws Exception { + Properties.createProperty(ClassToIntrospect.class.getMethod("is")); + } + + @Test(expected = IllegalArgumentException.class) + public void testNonPrimitiveBooleanPropertyIsMethod() throws Exception { + Properties.createProperty(ClassToIntrospect.class.getMethod("isValid")); + } + + @Test + public void testSingleCharPropertyGetterMethod() throws Exception { + Method getter = ClassToIntrospect.class.getMethod("getP"); + Property p = Properties.createProperty(getter); + assertNotNull(p); + assertEquals("p", p.getName()); + assertEquals(getter, p.getMember()); + } + + @Test + public void testSingleCharPropertySetterMethod() throws Exception { + Property p = Properties.createProperty(ClassToIntrospect.class.getMethod("setP", String.class)); + assertNotNull(p); + assertEquals("p", p.getName()); + } + + @Test(expected = IllegalArgumentException.class) + public void testGetterMethodWithVoidReturnType() throws Exception { + Properties.createProperty(ClassToIntrospect.class.getMethod("getFooBar")); + } + + @Test(expected = IllegalArgumentException.class) + public void testSetterMethodWithMultipleParameters() throws Exception { + Properties.createProperty(ClassToIntrospect.class.getMethod("setSalary", Double.class, Double.class)); + } + + @Test + public void testAcronymProperty() throws Exception { + Method getter = ClassToIntrospect.class.getMethod("getURL"); + Property p = Properties.createProperty(getter); + assertNotNull(p); + assertEquals("URL", p.getName()); + assertEquals(getter, p.getMember()); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/query/Person.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/query/Person.java new file mode 100644 index 00000000..b8241811 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/query/Person.java @@ -0,0 +1,38 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.properties.query; + +public class Person { + private String name; + private String title; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/query/PropertyQueryTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/query/PropertyQueryTest.java new file mode 100644 index 00000000..73bf9560 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/properties/query/PropertyQueryTest.java @@ -0,0 +1,77 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.properties.query; + +import org.jboss.seam.solder.properties.Property; +import org.jboss.seam.solder.properties.query.NamedPropertyCriteria; +import org.jboss.seam.solder.properties.query.PropertyQueries; +import org.jboss.seam.solder.properties.query.PropertyQuery; +import org.jboss.seam.solder.properties.query.TypedPropertyCriteria; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +/** + * Validate the property query mechanism. + * + * @author Dan Allen + */ +public class PropertyQueryTest { + /** + * Querying for a single result with a criteria that matches multiple + * properties should throw an exception. + * + * @see PropertyQuery#getSingleResult() + */ + @Test(expected = RuntimeException.class) + public void testNonUniqueSingleResultThrowsException() { + PropertyQuery q = PropertyQueries.createQuery(Person.class); + q.addCriteria(new TypedPropertyCriteria(String.class)); + q.getSingleResult(); + } + + /** + * Querying for a single result with a criteria that does not match + * any properties should throw an exception. + * + * @see PropertyQuery#getSingleResult() + */ + @Test(expected = RuntimeException.class) + public void testEmptySingleResultThrowsException() { + PropertyQuery q = PropertyQueries.createQuery(Person.class); + q.addCriteria(new TypedPropertyCriteria(Integer.class)); + q.getSingleResult(); + } + + /** + * Querying for a single result with a criterai that matches exactly one + * property should return the property. + * + * @see PropertyQuery#getSingleResult() + */ + @Test + public void testSingleResult() { + PropertyQuery q = PropertyQueries.createQuery(Person.class); + q.addCriteria(new NamedPropertyCriteria("name")); + Property p = q.getSingleResult(); + assertNotNull(p); + Person o = new Person(); + o.setName("Trap"); + assertEquals("Trap", p.getValue(o)); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/PrimitiveTypesTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/PrimitiveTypesTest.java new file mode 100644 index 00000000..d8615a5d --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/PrimitiveTypesTest.java @@ -0,0 +1,54 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.reflection; + +import java.sql.Date; + +import junit.framework.Assert; +import org.jboss.seam.solder.reflection.PrimitiveTypes; +import org.junit.Test; + +/** + * @author Dan Allen + */ +public class PrimitiveTypesTest { + @Test + public void should_box_primitive_type() { + Assert.assertNotSame(Double.class, Double.TYPE); + Assert.assertSame(Double.class, PrimitiveTypes.box(Double.TYPE)); + Assert.assertSame(Double.class, PrimitiveTypes.box(Double.class)); + } + + @Test + public void should_unbox_wrapper_type() { + Assert.assertNotSame(Double.TYPE, Double.class); + Assert.assertSame(Double.TYPE, PrimitiveTypes.unbox(Double.class)); + Assert.assertSame(Double.TYPE, PrimitiveTypes.unbox(Double.TYPE)); + } + + @Test + public void should_recognize_wrapper_type() { + Assert.assertTrue(PrimitiveTypes.isWrapperType(Double.class)); + Assert.assertFalse(PrimitiveTypes.isWrapperType(Double.TYPE)); + } + + @Test + public void should_not_affect_other_type() { + Assert.assertSame(Date.class, PrimitiveTypes.unbox(Date.class)); + Assert.assertSame(Date.class, PrimitiveTypes.box(Date.class)); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/ReflectionsTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/ReflectionsTest.java new file mode 100644 index 00000000..5dec29b5 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/ReflectionsTest.java @@ -0,0 +1,117 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.reflection; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import junit.framework.Assert; +import org.jboss.seam.solder.reflection.Reflections; +import org.jboss.seam.solder.test.reflection.model.Cat; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Dan Allen + */ +public class ReflectionsTest { + private Cat subject; + + @Before + public void setupFixture() { + subject = new Cat(); + } + + @Test + public void should_invoke_public_no_args_method() { + Method m = Reflections.findDeclaredMethod(Cat.class, "chewOnPowerCord"); + Reflections.invokeMethod(m, subject); + Assert.assertEquals(8, subject.getLives()); + } + + @Test + public void should_invoke_public_method_with_args() { + Method m = Reflections.findDeclaredMethod(Cat.class, "earnLives", Integer.TYPE); + Reflections.invokeMethod(m, subject, 1); + Assert.assertEquals(10, subject.getLives()); + } + + @Test(expected = RuntimeException.class) + public void should_fail_invoking_public_method_with_invalid_args() { + Method m = Reflections.findDeclaredMethod(Cat.class, "earnLives", Integer.TYPE); + Reflections.invokeMethod(m, subject, -1); + Assert.assertEquals(10, subject.getLives()); + } + + @Test(expected = RuntimeException.class) + public void should_fail_invoking_private_method() { + Method m = Reflections.findDeclaredMethod(Cat.class, "diveUnderMovingCar"); + Reflections.invokeMethod(m, subject); + } + + @Test + public void should_invoke_private_method_when_set_accessible() { + Method m = Reflections.findDeclaredMethod(Cat.class, "diveUnderMovingCar"); + Reflections.invokeMethod(true, m, subject); + } + + + @Test(expected = RuntimeException.class) + public void should_fail_invoking_package_method() { + Method m = Reflections.findDeclaredMethod(Cat.class, "fightWithBigDog"); + Reflections.invokeMethod(m, subject); + } + + @Test + public void should_invoke_package_method_when_set_accessible() { + Method m = Reflections.findDeclaredMethod(Cat.class, "fightWithBigDog"); + Reflections.invokeMethod(true, m, subject); + } + + @Test(expected = RuntimeException.class) + public void should_fail_setting_private_field() { + Field f = Reflections.findDeclaredField(Cat.class, "lives"); + Reflections.setFieldValue(f, subject, 1); + } + + @Test + public void should_set_private_field_when_set_accessible() { + Field f = Reflections.findDeclaredField(Cat.class, "lives"); + Reflections.setFieldValue(true, f, subject, 1); + Assert.assertEquals(1, subject.getLives()); + } + + @Test + public void should_set_method_accessible() { + Method m = Reflections.findDeclaredMethod(Cat.class, "fightWithBigDog"); + Assert.assertFalse(m.isAccessible()); + Method result = Reflections.setAccessible(m); + Assert.assertTrue(m.isAccessible()); + Assert.assertTrue(result.isAccessible()); + Assert.assertSame(m, result); + } + + @Test + public void should_set_field_accessible() { + Field f = Reflections.findDeclaredField(Cat.class, "lives"); + Assert.assertFalse(f.isAccessible()); + Field result = Reflections.setAccessible(f); + Assert.assertTrue(f.isAccessible()); + Assert.assertTrue(result.isAccessible()); + Assert.assertSame(f, result); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/model/Cat.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/model/Cat.java new file mode 100644 index 00000000..a4f3b8c7 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/reflection/model/Cat.java @@ -0,0 +1,44 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.reflection.model; + +public class Cat { + private int lives = 9; + + public void chewOnPowerCord() { + lives--; + } + + private void diveUnderMovingCar() { + lives--; + } + + void fightWithBigDog() { + lives--; + } + + public void earnLives(int lives) { + if (lives < 0) { + throw new IllegalArgumentException("Must be positive"); + } + this.lives += lives; + } + + public int getLives() { + return lives; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceClient.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceClient.java new file mode 100644 index 00000000..8d36613a --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceClient.java @@ -0,0 +1,34 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.resourceLoader; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; + +import org.jboss.seam.solder.resourceLoader.ResourceProvider; + +@RequestScoped +public class ResourceClient { + + @Inject + ResourceProvider resourceProvider; + + public ResourceProvider getResourceProvider() { + return resourceProvider; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java new file mode 100644 index 00000000..11ed4191 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java @@ -0,0 +1,140 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.resourceLoader; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.Properties; + +import javax.enterprise.context.spi.CreationalContext; +import javax.enterprise.inject.spi.Bean; +import javax.enterprise.inject.spi.BeanManager; +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.seam.solder.resourceLoader.Resource; +import org.jboss.seam.solder.resourceLoader.ResourceLoader; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.jboss.seam.solder.test.util.Deployments.targetContainerAdapterClass; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(Arquillian.class) +public class ResourceLoaderTest { + @Deployment + public static Archive deployment() { + // hack to work around container differences atm + boolean isEmbedded = targetContainerAdapterClass().getName().contains(".embedded"); + + WebArchive war = baseDeployment().addPackage(ResourceLoaderTest.class.getPackage()) + .addAsResource("com/acme/foo1") + .addAsResource("com/acme/foo2.properties"); + + if (isEmbedded) { + war.addPackage(ResourceLoader.class.getPackage()) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + return war; + } + + @Inject + ResourceClient resourceClient; + + @Inject + @Resource("com/acme/foo2.properties") + Properties foo2; + + @Inject + BeanManager beanManager; + + @Test + public void testLoadsStream() throws Throwable { + InputStream stream = resourceClient.getResourceProvider().loadResourceStream("com/acme/foo1"); + assert stream != null; + assert stream.available() > 0; + InputStreamReader reader = new InputStreamReader(stream); + char[] chars = new char[4]; + reader.read(chars, 0, 4); + assert new String(chars).equals("foo1"); + } + + @Test + public void testLoadsProperties() throws Throwable { + assertNotNull(foo2); + assertEquals(2, foo2.size()); + assertEquals("Pete", foo2.getProperty("name")); + assertEquals("28", foo2.getProperty("age")); + } + + @Test + public void testLoadsURLs() throws Throwable { + URL url = resourceClient.getResourceProvider().loadResource("com/acme/foo1"); + assert url != null; + InputStream stream = url.openStream(); + assert stream.available() > 0; + InputStreamReader reader = new InputStreamReader(stream); + char[] chars = new char[4]; + reader.read(chars, 0, 4); + assert new String(chars).equals("foo1"); + assert url.getFile().endsWith("/com/acme/foo1"); + } + + @Test + public void testInitialSlashIgnored() throws Throwable { + URL url = resourceClient.getResourceProvider().loadResource("/com/acme/foo1"); + assert url != null; + InputStream stream = url.openStream(); + assert stream.available() > 0; + InputStreamReader reader = new InputStreamReader(stream); + char[] chars = new char[4]; + reader.read(chars, 0, 4); + assert new String(chars).equals("foo1"); + assert url.getFile().endsWith("com/acme/foo1"); + } + + @Test + public void testStreamsAreCleanedUp() throws Throwable { + Bean bean = (Bean) beanManager.getBeans(ResourceClient.class).iterator().next(); + CreationalContext creationalContext = beanManager.createCreationalContext(bean); + ResourceClient client = bean.create(creationalContext); + InputStream stream = client.getResourceProvider().loadResourceStream("/com/acme/foo1"); + assert stream.available() > 0; + InputStreamReader reader = new InputStreamReader(stream); + char[] chars = new char[4]; + reader.read(chars, 0, 4); + assert new String(chars).equals("foo1"); + bean.destroy(client, creationalContext); + try { + stream.available(); + assert false; + } catch (IOException e) { + // Expected + } + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedEchoService.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedEchoService.java new file mode 100644 index 00000000..8655c06f --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedEchoService.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.serviceHandler; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.jboss.seam.solder.serviceHandler.ServiceHandlerType; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Retention(RUNTIME) +@Target(TYPE) +@ServiceHandlerType(DecoratedEchoServiceHandler.class) +public @interface DecoratedEchoService { +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedEchoServiceHandler.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedEchoServiceHandler.java new file mode 100644 index 00000000..5a769d36 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedEchoServiceHandler.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.serviceHandler; + +import javax.inject.Inject; +import javax.interceptor.AroundInvoke; +import javax.interceptor.InvocationContext; + +public class DecoratedEchoServiceHandler { + // test injection into the handler + @Inject + private EchoDecorator decorator; + + @AroundInvoke + public Object invoke(InvocationContext ctx) { + return decorator.decorate(ctx.getMethod().getName().toString()); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedHelloWorld.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedHelloWorld.java new file mode 100644 index 00000000..c50beaed --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/DecoratedHelloWorld.java @@ -0,0 +1,22 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.serviceHandler; + +@DecoratedEchoService +public interface DecoratedHelloWorld { + public String decoratedHelloWorld(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoDecorator.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoDecorator.java new file mode 100644 index 00000000..19e95def --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoDecorator.java @@ -0,0 +1,23 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.serviceHandler; + +public class EchoDecorator { + public String decorate(String message) { + return "-" + message + "-"; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoService.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoService.java new file mode 100644 index 00000000..7e4afda8 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoService.java @@ -0,0 +1,28 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.serviceHandler; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import org.jboss.seam.solder.serviceHandler.ServiceHandlerType; + +@Retention(RetentionPolicy.RUNTIME) +@ServiceHandlerType(EchoServiceHandler.class) +public @interface EchoService { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoServiceHandler.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoServiceHandler.java new file mode 100644 index 00000000..4ab86cb8 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/EchoServiceHandler.java @@ -0,0 +1,27 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.serviceHandler; + +import javax.interceptor.AroundInvoke; +import javax.interceptor.InvocationContext; + +public class EchoServiceHandler { + @AroundInvoke + public Object invoke(InvocationContext ctx) { + return ctx.getMethod().getName().toString(); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/GoodbyeWorld.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/GoodbyeWorld.java new file mode 100644 index 00000000..a72afc8b --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/GoodbyeWorld.java @@ -0,0 +1,27 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.serviceHandler; + +@EchoService +public abstract class GoodbyeWorld { + public String otherMethod() { + return "not saying goodbye"; + } + + public abstract String goodbyeWorld(); + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/HelloWorld.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/HelloWorld.java new file mode 100644 index 00000000..cb11a45a --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/HelloWorld.java @@ -0,0 +1,22 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.serviceHandler; + +@EchoService +public interface HelloWorld { + public String helloWorld(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java new file mode 100644 index 00000000..6319cb20 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java @@ -0,0 +1,66 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.serviceHandler; + +import javax.inject.Inject; + +import junit.framework.Assert; +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; + +/** + * @author Stuart Douglas + */ +@RunWith(Arquillian.class) +public class ServiceHandlerTest { + + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(ServiceHandlerTest.class.getPackage()); + } + + @Inject + private HelloWorld helloWorld; + + @Inject + private GoodbyeWorld goodbyeWorld; + + @Inject + private DecoratedHelloWorld decoratedHelloWorld; + + @Test + public void testProxiedInterface() { + Assert.assertTrue(helloWorld.helloWorld().equals("helloWorld")); + } + + @Test + public void testProxiedAbstractClass() { + Assert.assertTrue(goodbyeWorld.goodbyeWorld().equals("goodbyeWorld")); + Assert.assertFalse(goodbyeWorld.otherMethod().equals("otherMethod")); + } + + @Test + public void testInjectionIntoHandler() { + Assert.assertTrue(decoratedHelloWorld.decoratedHelloWorld().equals("-decoratedHelloWorld-")); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/BeanProducer.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/BeanProducer.java new file mode 100644 index 00000000..f8c015a3 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/BeanProducer.java @@ -0,0 +1,30 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.unwraps; + +import javax.enterprise.inject.spi.InjectionPoint; + +import org.jboss.seam.solder.unwraps.Unwraps; + +public class BeanProducer { + @Unwraps + public ProducedInterface produce(InjectionPoint injectionPoint) { + ProducedBean b = new ProducedBean(); + b.setValue(injectionPoint.getAnnotated().getAnnotation(MPType.class).value()); + return b; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/Lion.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/Lion.java new file mode 100644 index 00000000..deb2bb5b --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/Lion.java @@ -0,0 +1,36 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.unwraps; + +import org.jboss.seam.solder.core.Veto; + +@Veto +public class Lion { + private final String name; + + public Lion() { + name = "default lion"; + } + + public Lion(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/LionTamer.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/LionTamer.java new file mode 100644 index 00000000..51b984f4 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/LionTamer.java @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.unwraps; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; + +import org.jboss.seam.solder.unwraps.Unwraps; + +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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. + */ +@ApplicationScoped +public class LionTamer { + + private Lion lion = new Lion("lion one"); + + public void changeLion() { + lion = new Lion("lion two"); + } + + @Unwraps + @Named("lion") + public Lion produceLion() { + return lion; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/MPType.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/MPType.java new file mode 100644 index 00000000..816d7156 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/MPType.java @@ -0,0 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.unwraps; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface MPType { + String value(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ManagedReceiver.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ManagedReceiver.java new file mode 100644 index 00000000..c37a9eb1 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ManagedReceiver.java @@ -0,0 +1,38 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.unwraps; + +import javax.inject.Inject; + +public class ManagedReceiver { + @MPType("bean1") + @Inject + private ProducedInterface bean1; + + @MPType("bean2") + @Inject + private ProducedInterface bean2; + + public ProducedInterface getBean1() { + return bean1; + } + + public ProducedInterface getBean2() { + return bean2; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ProducedBean.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ProducedBean.java new file mode 100644 index 00000000..8a58d8d0 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ProducedBean.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.unwraps; + +import org.jboss.seam.solder.core.Veto; + +@Veto +public class ProducedBean implements ProducedInterface { + String value = "wrong"; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ProducedInterface.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ProducedInterface.java new file mode 100644 index 00000000..6b60a29f --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/ProducedInterface.java @@ -0,0 +1,23 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.unwraps; + +public interface ProducedInterface { + + public abstract String getValue(); + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java new file mode 100644 index 00000000..18633650 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java @@ -0,0 +1,61 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.unwraps; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; + +@RunWith(Arquillian.class) +public class UnwrapsTest { + + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(UnwrapsTest.class.getPackage()); + } + + @Inject + ManagedReceiver bean; + + @Inject + @Named("lion") + Lion lion; + + @Inject + LionTamer lionTamer; + + @Test + public void testUnwrapsInjectionPoint() { + assert bean.getBean1().getValue().equals("bean1") : " value: " + bean.getBean1().getValue(); + assert bean.getBean2().getValue().equals("bean2") : " value: " + bean.getBean2().getValue(); + } + + @Test + public void testUnwraps() { + assert lion.getName().equals("lion one"); + lionTamer.changeLion(); + assert lion.getName().equals("lion two"); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Animal.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Animal.java new file mode 100644 index 00000000..b751bb65 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Animal.java @@ -0,0 +1,27 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface Animal { + + String species(); + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Animals.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Animals.java new file mode 100644 index 00000000..7e1a0ec8 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Animals.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +public class Animals { + + @Animal(species = "Dog") + public void dog() { + + } + + @Cat + public void cat() { + + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotatedClass.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotatedClass.java new file mode 100644 index 00000000..633ad151 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotatedClass.java @@ -0,0 +1,24 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +@SimpleAnnotation +@IntMemberAnnotation(someMember = 0, value = 1) +@MultipleMembers(booleanMember = true, byteMember = 1, charMember = 'c', doubleMember = 0, floatMember = 0, intMember = 1, intArrayMember = {0, 1}, longMember = 1, shortMember = 1) +public class AnnotatedClass { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java new file mode 100644 index 00000000..48d6a930 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java @@ -0,0 +1,109 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +import java.lang.reflect.Method; + +import javax.enterprise.inject.spi.Annotated; +import javax.enterprise.inject.spi.AnnotatedMethod; +import javax.enterprise.inject.spi.AnnotatedType; +import javax.enterprise.inject.spi.BeanManager; +import javax.inject.Inject; + +import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.seam.solder.reflection.AnnotationInspector; +import org.jboss.seam.solder.reflection.annotated.AnnotatedTypeBuilder; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +@RunWith(Arquillian.class) +public class AnnotationInspectorTest { + @Deployment + public static Archive deployment() { + return baseDeployment().addPackage(AnnotationInspectorTest.class.getPackage()); + } + + private static final String DOG = "Dog"; + private static final String CAT = "Cat"; + + Method dogMethod; + Annotated dogAnnotated; + + Method catMethod; + Annotated catAnnotated; + + @Inject + BeanManager beanManager; + + //@Before + public void resolveMethods() throws Exception { + dogMethod = Animals.class.getMethod("dog"); + catMethod = Animals.class.getMethod("cat"); + + AnnotatedType animals = new AnnotatedTypeBuilder().readFromType(Animals.class).create(); + for (AnnotatedMethod candidate : animals.getMethods()) { + if (candidate.getJavaMember().getName().equals("dog")) { + dogAnnotated = candidate; + } else if (candidate.getJavaMember().getName().equals("cat")) { + catAnnotated = candidate; + } + } + } + + @Test + public void testAnnotationOnElement() throws Exception { + resolveMethods(); + assertTrue(dogMethod.isAnnotationPresent(Animal.class)); + + assertTrue(AnnotationInspector.isAnnotationPresent(dogMethod, Animal.class, false, beanManager)); + assertEquals(DOG, AnnotationInspector.getAnnotation(dogMethod, Animal.class, false, beanManager).species()); + + assertTrue(AnnotationInspector.isAnnotationPresent(dogMethod, Animal.class, beanManager)); + assertEquals(DOG, AnnotationInspector.getAnnotation(dogMethod, Animal.class, beanManager).species()); + + assertTrue(AnnotationInspector.isAnnotationPresent(dogAnnotated, Animal.class, beanManager)); + assertEquals(DOG, AnnotationInspector.getAnnotation(dogAnnotated, Animal.class, beanManager).species()); + } + + @Test + public void testAnnotationOnStereotype() throws Exception { + resolveMethods(); + assertFalse(catMethod.isAnnotationPresent(Animal.class)); + + assertTrue(AnnotationInspector.isAnnotationPresent(catMethod, Animal.class, true, beanManager)); + assertEquals(CAT, AnnotationInspector.getAnnotation(catMethod, Animal.class, true, beanManager).species()); + + assertTrue(AnnotationInspector.isAnnotationPresent(catMethod, Animal.class, beanManager)); + assertEquals(CAT, AnnotationInspector.getAnnotation(catMethod, Animal.class, beanManager).species()); + + assertTrue(AnnotationInspector.isAnnotationPresentOnStereotype(catMethod, Animal.class, beanManager)); + assertEquals(CAT, AnnotationInspector.getAnnotationFromStereotype(catMethod, Animal.class, beanManager).species()); + + assertTrue(AnnotationInspector.isAnnotationPresent(catAnnotated, Animal.class, beanManager)); + assertEquals(CAT, AnnotationInspector.getAnnotation(catAnnotated, Animal.class, beanManager).species()); + + assertTrue(AnnotationInspector.isAnnotationPresentOnStereotype(catAnnotated, Animal.class, beanManager)); + assertEquals(CAT, AnnotationInspector.getAnnotationFromStereotype(catAnnotated, Animal.class, beanManager).species()); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInstanceProviderTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInstanceProviderTest.java new file mode 100644 index 00000000..b021b294 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInstanceProviderTest.java @@ -0,0 +1,129 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.jboss.seam.solder.reflection.AnnotationInstanceProvider; +import org.jboss.seam.solder.reflection.NullMemberException; +import org.junit.Test; + +/** + * Test of dynamic annotation creation + * + * @author Stuart Douglas + */ +public class AnnotationInstanceProviderTest { + + /** + * basic test to make sure the annotation creator can create an annotation + */ + @Test + public void testSimpleAnnotationCreation() { + AnnotationInstanceProvider provider = new AnnotationInstanceProvider(); + SimpleAnnotation an = provider.get(SimpleAnnotation.class, Collections.emptyMap()); + assert an != null : "Annotation was null"; + assert an.annotationType() == SimpleAnnotation.class : "Annotation returned wrong result for annotationType()"; + SimpleAnnotation realAn = AnnotatedClass.class.getAnnotation(SimpleAnnotation.class); + assert an.equals(realAn) : "Equality between declared annotation failed"; + } + + /** + * Test with int members + */ + @Test + public void testIntMemberAnnotationCreation() { + AnnotationInstanceProvider provider = new AnnotationInstanceProvider(); + Map values = new HashMap(); + values.put("value", Long.valueOf(1)); + values.put("someMember", Integer.valueOf(0)); + IntMemberAnnotation an = provider.get(IntMemberAnnotation.class, values); + assert an != null : "Annotation was null"; + assert an.annotationType() == IntMemberAnnotation.class : "Annotation returned wrong result for annotationType()"; + IntMemberAnnotation realAn = AnnotatedClass.class.getAnnotation(IntMemberAnnotation.class); + assert an.equals(realAn) : "Equality between declared annotation failed"; + } + + /** + * Test with int members + */ + @Test + public void testNotEqualIntMemberAnnotationCreation() { + AnnotationInstanceProvider provider = new AnnotationInstanceProvider(); + Map values = new HashMap(); + values.put("value", Long.valueOf(6)); + values.put("someMember", Integer.valueOf(0)); + IntMemberAnnotation an = provider.get(IntMemberAnnotation.class, values); + assert an != null : "Annotation was null"; + assert an.annotationType() == IntMemberAnnotation.class : "Annotation returned wrong result for annotationType()"; + IntMemberAnnotation realAn = AnnotatedClass.class.getAnnotation(IntMemberAnnotation.class); + assert !an.equals(realAn) : "Equality between declared annotation failed, annotations were not equal but equals returned true"; + } + + /** + * Test with multiple members + */ + @Test + public void testMultipleMemberAnnotationCreation() { + AnnotationInstanceProvider provider = new AnnotationInstanceProvider(); + Map values = new HashMap(); + values.put("intMember", 1); + values.put("longMember", 1); + values.put("shortMember", 1); + values.put("floatMember", 0); + values.put("doubleMember", 0); + values.put("byteMember", ((byte) 1)); + values.put("charMember", 'c'); + values.put("booleanMember", true); + values.put("intArrayMember", new int[]{0, 1}); + MultipleMembers an = provider.get(MultipleMembers.class, values); + assert an != null : "Annotation was null"; + assert an.annotationType() == MultipleMembers.class : "Annotation returned wrong result for annotationType()"; + MultipleMembers realAn = AnnotatedClass.class.getAnnotation(MultipleMembers.class); + assert an.equals(realAn) : "Equality between declared annotation failed"; + } + + /** + * Test that an exception is thrown when a member is null + */ + @Test(expected = NullMemberException.class) + public void testNullMemberException() { + AnnotationInstanceProvider provider = new AnnotationInstanceProvider(); + Map values = new HashMap(); + values.put("value", Long.valueOf(1)); + values.put("someMember", null); + IntMemberAnnotation an = provider.get(IntMemberAnnotation.class, values); + + } + + /** + * Test that an Annotation will use the default values if a member with + * default values is null + */ + @Test + public void testDefaultValue() { + AnnotationInstanceProvider provider = new AnnotationInstanceProvider(); + Map values = new HashMap(); + values.put("someMember", Integer.valueOf(0)); + IntMemberAnnotation an = provider.get(IntMemberAnnotation.class, values); + assert an != null : "Annotation was null"; + assert an.value() == 1 : "Annotation member was not equal to default value"; + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Cat.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Cat.java new file mode 100644 index 00000000..9eda0fde --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Cat.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.enterprise.inject.Stereotype; + +@Retention(RetentionPolicy.RUNTIME) +@Stereotype +@Target(ElementType.METHOD) +@Animal(species = "Cat") +public @interface Cat { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Deployments.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Deployments.java new file mode 100644 index 00000000..4e626950 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Deployments.java @@ -0,0 +1,39 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +import org.jboss.arquillian.spi.client.container.DeployableContainer; +import org.jboss.arquillian.spi.util.ServiceLoader; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; + +public class Deployments { + public static WebArchive baseDeployment() { + return ShrinkWrap.create(WebArchive.class, "test.war") + .addAsLibraries( + MavenArtifactResolver.resolve("org.jboss.seam.solder", "seam-solder-api"), + MavenArtifactResolver.resolve("org.jboss.seam.solder", "seam-solder"), + MavenArtifactResolver.resolve("org.jboss.seam.solder", "seam-solder-logging")) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + public static Class targetContainerAdapterClass() { + ServiceLoader l = ServiceLoader.load(DeployableContainer.class); + return l.getProviders().iterator().next().getClass(); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/IntMemberAnnotation.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/IntMemberAnnotation.java new file mode 100644 index 00000000..d7448ec9 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/IntMemberAnnotation.java @@ -0,0 +1,27 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface IntMemberAnnotation { + int value() default 1; + + int someMember(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MavenArtifactPathResolverTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MavenArtifactPathResolverTest.java new file mode 100644 index 00000000..85090cd1 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MavenArtifactPathResolverTest.java @@ -0,0 +1,145 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class MavenArtifactPathResolverTest { + public static final String groupId = "org.jboss.seam.solder"; + public static final String artifactId = "seam-solder-api"; + + public static final char linuxFileSeparator = '/'; + public static final char linuxPathSeparator = ':'; + + public static final char windowsFileSeparator = '\\'; + public static final char windowsPathSeparator = ';'; + + @Test + public void testWindowsInLocalModule() { + List targetContents = Arrays.asList("V:\\workspace\\extensions\\impl\\target\\surefire-report", "V:\\workspace\\extensions\\impl\\target\\classes", "V:\\workspace\\extensions\\impl\\target\\test-classes", "V:\\workspace\\extensions\\impl\\target\\seam-solder-api-3.0.1-SNAPSHOT-sources.jar", "V:\\workspace\\extensions\\impl\\target\\seam-solder-api-3.0.1-SNAPSHOT.jar"); + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, null, windowsPathSeparator, windowsFileSeparator); + String path = resolver.scanForArtifact(targetContents); + assertEquals("V:\\workspace\\extensions\\impl\\target\\seam-solder-api-3.0.1-SNAPSHOT.jar", path); + } + + @Test + public void testWindowsInLocalModuleWithDotQualifier() { + List targetContents = Arrays.asList("V:\\workspace\\extensions\\impl\\target\\surefire-report", "V:\\workspace\\extensions\\impl\\target\\classes", "V:\\workspace\\extensions\\impl\\target\\test-classes", "V:\\workspace\\extensions\\impl\\target\\seam-solder-api-3.0.1.Final-sources.jar", "V:\\workspace\\extensions\\impl\\target\\seam-solder-api-3.0.1.Final.jar"); + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, null, windowsPathSeparator, windowsFileSeparator); + String path = resolver.scanForArtifact(targetContents); + assertEquals("V:\\workspace\\extensions\\impl\\target\\seam-solder-api-3.0.1.Final.jar", path); + } + + + @Test + public void testLinuxInLocalModule() { + List targetContents = Arrays.asList("/workspace/extensions/impl/target/surefire-report", "/workspace/extensions/impl/target/classes", "/workspace/extensions/impl/target/test-classes", "/workspace/extensions/impl/target/seam-solder-api-3.0.1-SNAPSHOT-sources.jar", "/workspace/extensions/impl/target/seam-solder-api-3.0.1-SNAPSHOT.jar"); + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, null, windowsPathSeparator, windowsFileSeparator); + String path = resolver.scanForArtifact(targetContents); + assertEquals("/workspace/extensions/impl/target/seam-solder-api-3.0.1-SNAPSHOT.jar", path); + } + + @Test + public void testLinuxInLocalModuleWithDotQualifier() { + List targetContents = Arrays.asList("/workspace/extensions/impl/target/surefire-report", "/workspace/extensions/impl/target/classes", "/workspace/extensions/impl/target/test-classes", "/workspace/extensions/impl/target/seam-solder-api-3.0.1.Final-sources.jar", "/workspace/extensions/impl/target/seam-solder-api-3.0.1.Final.jar"); + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, null, windowsPathSeparator, windowsFileSeparator); + String path = resolver.scanForArtifact(targetContents); + assertEquals("/workspace/extensions/impl/target/seam-solder-api-3.0.1.Final.jar", path); + } + + @Test + public void testWindows() { + String classPath = "V:\\workspace\\extensions\\impl\\target\\test-classes;V:\\workspace\\extensions\\impl\\target\\classes;C:\\Users\\john.doe\\.m2\\repository\\org\\javassist\\javassist\\3.13.0-GA\\javassist-3.13.0-GA.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\seam\\solder\\seam-solder-api\\3.0.1-SNAPSHOT\\seam-solder-api-3.0.1-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\enterprise\\cdi-api\\1.0-SP2\\cdi-api-1.0-SP2.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\spec\\javax\\interceptor\\jboss-interceptors-api_1.1_spec\\1.0.0.Beta1\\jboss-interceptors-api_1.1_spec-1.0.0.Beta1.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\annotation\\jsr250-api\\1.0\\jsr250-api-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\inject\\javax.inject\\1\\javax.inject-1.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\slf4j\\slf4j-api\\1.5.10\\slf4j-api-1.5.10.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-core\\1.1.0-SNAPSHOT\\weld-core-1.1.0-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-api\\1.1-SNAPSHOT\\weld-api-1.1-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-spi\\1.1-SNAPSHOT\\weld-spi-1.1-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\com\\google\\guava\\guava\\r06\\guava-r06.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\interceptor\\jboss-interceptor\\1.0.0-CR11\\jboss-interceptor-1.0.0-CR11.jar;C:\\Users\\john.doe\\.m2\\repository\\javassist\\javassist\\3.11.0.GA\\javassist-3.11.0.GA.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\slf4j\\slf4j-ext\\1.5.10\\slf4j-ext-1.5.10.jar;C:\\Users\\john.doe\\.m2\\repository\\ch\\qos\\cal10n\\cal10n-api\\0.7.2\\cal10n-api-0.7.2.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\ejb3\\jboss-ejb3-api\\3.1.0\\jboss-ejb3-api-3.1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\servlet\\servlet-api\\2.5\\servlet-api-2.5.jar;C:\\Users\\john.doe\\.m2\\repository\\junit\\junit\\4.8.1\\junit-4.8.1.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-junit\\1.0.0.Alpha3\\arquillian-junit-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-impl-base\\1.0.0.Alpha3\\arquillian-impl-base-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-api\\1.0.0.Alpha3\\arquillian-api-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-api\\1.0.0-alpha-11\\shrinkwrap-api-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-spi\\1.0.0.Alpha3\\arquillian-spi-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-impl-base\\1.0.0-alpha-11\\shrinkwrap-impl-base-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-spi\\1.0.0-alpha-11\\shrinkwrap-spi-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\el\\el-api\\2.2\\el-api-2.2.jar;C:\\Users\\john.doe\\.m2\\repository\\el-impl\\el-impl\\1.0\\el-impl-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\container\\arquillian-weld-ee-embedded-1.1\\1.0.0.Alpha3\\arquillian-weld-ee-embedded-1.1-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\protocol\\arquillian-protocol-local\\1.0.0.Alpha3\\arquillian-protocol-local-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\testenricher\\arquillian-testenricher-cdi\\1.0.0.Alpha3\\arquillian-testenricher-cdi-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-extension-classloader\\1.0.0-alpha-11\\shrinkwrap-extension-classloader-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\transaction\\jta\\1.1\\jta-1.1.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\persistence\\persistence-api\\1.0\\persistence-api-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\validation\\validation-api\\1.0.0.GA\\validation-api-1.0.0.GA.jar;/V:/eclipse/configuration/org.eclipse.osgi/bundles/311/1/.cp/;/V:/eclipse/configuration/org.eclipse.osgi/bundles/309/1/.cp/;/V:/eclipse/configuration/org.eclipse.osgi/bundles/310/1/.cp/"; + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, classPath, windowsPathSeparator, windowsFileSeparator); + String path = resolver.resolve(); + assertEquals("C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\seam\\solder\\seam-solder-api\\3.0.1-SNAPSHOT\\seam-solder-api-3.0.1-SNAPSHOT.jar", path); + } + + @Test + public void testWindowsInReactorWithDotQualifier() { + String classPath = "V:\\workspace\\extensions\\impl\\target\\test-classes;V:\\workspace\\extensions\\impl\\target\\classes;V:\\workspace\\extensions\\impl\\target\\seam-solder-api-3.0.1.Final.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\javassist\\javassist\\3.13.0-GA\\javassist-3.13.0-GA.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\enterprise\\cdi-api\\1.0-SP2\\cdi-api-1.0-SP2.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\spec\\javax\\interceptor\\jboss-interceptors-api_1.1_spec\\1.0.0.Beta1\\jboss-interceptors-api_1.1_spec-1.0.0.Beta1.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\annotation\\jsr250-api\\1.0\\jsr250-api-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\inject\\javax.inject\\1\\javax.inject-1.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\slf4j\\slf4j-api\\1.5.10\\slf4j-api-1.5.10.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-core\\1.1.0-SNAPSHOT\\weld-core-1.1.0-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-api\\1.1-SNAPSHOT\\weld-api-1.1-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-spi\\1.1-SNAPSHOT\\weld-spi-1.1-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\com\\google\\guava\\guava\\r06\\guava-r06.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\interceptor\\jboss-interceptor\\1.0.0-CR11\\jboss-interceptor-1.0.0-CR11.jar;C:\\Users\\john.doe\\.m2\\repository\\javassist\\javassist\\3.11.0.GA\\javassist-3.11.0.GA.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\slf4j\\slf4j-ext\\1.5.10\\slf4j-ext-1.5.10.jar;C:\\Users\\john.doe\\.m2\\repository\\ch\\qos\\cal10n\\cal10n-api\\0.7.2\\cal10n-api-0.7.2.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\ejb3\\jboss-ejb3-api\\3.1.0\\jboss-ejb3-api-3.1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\servlet\\servlet-api\\2.5\\servlet-api-2.5.jar;C:\\Users\\john.doe\\.m2\\repository\\junit\\junit\\4.8.1\\junit-4.8.1.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-junit\\1.0.0.Alpha3\\arquillian-junit-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-impl-base\\1.0.0.Alpha3\\arquillian-impl-base-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-api\\1.0.0.Alpha3\\arquillian-api-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-api\\1.0.0-alpha-11\\shrinkwrap-api-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-spi\\1.0.0.Alpha3\\arquillian-spi-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-impl-base\\1.0.0-alpha-11\\shrinkwrap-impl-base-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-spi\\1.0.0-alpha-11\\shrinkwrap-spi-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\el\\el-api\\2.2\\el-api-2.2.jar;C:\\Users\\john.doe\\.m2\\repository\\el-impl\\el-impl\\1.0\\el-impl-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\container\\arquillian-weld-ee-embedded-1.1\\1.0.0.Alpha3\\arquillian-weld-ee-embedded-1.1-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\protocol\\arquillian-protocol-local\\1.0.0.Alpha3\\arquillian-protocol-local-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\testenricher\\arquillian-testenricher-cdi\\1.0.0.Alpha3\\arquillian-testenricher-cdi-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-extension-classloader\\1.0.0-alpha-11\\shrinkwrap-extension-classloader-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\transaction\\jta\\1.1\\jta-1.1.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\persistence\\persistence-api\\1.0\\persistence-api-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\validation\\validation-api\\1.0.0.GA\\validation-api-1.0.0.GA.jar;/V:/eclipse/configuration/org.eclipse.osgi/bundles/311/1/.cp/;/V:/eclipse/configuration/org.eclipse.osgi/bundles/309/1/.cp/;/V:/eclipse/configuration/org.eclipse.osgi/bundles/310/1/.cp/"; + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, classPath, windowsPathSeparator, windowsFileSeparator); + String path = resolver.resolve(); + assertEquals("V:\\workspace\\extensions\\impl\\target\\seam-solder-api-3.0.1.Final.jar", path); + } + + @Test + public void testWindowsWithDotQualifier() { + String classPath = "V:\\workspace\\extensions\\impl\\target\\test-classes;V:\\workspace\\extensions\\impl\\target\\classes;C:\\Users\\john.doe\\.m2\\repository\\org\\javassist\\javassist\\3.13.0-GA\\javassist-3.13.0-GA.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\seam\\solder\\seam-solder-api\\3.0.1.Final\\seam-solder-api-3.0.1.Final.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\enterprise\\cdi-api\\1.0-SP2\\cdi-api-1.0-SP2.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\spec\\javax\\interceptor\\jboss-interceptors-api_1.1_spec\\1.0.0.Beta1\\jboss-interceptors-api_1.1_spec-1.0.0.Beta1.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\annotation\\jsr250-api\\1.0\\jsr250-api-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\inject\\javax.inject\\1\\javax.inject-1.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\slf4j\\slf4j-api\\1.5.10\\slf4j-api-1.5.10.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-core\\1.1.0-SNAPSHOT\\weld-core-1.1.0-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-api\\1.1-SNAPSHOT\\weld-api-1.1-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-spi\\1.1-SNAPSHOT\\weld-spi-1.1-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\com\\google\\guava\\guava\\r06\\guava-r06.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\interceptor\\jboss-interceptor\\1.0.0-CR11\\jboss-interceptor-1.0.0-CR11.jar;C:\\Users\\john.doe\\.m2\\repository\\javassist\\javassist\\3.11.0.GA\\javassist-3.11.0.GA.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\slf4j\\slf4j-ext\\1.5.10\\slf4j-ext-1.5.10.jar;C:\\Users\\john.doe\\.m2\\repository\\ch\\qos\\cal10n\\cal10n-api\\0.7.2\\cal10n-api-0.7.2.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\ejb3\\jboss-ejb3-api\\3.1.0\\jboss-ejb3-api-3.1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\servlet\\servlet-api\\2.5\\servlet-api-2.5.jar;C:\\Users\\john.doe\\.m2\\repository\\junit\\junit\\4.8.1\\junit-4.8.1.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-junit\\1.0.0.Alpha3\\arquillian-junit-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-impl-base\\1.0.0.Alpha3\\arquillian-impl-base-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-api\\1.0.0.Alpha3\\arquillian-api-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-api\\1.0.0-alpha-11\\shrinkwrap-api-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-spi\\1.0.0.Alpha3\\arquillian-spi-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-impl-base\\1.0.0-alpha-11\\shrinkwrap-impl-base-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-spi\\1.0.0-alpha-11\\shrinkwrap-spi-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\el\\el-api\\2.2\\el-api-2.2.jar;C:\\Users\\john.doe\\.m2\\repository\\el-impl\\el-impl\\1.0\\el-impl-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\container\\arquillian-weld-ee-embedded-1.1\\1.0.0.Alpha3\\arquillian-weld-ee-embedded-1.1-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\protocol\\arquillian-protocol-local\\1.0.0.Alpha3\\arquillian-protocol-local-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\testenricher\\arquillian-testenricher-cdi\\1.0.0.Alpha3\\arquillian-testenricher-cdi-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-extension-classloader\\1.0.0-alpha-11\\shrinkwrap-extension-classloader-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\transaction\\jta\\1.1\\jta-1.1.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\persistence\\persistence-api\\1.0\\persistence-api-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\validation\\validation-api\\1.0.0.GA\\validation-api-1.0.0.GA.jar;/V:/eclipse/configuration/org.eclipse.osgi/bundles/311/1/.cp/;/V:/eclipse/configuration/org.eclipse.osgi/bundles/309/1/.cp/;/V:/eclipse/configuration/org.eclipse.osgi/bundles/310/1/.cp/"; + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, classPath, windowsPathSeparator, windowsFileSeparator); + String path = resolver.resolve(); + assertEquals("C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\seam\\solder\\seam-solder-api\\3.0.1.Final\\seam-solder-api-3.0.1.Final.jar", path); + } + + @Test + public void testWindowsInReactor() { + String classPath = "V:\\workspace\\extensions\\impl\\target\\test-classes;V:\\workspace\\extensions\\impl\\target\\classes;V:\\workspace\\extensions\\impl\\target\\seam-solder-api-3.0.1-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\javassist\\javassist\\3.13.0-GA\\javassist-3.13.0-GA.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\enterprise\\cdi-api\\1.0-SP2\\cdi-api-1.0-SP2.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\spec\\javax\\interceptor\\jboss-interceptors-api_1.1_spec\\1.0.0.Beta1\\jboss-interceptors-api_1.1_spec-1.0.0.Beta1.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\annotation\\jsr250-api\\1.0\\jsr250-api-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\inject\\javax.inject\\1\\javax.inject-1.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\slf4j\\slf4j-api\\1.5.10\\slf4j-api-1.5.10.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-core\\1.1.0-SNAPSHOT\\weld-core-1.1.0-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-api\\1.1-SNAPSHOT\\weld-api-1.1-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\weld\\weld-spi\\1.1-SNAPSHOT\\weld-spi-1.1-SNAPSHOT.jar;C:\\Users\\john.doe\\.m2\\repository\\com\\google\\guava\\guava\\r06\\guava-r06.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\interceptor\\jboss-interceptor\\1.0.0-CR11\\jboss-interceptor-1.0.0-CR11.jar;C:\\Users\\john.doe\\.m2\\repository\\javassist\\javassist\\3.11.0.GA\\javassist-3.11.0.GA.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\slf4j\\slf4j-ext\\1.5.10\\slf4j-ext-1.5.10.jar;C:\\Users\\john.doe\\.m2\\repository\\ch\\qos\\cal10n\\cal10n-api\\0.7.2\\cal10n-api-0.7.2.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\ejb3\\jboss-ejb3-api\\3.1.0\\jboss-ejb3-api-3.1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\servlet\\servlet-api\\2.5\\servlet-api-2.5.jar;C:\\Users\\john.doe\\.m2\\repository\\junit\\junit\\4.8.1\\junit-4.8.1.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-junit\\1.0.0.Alpha3\\arquillian-junit-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-impl-base\\1.0.0.Alpha3\\arquillian-impl-base-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-api\\1.0.0.Alpha3\\arquillian-api-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-api\\1.0.0-alpha-11\\shrinkwrap-api-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\arquillian-spi\\1.0.0.Alpha3\\arquillian-spi-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-impl-base\\1.0.0-alpha-11\\shrinkwrap-impl-base-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-spi\\1.0.0-alpha-11\\shrinkwrap-spi-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\el\\el-api\\2.2\\el-api-2.2.jar;C:\\Users\\john.doe\\.m2\\repository\\el-impl\\el-impl\\1.0\\el-impl-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\container\\arquillian-weld-ee-embedded-1.1\\1.0.0.Alpha3\\arquillian-weld-ee-embedded-1.1-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\protocol\\arquillian-protocol-local\\1.0.0.Alpha3\\arquillian-protocol-local-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\arquillian\\testenricher\\arquillian-testenricher-cdi\\1.0.0.Alpha3\\arquillian-testenricher-cdi-1.0.0.Alpha3.jar;C:\\Users\\john.doe\\.m2\\repository\\org\\jboss\\shrinkwrap\\shrinkwrap-extension-classloader\\1.0.0-alpha-11\\shrinkwrap-extension-classloader-1.0.0-alpha-11.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\transaction\\jta\\1.1\\jta-1.1.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\persistence\\persistence-api\\1.0\\persistence-api-1.0.jar;C:\\Users\\john.doe\\.m2\\repository\\javax\\validation\\validation-api\\1.0.0.GA\\validation-api-1.0.0.GA.jar;/V:/eclipse/configuration/org.eclipse.osgi/bundles/311/1/.cp/;/V:/eclipse/configuration/org.eclipse.osgi/bundles/309/1/.cp/;/V:/eclipse/configuration/org.eclipse.osgi/bundles/310/1/.cp/"; + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, classPath, windowsPathSeparator, windowsFileSeparator); + String path = resolver.resolve(); + assertEquals("V:\\workspace\\extensions\\impl\\target\\seam-solder-api-3.0.1-SNAPSHOT.jar", path); + } + + @Test + public void testLinux() { + String classPath = "/home/user/workspace/extensions/impl/target/test-classes:/home/jdoe/workspace/extensions/impl/target/classes:/home/jdoe/.m2/repository/org/javassist/javassist/3.13.0-GA/javassist-3.13.0-GA.jar:/home/jdoe/.m2/repository/org/jboss/seam/solder/seam-solder-api/3.0.1-SNAPSHOT/seam-solder-api-3.0.1-SNAPSHOT.jar:/home/jdoe/.m2/repository/javax/enterprise/cdi-api/1.0-SP2/cdi-api-1.0-SP2.jar:/home/jdoe/.m2/repository/org/jboss/spec/javax/interceptor/jboss-interceptors-api_1.1_spec/1.0.0.Beta1/jboss-interceptors-api_1.1_spec-1.0.0.Beta1.jar:/home/jdoe/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar:/home/jdoe/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/home/jdoe/.m2/repository/org/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-core/1.1.0-SNAPSHOT/weld-core-1.1.0-SNAPSHOT.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-api/1.1-SNAPSHOT/weld-api-1.1-SNAPSHOT.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-spi/1.1-SNAPSHOT/weld-spi-1.1-SNAPSHOT.jar:/home/jdoe/.m2/repository/com/google/guava/guava/r06/guava-r06.jar:/home/jdoe/.m2/repository/org/jboss/interceptor/jboss-interceptor/1.0.0-CR11/jboss-interceptor-1.0.0-CR11.jar:/home/jdoe/.m2/repository/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA.jar:/home/jdoe/.m2/repository/org/slf4j/slf4j-ext/1.5.10/slf4j-ext-1.5.10.jar:/home/jdoe/.m2/repository/ch/qos/cal10n/cal10n-api/0.7.2/cal10n-api-0.7.2.jar:/home/jdoe/.m2/repository/org/jboss/ejb3/jboss-ejb3-api/3.1.0/jboss-ejb3-api-3.1.0.jar:/home/jdoe/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:/home/jdoe/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-junit/1.0.0.Alpha3/arquillian-junit-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-impl-base/1.0.0.Alpha3/arquillian-impl-base-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-api/1.0.0.Alpha3/arquillian-api-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-api/1.0.0-alpha-11/shrinkwrap-api-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-spi/1.0.0.Alpha3/arquillian-spi-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-impl-base/1.0.0-alpha-11/shrinkwrap-impl-base-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-spi/1.0.0-alpha-11/shrinkwrap-spi-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/javax/el/el-api/2.2/el-api-2.2.jar:/home/jdoe/.m2/repository/el-impl/el-impl/1.0/el-impl-1.0.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/container/arquillian-weld-ee-embedded-1.1/1.0.0.Alpha3/arquillian-weld-ee-embedded-1.1-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/protocol/arquillian-protocol-local/1.0.0.Alpha3/arquillian-protocol-local-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/testenricher/arquillian-testenricher-cdi/1.0.0.Alpha3/arquillian-testenricher-cdi-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-extension-classloader/1.0.0-alpha-11/shrinkwrap-extension-classloader-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar:/home/jdoe/.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar:/home/jdoe/.m2/repository/javax/validation/validation-api/1.0.0.GA/validation-api-1.0.0.GA.jar:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/112/1/.cp/:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/110/1/.cp/:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/111/1/.cp/"; + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, classPath, linuxPathSeparator, linuxFileSeparator); + String path = resolver.resolve(); + assertEquals("/home/jdoe/.m2/repository/org/jboss/seam/solder/seam-solder-api/3.0.1-SNAPSHOT/seam-solder-api-3.0.1-SNAPSHOT.jar", path); + } + + @Test + public void testLinuxWithDotQualifier() { + String classPath = "/home/user/workspace/extensions/impl/target/test-classes:/home/jdoe/workspace/extensions/impl/target/classes:/home/jdoe/.m2/repository/org/javassist/javassist/3.13.0-GA/javassist-3.13.0-GA.jar:/home/jdoe/.m2/repository/org/jboss/seam/solder/seam-solder-api/3.0.1.Final/seam-solder-api-3.0.1.Final.jar:/home/jdoe/.m2/repository/javax/enterprise/cdi-api/1.0-SP2/cdi-api-1.0-SP2.jar:/home/jdoe/.m2/repository/org/jboss/spec/javax/interceptor/jboss-interceptors-api_1.1_spec/1.0.0.Beta1/jboss-interceptors-api_1.1_spec-1.0.0.Beta1.jar:/home/jdoe/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar:/home/jdoe/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/home/jdoe/.m2/repository/org/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-core/1.1.0-SNAPSHOT/weld-core-1.1.0-SNAPSHOT.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-api/1.1-SNAPSHOT/weld-api-1.1-SNAPSHOT.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-spi/1.1-SNAPSHOT/weld-spi-1.1-SNAPSHOT.jar:/home/jdoe/.m2/repository/com/google/guava/guava/r06/guava-r06.jar:/home/jdoe/.m2/repository/org/jboss/interceptor/jboss-interceptor/1.0.0-CR11/jboss-interceptor-1.0.0-CR11.jar:/home/jdoe/.m2/repository/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA.jar:/home/jdoe/.m2/repository/org/slf4j/slf4j-ext/1.5.10/slf4j-ext-1.5.10.jar:/home/jdoe/.m2/repository/ch/qos/cal10n/cal10n-api/0.7.2/cal10n-api-0.7.2.jar:/home/jdoe/.m2/repository/org/jboss/ejb3/jboss-ejb3-api/3.1.0/jboss-ejb3-api-3.1.0.jar:/home/jdoe/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:/home/jdoe/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-junit/1.0.0.Alpha3/arquillian-junit-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-impl-base/1.0.0.Alpha3/arquillian-impl-base-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-api/1.0.0.Alpha3/arquillian-api-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-api/1.0.0-alpha-11/shrinkwrap-api-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-spi/1.0.0.Alpha3/arquillian-spi-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-impl-base/1.0.0-alpha-11/shrinkwrap-impl-base-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-spi/1.0.0-alpha-11/shrinkwrap-spi-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/javax/el/el-api/2.2/el-api-2.2.jar:/home/jdoe/.m2/repository/el-impl/el-impl/1.0/el-impl-1.0.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/container/arquillian-weld-ee-embedded-1.1/1.0.0.Alpha3/arquillian-weld-ee-embedded-1.1-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/protocol/arquillian-protocol-local/1.0.0.Alpha3/arquillian-protocol-local-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/testenricher/arquillian-testenricher-cdi/1.0.0.Alpha3/arquillian-testenricher-cdi-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-extension-classloader/1.0.0-alpha-11/shrinkwrap-extension-classloader-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar:/home/jdoe/.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar:/home/jdoe/.m2/repository/javax/validation/validation-api/1.0.0.GA/validation-api-1.0.0.GA.jar:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/112/1/.cp/:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/110/1/.cp/:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/111/1/.cp/"; + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, classPath, linuxPathSeparator, linuxFileSeparator); + String path = resolver.resolve(); + assertEquals("/home/jdoe/.m2/repository/org/jboss/seam/solder/seam-solder-api/3.0.1.Final/seam-solder-api-3.0.1.Final.jar", path); + } + + @Test + public void testLinuxInReactor() { + String classPath = "/home/user/workspace/extensions/impl/target/test-classes:/home/jdoe/workspace/extensions/impl/target/classes:/home/jdoe/workspace/extensions/impl/target/seam-solder-api-3.0.1-SNAPSHOT.jar:/home/jdoe/.m2/repository/org/javassist/javassist/3.13.0-GA/javassist-3.13.0-GA.jar:/home/jdoe/.m2/repository/javax/enterprise/cdi-api/1.0-SP2/cdi-api-1.0-SP2.jar:/home/jdoe/.m2/repository/org/jboss/spec/javax/interceptor/jboss-interceptors-api_1.1_spec/1.0.0.Beta1/jboss-interceptors-api_1.1_spec-1.0.0.Beta1.jar:/home/jdoe/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar:/home/jdoe/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/home/jdoe/.m2/repository/org/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-core/1.1.0-SNAPSHOT/weld-core-1.1.0-SNAPSHOT.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-api/1.1-SNAPSHOT/weld-api-1.1-SNAPSHOT.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-spi/1.1-SNAPSHOT/weld-spi-1.1-SNAPSHOT.jar:/home/jdoe/.m2/repository/com/google/guava/guava/r06/guava-r06.jar:/home/jdoe/.m2/repository/org/jboss/interceptor/jboss-interceptor/1.0.0-CR11/jboss-interceptor-1.0.0-CR11.jar:/home/jdoe/.m2/repository/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA.jar:/home/jdoe/.m2/repository/org/slf4j/slf4j-ext/1.5.10/slf4j-ext-1.5.10.jar:/home/jdoe/.m2/repository/ch/qos/cal10n/cal10n-api/0.7.2/cal10n-api-0.7.2.jar:/home/jdoe/.m2/repository/org/jboss/ejb3/jboss-ejb3-api/3.1.0/jboss-ejb3-api-3.1.0.jar:/home/jdoe/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:/home/jdoe/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-junit/1.0.0.Alpha3/arquillian-junit-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-impl-base/1.0.0.Alpha3/arquillian-impl-base-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-api/1.0.0.Alpha3/arquillian-api-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-api/1.0.0-alpha-11/shrinkwrap-api-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-spi/1.0.0.Alpha3/arquillian-spi-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-impl-base/1.0.0-alpha-11/shrinkwrap-impl-base-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-spi/1.0.0-alpha-11/shrinkwrap-spi-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/javax/el/el-api/2.2/el-api-2.2.jar:/home/jdoe/.m2/repository/el-impl/el-impl/1.0/el-impl-1.0.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/container/arquillian-weld-ee-embedded-1.1/1.0.0.Alpha3/arquillian-weld-ee-embedded-1.1-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/protocol/arquillian-protocol-local/1.0.0.Alpha3/arquillian-protocol-local-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/testenricher/arquillian-testenricher-cdi/1.0.0.Alpha3/arquillian-testenricher-cdi-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-extension-classloader/1.0.0-alpha-11/shrinkwrap-extension-classloader-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar:/home/jdoe/.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar:/home/jdoe/.m2/repository/javax/validation/validation-api/1.0.0.GA/validation-api-1.0.0.GA.jar:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/112/1/.cp/:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/110/1/.cp/:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/111/1/.cp/"; + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, classPath, linuxPathSeparator, linuxFileSeparator); + String path = resolver.resolve(); + assertEquals("/home/jdoe/workspace/extensions/impl/target/seam-solder-api-3.0.1-SNAPSHOT.jar", path); + } + + @Test + public void testLinuxInReactorWithDotQualifier() { + String classPath = "/home/user/workspace/extensions/impl/target/test-classes:/home/jdoe/workspace/extensions/impl/target/classes:/home/jdoe/workspace/extensions/impl/target/seam-solder-api-3.0.1.Final.jar:/home/jdoe/.m2/repository/org/javassist/javassist/3.13.0-GA/javassist-3.13.0-GA.jar:/home/jdoe/.m2/repository/javax/enterprise/cdi-api/1.0-SP2/cdi-api-1.0-SP2.jar:/home/jdoe/.m2/repository/org/jboss/spec/javax/interceptor/jboss-interceptors-api_1.1_spec/1.0.0.Beta1/jboss-interceptors-api_1.1_spec-1.0.0.Beta1.jar:/home/jdoe/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar:/home/jdoe/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/home/jdoe/.m2/repository/org/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-core/1.1.0-SNAPSHOT/weld-core-1.1.0-SNAPSHOT.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-api/1.1-SNAPSHOT/weld-api-1.1-SNAPSHOT.jar:/home/jdoe/.m2/repository/org/jboss/weld/weld-spi/1.1-SNAPSHOT/weld-spi-1.1-SNAPSHOT.jar:/home/jdoe/.m2/repository/com/google/guava/guava/r06/guava-r06.jar:/home/jdoe/.m2/repository/org/jboss/interceptor/jboss-interceptor/1.0.0-CR11/jboss-interceptor-1.0.0-CR11.jar:/home/jdoe/.m2/repository/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA.jar:/home/jdoe/.m2/repository/org/slf4j/slf4j-ext/1.5.10/slf4j-ext-1.5.10.jar:/home/jdoe/.m2/repository/ch/qos/cal10n/cal10n-api/0.7.2/cal10n-api-0.7.2.jar:/home/jdoe/.m2/repository/org/jboss/ejb3/jboss-ejb3-api/3.1.0/jboss-ejb3-api-3.1.0.jar:/home/jdoe/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:/home/jdoe/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-junit/1.0.0.Alpha3/arquillian-junit-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-impl-base/1.0.0.Alpha3/arquillian-impl-base-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-api/1.0.0.Alpha3/arquillian-api-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-api/1.0.0-alpha-11/shrinkwrap-api-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/arquillian-spi/1.0.0.Alpha3/arquillian-spi-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-impl-base/1.0.0-alpha-11/shrinkwrap-impl-base-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-spi/1.0.0-alpha-11/shrinkwrap-spi-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/javax/el/el-api/2.2/el-api-2.2.jar:/home/jdoe/.m2/repository/el-impl/el-impl/1.0/el-impl-1.0.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/container/arquillian-weld-ee-embedded-1.1/1.0.0.Alpha3/arquillian-weld-ee-embedded-1.1-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/protocol/arquillian-protocol-local/1.0.0.Alpha3/arquillian-protocol-local-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/arquillian/testenricher/arquillian-testenricher-cdi/1.0.0.Alpha3/arquillian-testenricher-cdi-1.0.0.Alpha3.jar:/home/jdoe/.m2/repository/org/jboss/shrinkwrap/shrinkwrap-extension-classloader/1.0.0-alpha-11/shrinkwrap-extension-classloader-1.0.0-alpha-11.jar:/home/jdoe/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar:/home/jdoe/.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar:/home/jdoe/.m2/repository/javax/validation/validation-api/1.0.0.GA/validation-api-1.0.0.GA.jar:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/112/1/.cp/:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/110/1/.cp/:/home/jdoe/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.osgi/bundles/111/1/.cp/"; + + MavenArtifactResolver resolver = new MavenArtifactResolver(groupId, artifactId, classPath, linuxPathSeparator, linuxFileSeparator); + String path = resolver.resolve(); + assertEquals("/home/jdoe/workspace/extensions/impl/target/seam-solder-api-3.0.1.Final.jar", path); + } + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MavenArtifactResolver.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MavenArtifactResolver.java new file mode 100644 index 00000000..602205e1 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MavenArtifactResolver.java @@ -0,0 +1,148 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Resolves a maven artifact present on the test classpath. + * + * @author Stuart Douglas + */ +public class MavenArtifactResolver { + + public static File resolve(String groupId, String artifactId) { + if (groupId == null) { + throw new IllegalArgumentException("groupId cannot be null"); + } + if (artifactId == null) { + throw new IllegalArgumentException("artifactId cannot be null"); + } + String path = new MavenArtifactResolver(groupId.trim(), artifactId.trim(), System.getProperty("java.class.path"), File.pathSeparatorChar, File.separatorChar).resolve(); + if (path == null) { + throw new IllegalArgumentException("Cannot locate artifact for " + groupId + ":" + artifactId); + } + return new File(path); + } + + public static File resolve(String qualifiedArtifactId) { + String[] segments = qualifiedArtifactId.split(":"); + if (segments.length == 2) { + return resolve(segments[0], segments[1]); + } else { + throw new IllegalArgumentException("Unable to parse " + qualifiedArtifactId + " as a groupId:artifactId"); + } + } + + private final String classPathSeparatorRegex; + private final char fileSeparator; + private final String groupId; + private final String artifactId; + private final String classPath; + + MavenArtifactResolver(String groupId, String artifactId, String classPath, char pathSeparator, char fileSeparator) { + this.groupId = groupId; + this.artifactId = artifactId; + this.classPath = classPath; + this.classPathSeparatorRegex = "[^" + pathSeparator + "]*"; + this.fileSeparator = fileSeparator; + } + + String resolve() { + Matcher matches = createFullyQualifiedMatcher(); + if (!matches.find()) { + matches = createUnqualifiedMatcher(); + if (!matches.find()) { + matches = createTargetClassesMatcher(); + if (!matches.find()) { + return null; + } else { + String fileName = scanForArtifact(matches); + if (fileName == null) { + return null; + } else { + return fileName; + } + } + } + } + return matches.group(0); + } + + private String scanForArtifact(Matcher targetClassesMatcher) { + // Locate all target/classes in classpath and store the path to all files target/ + List paths = new ArrayList(); + do { + String path = targetClassesMatcher.group(); + File target = new File(path.substring(0, path.length() - 8)); + if (target.exists()) { + if (!target.isDirectory()) { + throw new IllegalStateException("Found ${project.dir}/target/ but it is not a directory!"); + } + for (File file : target.listFiles()) { + paths.add(file.getPath()); + } + } + } + while (targetClassesMatcher.find()); + return scanForArtifact(paths); + } + + String scanForArtifact(List paths) { + Pattern pattern = Pattern.compile(artifactId + "-[\\d+\\.]+(?:[\\-\\.]\\p{Alnum}*)?.jar$"); + for (String path : paths) { + if (pattern.matcher(path).find()) { + return path; + } + } + return null; + } + + /** + * Creates a matcher that returns any fully qualified matches of the form + * com/acme/acme-core/1.0/acme-core-1.0.jar. This will match + * artifacts on the classpath from the Maven repo. + */ + private Matcher createFullyQualifiedMatcher() { + String pathString = groupId.replace('.', fileSeparator) + fileSeparator + artifactId; + Pattern p = Pattern.compile(classPathSeparatorRegex + Pattern.quote(pathString) + classPathSeparatorRegex, Pattern.CASE_INSENSITIVE); + return p.matcher(classPath); + } + + /** + * Creates a matcher that returns any unqualified matches of the form + * target/acme-foo-1.0.jar. This will match artifacts on the + * classpath from the reactor. + */ + private Matcher createUnqualifiedMatcher() { + Pattern p = Pattern.compile(classPathSeparatorRegex + Pattern.quote("target" + fileSeparator + artifactId) + classPathSeparatorRegex, Pattern.CASE_INSENSITIVE); + return p.matcher(classPath); + } + + /** + * Creates a matcher that returns any unqualified matches of the form + * target/acme-foo-1.0.jar. This locates all + */ + private Matcher createTargetClassesMatcher() { + Pattern p = Pattern.compile(classPathSeparatorRegex + Pattern.quote("target" + fileSeparator + "classes") + classPathSeparatorRegex, Pattern.CASE_INSENSITIVE); + return p.matcher(classPath); + } +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MultipleMembers.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MultipleMembers.java new file mode 100644 index 00000000..d3c13a9b --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/MultipleMembers.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface MultipleMembers { + int intMember(); + + long longMember(); + + short shortMember(); + + float floatMember(); + + double doubleMember(); + + byte byteMember(); + + char charMember(); + + boolean booleanMember(); + + int[] intArrayMember(); +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/SimpleAnnotation.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/SimpleAnnotation.java new file mode 100644 index 00000000..fbedbb7c --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/SimpleAnnotation.java @@ -0,0 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface SimpleAnnotation { + +} diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/collections/CompilerBugTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/collections/CompilerBugTest.java new file mode 100644 index 00000000..3d975f89 --- /dev/null +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/collections/CompilerBugTest.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.seam.solder.test.util.collections; + +import org.jboss.seam.solder.util.collections.WrappedListIterator; +import org.junit.Test; + +/** + * tests for the presenece of a specific compiler bug + * + * @author stuart + */ +public class CompilerBugTest { + @Test + public void testcompilerBug() { + WrappedListIterator.class.getTypeParameters(); + } +} diff --git a/testsuite/internals/base/src/main/resources/META-INF/services/javax.el.ExpressionFactory b/testsuite/internals/base/src/main/resources/META-INF/services/javax.el.ExpressionFactory new file mode 100644 index 00000000..0bfaf3a8 --- /dev/null +++ b/testsuite/internals/base/src/main/resources/META-INF/services/javax.el.ExpressionFactory @@ -0,0 +1 @@ +com.sun.el.ExpressionFactoryImpl diff --git a/testsuite/internals/base/src/main/resources/arquillian.xml b/testsuite/internals/base/src/main/resources/arquillian.xml new file mode 100644 index 00000000..22bf2da6 --- /dev/null +++ b/testsuite/internals/base/src/main/resources/arquillian.xml @@ -0,0 +1,26 @@ + + + + + + + -Xmx512m -XX:MaxPermSize=256m + + + \ No newline at end of file diff --git a/testsuite/internals/base/src/main/resources/com/acme/foo1 b/testsuite/internals/base/src/main/resources/com/acme/foo1 new file mode 100644 index 00000000..a9f68623 --- /dev/null +++ b/testsuite/internals/base/src/main/resources/com/acme/foo1 @@ -0,0 +1 @@ +foo1 \ No newline at end of file diff --git a/testsuite/internals/base/src/main/resources/com/acme/foo2.properties b/testsuite/internals/base/src/main/resources/com/acme/foo2.properties new file mode 100644 index 00000000..509caa97 --- /dev/null +++ b/testsuite/internals/base/src/main/resources/com/acme/foo2.properties @@ -0,0 +1,2 @@ +name Pete +age=28 \ No newline at end of file diff --git a/testsuite/internals/base/src/main/resources/jndi.properties b/testsuite/internals/base/src/main/resources/jndi.properties new file mode 100644 index 00000000..c5425b45 --- /dev/null +++ b/testsuite/internals/base/src/main/resources/jndi.properties @@ -0,0 +1,4 @@ +#jboss JNDI properties +java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory +java.naming.provider.url=jnp://localhost:1099 +java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces \ No newline at end of file diff --git a/testsuite/internals/base/src/main/resources/org/jboss/seam/solder/test/bean/generic/alternative/beans.xml b/testsuite/internals/base/src/main/resources/org/jboss/seam/solder/test/bean/generic/alternative/beans.xml new file mode 100644 index 00000000..5a4fef27 --- /dev/null +++ b/testsuite/internals/base/src/main/resources/org/jboss/seam/solder/test/bean/generic/alternative/beans.xml @@ -0,0 +1,8 @@ + + + + org.jboss.seam.solder.test.bean.generic.alternative.EnabledAlternativeProducer + + diff --git a/testsuite/internals/base/src/main/resources/org/jboss/seam/solder/test/messages/BirdMessages.i18n_fr.properties b/testsuite/internals/base/src/main/resources/org/jboss/seam/solder/test/messages/BirdMessages.i18n_fr.properties new file mode 100644 index 00000000..b5b506c0 --- /dev/null +++ b/testsuite/internals/base/src/main/resources/org/jboss/seam/solder/test/messages/BirdMessages.i18n_fr.properties @@ -0,0 +1 @@ +numberOfJaysSpotted=Spotted %s geais \ No newline at end of file diff --git a/testsuite/internals/jbossas/pom.xml b/testsuite/internals/jbossas/pom.xml new file mode 100644 index 00000000..f92e57f3 --- /dev/null +++ b/testsuite/internals/jbossas/pom.xml @@ -0,0 +1,168 @@ + + + 4.0.0 + + + org.jboss.seam.solder + seam-solder-testsuite-integration-internals + 3.1.0-SNAPSHOT + ../pom.xml + + + seam-solder-testsuite-integration-internals-jbossas + Seam Solder Test Suite: Internals Integration Tests for JBoss AS + jar + + + + + org.jboss.seam.solder + seam-solder + + + + org.jboss.seam.solder + seam-solder-testsuite-common + test + + + + org.jboss.seam.config + seam-config-xml + test + + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven + test + + + + junit + junit + test + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + maven-dependency-plugin + + + unpack-base-tests + process-test-classes + + unpack + + + + + org.jboss.seam.solder + seam-solder-testsuite-integration-internals-base + ${project.version} + jar + ${project.build.directory}/test-classes/ + + + + + + + + + + + + jbossas-managed-7 + + true + + arquillian + jbossas-managed-7 + + + + + + + org.jboss.seam.test + jbossas-managed-7 + pom + test + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack-as7 + process-test-classes + + unpack + + + + + org.jboss.as + jboss-as-dist + ${jbossas.7.version} + zip + false + ${project.build.directory} + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + surefire-it + integration-test + + test + + + false + true + false + true + always + + + + + + + + + diff --git a/testsuite/internals/jbossas/src/test/resources/arquillian.xml b/testsuite/internals/jbossas/src/test/resources/arquillian.xml new file mode 100644 index 00000000..9667d581 --- /dev/null +++ b/testsuite/internals/jbossas/src/test/resources/arquillian.xml @@ -0,0 +1,37 @@ + + + + + + + + + + REMOTE + + + -client -noverify -XX:+UseFastAccessorMethods -Xms64m -Xmx512m + target/jboss-as-7.0.0.Final + + + diff --git a/testsuite/internals/pom.xml b/testsuite/internals/pom.xml new file mode 100644 index 00000000..031c7e5e --- /dev/null +++ b/testsuite/internals/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + + org.jboss.seam.solder + seam-solder-testsuite + 3.1.0-SNAPSHOT + ../pom.xml + + + seam-solder-testsuite-integration-internals + Seam Solder Test Suite: Internals Integration Tests + pom + + + base + jbossas + + + diff --git a/testsuite/pom.xml b/testsuite/pom.xml new file mode 100644 index 00000000..358fc825 --- /dev/null +++ b/testsuite/pom.xml @@ -0,0 +1,80 @@ + + 4.0.0 + + + org.jboss.seam.solder + seam-solder-parent + 3.1.0-SNAPSHOT + ../pom.xml + + + seam-solder-testsuite + + pom + Seam Solder Test Suite: Aggregator + + + common + + internals + + + + + + + + org.jboss.seam.solder + seam-solder-testsuite-common + ${project.version} + test + + + + org.jboss.seam.solder + seam-solder-testsuite-integration-internals-base + ${project.version} + + + + + + + + allTests + + + allTests + + + + + + code-coverage + + + + org.codehaus.mojo + emma-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.sonatype.maven.plugin + emma4it-maven-plugin + + + + + + + From 1afe00ee9f1012d545c2aaddc7bd59bd3eb0f1eb Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 21 Aug 2011 11:16:27 +1000 Subject: [PATCH 04/16] messing around with test configurations --- impl/pom.xml | 5 +-- .../base/src/main/resources/arquillian.xml | 3 +- testsuite/internals/jbossas/pom.xml | 42 ++++++++++++++++--- .../jbossas/src/test/resources/arquillian.xml | 5 +-- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/impl/pom.xml b/impl/pom.xml index e38621fa..712245e1 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -115,11 +115,10 @@ junit-dep - + org.slf4j diff --git a/testsuite/internals/base/src/main/resources/arquillian.xml b/testsuite/internals/base/src/main/resources/arquillian.xml index 22bf2da6..b50ceb5d 100644 --- a/testsuite/internals/base/src/main/resources/arquillian.xml +++ b/testsuite/internals/base/src/main/resources/arquillian.xml @@ -23,4 +23,5 @@ -Xmx512m -XX:MaxPermSize=256m - \ No newline at end of file + + diff --git a/testsuite/internals/jbossas/pom.xml b/testsuite/internals/jbossas/pom.xml index f92e57f3..f2a7972d 100644 --- a/testsuite/internals/jbossas/pom.xml +++ b/testsuite/internals/jbossas/pom.xml @@ -15,7 +15,7 @@ jar - + org.jboss.seam.solder seam-solder @@ -45,24 +45,54 @@ test + + + org.glassfish.web + el-impl + compile + + junit junit - test + compile + - + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + generate-sources + + add-test-source + + + + ../base/src/main/java + + + + + + org.apache.maven.plugins maven-surefire-plugin true + - + + @@ -138,12 +168,14 @@ + org.apache.maven.plugins maven-surefire-plugin true + surefire-it diff --git a/testsuite/internals/jbossas/src/test/resources/arquillian.xml b/testsuite/internals/jbossas/src/test/resources/arquillian.xml index 9667d581..b7a7b7c9 100644 --- a/testsuite/internals/jbossas/src/test/resources/arquillian.xml +++ b/testsuite/internals/jbossas/src/test/resources/arquillian.xml @@ -19,11 +19,10 @@ xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> - @@ -31,7 +30,7 @@ -client -noverify -XX:+UseFastAccessorMethods -Xms64m -Xmx512m - target/jboss-as-7.0.0.Final + target/jboss-as-7.0.1.Final From 642d0a0a0b89778b7e40c065fad5b99122142805 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Mon, 22 Aug 2011 10:07:48 +1000 Subject: [PATCH 05/16] fix test compiler errors --- impl/pom.xml | 27 +++++++++---------- .../bean/defaultbean/DefaultBeanTest.java | 2 +- .../GenericBeanAlternativeTest.java | 2 +- .../bean/generic/field/GenericBeanTest.java | 2 +- .../generic/field/GenericBeanUnwrapTest.java | 3 ++- .../generic/field/GenericProductTest.java | 2 +- .../field/ObserversOnGenericBeanTest.java | 2 +- .../field/ProducersOnGenericBeanTest.java | 2 +- .../bean/generic/method/GenericBeanTest.java | 2 +- .../generic/method/GenericProductTest.java | 3 ++- .../method/ProducersOnGenericBeanTest.java | 2 +- .../method/QualifierOnlyGenericBeanTest.java | 2 +- .../jboss/seam/solder/test/core/CoreTest.java | 3 ++- .../test/core/requires/RequiresTest.java | 2 +- .../test/defaultbean/DefaultBeanTest.java | 2 +- .../org/jboss/seam/solder/test/el/ElTest.java | 3 ++- .../test/logging/LoggerInjectionTest.java | 3 ++- .../TypedMessageLoggerInjectionTest.java | 2 +- .../TypedMessageBundleInjectionTest.java | 2 +- .../resourceLoader/ResourceLoaderTest.java | 2 +- .../serviceHandler/ServiceHandlerTest.java | 3 ++- .../seam/solder/test/unwraps/UnwrapsTest.java | 2 +- .../test/util/AnnotationInspectorTest.java | 2 +- .../seam/solder/test/util/Deployments.java | 5 ++-- 24 files changed, 44 insertions(+), 38 deletions(-) diff --git a/impl/pom.xml b/impl/pom.xml index 712245e1..a81bcd22 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -74,14 +74,6 @@ true - - log4j log4j @@ -115,16 +107,23 @@ junit-dep - - org.slf4j slf4j-simple test + + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + junit + junit + test + org.hamcrest @@ -182,7 +181,7 @@ default
- + org.jboss.arquillian.container diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java index fc442428..9ee02499 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java @@ -21,7 +21,7 @@ import javax.enterprise.inject.spi.Extension; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.logging.Category; import org.jboss.seam.solder.logging.internal.Logger; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java index 66fb3f39..1e912809 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java @@ -22,7 +22,7 @@ import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java index 32d3925c..36a7ea80 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java index c43d86fe..0819291d 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java @@ -19,7 +19,8 @@ import javax.inject.Inject; import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; + +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java index 3db1a45d..4a27e188 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java index 7e21b75a..3bbfc734 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java @@ -19,7 +19,7 @@ import javax.enterprise.event.Event; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java index 10148385..7df8dc9b 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java index 4c0c6854..5bdfef0c 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java index 5ca76fd4..6d4f980c 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java @@ -25,7 +25,8 @@ import javax.inject.Inject; import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; + +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java index 1b237151..d6a173ca 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java @@ -21,7 +21,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java index caed6203..83cf9e78 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/core/CoreTest.java b/impl/src/test/java/org/jboss/seam/solder/test/core/CoreTest.java index d2db84a0..3f078730 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/core/CoreTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/core/CoreTest.java @@ -25,7 +25,8 @@ import javax.inject.Inject; import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; + +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.core.CoreExtension; import org.jboss.seam.solder.core.VersionLoggerUtil; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java b/impl/src/test/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java index 87c4b456..94e21862 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java @@ -19,7 +19,7 @@ import javax.enterprise.inject.spi.BeanManager; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.test.core.requires.beans.EnabledOptionalBean; import org.jboss.seam.solder.test.core.requires.beans.pkg.OptionalBeanWithPackageLevelDependencies; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java b/impl/src/test/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java index 0a7796e9..d3caed48 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java @@ -19,7 +19,7 @@ import javax.enterprise.inject.spi.BeanManager; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.literal.DefaultLiteral; import org.jboss.shrinkwrap.api.spec.WebArchive; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/el/ElTest.java b/impl/src/test/java/org/jboss/seam/solder/test/el/ElTest.java index bf5f9bbd..e2e68cc6 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/el/ElTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/el/ElTest.java @@ -20,7 +20,8 @@ import javax.inject.Inject; import com.sun.el.ExpressionFactoryImpl; -import org.jboss.arquillian.api.Deployment; + +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.el.ELResolverProducer; import org.jboss.seam.solder.el.Expressions; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java b/impl/src/test/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java index 34c2bd04..ea2d3206 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java @@ -22,7 +22,8 @@ import javax.enterprise.inject.spi.InjectionTarget; import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; + +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.test.util.Deployments; import org.jboss.shrinkwrap.api.Archive; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java b/impl/src/test/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java index 248f1e03..669ccade 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java @@ -19,7 +19,7 @@ import javax.enterprise.inject.Instance; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java b/impl/src/test/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java index 958d6099..fb60b02e 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java @@ -17,7 +17,7 @@ package org.jboss.seam.solder.test.messages; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java b/impl/src/test/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java index 11ed4191..e55d0ea9 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java @@ -28,7 +28,7 @@ import javax.enterprise.inject.spi.BeanManager; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.resourceLoader.Resource; import org.jboss.seam.solder.resourceLoader.ResourceLoader; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java b/impl/src/test/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java index 6319cb20..42a3d1f7 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java @@ -19,7 +19,8 @@ import javax.inject.Inject; import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; + +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java b/impl/src/test/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java index 18633650..c6b9dc57 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java @@ -19,7 +19,7 @@ import javax.inject.Inject; import javax.inject.Named; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java b/impl/src/test/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java index 48d6a930..aeca0122 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java @@ -24,7 +24,7 @@ import javax.enterprise.inject.spi.BeanManager; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.reflection.AnnotationInspector; import org.jboss.seam.solder.reflection.annotated.AnnotatedTypeBuilder; diff --git a/impl/src/test/java/org/jboss/seam/solder/test/util/Deployments.java b/impl/src/test/java/org/jboss/seam/solder/test/util/Deployments.java index 4e626950..72d489ea 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/util/Deployments.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/util/Deployments.java @@ -16,8 +16,9 @@ */ package org.jboss.seam.solder.test.util; -import org.jboss.arquillian.spi.client.container.DeployableContainer; -import org.jboss.arquillian.spi.util.ServiceLoader; +import org.jboss.arquillian.container.spi.client.container.DeployableContainer; +import org.jboss.arquillian.container.test.spi.util.ServiceLoader; + import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; From 9de49f8b73ae1a493f6a77df8c57eed6830562ab Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Mon, 22 Aug 2011 11:08:53 +1000 Subject: [PATCH 06/16] fixed the damn tests --- .../alternative/GenericBeanAlternativeTest.java | 5 +++-- .../java/org/jboss/seam/solder/test/el/ElTest.java | 8 ++++---- .../solder/test/resourceLoader/ResourceLoaderTest.java | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java index 1e912809..a3462d8b 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java @@ -32,8 +32,9 @@ public class GenericBeanAlternativeTest { @Deployment public static WebArchive deployment() { - return baseDeployment().addPackage(GenericBeanAlternativeTest.class.getPackage()).addAsWebInfResource( - "org/jboss/seam/solder/test/bean/generic/alternative/beans.xml", "beans.xml"); + return baseDeployment().addPackage(GenericBeanAlternativeTest.class.getPackage()) + .addAsWebInfResource("org/jboss/seam/solder/test/bean/generic/alternative/beans.xml", "beans.xml") + .addAsManifestResource("org/jboss/seam/solder/test/bean/generic/alternative/beans.xml", "beans.xml"); } @Inject diff --git a/impl/src/test/java/org/jboss/seam/solder/test/el/ElTest.java b/impl/src/test/java/org/jboss/seam/solder/test/el/ElTest.java index e2e68cc6..4bcf3853 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/el/ElTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/el/ElTest.java @@ -33,7 +33,7 @@ import org.junit.runner.RunWith; import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; -import static org.jboss.seam.solder.test.util.Deployments.targetContainerAdapterClass; +//import static org.jboss.seam.solder.test.util.Deployments.targetContainerAdapterClass; @RunWith(Arquillian.class) public class ElTest { @@ -43,15 +43,15 @@ public class ElTest { @Deployment public static Archive deployment() { // hack to work around container differences atm - boolean isEmbedded = targetContainerAdapterClass().getName().contains(".embedded"); + //boolean isEmbedded = targetContainerAdapterClass().getName().contains(".embedded"); WebArchive war = baseDeployment().addPackage(ElTest.class.getPackage()); - if (isEmbedded) { + //if (isEmbedded) { war.addPackage(ELResolverProducer.class.getPackage()) // set proper EL implementation using META-INF/services/javax.el.ExpressionFactory for Weld embedded .addAsServiceProvider(ExpressionFactory.class, ExpressionFactoryImpl.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); - } + //} return war; } diff --git a/impl/src/test/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java b/impl/src/test/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java index e55d0ea9..766c3341 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java @@ -39,7 +39,7 @@ import org.junit.runner.RunWith; import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; -import static org.jboss.seam.solder.test.util.Deployments.targetContainerAdapterClass; +//import static org.jboss.seam.solder.test.util.Deployments.targetContainerAdapterClass; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -48,16 +48,16 @@ public class ResourceLoaderTest { @Deployment public static Archive deployment() { // hack to work around container differences atm - boolean isEmbedded = targetContainerAdapterClass().getName().contains(".embedded"); + //boolean isEmbedded = targetContainerAdapterClass().getName().contains(".embedded"); WebArchive war = baseDeployment().addPackage(ResourceLoaderTest.class.getPackage()) .addAsResource("com/acme/foo1") .addAsResource("com/acme/foo2.properties"); - if (isEmbedded) { + //if (isEmbedded) { war.addPackage(ResourceLoader.class.getPackage()) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); - } + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + //} return war; } From 3f907cf6ef83a2b31b1e202bcb61e19aca2822fc Mon Sep 17 00:00:00 2001 From: "John D. Ament" Date: Sun, 21 Aug 2011 21:19:23 -0400 Subject: [PATCH 07/16] Added new deployment method to not add beans.xml. Modified Alternative test to not add beans.xml. --- .../generic/alternative/GenericBeanAlternativeTest.java | 7 +++---- .../java/org/jboss/seam/solder/test/util/Deployments.java | 8 ++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java index a3462d8b..b1497428 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java @@ -16,7 +16,7 @@ */ package org.jboss.seam.solder.test.bean.generic.alternative; -import static org.jboss.seam.solder.test.util.Deployments.baseDeployment; +import static org.jboss.seam.solder.test.util.Deployments.baseDeploymentNoBeans; import javax.inject.Inject; @@ -32,9 +32,8 @@ public class GenericBeanAlternativeTest { @Deployment public static WebArchive deployment() { - return baseDeployment().addPackage(GenericBeanAlternativeTest.class.getPackage()) - .addAsWebInfResource("org/jboss/seam/solder/test/bean/generic/alternative/beans.xml", "beans.xml") - .addAsManifestResource("org/jboss/seam/solder/test/bean/generic/alternative/beans.xml", "beans.xml"); + return baseDeploymentNoBeans().addPackage(GenericBeanAlternativeTest.class.getPackage()) + .addAsWebInfResource("org/jboss/seam/solder/test/bean/generic/alternative/beans.xml", "beans.xml"); } @Inject diff --git a/impl/src/test/java/org/jboss/seam/solder/test/util/Deployments.java b/impl/src/test/java/org/jboss/seam/solder/test/util/Deployments.java index 72d489ea..1790ce92 100644 --- a/impl/src/test/java/org/jboss/seam/solder/test/util/Deployments.java +++ b/impl/src/test/java/org/jboss/seam/solder/test/util/Deployments.java @@ -32,6 +32,14 @@ public static WebArchive baseDeployment() { MavenArtifactResolver.resolve("org.jboss.seam.solder", "seam-solder-logging")) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); } + + public static WebArchive baseDeploymentNoBeans() { + return ShrinkWrap.create(WebArchive.class, "test.war") + .addAsLibraries( + MavenArtifactResolver.resolve("org.jboss.seam.solder", "seam-solder-api"), + MavenArtifactResolver.resolve("org.jboss.seam.solder", "seam-solder"), + MavenArtifactResolver.resolve("org.jboss.seam.solder", "seam-solder-logging")); + } public static Class targetContainerAdapterClass() { ServiceLoader l = ServiceLoader.load(DeployableContainer.class); From aaab439c972444ed579f1ba6b413c33f468139a2 Mon Sep 17 00:00:00 2001 From: Ken Finnigan Date: Sun, 21 Aug 2011 22:46:25 -0400 Subject: [PATCH 08/16] Fixes for solder testsuite --- .../seam/solder/test/bean/defaultbean/DefaultBeanTest.java | 4 ++-- .../generic/alternative/GenericBeanAlternativeTest.java | 4 ++-- .../solder/test/bean/generic/field/GenericBeanTest.java | 4 ++-- .../test/bean/generic/field/GenericBeanUnwrapTest.java | 4 ++-- .../solder/test/bean/generic/field/GenericProductTest.java | 4 ++-- .../test/bean/generic/field/ObserversOnGenericBeanTest.java | 4 ++-- .../test/bean/generic/field/ProducersOnGenericBeanTest.java | 4 ++-- .../solder/test/bean/generic/method/GenericBeanTest.java | 4 ++-- .../solder/test/bean/generic/method/GenericProductTest.java | 4 ++-- .../bean/generic/method/ProducersOnGenericBeanTest.java | 4 ++-- .../bean/generic/method/QualifierOnlyGenericBeanTest.java | 4 ++-- .../main/java/org/jboss/seam/solder/test/core/CoreTest.java | 4 ++-- .../jboss/seam/solder/test/core/requires/RequiresTest.java | 4 ++-- .../jboss/seam/solder/test/defaultbean/DefaultBeanTest.java | 4 ++-- .../src/main/java/org/jboss/seam/solder/test/el/ElTest.java | 4 ++-- .../jboss/seam/solder/test/logging/LoggerInjectionTest.java | 4 ++-- .../test/logging/TypedMessageLoggerInjectionTest.java | 4 ++-- .../test/messages/TypedMessageBundleInjectionTest.java | 4 ++-- .../seam/solder/test/resourceLoader/ResourceLoaderTest.java | 4 ++-- .../seam/solder/test/serviceHandler/ServiceHandlerTest.java | 4 ++-- .../org/jboss/seam/solder/test/unwraps/UnwrapsTest.java | 4 ++-- .../seam/solder/test/util/AnnotationInspectorTest.java | 4 ++-- .../java/org/jboss/seam/solder/test/util/Deployments.java | 4 ++-- testsuite/internals/jbossas/pom.xml | 6 ++++++ 24 files changed, 52 insertions(+), 46 deletions(-) diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java index fc442428..78ad1d5c 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/defaultbean/DefaultBeanTest.java @@ -21,7 +21,7 @@ import javax.enterprise.inject.spi.Extension; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.logging.Category; import org.jboss.seam.solder.logging.internal.Logger; @@ -61,7 +61,7 @@ public class DefaultBeanTest { @Inject private Vehicle vehicle; - @Deployment + @Deployment(name = "DefaultBean") public static WebArchive createDeployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war"); war.addPackage(DefaultBeanTest.class.getPackage()); diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java index 66fb3f39..126ccc51 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/alternative/GenericBeanAlternativeTest.java @@ -22,7 +22,7 @@ import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; @@ -30,7 +30,7 @@ @RunWith(Arquillian.class) public class GenericBeanAlternativeTest { - @Deployment + @Deployment(name = "GenericBeanAlternative") public static WebArchive deployment() { return baseDeployment().addPackage(GenericBeanAlternativeTest.class.getPackage()).addAsWebInfResource( "org/jboss/seam/solder/test/bean/generic/alternative/beans.xml", "beans.xml"); diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java index 32d3925c..860ab292 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanTest.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -32,7 +32,7 @@ @RunWith(Arquillian.class) public class GenericBeanTest { - @Deployment + @Deployment(name = "GenericBeanField") public static Archive deployment() { return baseDeployment().addPackage(GenericBeanTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java index c43d86fe..eebb7760 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericBeanUnwrapTest.java @@ -19,7 +19,7 @@ import javax.inject.Inject; import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -29,7 +29,7 @@ @RunWith(Arquillian.class) public class GenericBeanUnwrapTest { - @Deployment + @Deployment(name = "GenericBeanUnwrap") public static Archive deployment() { return baseDeployment().addPackage(GenericBeanUnwrapTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java index 3db1a45d..37248643 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/GenericProductTest.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -31,7 +31,7 @@ @RunWith(Arquillian.class) public class GenericProductTest { - @Deployment + @Deployment(name = "GenericProductField") public static Archive deployment() { return baseDeployment().addPackage(GenericProductTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java index 7e21b75a..15e4dbfc 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ObserversOnGenericBeanTest.java @@ -19,7 +19,7 @@ import javax.enterprise.event.Event; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -32,7 +32,7 @@ @RunWith(Arquillian.class) public class ObserversOnGenericBeanTest { - @Deployment + @Deployment(name = "ObserversOnGenericBean") public static Archive deployment() { return baseDeployment().addPackage(ObserversOnGenericBeanTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java index 10148385..1b31cb37 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/field/ProducersOnGenericBeanTest.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -31,7 +31,7 @@ @RunWith(Arquillian.class) public class ProducersOnGenericBeanTest { - @Deployment + @Deployment(name = "ProducersOnGenericBean") public static Archive deployment() { return baseDeployment().addPackage(ProducersOnGenericBeanTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java index 4c0c6854..8e249198 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericBeanTest.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -32,7 +32,7 @@ @RunWith(Arquillian.class) public class GenericBeanTest { - @Deployment + @Deployment(name = "GenericBeanMethod") public static Archive deployment() { return baseDeployment().addPackage(GenericBeanTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java index 5ca76fd4..2b9b2b60 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/GenericProductTest.java @@ -25,7 +25,7 @@ import javax.inject.Inject; import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -38,7 +38,7 @@ @RunWith(Arquillian.class) public class GenericProductTest { - @Deployment + @Deployment(name = "GenericProductMethod") public static Archive deployment() { return baseDeployment().addPackage(GenericProductTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java index 1b237151..cf5608c3 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/ProducersOnGenericBeanTest.java @@ -21,7 +21,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -35,7 +35,7 @@ @RunWith(Arquillian.class) public class ProducersOnGenericBeanTest { - @Deployment + @Deployment(name = "ProducersOnGenericBean") public static Archive deployment() { return baseDeployment().addPackage(ProducersOnGenericBeanTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java index caed6203..ffe0ae7d 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/bean/generic/method/QualifierOnlyGenericBeanTest.java @@ -18,7 +18,7 @@ import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -31,7 +31,7 @@ @RunWith(Arquillian.class) public class QualifierOnlyGenericBeanTest { - @Deployment + @Deployment(name = "QualifierOnlyGenericBean") public static Archive deployment() { return baseDeployment().addPackage(QualifierOnlyGenericBeanTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/CoreTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/CoreTest.java index d2db84a0..bbf5955b 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/CoreTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/CoreTest.java @@ -25,7 +25,7 @@ import javax.inject.Inject; import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.core.CoreExtension; import org.jboss.seam.solder.core.VersionLoggerUtil; @@ -46,7 +46,7 @@ @RunWith(Arquillian.class) public class CoreTest { - @Deployment + @Deployment(name = "Core") public static Archive deployment() { return baseDeployment().addPackage(CoreTest.class.getPackage()) .addPackage(FullyQualifiedFromPackageNamedBean.class.getPackage()) diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java index 87c4b456..2420e145 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/core/requires/RequiresTest.java @@ -19,7 +19,7 @@ import javax.enterprise.inject.spi.BeanManager; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.test.core.requires.beans.EnabledOptionalBean; import org.jboss.seam.solder.test.core.requires.beans.pkg.OptionalBeanWithPackageLevelDependencies; @@ -36,7 +36,7 @@ public class RequiresTest { @Inject private BeanManager manager; - @Deployment + @Deployment(name = "Requires") public static WebArchive getDeployment() { return baseDeployment().addClasses(CommonInterface.class, Tiger.class, Lion.class) .addPackage(EnabledOptionalBean.class.getPackage()) diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java index 0a7796e9..64cc0a9f 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/defaultbean/DefaultBeanTest.java @@ -19,7 +19,7 @@ import javax.enterprise.inject.spi.BeanManager; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.literal.DefaultLiteral; import org.jboss.shrinkwrap.api.spec.WebArchive; @@ -60,7 +60,7 @@ public class DefaultBeanTest { @LaptopHardDrive HardDrive laptopHardDrive; - @Deployment + @Deployment(name = "DefaultBeanTest") public static WebArchive deployment() { return baseDeployment().addPackage(DefaultBeanTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/ElTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/ElTest.java index bf5f9bbd..8501f3de 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/ElTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/el/ElTest.java @@ -20,7 +20,7 @@ import javax.inject.Inject; import com.sun.el.ExpressionFactoryImpl; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.el.ELResolverProducer; import org.jboss.seam.solder.el.Expressions; @@ -39,7 +39,7 @@ public class ElTest { @Inject Expressions expressions; - @Deployment + @Deployment(name = "EL") public static Archive deployment() { // hack to work around container differences atm boolean isEmbedded = targetContainerAdapterClass().getName().contains(".embedded"); diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java index 34c2bd04..25ae5576 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/LoggerInjectionTest.java @@ -22,7 +22,7 @@ import javax.enterprise.inject.spi.InjectionTarget; import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.test.util.Deployments; import org.jboss.shrinkwrap.api.Archive; @@ -42,7 +42,7 @@ */ @RunWith(Arquillian.class) public class LoggerInjectionTest { - @Deployment + @Deployment(name = "LoggerInjection") public static Archive createDeployment() { return Deployments.baseDeployment() .addClasses(Sparrow.class, Finch.class, Wren.class, Raven.class, NonBean.class); diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java index 248f1e03..4d255c01 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/logging/TypedMessageLoggerInjectionTest.java @@ -19,7 +19,7 @@ import javax.enterprise.inject.Instance; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -42,7 +42,7 @@ */ @RunWith(Arquillian.class) public class TypedMessageLoggerInjectionTest { - @Deployment + @Deployment(name = "TypedMessageLoggerInjection") public static Archive createDeployment() { return baseDeployment() .addPackage(TypedMessageLoggerInjectionTest.class.getPackage()); diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java index 958d6099..a891b9b2 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/messages/TypedMessageBundleInjectionTest.java @@ -17,7 +17,7 @@ package org.jboss.seam.solder.test.messages; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -34,7 +34,7 @@ */ @RunWith(Arquillian.class) public class TypedMessageBundleInjectionTest { - @Deployment + @Deployment(name = "TypedMessageBundleInjection") public static Archive createDeployment() { return baseDeployment() .addPackage(TypedMessageBundleInjectionTest.class.getPackage()); diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java index 11ed4191..f56b7648 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/resourceLoader/ResourceLoaderTest.java @@ -28,7 +28,7 @@ import javax.enterprise.inject.spi.BeanManager; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.resourceLoader.Resource; import org.jboss.seam.solder.resourceLoader.ResourceLoader; @@ -45,7 +45,7 @@ @RunWith(Arquillian.class) public class ResourceLoaderTest { - @Deployment + @Deployment(name = "ResourceLoader") public static Archive deployment() { // hack to work around container differences atm boolean isEmbedded = targetContainerAdapterClass().getName().contains(".embedded"); diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java index 6319cb20..9af7dffa 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/serviceHandler/ServiceHandlerTest.java @@ -19,7 +19,7 @@ import javax.inject.Inject; import junit.framework.Assert; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -33,7 +33,7 @@ @RunWith(Arquillian.class) public class ServiceHandlerTest { - @Deployment + @Deployment(name = "ServiceHandler") public static Archive deployment() { return baseDeployment().addPackage(ServiceHandlerTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java index 18633650..32cec642 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/unwraps/UnwrapsTest.java @@ -19,7 +19,7 @@ import javax.inject.Inject; import javax.inject.Named; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.junit.Test; @@ -30,7 +30,7 @@ @RunWith(Arquillian.class) public class UnwrapsTest { - @Deployment + @Deployment(name = "Unwraps") public static Archive deployment() { return baseDeployment().addPackage(UnwrapsTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java index 48d6a930..e6937342 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/AnnotationInspectorTest.java @@ -24,7 +24,7 @@ import javax.enterprise.inject.spi.BeanManager; import javax.inject.Inject; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.seam.solder.reflection.AnnotationInspector; import org.jboss.seam.solder.reflection.annotated.AnnotatedTypeBuilder; @@ -39,7 +39,7 @@ @RunWith(Arquillian.class) public class AnnotationInspectorTest { - @Deployment + @Deployment(name = "AnnotationInspector") public static Archive deployment() { return baseDeployment().addPackage(AnnotationInspectorTest.class.getPackage()); } diff --git a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Deployments.java b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Deployments.java index 4e626950..16df19f9 100644 --- a/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Deployments.java +++ b/testsuite/internals/base/src/main/java/org/jboss/seam/solder/test/util/Deployments.java @@ -16,8 +16,8 @@ */ package org.jboss.seam.solder.test.util; -import org.jboss.arquillian.spi.client.container.DeployableContainer; -import org.jboss.arquillian.spi.util.ServiceLoader; +import org.jboss.arquillian.container.spi.client.container.DeployableContainer; +import org.jboss.arquillian.container.test.spi.util.ServiceLoader; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; diff --git a/testsuite/internals/jbossas/pom.xml b/testsuite/internals/jbossas/pom.xml index f2a7972d..a389bde4 100644 --- a/testsuite/internals/jbossas/pom.xml +++ b/testsuite/internals/jbossas/pom.xml @@ -19,6 +19,12 @@ org.jboss.seam.solder seam-solder + compile + + + org.jboss.seam.solder + seam-solder-api + compile From 0246ba7dac51b6ff4613b5397d7ea416e4dfd577 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Mon, 22 Aug 2011 18:46:59 +1000 Subject: [PATCH 09/16] fix distribution --- dist/src/main/assembly/assembly.xml | 2 ++ pom.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dist/src/main/assembly/assembly.xml b/dist/src/main/assembly/assembly.xml index c5faead1..001afe97 100644 --- a/dist/src/main/assembly/assembly.xml +++ b/dist/src/main/assembly/assembly.xml @@ -20,6 +20,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + distribution + zip diff --git a/pom.xml b/pom.xml index c3826d6f..e3154102 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ - 3.1.0.Beta1 + 3.1.0-SNAPSHOT 2.0.5312 From 29d311f170df2d68338f54c896a7428b75c26bc2 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Tue, 23 Aug 2011 12:49:13 +1000 Subject: [PATCH 10/16] update parent, seam-bom versions --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e3154102..ed79711f 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.jboss.seam seam-parent - 13-SNAPSHOT + 13 org.jboss.seam.solder @@ -50,7 +50,7 @@ - 3.1.0-SNAPSHOT + 3.1.0.Beta2 2.0.5312 From a16d53bd0dc8a4819e84310e37a6fac6255a7db7 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Tue, 23 Aug 2011 13:38:46 +1000 Subject: [PATCH 11/16] update parent version, fix distribution --- dist/pom.xml | 8 -------- pom.xml | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/dist/pom.xml b/dist/pom.xml index 158fae80..aa199ca5 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -59,14 +59,6 @@ true - - org.jboss.seam.solder - seam-solder-logging - ${project.version} - sources - true - - org.jboss.seam.solder seam-solder-tooling diff --git a/pom.xml b/pom.xml index ed79711f..1be23d52 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.jboss.seam seam-parent - 13 + 14 org.jboss.seam.solder From 8c0be93ac64b2c1dab89e1a84d45c29e56e532b7 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Tue, 23 Aug 2011 13:50:29 +1000 Subject: [PATCH 12/16] fix scm url, damn you maven!!! --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1be23d52..9e8ef261 100644 --- a/pom.xml +++ b/pom.xml @@ -286,7 +286,7 @@ scm:git:git://github.com/seam/solder.git - scm:git:git://github.com/seam/solder.git + scm:git:git@github.com:seam/solder.git http://github.com/seam/solder From f230d2e8df3cf717e161a24e5806928090e57480 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Tue, 23 Aug 2011 14:11:49 +1000 Subject: [PATCH 13/16] force creation of logging source artifact --- logging/pom.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/logging/pom.xml b/logging/pom.xml index 579f244c..b94bb898 100644 --- a/logging/pom.xml +++ b/logging/pom.xml @@ -19,6 +19,15 @@ + + + maven-source-plugin + + + true + + + maven-surefire-plugin From 4a793cf2cb6ea267f7ed40ffb3d6b2d1bcfcba93 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Tue, 23 Aug 2011 14:23:26 +1000 Subject: [PATCH 14/16] [maven-release-plugin] prepare release 3.1.0.Beta2 --- api/pom.xml | 2 +- dist/pom.xml | 2 +- docs/pom.xml | 2 +- impl/pom.xml | 2 +- logging/pom.xml | 2 +- pom.xml | 2 +- tooling/pom.xml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index 7deb96fc..902097d0 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -21,7 +21,7 @@ org.jboss.seam.solder seam-solder-parent - 3.1.0-SNAPSHOT + 3.1.0.Beta2 ../pom.xml diff --git a/dist/pom.xml b/dist/pom.xml index aa199ca5..06adada1 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -5,7 +5,7 @@ org.jboss.seam.solder seam-solder-parent - 3.1.0-SNAPSHOT + 3.1.0.Beta2 ../pom.xml diff --git a/docs/pom.xml b/docs/pom.xml index f7a36afd..0afc35b8 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -21,7 +21,7 @@ org.jboss.seam.solder seam-solder-parent - 3.1.0-SNAPSHOT + 3.1.0.Beta2 ../pom.xml diff --git a/impl/pom.xml b/impl/pom.xml index a81bcd22..b154f126 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -21,7 +21,7 @@ org.jboss.seam.solder seam-solder-parent - 3.1.0-SNAPSHOT + 3.1.0.Beta2 ../pom.xml diff --git a/logging/pom.xml b/logging/pom.xml index b94bb898..feb69ecd 100644 --- a/logging/pom.xml +++ b/logging/pom.xml @@ -4,7 +4,7 @@ seam-solder-parent org.jboss.seam.solder - 3.1.0-SNAPSHOT + 3.1.0.Beta2 seam-solder-logging Seam Solder Logging diff --git a/pom.xml b/pom.xml index 9e8ef261..58191efe 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.jboss.seam.solder seam-solder-parent pom - 3.1.0-SNAPSHOT + 3.1.0.Beta2 Seam Solder Project A portable CDI extensions library for developing CDI applications, frameworks or other extensions diff --git a/tooling/pom.xml b/tooling/pom.xml index 7aedc973..cfbe293d 100644 --- a/tooling/pom.xml +++ b/tooling/pom.xml @@ -21,7 +21,7 @@ org.jboss.seam.solder seam-solder-parent - 3.1.0-SNAPSHOT + 3.1.0.Beta2 ../pom.xml From f01e4d2e2abc2f831c9cbaa78a0bdd7cb97603db Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Tue, 23 Aug 2011 14:23:37 +1000 Subject: [PATCH 15/16] [maven-release-plugin] prepare for next development iteration --- api/pom.xml | 2 +- dist/pom.xml | 2 +- docs/pom.xml | 2 +- impl/pom.xml | 2 +- logging/pom.xml | 2 +- pom.xml | 2 +- tooling/pom.xml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index 902097d0..7deb96fc 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -21,7 +21,7 @@ org.jboss.seam.solder seam-solder-parent - 3.1.0.Beta2 + 3.1.0-SNAPSHOT ../pom.xml diff --git a/dist/pom.xml b/dist/pom.xml index 06adada1..aa199ca5 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -5,7 +5,7 @@ org.jboss.seam.solder seam-solder-parent - 3.1.0.Beta2 + 3.1.0-SNAPSHOT ../pom.xml diff --git a/docs/pom.xml b/docs/pom.xml index 0afc35b8..f7a36afd 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -21,7 +21,7 @@ org.jboss.seam.solder seam-solder-parent - 3.1.0.Beta2 + 3.1.0-SNAPSHOT ../pom.xml diff --git a/impl/pom.xml b/impl/pom.xml index b154f126..a81bcd22 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -21,7 +21,7 @@ org.jboss.seam.solder seam-solder-parent - 3.1.0.Beta2 + 3.1.0-SNAPSHOT ../pom.xml diff --git a/logging/pom.xml b/logging/pom.xml index feb69ecd..b94bb898 100644 --- a/logging/pom.xml +++ b/logging/pom.xml @@ -4,7 +4,7 @@ seam-solder-parent org.jboss.seam.solder - 3.1.0.Beta2 + 3.1.0-SNAPSHOT seam-solder-logging Seam Solder Logging diff --git a/pom.xml b/pom.xml index 58191efe..9e8ef261 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.jboss.seam.solder seam-solder-parent pom - 3.1.0.Beta2 + 3.1.0-SNAPSHOT Seam Solder Project A portable CDI extensions library for developing CDI applications, frameworks or other extensions diff --git a/tooling/pom.xml b/tooling/pom.xml index cfbe293d..7aedc973 100644 --- a/tooling/pom.xml +++ b/tooling/pom.xml @@ -21,7 +21,7 @@ org.jboss.seam.solder seam-solder-parent - 3.1.0.Beta2 + 3.1.0-SNAPSHOT ../pom.xml From 366cd2bfc43f3ede6ad21613537eb7ccbc7d84c3 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Tue, 23 Aug 2011 14:56:46 +1000 Subject: [PATCH 16/16] remove arquillian version property --- impl/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/impl/pom.xml b/impl/pom.xml index a81bcd22..6ffcaea9 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -244,7 +244,6 @@ org.jboss.arquillian.container arquillian-openwebbeans-embedded-1 - ${version.arquillian} @@ -337,7 +336,6 @@ org.jboss.arquillian.container arquillian-jbossas-managed-6 - ${version.arquillian} org.jboss.jbossas @@ -367,7 +365,6 @@ org.jboss.arquillian.container arquillian-jbossas-remote-6 - ${version.arquillian} org.jboss.jbossas @@ -405,7 +402,6 @@ org.jboss.arquillian.container arquillian-glassfish-remote-3.1 - ${version.arquillian} test