JBoss Tools SVN: r36531 - in trunk/ws: plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2011-11-22 08:26:39 -0500 (Tue, 22 Nov 2011)
New Revision: 36531
Added:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java
Removed:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/CollectionFilterUtils.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MemberAnnotationBindingVisitor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MemberAnnotationBindingsVisitor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MethodBindingVisitor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignatureVisitor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/AbstractBuildDelegateTestCase.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaAnnotationsVisitor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsResourceMethod.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/contentassist/PathParamAnnotationValueCompletionProposalComputer.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelFullBuildJobTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java
Log:
Moved content assist/validation into the core plugin - using the metamodel
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -334,4 +334,37 @@
return false;
}
+ @Override
+ public List<String> getPathParamValueProposals() {
+ List<String> proposals = new ArrayList<String>();
+ final Annotation methodPathAnnotation = getPathAnnotation();
+ if(methodPathAnnotation != null) {
+ final String value = methodPathAnnotation.getValue("value");
+ proposals.addAll(extractParamsFromUriTemplateFragment(value));
+ }
+ final Annotation typePathAnnotation = getParentResource().getPathAnnotation();
+ if(typePathAnnotation != null) {
+ final String value = typePathAnnotation.getValue("value");
+ proposals.addAll(extractParamsFromUriTemplateFragment(value));
+ }
+ return proposals;
+ }
+
+ /**
+ * Extracts all the character sequences inside of curly braces ('{' and '}') and returns them as a list of strings
+ * @param value the given value
+ * @return the list of character sequences, or an empty list
+ */
+ private static List<String> extractParamsFromUriTemplateFragment(String value) {
+ List<String> params = new ArrayList<String>();
+ int beginIndex = -1;
+ while ((beginIndex = value.indexOf("{", beginIndex + 1)) != -1) {
+ int semicolonIndex = value.indexOf(":", beginIndex);
+ int closingCurlyBraketIndex = value.indexOf("}", beginIndex);
+ int endIndex = semicolonIndex != -1 ? semicolonIndex : closingCurlyBraketIndex;
+ params.add(value.substring(beginIndex + 1, endIndex).trim());
+ }
+ return params;
+ }
+
}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/CollectionFilterUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/CollectionFilterUtils.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/CollectionFilterUtils.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -1,5 +0,0 @@
-package org.jboss.tools.ws.jaxrs.core.internal.utils;
-
-public class CollectionFilterUtils {
-
-}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MemberAnnotationBindingVisitor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MemberAnnotationBindingVisitor.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MemberAnnotationBindingVisitor.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -1,5 +0,0 @@
-package org.jboss.tools.ws.jaxrs.core.internal.utils;
-
-public class MemberAnnotationBindingVisitor {
-
-}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MemberAnnotationBindingsVisitor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MemberAnnotationBindingsVisitor.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MemberAnnotationBindingsVisitor.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -1,5 +0,0 @@
-package org.jboss.tools.ws.jaxrs.core.internal.utils;
-
-public class MemberAnnotationBindingsVisitor {
-
-}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MethodBindingVisitor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MethodBindingVisitor.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/MethodBindingVisitor.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -1,5 +0,0 @@
-package org.jboss.tools.ws.jaxrs.core.internal.utils;
-
-public class MethodBindingVisitor {
-
-}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -32,45 +32,6 @@
this.region = region;
}
- /** convenient constructor: no typed region specified
- *
- * @param annotation
- * @param name
- * @param annotationElements */
- public Annotation(IAnnotation annotation, String name, Map<String, List<String>> annotationElements) {
- this.javaAnnotation = annotation;
- this.javaAnnotationName = name;
- this.javaAnnotationElements = new HashMap<String, List<String>>(annotationElements);
- this.region = null;
- }
-
- /** Convenient constructor : only one element named "value", whose value is
- * given in parameter
- *
- * @param annotation
- * @param name */
- public Annotation(IAnnotation annotation, String name) {
- this.javaAnnotation = annotation;
- this.javaAnnotationName = name;
- this.javaAnnotationElements = new HashMap<String, List<String>>();
- this.region = null;
- }
-
- /** Convenient constructor : no element provided
- *
- * @param annotation
- * @param name
- * @param singleElementValue */
- public Annotation(IAnnotation annotation, String name, String singleElementValue) {
- this.javaAnnotation = annotation;
- this.javaAnnotationName = name;
- this.javaAnnotationElements = new HashMap<String, List<String>>();
- if (singleElementValue != null) {
- this.javaAnnotationElements.put("value", Arrays.asList(singleElementValue));
- }
- this.region = null;
- }
-
public boolean update(Annotation annotation) {
assert annotation != null;
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaAnnotationsVisitor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaAnnotationsVisitor.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaAnnotationsVisitor.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -28,6 +28,8 @@
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TypedRegion;
/** A visitor for a single annotation on a java member (can be a method or a
* type).
@@ -45,7 +47,7 @@
private final List<String> annotationNames = new ArrayList<String>();
/** the bindings for the matching annotation. */
- private final List<IAnnotationBinding> annotationBindings = new ArrayList<IAnnotationBinding>();
+ private final List<Annotation> annotations = new ArrayList<Annotation>();
/** Full Constructor to resolve a single annotation from its fully qualified
* name.
@@ -140,12 +142,18 @@
private void visitExtendedModifiers(final List<?> modifiers) {
for (Object modifier : modifiers) {
if (modifier instanceof org.eclipse.jdt.core.dom.Annotation) {
- IAnnotationBinding binding = ((org.eclipse.jdt.core.dom.Annotation) modifier)
+ final org.eclipse.jdt.core.dom.Annotation annotation = (org.eclipse.jdt.core.dom.Annotation) modifier;
+ IAnnotationBinding annotationBinding = ((org.eclipse.jdt.core.dom.Annotation) modifier)
.resolveAnnotationBinding();
- final String qualifiedName = binding.getAnnotationType().getQualifiedName();
- final String name = binding.getAnnotationType().getName();
+ final String qualifiedName = annotationBinding.getAnnotationType().getQualifiedName();
+ final String name = annotationBinding.getAnnotationType().getName();
if (annotationNames.contains(qualifiedName) || annotationNames.contains(name)) {
- annotationBindings.add(binding);
+ final String annotationName = annotationBinding.getAnnotationType().getQualifiedName();
+ final Map<String, List<String>> annotationElements = resolveAnnotationElements(annotationBinding);
+ final TypedRegion typedRegion = new TypedRegion(annotation.getStartPosition(),
+ annotation.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
+ final IAnnotation javaAnnotation = (IAnnotation) annotationBinding.getJavaElement();
+ annotations.add(new Annotation(javaAnnotation, annotationName, annotationElements, typedRegion));
}
}
}
@@ -161,15 +169,10 @@
* in case of underlying exception */
public final Annotation getResolvedAnnotation() throws JavaModelException {
assert annotationNames.size() == 1;
- if (annotationBindings.size() == 0) {
+ if (annotations.size() == 0) {
return null;
}
- final IAnnotationBinding annotationBinding = annotationBindings.get(0);
- final IAnnotation annotation = (IAnnotation) annotationBinding.getJavaElement();
- final String annotationName = annotationBinding.getAnnotationType().getQualifiedName();
- final Map<String, List<String>> annotationElements = resolveAnnotationElements(annotationBinding);
- final Annotation resolvedJavaAnnotation = new Annotation(annotation, annotationName, annotationElements);
- return resolvedJavaAnnotation;
+ return annotations.get(0);
}
/** Returns the Annotation elements matching the annotations name given in
@@ -184,11 +187,8 @@
* in case of underlying exception */
public final Map<String, Annotation> getResolvedAnnotations() throws JavaModelException {
final Map<String, Annotation> resolvedJavaAnnotations = new HashMap<String, Annotation>();
- for (IAnnotationBinding annotationBinding : annotationBindings) {
- final IAnnotation annotation = (IAnnotation) annotationBinding.getJavaElement();
- final String annotationName = annotationBinding.getAnnotationType().getQualifiedName();
- final Map<String, List<String>> annotationElements = resolveAnnotationElements(annotationBinding);
- resolvedJavaAnnotations.put(annotationName, new Annotation(annotation, annotationName, annotationElements));
+ for (Annotation annotation: annotations) {
+ resolvedJavaAnnotations.put(annotation.getName(), annotation);
}
return resolvedJavaAnnotations;
}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignatureVisitor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignatureVisitor.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignatureVisitor.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -1,142 +0,0 @@
-package org.jboss.tools.ws.jaxrs.core.jdt;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.ASTVisitor;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.IAnnotationBinding;
-import org.eclipse.jdt.core.dom.IMemberValuePairBinding;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jface.text.TypedRegion;
-import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
-
-public class JavaMethodSignatureVisitor extends ASTVisitor {
-
- private final ICompilationUnit compilationUnit;
-
- private final IMethod method;
-
- private JavaMethodSignature methodSignature = null;
-
- public JavaMethodSignatureVisitor(IMethod method) {
- this.compilationUnit = method.getCompilationUnit();
- this.method = method;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse
- * .jdt.core.dom.MethodDeclaration)
- */
- @Override
- public boolean visit(MethodDeclaration declaration) {
- try {
- IMethod method = (IMethod) compilationUnit.getElementAt(declaration.getStartPosition());
- if (!this.method.getHandleIdentifier().equals(method.getHandleIdentifier())) {
- return true;
- }
-
- final IMethodBinding methodBinding = declaration.resolveBinding();
- // sometimes, the binding cannot be resolved
- if (methodBinding == null) {
- Logger.warn("Could not resolve bindings form method " + method.getElementName());
- } else {
- final IType returnedType = methodBinding.getReturnType() != null ? (IType) methodBinding
- .getReturnType().getJavaElement() : null;
- final ITypeBinding[] parameterTypeBindings = methodBinding.getParameterTypes();
- List<JavaMethodParameter> methodParameters = new ArrayList<JavaMethodParameter>();
- @SuppressWarnings("unchecked")
- List<SingleVariableDeclaration> parameters = declaration.parameters();
- for (SingleVariableDeclaration parameter : parameters) {
- final String paramName = parameter.getName().getFullyQualifiedName();
- final IVariableBinding paramBinding = parameter.resolveBinding();
- final String paramTypeName = paramBinding.getType().getQualifiedName();
- final List<org.jboss.tools.ws.jaxrs.core.jdt.Annotation> paramAnnotations = new ArrayList<org.jboss.tools.ws.jaxrs.core.jdt.Annotation>();
- final List<?> modifiers = (List<?>) (parameter
- .getStructuralProperty(SingleVariableDeclaration.MODIFIERS2_PROPERTY));
- for (Object modifier : modifiers) {
- if (modifier instanceof Annotation) {
- final Annotation annotation = (Annotation) modifier;
- IAnnotationBinding annotationBinding = annotation.resolveAnnotationBinding();
- final String annotationName = annotationBinding.getAnnotationType().getQualifiedName();
- final Map<String, List<String>> annotationElements = resolveAnnotationElements(annotationBinding);
- final TypedRegion typedRegion = new TypedRegion(annotation.getStartPosition(),
- annotation.getLength(), parameter.getType().toString());
- paramAnnotations.add(new org.jboss.tools.ws.jaxrs.core.jdt.Annotation(null, annotationName,
- annotationElements, typedRegion));
- }
- }
- methodParameters.add(new JavaMethodParameter(paramName, paramTypeName, paramAnnotations));
- }
- /*
- * for (int i = 0; i < parameterTypeBindings.length; i++) {
- * final ITypeBinding parameterTypeBinding =
- * parameterTypeBindings[i];
- * final String paramTypeName =
- * parameterTypeBinding.getQualifiedName();
- * final List<Annotation> paramAnnotations = new
- * ArrayList<Annotation>();
- * final IAnnotationBinding[] parameterAnnotationBindings =
- * methodBinding.getParameterAnnotations(i);
- * for (IAnnotationBinding parameterAnnotationBinding :
- * parameterAnnotationBindings) {
- * parameterAnnotationBinding.getAnnotationType().getJavaElement(
- * );
- * final String annotationName =
- * parameterAnnotationBinding.getAnnotationType
- * ().getBinaryName();
- * final Map<String, List<String>> annotationElements =
- * resolveAnnotationElements(parameterAnnotationBinding);
- * final TypedRegion typedRegion = new
- * TypedRegion(annotation.getStartPosition(),
- * annotation.getLength(), param.getType().toString());
- *
- * paramAnnotations.add(new Annotation(null, annotationName,
- * annotationElements));
- * }
- * methodParameters.add(new JavaMethodParameter(paramName,
- * paramTypeName, paramAnnotations));
- * }
- */
- // TODO : add support for thrown exceptions
- this.methodSignature = new JavaMethodSignature(method, returnedType, methodParameters);
- }
- } catch (JavaModelException e) {
- Logger.error("Failed to analyse compilation unit methods", e);
- }
- return true;
- }
-
- private static Map<String, List<String>> resolveAnnotationElements(IAnnotationBinding annotationBinding) {
- final Map<String, List<String>> annotationElements = new HashMap<String, List<String>>();
- for (IMemberValuePairBinding binding : annotationBinding.getAllMemberValuePairs()) {
- final List<String> values = new ArrayList<String>();
- if (binding.getValue() instanceof Object[]) {
- for (Object v : (Object[]) binding.getValue()) {
- values.add(v.toString());
- }
- } else {
- values.add(binding.getValue().toString());
- }
- annotationElements.put(binding.getName(), values);
- }
- return annotationElements;
- }
-
- /** @return the methodDeclarations */
- public JavaMethodSignature getMethodSignature() {
- return methodSignature;
- }
-}
\ No newline at end of file
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -1,96 +0,0 @@
-package org.jboss.tools.ws.jaxrs.core.jdt;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.ASTVisitor;
-import org.eclipse.jdt.core.dom.IAnnotationBinding;
-import org.eclipse.jdt.core.dom.IMemberValuePairBinding;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
-
-public class JavaMethodSignaturesVisitor extends ASTVisitor {
-
- private final ICompilationUnit compilationUnit;
-
- private final List<JavaMethodSignature> methodSignatures = new ArrayList<JavaMethodSignature>();
-
- public JavaMethodSignaturesVisitor(ICompilationUnit compilationUnit2) {
- this.compilationUnit = compilationUnit2;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse
- * .jdt.core.dom.MethodDeclaration)
- */
- @Override
- public boolean visit(MethodDeclaration declaration) {
- try {
- IMethod method = (IMethod) compilationUnit.getElementAt(declaration.getStartPosition());
- final IMethodBinding methodBinding = declaration.resolveBinding();
- // sometimes, the binding cannot be resolved
- if (methodBinding == null) {
- Logger.warn("Could not resolve bindings form method " + method.getElementName());
- } else {
- final IType returnedType = methodBinding.getReturnType() != null ? (IType) methodBinding
- .getReturnType().getJavaElement() : null;
- final ITypeBinding[] parameterTypeBindings = methodBinding.getParameterTypes();
- List<JavaMethodParameter> methodParameters = new ArrayList<JavaMethodParameter>();
- @SuppressWarnings("unchecked")
- List<SingleVariableDeclaration> parameters = declaration.parameters();
- for (int i = 0; i < parameterTypeBindings.length; i++) {
- final ITypeBinding parameterTypeBinding = parameterTypeBindings[i];
- final String paramTypeName = parameterTypeBinding.getQualifiedName();
- final String paramName = parameters.get(i).getName().getFullyQualifiedName();
- final List<Annotation> paramAnnotations = new ArrayList<Annotation>();
- final IAnnotationBinding[] parameterAnnotationBindings = methodBinding.getParameterAnnotations(i);
- for (IAnnotationBinding parameterAnnotationBinding : parameterAnnotationBindings) {
- final String annotationName = parameterAnnotationBinding.getAnnotationType().getBinaryName();
- // ((IType)parameterAnnotationBinding.getAnnotationType().getJavaElement()).getF
- final Map<String, List<String>> annotationElements = resolveAnnotationElements(parameterAnnotationBinding);
- // method parameters are not eligible java elements...
- paramAnnotations.add(new Annotation(null, annotationName, annotationElements));
- }
- methodParameters.add(new JavaMethodParameter(paramName, paramTypeName, paramAnnotations));
- }
- // TODO : add support for thrown exceptions
- methodSignatures.add(new JavaMethodSignature(method, returnedType, methodParameters));
- }
- } catch (JavaModelException e) {
- Logger.error("Failed to analyse compilation unit methods", e);
- }
- return true;
- }
-
- private static Map<String, List<String>> resolveAnnotationElements(IAnnotationBinding annotationBinding) {
- final Map<String, List<String>> annotationElements = new HashMap<String, List<String>>();
- for (IMemberValuePairBinding binding : annotationBinding.getAllMemberValuePairs()) {
- final List<String> values = new ArrayList<String>();
- if (binding.getValue() instanceof Object[]) {
- for (Object v : (Object[]) binding.getValue()) {
- values.add(v.toString());
- }
- } else {
- values.add(binding.getValue().toString());
- }
- annotationElements.put(binding.getName(), values);
- }
- return annotationElements;
- }
-
- /** @return the methodDeclarations */
- public List<JavaMethodSignature> getMethodSignatures() {
- return methodSignatures;
- }
-}
\ No newline at end of file
Copied: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java (from rev 36520, trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignatureVisitor.java)
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -0,0 +1,138 @@
+package org.jboss.tools.ws.jaxrs.core.jdt;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.IAnnotationBinding;
+import org.eclipse.jdt.core.dom.IMemberValuePairBinding;
+import org.eclipse.jdt.core.dom.IMethodBinding;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.IVariableBinding;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TypedRegion;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
+
+public class JavaMethodSignaturesVisitor extends ASTVisitor {
+
+ private final ICompilationUnit compilationUnit;
+
+ private final IMethod method;
+
+ private final List<JavaMethodSignature> methodSignatures = new ArrayList<JavaMethodSignature>();
+
+ /**
+ * Constructor to use when you need all Java Method signatures in the given
+ * compilation unit
+ *
+ * @param method
+ */
+ public JavaMethodSignaturesVisitor(ICompilationUnit compilationUnit) {
+ this.compilationUnit = compilationUnit;
+ this.method = null;
+ }
+
+ /**
+ * Constructor to use when you only need a single Java Method signature
+ *
+ * @param method
+ */
+ public JavaMethodSignaturesVisitor(IMethod method) {
+ this.compilationUnit = method.getCompilationUnit();
+ this.method = method;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse
+ * .jdt.core.dom.MethodDeclaration)
+ */
+ @Override
+ public boolean visit(MethodDeclaration declaration) {
+ try {
+ IMethod method = (IMethod) compilationUnit.getElementAt(declaration.getStartPosition());
+ if (this.method != null && !this.method.getHandleIdentifier().equals(method.getHandleIdentifier())) {
+ return true;
+ }
+
+ final IMethodBinding methodBinding = declaration.resolveBinding();
+ // sometimes, the binding cannot be resolved
+ if (methodBinding == null) {
+ Logger.warn("Could not resolve bindings form method " + method.getElementName());
+ } else {
+ final IType returnedType = methodBinding.getReturnType() != null ? (IType) methodBinding
+ .getReturnType().getJavaElement() : null;
+ List<JavaMethodParameter> methodParameters = new ArrayList<JavaMethodParameter>();
+ @SuppressWarnings("unchecked")
+ List<SingleVariableDeclaration> parameters = declaration.parameters();
+ for (SingleVariableDeclaration parameter : parameters) {
+ final String paramName = parameter.getName().getFullyQualifiedName();
+ final IVariableBinding paramBinding = parameter.resolveBinding();
+ final String paramTypeName = paramBinding.getType().getQualifiedName();
+ final List<org.jboss.tools.ws.jaxrs.core.jdt.Annotation> paramAnnotations = new ArrayList<org.jboss.tools.ws.jaxrs.core.jdt.Annotation>();
+ final List<?> modifiers = (List<?>) (parameter
+ .getStructuralProperty(SingleVariableDeclaration.MODIFIERS2_PROPERTY));
+ for (Object modifier : modifiers) {
+ if (modifier instanceof Annotation) {
+ final Annotation annotation = (Annotation) modifier;
+ IAnnotationBinding annotationBinding = annotation.resolveAnnotationBinding();
+ final String annotationName = annotationBinding.getAnnotationType().getQualifiedName();
+ final Map<String, List<String>> annotationElements = resolveAnnotationElements(annotationBinding);
+ final TypedRegion typedRegion = new TypedRegion(annotation.getStartPosition(),
+ annotation.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
+ paramAnnotations.add(new org.jboss.tools.ws.jaxrs.core.jdt.Annotation(null, annotationName,
+ annotationElements, typedRegion));
+ }
+ }
+ methodParameters.add(new JavaMethodParameter(paramName, paramTypeName, paramAnnotations));
+ }
+
+ // TODO : add support for thrown exceptions
+ this.methodSignatures.add(new JavaMethodSignature(method, returnedType, methodParameters));
+ }
+ } catch (JavaModelException e) {
+ Logger.error("Failed to analyse compilation unit methods", e);
+ }
+ return true;
+ }
+
+ private static Map<String, List<String>> resolveAnnotationElements(IAnnotationBinding annotationBinding) {
+ final Map<String, List<String>> annotationElements = new HashMap<String, List<String>>();
+ for (IMemberValuePairBinding binding : annotationBinding.getAllMemberValuePairs()) {
+ final List<String> values = new ArrayList<String>();
+ if (binding.getValue() instanceof Object[]) {
+ for (Object v : (Object[]) binding.getValue()) {
+ values.add(v.toString());
+ }
+ } else {
+ values.add(binding.getValue().toString());
+ }
+ annotationElements.put(binding.getName(), values);
+ }
+ return annotationElements;
+ }
+
+ /** @return the methodDeclarations */
+ public JavaMethodSignature getMethodSignature() {
+ if (this.methodSignatures.size() == 0) {
+ return null;
+ }
+ return this.methodSignatures.get(0);
+
+ }
+
+ /** @return the methodDeclarations */
+ public List<JavaMethodSignature> getMethodSignatures() {
+ return this.methodSignatures;
+ }
+}
\ No newline at end of file
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -247,8 +247,8 @@
if (member.isBinary()) {
IAnnotatable javaElement = (IAnnotatable) member;
final IAnnotation annotation = javaElement.getAnnotation(annotationName);
- if (annotation.exists()) {
- return new Annotation(annotation, annotation.getElementName(), resolveAnnotationElements(annotation));
+ if (annotation != null && annotation.exists()) {
+ return new Annotation(annotation, annotation.getElementName(), resolveAnnotationElements(annotation), null);
}
return null;
}
@@ -291,7 +291,7 @@
final IAnnotation annotation = javaElement.getAnnotation(annotationName);
if (annotation.exists()) {
annotations.put(annotationName, new Annotation(annotation, annotation.getElementName(),
- resolveAnnotationElements(annotation)));
+ resolveAnnotationElements(annotation), null));
}
}
return annotations;
@@ -754,7 +754,7 @@
}
public static JavaMethodSignature resolveMethodSignature(IMethod method, CompilationUnit ast) {
- JavaMethodSignatureVisitor methodsVisitor = new JavaMethodSignatureVisitor(method);
+ JavaMethodSignaturesVisitor methodsVisitor = new JavaMethodSignaturesVisitor(method);
ast.accept(methodsVisitor);
return methodsVisitor.getMethodSignature();
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsResourceMethod.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsResourceMethod.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsResourceMethod.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -42,5 +42,12 @@
abstract List<String> getProducedMediaTypes();
List<JavaMethodParameter> getJavaMethodParameters();
+
+ /**
+ * Determines the proposals for the PathParam annotated method parameters of the underlying Java Method.
+ * This list is based on the @Path annotation found on the Java Method and on the parent Java Type.
+ * @return
+ */
+ List<String> getPathParamValueProposals();
}
\ No newline at end of file
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/contentassist/PathParamAnnotationValueCompletionProposalComputer.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/contentassist/PathParamAnnotationValueCompletionProposalComputer.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/contentassist/PathParamAnnotationValueCompletionProposalComputer.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -22,8 +22,6 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer;
@@ -46,10 +44,12 @@
import org.jboss.tools.ws.jaxrs.ui.JBossJaxrsUIPlugin;
import org.jboss.tools.ws.jaxrs.ui.internal.utils.Logger;
-/** Computes proposals for <code>java.ws.rs.PathParam</code> annotation values in
+/**
+ * Computes proposals for <code>java.ws.rs.PathParam</code> annotation values in
* the compilation unit context.
*
- * @author xcoulon */
+ * @author xcoulon
+ */
public class PathParamAnnotationValueCompletionProposalComputer implements IJavaCompletionProposalComputer {
/** Icon for completion proposals. */
@@ -101,7 +101,8 @@
return Collections.emptyList();
}
- /** Computes the valid proposals for the <code>javax.ws.rs.PathParam</code>
+ /**
+ * Computes the valid proposals for the <code>javax.ws.rs.PathParam</code>
* annotation value. The proposals are based on:
* <ul>
* <li>The values of the <code>javax.ws.rs.Path</code> annotations, both at
@@ -120,64 +121,46 @@
* @throws CoreException
* in case of underlying exception
* @throws BadLocationException
- * @throws org.eclipse.jface.text.BadLocationException */
+ * @throws org.eclipse.jface.text.BadLocationException
+ */
private List<ICompletionProposal> internalComputePathParamProposals(
final JavaContentAssistInvocationContext javaContext, final Annotation pathParamAnnotation,
final IJaxrsResourceMethod resourceMethod) throws CoreException, BadLocationException {
- ITypedRegion region = getRegion(javaContext);
+ final List<ICompletionProposal> completionProposals = new ArrayList<ICompletionProposal>();
+ final ITypedRegion region = getRegion(javaContext);
String matchValue = javaContext.getDocument().get(region.getOffset(),
javaContext.getInvocationOffset() - region.getOffset());
- // int cursorPosition = javaContext.getInvocationOffset();
- List<ICompletionProposal> completionProposals = new ArrayList<ICompletionProposal>();
- // compute proposals from @Path annotations on the method
- completionProposals.addAll(generateCompletionProposal(resourceMethod.getPathAnnotation(), region, matchValue));
- // compute proposals from @Path annotations on the type
- completionProposals.addAll(generateCompletionProposal(resourceMethod.getParentResource().getPathAnnotation(),
- region, matchValue));
- return completionProposals;
- }
+ if(matchValue.charAt(0) == '\"') {
+ matchValue = matchValue.substring(1);
+ }
+ List<String> proposals = resourceMethod.getPathParamValueProposals();
+ for (String proposal : proposals) {
+ if (proposal.startsWith(matchValue)) {
+ completionProposals.add(generateCompletionProposal(resourceMethod.getJavaElement(), region, proposal));
- private List<ICompletionProposal> generateCompletionProposal(Annotation annotation, ITypedRegion region,
- String matchValue) throws CoreException {
- final List<ICompletionProposal> completionProposals = new ArrayList<ICompletionProposal>();
- if (annotation != null) {
- final String pathAnnotationValue = annotation.getValue("value");
- if (pathAnnotationValue != null && pathAnnotationValue.contains("{") && pathAnnotationValue.contains("}")) {
- List<String> uriParams = extractParamsFromUriTemplateFragment(pathAnnotationValue);
- for (String uriParam : uriParams) {
- String replacementValue = "\"" + uriParam + "\"";
- if (replacementValue.startsWith(matchValue)) {
- String displayString = uriParam + " - JAX-RS Mapping";
- StyledString displayStyledString = new StyledString(displayString);
- displayStyledString.setStyle(uriParam.length(), displayString.length() - uriParam.length(),
- StyledString.QUALIFIER_STYLER);
- completionProposals.add(new AnnotationCompletionProposal(replacementValue, displayStyledString,
- region, icon, (IMember) annotation.getJavaParent()));
- }
- }
}
}
return completionProposals;
}
- private static List<String> extractParamsFromUriTemplateFragment(String fragment) {
- List<String> params = new ArrayList<String>();
- int beginIndex = -1;
- while ((beginIndex = fragment.indexOf("{", beginIndex + 1)) != -1) {
- int semicolonIndex = fragment.indexOf(":", beginIndex);
- int closingCurlyBraketIndex = fragment.indexOf("}", beginIndex);
- int endIndex = semicolonIndex != -1 ? semicolonIndex : closingCurlyBraketIndex;
- params.add(fragment.substring(beginIndex + 1, endIndex).trim());
- }
- return params;
+ private ICompletionProposal generateCompletionProposal(IMember member, ITypedRegion region, String proposalValue)
+ throws CoreException {
+ String replacementValue = "\"" + proposalValue + "\"";
+ String displayString = proposalValue + " - JAX-RS Mapping";
+ StyledString displayStyledString = new StyledString(displayString);
+ displayStyledString.setStyle(proposalValue.length(), displayString.length() - proposalValue.length(),
+ StyledString.QUALIFIER_STYLER);
+ return new AnnotationCompletionProposal(replacementValue, displayStyledString, region, icon, member);
}
- /** Resolves the typed region for the given java content assist invocation
+ /**
+ * Resolves the typed region for the given java content assist invocation
* context.
*
* @param javaContext
* the java content assist invocation context
- * @return the typed region */
+ * @return the typed region
+ */
private ITypedRegion getRegion(final JavaContentAssistInvocationContext javaContext) {
IDocument document = javaContext.getDocument();
IDocumentPartitioner documentPartitioner = ((IDocumentExtension3) document)
@@ -185,35 +168,6 @@
return documentPartitioner.getPartition(javaContext.getInvocationOffset());
}
- /** Returns the enclosing java type for the given java element.
- *
- * @param element
- * the element
- * @return the enclosing type, or null if the given element is neither a
- * method nor the type itself
- * @throws JavaModelException
- * in case of underlying exception */
- private IType getEnclosingType(final IJavaElement element) throws JavaModelException {
- if (element == null) {
- // no enclosing parent. For example, an annotation is set before the
- // method itself was written.
- return null;
- }
- switch (element.getElementType()) {
- case IJavaElement.TYPE:
- return (IType) element;
- case IJavaElement.METHOD:
- return (IType) element.getParent();
- case IJavaElement.FIELD:
- return null;
- default:
- break;
- }
- // Logger.error("Unexpected element type for " +
- // element.getElementName() + ": " + element.getElementType());
- return null;
- }
-
/** {@inheritDoc} */
@Override
public final List<IContextInformation> computeContextInformation(final ContentAssistInvocationContext context,
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -22,8 +22,10 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
@@ -63,6 +65,8 @@
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages;
+import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
+import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.osgi.framework.Bundle;
@@ -813,4 +817,25 @@
return found;
}
+ public static Annotation getAnnotation(final IMember member, final Class<?> annotationClass) throws JavaModelException {
+ if(annotationClass == null) {
+ return null;
+ }
+ return JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, null), annotationClass);
+ }
+
+ public static Annotation getAnnotation(final IMember member, final Class<?> annotationClass, String... values)
+ throws JavaModelException {
+ Annotation annotation = JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, null),
+ annotationClass);
+ Map<String, List<String>> elements = new HashMap<String, List<String>>();
+ elements.put("value", Arrays.asList(values));
+ annotation.update(new Annotation(annotation.getJavaAnnotation(), annotation.getName(), elements, null));
+ return annotation;
+ }
+
+ public static IType getType(String typeName, IJavaProject javaProject) throws CoreException {
+ return JdtUtils.resolveType(typeName, javaProject, null);
+ }
+
}
Deleted: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/AbstractBuildDelegateTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/AbstractBuildDelegateTestCase.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/AbstractBuildDelegateTestCase.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xavier Coulon - Initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder;
-
-import org.jboss.tools.ws.jaxrs.core.AbstractCommonTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractBuildDelegateTestCase extends AbstractCommonTestCase {
-
- protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractBuildDelegateTestCase.class);
-
-}
\ No newline at end of file
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -8,6 +8,9 @@
import static org.hamcrest.Matchers.everyItem;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getAnnotation;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getMethod;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getType;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.IJavaElementDeltaFlag.F_SIGNATURE;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementChangedEvent.F_CONSUMED_MEDIATYPES_VALUE;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementChangedEvent.F_ELEMENT_KIND;
@@ -49,6 +52,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IMember;
@@ -105,28 +109,20 @@
return httpMethod;
}
- private IType getType(String typeName) throws CoreException {
- return JdtUtils.resolveType(typeName, javaProject, progressMonitor);
+
+ private Annotation createAnnotation(IAnnotation annotation, String name) {
+ return createAnnotation(annotation, name, null);
}
- private IMethod getMethod(IType parentType, String methodName) throws JavaModelException {
- return WorkbenchUtils.getMethod(parentType, methodName);
+ private Annotation createAnnotation(Class<?> clazz, String value) {
+ return createAnnotation(null, clazz.getName(), value);
}
-
- private Annotation getAnnotation(final IMember member, final Class<?> annotationClass) throws JavaModelException {
- return JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, progressMonitor), annotationClass);
+
+ private Annotation createAnnotation(IAnnotation annotation, String name, String value) {
+ Map<String, List<String>> values = new HashMap<String, List<String>>();
+ values.put("value", Arrays.asList(value));
+ return new Annotation(annotation, name, values, null);
}
-
- private Annotation getAnnotation(final IMember member, final Class<?> annotationClass, String... values)
- throws JavaModelException {
- Annotation annotation = JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, progressMonitor),
- annotationClass);
- Map<String, List<String>> elements = new HashMap<String, List<String>>();
- elements.put("value", Arrays.asList(values));
- annotation.update(new Annotation(annotation.getJavaAnnotation(), annotation.getName(), elements));
- return annotation;
- }
-
private List<JaxrsElementChangedEvent> processEvent(JavaElementChangedEvent event, IProgressMonitor progressmonitor) {
return delegate.processEvents(Arrays.asList(event), progressmonitor);
}
@@ -411,7 +407,7 @@
@Test
public void shouldAddResourceWhenAddingSourceCompilationUnit() throws CoreException {
// pre-conditions
- IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
// operation
final JavaElementChangedEvent event = createEvent(type.getCompilationUnit(), ADDED);
final List<JaxrsElementChangedEvent> impacts = processEvent(event, progressMonitor);
@@ -426,7 +422,7 @@
// pre-conditions
final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
metamodel.add(httpMethod);
- IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
+ IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource", javaProject);
// operation
final JavaElementChangedEvent event = createEvent(type.getCompilationUnit(), ADDED);
final List<JaxrsElementChangedEvent> impacts = processEvent(event, progressMonitor);
@@ -440,7 +436,7 @@
@Test
public void shouldAddSubresourceLocatorWhenAddingSourceCompilationUnit() throws CoreException {
// pre-conditions
- IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
// operation
final JavaElementChangedEvent event = createEvent(type.getCompilationUnit(), ADDED);
final List<JaxrsElementChangedEvent> impacts = processEvent(event, progressMonitor);
@@ -454,7 +450,7 @@
@Test
public void shouldAddResourceWhenAddingSourceType() throws CoreException {
// pre-conditions
- IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
// operation
final JavaElementChangedEvent event = createEvent(type, ADDED);
final List<JaxrsElementChangedEvent> impacts = processEvent(event, progressMonitor);
@@ -470,7 +466,7 @@
@Test
public void shouldAddResourceWhenAddingPathAnnotation() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation annotation = getAnnotation(type, Path.class);
// operation
final JavaElementChangedEvent event = createEvent(annotation, ADDED);
@@ -491,7 +487,7 @@
@Test
public void shouldBecomeRootResourceWhenAddingPathAnnotation() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation annotation = getAnnotation(type, Path.class);
final IJaxrsResource resource = new JaxrsResource.Builder(type, metamodel).build();
metamodel.add(resource);
@@ -507,7 +503,7 @@
@Test
public void shouldNotAddResourceWhenAddingAnotherAnnotation() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation annotation = getAnnotation(type, Consumes.class);
// operation
final JavaElementChangedEvent event = createEvent(annotation, ADDED);
@@ -520,7 +516,7 @@
@Test
public void shouldUpdateResourceWhenChangingPathAnnotationValue() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation annotation = getAnnotation(type, Path.class, "/bar");
final IJaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(annotation).build();
metamodel.add(resource);
@@ -537,7 +533,7 @@
@Test
public void shouldUpdateResourceWhenAddingConsumesAnnotation() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation annotation = getAnnotation(type, Consumes.class);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
@@ -554,7 +550,7 @@
@Test
public void shouldUpdateResourceWhenChangingConsumesAnnotationValue() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final Annotation consumesAnnotation = getAnnotation(type, Consumes.class, "application/foo");
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation)
@@ -572,7 +568,7 @@
@Test
public void shouldUpdateResourceWhenRemovingConsumesAnnotation() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final Annotation consumesAnnotation = getAnnotation(type, Consumes.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation)
@@ -590,7 +586,7 @@
@Test
public void shouldUpdateResourceWhenAddingProducesAnnotation() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -607,7 +603,7 @@
@Test
public void shouldUpdateResourceWhenChangingProducesAnnotationValue() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation annotation = getAnnotation(type, Produces.class, "application/foo");
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation)
@@ -625,7 +621,7 @@
@Test
public void shouldUpdateResourceWhenRemovingProducesAnnotation() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation annotation = getAnnotation(type, Produces.class);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation)
@@ -643,7 +639,7 @@
@Test
public void shouldAddResourceFieldWhenAddingPathParamAnnotationOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -657,6 +653,7 @@
}
@Test
+ @Ignore
public void shouldAddResourceFieldWhenAddingImportPathParam() throws CoreException {
/*
* // pre-conditions final IType type =
@@ -676,7 +673,7 @@
@Test
public void shouldAddResourceFieldWhenAddingQueryParamAnnotationOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -692,7 +689,7 @@
@Test
public void shouldAddResourceFieldWhenAddingMatrixParamAnnotationOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -708,7 +705,7 @@
@Test
public void shouldAddResourceFieldWhenAddingFieldAnnotatedWithPathParam() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -724,7 +721,7 @@
@Test
public void shouldAddResourceFieldWhenAddingFieldAnnotatedWithQueryParam() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -740,7 +737,7 @@
@Test
public void shouldAddResourceFieldWhenAddingFieldAnnotatedWithMatrixParam() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -756,7 +753,7 @@
@Test
public void shouldDoNothingWhenAddingFieldWithAnyAnnotation() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -771,7 +768,7 @@
@Test
public void shouldDoNothingWhenAddingAnotherAnnotationOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -786,7 +783,7 @@
@Test
public void shouldUpdateResourceFieldWhenChangingPathParamAnnotationValueOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -805,7 +802,7 @@
@Test
public void shouldUpdateResourceFieldWhenChangingQueryParamAnnotationValueOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -824,7 +821,7 @@
@Test
public void shouldUpdateResourceFieldWhenChangingMatrixParamAnnotationValueOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -843,7 +840,7 @@
@Test
public void shouldDoNothingWhenChangingAnotherAnnotationValueOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -861,7 +858,7 @@
@Test
public void shouldRemoveResourceFieldWhenRemovingPathParamAnnotatedOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -880,7 +877,7 @@
@Test
public void shouldRemoveResourceFieldWhenRemovingQueryParamAnnotationOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -899,7 +896,7 @@
@Test
public void shouldRemoveResourceFieldWhenRemovingMatrixParamAnnotationOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -918,7 +915,7 @@
@Test
public void shouldRemoveResourceFieldWhenRemovingFieldAnnotatedWithQueryParam() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -937,7 +934,7 @@
@Test
public void shouldRemoveResourceFieldWhenRemovingFieldAnnotatedWithPathParam() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -957,7 +954,7 @@
@Test
public void shouldRemoveResourceFieldWhenRemovingFieldAnnotatedWithMatrixParam() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -976,7 +973,7 @@
@Test
public void shouldDoNothingWhenRemovingAnotherAnnotationOnField() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -991,7 +988,7 @@
@Test
public void shouldDoNothingWhenAnnotationValueRemainsSameOnResource() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation annotation = JdtUtils.resolveAnnotation(type, JdtUtils.parse(type, progressMonitor),
Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(annotation).build();
@@ -1006,7 +1003,7 @@
@Test
public void shouldDoNothingResourceWhenChangingAnotherAnnotationValue() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1021,7 +1018,7 @@
@Test
public void shouldRemoveResourceWhenRemovingCompilationUnit() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final IJaxrsResource resource = new JaxrsResource.Builder(type, metamodel).build();
metamodel.add(resource);
// operation
@@ -1037,7 +1034,7 @@
@Test
public void shouldRemoveResourceWhenRemovingSourceType() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final IJaxrsResource resource = new JaxrsResource.Builder(type, metamodel).build();
metamodel.add(resource);
// operation
@@ -1053,7 +1050,7 @@
@Test
public void shouldRemoveResourceWhenRemovingAnnotation() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation annotation = getAnnotation(type, Path.class);
final IJaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(annotation).build();
metamodel.add(resource);
@@ -1076,7 +1073,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1101,7 +1098,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
metamodel.add(httpMethod);
// JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1123,7 +1120,7 @@
@Test
public void shouldDoNothingWhenRemovingAnotherAnnotationOnResource() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final IJaxrsResource resource = new JaxrsResource.Builder(type, metamodel).build();
metamodel.add(resource);
// in case it would be removed
@@ -1141,7 +1138,7 @@
// pre-conditions
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation annotation = getAnnotation(type, Consumes.class);
final IJaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(annotation).build();
metamodel.add(resource);
@@ -1165,7 +1162,7 @@
// JAX-RS HttpMethod
metamodel.add(createHttpMethod(POST.class));
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1185,7 +1182,7 @@
// JAX-RS HttpMethod
metamodel.add(createHttpMethod(POST.class));
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1202,7 +1199,7 @@
public void shouldAddSubresourceLocatorWhenAddingPathAnnotation() throws CoreException {
// pre-conditions
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1223,7 +1220,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1247,7 +1244,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(
getAnnotation(type, Path.class)).build();
metamodel.add(resource);
@@ -1274,7 +1271,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(
getAnnotation(type, Path.class)).build();
metamodel.add(resource);
@@ -1301,7 +1298,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(
getAnnotation(type, Path.class)).build();
metamodel.add(resource);
@@ -1325,7 +1322,7 @@
public void shouldRemoveSubresourceLocatorWhenRemovingPathAnnotation() throws CoreException {
// pre-conditions
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(
getAnnotation(type, Path.class)).build();
metamodel.add(resource);
@@ -1350,7 +1347,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(
getAnnotation(type, Path.class)).build();
metamodel.add(resource);
@@ -1377,7 +1374,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1404,7 +1401,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1431,7 +1428,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1458,7 +1455,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1485,7 +1482,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1512,7 +1509,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1542,7 +1539,7 @@
// the method signature is changed
// pre-conditions
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1550,9 +1547,9 @@
final IMethod method = getMethod(type, "getCustomer");
final JavaMethodParameter pathParameter = new JavaMethodParameter("id", Integer.class.getName(), null);
final JavaMethodParameter contextParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(new Annotation(null, Context.class.getName())));
+ Arrays.asList(createAnnotation(Context.class, null)));
final IJaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType(Response.class.getName()))
+ .httpMethod(getAnnotation(method, GET.class)).returnType(getType(Response.class.getName(), javaProject))
.methodParameter(pathParameter).methodParameter(contextParameter).build();
metamodel.add(resourceMethod);
// operation
@@ -1570,18 +1567,18 @@
// the method signature is changed
// pre-conditions
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "getCustomer");
final JavaMethodParameter pathParameter = new JavaMethodParameter("id", Integer.class.getName(),
- Arrays.asList(new Annotation(null, PathParam.class.getName(), "foo!")));
+ Arrays.asList(createAnnotation(PathParam.class, "foo!")));
final JavaMethodParameter contextParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(new Annotation(null, Context.class.getName())));
+ Arrays.asList(createAnnotation(Context.class, null)));
final IJaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType(Response.class.getName()))
+ .httpMethod(getAnnotation(method, GET.class)).returnType(getType(Response.class.getName(), javaProject))
.methodParameter(pathParameter).methodParameter(contextParameter).build();
metamodel.add(resourceMethod);
// operation
@@ -1598,19 +1595,19 @@
// the method signature is changed
// pre-conditions
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "updateCustomer");
final JavaMethodParameter pathParameter = new JavaMethodParameter("id", Integer.class.getName(),
- Arrays.asList(new Annotation(null, PathParam.class.getName(), "id")));
+ Arrays.asList(createAnnotation(PathParam.class, "id")));
final JavaMethodParameter customerParameter = new JavaMethodParameter("update",
- "org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", Arrays.asList(new Annotation(null,
- PathParam.class.getName(), "foo")));
+ "org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", Arrays.asList(createAnnotation(
+ PathParam.class, "foo")));
final IJaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, PUT.class)).returnType(getType("void"))
+ .httpMethod(getAnnotation(method, PUT.class)).returnType(getType("void", javaProject))
.methodParameter(pathParameter).methodParameter(customerParameter).build();
metamodel.add(resourceMethod);
// operation
@@ -1627,18 +1624,18 @@
// the method signature is changed
// pre-conditions
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (size param is not declared)
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int",
- Arrays.asList(new Annotation(null, QueryParam.class.getName(), "start")));
+ Arrays.asList(createAnnotation(QueryParam.class, "start")));
final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(new Annotation(null, Context.class.getName())));
+ Arrays.asList(createAnnotation(Context.class, null)));
final IJaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List"))
+ .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List", javaProject))
.methodParameter(startParameter).methodParameter(uriInfoParameter).build();
metamodel.add(jaxrsMethod);
// operation
@@ -1655,20 +1652,20 @@
// the method signature is changed
// pre-conditions
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (@QueryParam on 'size' param is not declared)
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int",
- Arrays.asList(new Annotation(null, QueryParam.class.getName(), "start")));
- final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(new Annotation(
- null, DefaultValue.class.getName(), "2")));
+ Arrays.asList(createAnnotation(QueryParam.class, "start")));
+ final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(createAnnotation(
+ DefaultValue.class, "2")));
final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(new Annotation(null, Context.class.getName())));
+ Arrays.asList(createAnnotation(Context.class, null)));
final IJaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List"))
+ .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List", javaProject))
.methodParameter(startParameter).methodParameter(sizeParameter).methodParameter(uriInfoParameter)
.build();
metamodel.add(jaxrsMethod);
@@ -1686,7 +1683,7 @@
// the method signature is changed
// pre-conditions
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1694,13 +1691,13 @@
// "size" on second param)
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int",
- Arrays.asList(new Annotation(null, QueryParam.class.getName(), "start")));
- final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(new Annotation(
- null, QueryParam.class.getName(), "length"), new Annotation(null, DefaultValue.class.getName(), "2")));
+ Arrays.asList(createAnnotation(QueryParam.class, "start")));
+ final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(createAnnotation(
+ QueryParam.class, "length"), createAnnotation(DefaultValue.class, "2")));
final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(new Annotation(null, Context.class.getName())));
+ Arrays.asList(createAnnotation(Context.class, null)));
final IJaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List"))
+ .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List", javaProject))
.methodParameter(startParameter).methodParameter(sizeParameter).methodParameter(uriInfoParameter)
.build();
metamodel.add(jaxrsMethod);
@@ -1718,21 +1715,21 @@
// the method signature is changed
// pre-conditions
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (an extra annotation on 'start' param)
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int", Arrays.asList(
- new Annotation(null, QueryParam.class.getName(), "start"),
- new Annotation(null, DefaultValue.class.getName(), "0")));
- final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(new Annotation(
- null, QueryParam.class.getName(), "size"), new Annotation(null, DefaultValue.class.getName(), "2")));
+ createAnnotation(QueryParam.class, "start"),
+ createAnnotation(DefaultValue.class, "0")));
+ final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(createAnnotation(
+ QueryParam.class, "size"), createAnnotation(DefaultValue.class, "2")));
final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(new Annotation(null, Context.class.getName())));
+ Arrays.asList(createAnnotation(Context.class, null)));
final IJaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List"))
+ .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List", javaProject))
.methodParameter(startParameter).methodParameter(sizeParameter).methodParameter(uriInfoParameter)
.build();
metamodel.add(jaxrsMethod);
@@ -1768,7 +1765,7 @@
// the method signature is changed
// pre-conditions
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1776,13 +1773,13 @@
// 'javax.ws.rs.Response')
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int",
- Arrays.asList(new Annotation(null, QueryParam.class.getName(), "start")));
- final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(new Annotation(
- null, QueryParam.class.getName(), "size"), new Annotation(null, DefaultValue.class.getName(), "2")));
+ Arrays.asList(createAnnotation(QueryParam.class, "start")));
+ final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(createAnnotation(
+ QueryParam.class, "size"), createAnnotation(DefaultValue.class, "2")));
final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(new Annotation(null, Context.class.getName())));
+ Arrays.asList(createAnnotation(Context.class, null)));
final IJaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType(Response.class.getName()))
+ .httpMethod(getAnnotation(method, GET.class)).returnType(getType(Response.class.getName(), javaProject))
.methodParameter(startParameter).methodParameter(sizeParameter).methodParameter(uriInfoParameter)
.build();
metamodel.add(jaxrsMethod);
@@ -1792,7 +1789,8 @@
// verifications
assertThat(impacts.size(), equalTo(1));
assertThat(impacts.get(0).getDeltaKind(), equalTo(CHANGED));
- assertThat(impacts.get(0).getFlags(), equalTo(F_METHOD_RETURN_TYPE));
+ // annotations were not provided but are retrieved...
+ assertThat(impacts.get(0).getFlags(), equalTo(F_METHOD_RETURN_TYPE + F_METHOD_PARAMETERS));
}
@Test
@@ -1806,16 +1804,16 @@
// the method signature is changed
// pre-conditions
// Parent JAX-RS Resource
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (@Context is not declared on 'uriInfo' param)
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int",
- Arrays.asList(new Annotation(null, QueryParam.class.getName(), "start")));
- final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(new Annotation(
- null, QueryParam.class.getName(), "length"), new Annotation(null, DefaultValue.class.getName(), "2")));
+ Arrays.asList(createAnnotation(QueryParam.class, "start")));
+ final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(createAnnotation(
+ QueryParam.class, "length"), createAnnotation(DefaultValue.class, "2")));
final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(), null);
final IJaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.methodParameter(startParameter).methodParameter(sizeParameter).methodParameter(uriInfoParameter)
@@ -1843,7 +1841,7 @@
@Test
public void shouldDoNothingWhenAddingBasicJavaMethod() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1859,7 +1857,7 @@
@Test
public void shouldDoNothingWhenChangingBasicJavaMethod() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
@@ -1875,7 +1873,7 @@
@Test
public void shouldDoNothingWhenRemovingBasicJavaMethod() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation pathAnnotation = getAnnotation(type, Path.class);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementChangedProcessorTestCase.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementChangedProcessorTestCase.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -54,6 +54,8 @@
import org.junit.Ignore;
import org.junit.Test;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.*;
+
public class JaxrsElementChangedProcessorTestCase extends AbstractCommonTestCase {
private JaxrsMetamodel metamodel;
@@ -68,7 +70,7 @@
}
private JaxrsResource createResource(String typeName) throws CoreException, JavaModelException {
- final IType resourceType = getType(typeName);
+ final IType resourceType = getType(typeName, javaProject);
final JaxrsResource customerResource = new JaxrsResource.Builder(resourceType, metamodel).pathTemplate(
getAnnotation(resourceType, Path.class)).build();
metamodel.add(customerResource);
@@ -95,7 +97,7 @@
}
private JaxrsHttpMethod createHttpMethod(Class<?> annotationClass) throws JavaModelException, CoreException {
- final IType type = getType(annotationClass.getName());
+ final IType type = getType(annotationClass.getName(), javaProject);
final Annotation httpAnnotation = getAnnotation(type, HttpMethod.class);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, httpAnnotation, metamodel);
metamodel.add(httpMethod);
@@ -109,31 +111,7 @@
return endpoint;
}
- private IType getType(String typeName) throws CoreException {
- return JdtUtils.resolveType(typeName, javaProject, progressMonitor);
- }
-
- private IMethod getMethod(IType parentType, String methodName) throws JavaModelException {
- return WorkbenchUtils.getMethod(parentType, methodName);
- }
-
- private Annotation getAnnotation(final IMember member, final Class<?> annotationClass) throws JavaModelException {
- if (annotationClass == null) {
- return null;
- }
- return JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, progressMonitor), annotationClass);
- }
-
- private Annotation getAnnotation(final IMember member, final Class<?> annotationClass, String... values)
- throws JavaModelException {
- Annotation annotation = JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, progressMonitor),
- annotationClass);
- Map<String, List<String>> elements = new HashMap<String, List<String>>();
- elements.put("value", Arrays.asList(values));
- annotation.update(new Annotation(annotation.getJavaAnnotation(), annotation.getName(), elements));
- return annotation;
- }
-
+
@Test
public void shouldConstructSimpleEndpoint() throws JavaModelException, CoreException {
// pre-conditions
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelFullBuildJobTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelFullBuildJobTestCase.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelFullBuildJobTestCase.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -11,8 +11,15 @@
package org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.emptyIterable;
+import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getMethod;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getType;
import static org.junit.Assert.assertThat;
import java.util.HashSet;
@@ -20,12 +27,13 @@
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
import org.jboss.tools.ws.jaxrs.core.builder.AbstractMetamodelBuilderTestCase;
-import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsEndpoint;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsHttpMethod;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsResource;
+import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsResourceMethod;
import org.junit.Assert;
import org.junit.Test;
@@ -45,76 +53,16 @@
}
}
- /** @Test
- * @Ignore
- * public void shouldAssertProviders() throws CoreException {
- * // FIXME : check no abstract class is registered
- * Assert.assertEquals(2,
- * metamodel.getProviders(EnumKind.CONSUMER).size());
- * for (IJaxrsProvider p :
- * metamodel.getProviders(EnumKind.CONSUMER)) {
- * Assert.assertNotNull("Missing provided type",
- * p.getProvidedKinds().containsKey(EnumKind.CONSUMER));
- * /
- * Assert.assertNotNull("Missing mime-type: " +
- * p.getJavaType().getFullyQualifiedName(),
- * p.getMediaTypes(EnumKind.CONSUMER));
- * /
- * Assert.assertFalse("Provider type shouldn't be abstract: " +
- * p.getJavaElement().getFullyQualifiedName(),
- * JdtUtils.isAbstractType(p.getJavaElement()));
- * }
- *
- * Assert.assertEquals(3,
- * metamodel.getProviders(EnumKind.PRODUCER).size());
- * for (IJaxrsProvider p :
- * metamodel.getProviders(EnumKind.PRODUCER)) {
- * Assert.assertNotNull("Missing provided type",
- * p.getProvidedKinds().containsKey(EnumKind.PRODUCER));
- * /
- * Assert.assertNotNull("Missing mime-type: " +
- * p.getJavaType().getFullyQualifiedName(),
- * p.getMediaTypes(EnumKind.PRODUCER));
- * /
- * Assert.assertFalse("Provider type shouldn't be abstract: " +
- * p.getJavaElement().getFullyQualifiedName(),
- * JdtUtils.isAbstractType(p.getJavaElement()));
- * }
- *
- * Assert.assertEquals(3,
- * metamodel.getProviders(EnumKind.EXCEPTION_MAPPER).size());
- * for (IJaxrsProvider p :
- * metamodel.getProviders(EnumKind.EXCEPTION_MAPPER)) {
- * Assert.assertNotNull("Missing provided type",
- * p.getProvidedKinds().containsKey(EnumKind.EXCEPTION_MAPPER));
- * Assert.assertNull("Unexpected mime-type: " +
- * p.getJavaElement().getFullyQualifiedName(),
- * p.getMediaTypeCapabilities(EnumKind.EXCEPTION_MAPPER));
- * Assert.assertFalse("Provider type shouldn't be abstract: " +
- * p.getJavaElement().getFullyQualifiedName(),
- * JdtUtils.isAbstractType(p.getJavaElement()));
- * }
- * } */
-
@Test
public void shouldAssertResourcesAndMethods() throws CoreException {
// for now, the result excludes the (binary) AsynchronousDispatcher, and
// hence, its (sub)resources
- // FIXME : should this include the subresource locator (method) ???
Assert.assertEquals(5, metamodel.getAllResources().size());
for (IJaxrsResource jaxrsResource : metamodel.getAllResources()) {
assertThat(jaxrsResource.getJavaElement(), notNullValue());
assertThat(jaxrsResource.getKind(), notNullValue());
assertThat(jaxrsResource.getAllMethods().size(), greaterThan(0));
}
- /*
- * for (IJaxrsResource resource : metamodel.getAllResources()) {
- * Assert.assertNotNull("JavaType not found",
- * resource.getJavaElement());
- * Assert.assertEquals("Wrong kind", EnumKind.ROOT_RESOURCE,
- * resource.getKind());
- * }
- */
}
@Test
@@ -132,24 +80,50 @@
Assert.assertFalse("No consumed media types", endpoint.getConsumedMediaTypes().isEmpty());
Assert.assertFalse("No produced media types", endpoint.getProducedMediaTypes().isEmpty());
}
- /*
- * List<Route> uriMappings = new
- * ArrayList<Route>(resolveUriMappings.keySet());
- * Collections.sort(uriMappings); Assert.assertEquals("Wrong result",
- * "/customers?start={int}&size={int}", uriMappings.get(0)
- * .getFullUriPathTemplate()); Assert.assertEquals("Wrong result",
- * "GET", uriMappings.get(0).getHTTPMethod().getHttpVerb());
- * Assert.assertEquals("Wrong result", "/products/{type}/{id}",
- * uriMappings.get(9).getFullUriPathTemplate());
- */
}
@Test
- public void shouldFullyAssertCustomerResource() throws CoreException {
- IJaxrsResource customerResource = (IJaxrsResource) metamodel.getElement(JdtUtils.resolveType(
- "org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject, new NullProgressMonitor()));
- Assert.assertNotNull("CustomerResource not found", customerResource);
+ public void shouldRetrieveCustomerResource() throws CoreException {
+ IType customerType = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
+ final IJaxrsResource customerResource = (IJaxrsResource) metamodel.getElement(customerType);
+ Assert.assertNotNull("CustomerResource not found", customerType);
Assert.assertEquals("Wrong number of resource resourceMethods", 6, customerResource.getResourceMethods().size());
}
+ @Test
+ public void shouldRetrieveCustomerResourceMethodProposals() throws CoreException {
+ IType customerType = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
+ IMethod customerMethod = getMethod(customerType, "getCustomers");
+ final IJaxrsResourceMethod customerResourceMethod = (IJaxrsResourceMethod) metamodel.getElement(customerMethod);
+ Assert.assertThat(customerResourceMethod, notNullValue());
+ Assert.assertThat(customerResourceMethod.getPathParamValueProposals().size(), equalTo(0));
+ }
+
+ @Test
+ public void shouldRetrieveCustomerSubresourceMethodProposals() throws CoreException {
+ IType customerType = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
+ IMethod customerMethod = getMethod(customerType, "getCustomer");
+ final IJaxrsResourceMethod customerResourceMethod = (IJaxrsResourceMethod) metamodel.getElement(customerMethod);
+ Assert.assertThat(customerResourceMethod, notNullValue());
+ Assert.assertThat(customerResourceMethod.getPathParamValueProposals(), containsInAnyOrder("id"));
+ }
+
+ @Test
+ public void shouldRetrieveBookResourceMethodProposals() throws CoreException {
+ IType customerType = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource", javaProject);
+ IMethod customerMethod = getMethod(customerType, "getAllProducts");
+ final IJaxrsResourceMethod customerResourceMethod = (IJaxrsResourceMethod) metamodel.getElement(customerMethod);
+ Assert.assertThat(customerResourceMethod, notNullValue());
+ Assert.assertThat(customerResourceMethod.getPathParamValueProposals().size(), equalTo(0));
+ }
+
+ @Test
+ public void shouldRetrieveBooksubresourceMethodProposals() throws CoreException {
+ IType customerType = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource", javaProject);
+ IMethod customerMethod = getMethod(customerType, "getProduct");
+ final IJaxrsResourceMethod customerResourceMethod = (IJaxrsResourceMethod) metamodel.getElement(customerMethod);
+ Assert.assertThat(customerResourceMethod, notNullValue());
+ Assert.assertThat(customerResourceMethod.getPathParamValueProposals(), containsInAnyOrder("id"));
+ }
+
}
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java 2011-11-22 12:30:55 UTC (rev 36530)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java 2011-11-22 13:26:39 UTC (rev 36531)
@@ -655,6 +655,7 @@
assertThat(javaAnnotation.getName(), equalTo(Path.class.getName()));
assertThat(javaAnnotation.getJavaAnnotationElements().size(), equalTo(1));
assertThat(javaAnnotation.getJavaAnnotationElements().get("value").get(0), equalTo("/customers"));
+ assertThat(javaAnnotation.getRegion(), notNullValue());
}
@Test
@@ -670,8 +671,9 @@
// verifications
assertThat(javaAnnotations.size(), equalTo(4));
for (Entry<String, Annotation> entry : javaAnnotations.entrySet()) {
+ assertThat(entry.getKey(), equalTo(entry.getValue().getName()));
assertThat(entry.getValue().getJavaAnnotation(), notNullValue());
- assertThat(entry.getKey(), equalTo(entry.getValue().getName()));
+ assertThat(entry.getValue().getRegion(), notNullValue());
}
}
14 years, 4 months
JBoss Tools SVN: r36530 - in trunk/vpe/tests/org.jboss.tools.vpe.html.test: resources/htmlTest/WebContent/pages and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2011-11-22 07:30:55 -0500 (Tue, 22 Nov 2011)
New Revision: 36530
Added:
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/img/jbide9975( pic ).png
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/CSSUrlQuotes.html
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/CSSUrlQuotes.html.xml
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/jbide9975( pic ).png
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.html.test/src/org/jboss/tools/vpe/html/test/HtmlComponentContentTest.java
Log:
https://issues.jboss.org/browse/JBIDE-9975 - JUnit with ContentTest for quotes in css url was added.
Added: trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/img/jbide9975( pic ).png
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/img/jbide9975( pic ).png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/CSSUrlQuotes.html
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/CSSUrlQuotes.html (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/CSSUrlQuotes.html 2011-11-22 12:30:55 UTC (rev 36530)
@@ -0,0 +1,24 @@
+<html>
+<body>
+<!-- Check that this url will be added to style and JBDS will put the full file path in it -->
+<!-- Checking escaping slashes in this case -->
+<div ID="id1" style="background: url(../../img/jbide9975\(\ pic\ \).png);">
+[GOOD] Checking escaping slashes in this case
+</div>
+<!-- Check that this url will be added to style and JBDS will put the full file path in it -->
+<!-- Checking putting url into quotes -->
+<div ID="id2" style="background: url('jbide9975( pic ).png');">
+[GOOD] Checking putting url into quotes
+</div>
+<!-- Check that this url will NOT be added to style and JBDS will ignore it also -->
+<!-- Checking bad escaping example -->
+<div ID="id3" style="background: url(../../img/jbide9975( pic\ \).png);">
+[BAD] Checking bad escaping example
+</div>
+<!-- Check that this url will NOT be added to style and JBDS will ignore it also -->
+<!-- Checking example with no escaping at all-->
+<div ID="id4" style="background: url(jbide9975( pic ).png);">
+[BAD] Checking example with no escaping at all
+</div>
+</body>
+</html>
Copied: trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/CSSUrlQuotes.html.xml (from rev 36432, trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/block/ul.html.xml)
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/CSSUrlQuotes.html.xml (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/CSSUrlQuotes.html.xml 2011-11-22 12:30:55 UTC (rev 36530)
@@ -0,0 +1,32 @@
+<tests>
+ <test id="id1">
+ <DIV
+ STYLE="/.*WebContent/img/jbide9975\(%20pic%20\).png.*\) repeat scroll 0% 0% transparent; -moz-user-modify: read-write;/">
+ <SPAN CLASS="vpe-text">
+ [GOOD] Checking escaping slashes in this case
+ </SPAN>
+ </DIV>
+ </test>
+ <test id="id2">
+ <DIV
+ STYLE="/.*WebContent/pages/jbide9975\(%201%20\)/jbide9975\(%20pic%20\).png.*\) repeat scroll 0% 0% transparent; -moz-user-modify: read-write;/">
+ <SPAN CLASS="vpe-text">
+ [GOOD] Checking putting url into quotes
+ </SPAN>
+ </DIV>
+ </test>
+ <test id="id3">
+ <DIV STYLE="-moz-user-modify: read-write;">
+ <SPAN CLASS="vpe-text">
+ [BAD] Checking bad escaping example
+ </SPAN>
+ </DIV>
+ </test>
+ <test id="id4">
+ <DIV STYLE="-moz-user-modify: read-write;">
+ <SPAN CLASS="vpe-text">
+ [BAD] Checking example with no escaping at all
+ </SPAN>
+ </DIV>
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/jbide9975( pic ).png
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide9975( 1 )/jbide9975( pic ).png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/vpe/tests/org.jboss.tools.vpe.html.test/src/org/jboss/tools/vpe/html/test/HtmlComponentContentTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.html.test/src/org/jboss/tools/vpe/html/test/HtmlComponentContentTest.java 2011-11-22 12:06:59 UTC (rev 36529)
+++ trunk/vpe/tests/org.jboss.tools.vpe.html.test/src/org/jboss/tools/vpe/html/test/HtmlComponentContentTest.java 2011-11-22 12:30:55 UTC (rev 36530)
@@ -481,6 +481,10 @@
performContentTest("components/other/xmp.xhtml"); //$NON-NLS-1$
}
+ public void testCssUrl() throws Throwable {
+ performContentTest("jbide9975( 1 )/CSSUrlQuotes.html"); //$NON-NLS-1$
+ }
+
protected String getTestProjectName() {
return HtmlAllTests.IMPORT_PROJECT_NAME;
}
14 years, 4 months
JBoss Tools SVN: r36529 - in trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test: matcher/workspace/file/xml and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-22 07:06:59 -0500 (Tue, 22 Nov 2011)
New Revision: 36529
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/XMLNode.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java
Log:
added method for splitting sml node path
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/XMLNode.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/XMLNode.java 2011-11-22 12:06:33 UTC (rev 36528)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/XMLNode.java 2011-11-22 12:06:59 UTC (rev 36529)
@@ -3,6 +3,8 @@
public class XMLNode {
+ public static final String NODES_SEPARATOR = "/";
+
private String path;
private String content;
@@ -13,10 +15,18 @@
this.content = content;
}
+ public String getNodeName(){
+ return getPathAsArray()[getPathAsArray().length - 1];
+ }
+
+ public String[] getPathAsArray(){
+ return path.split(NODES_SEPARATOR);
+ }
+
public String getPath() {
return path;
}
-
+
public void setPath(String path) {
this.path = path;
}
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java 2011-11-22 12:06:33 UTC (rev 36528)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java 2011-11-22 12:06:59 UTC (rev 36529)
@@ -44,23 +44,18 @@
}
private boolean containsNode(SWTBot bot, SWTBotTree tree, XMLNode node) {
- SWTBotTreeItem item = SWTEclipseExt.getTreeItemOnPathStartsWith(bot, tree, 0, getNodeName(node), getNodePath(node));
+ SWTBotTreeItem item = SWTEclipseExt.getTreeItemOnPathStartsWith(bot, tree, 0, node.getNodeName(), getNodePath(node));
return item.cell(1).contains(node.getContent());
}
private String[] getNodePath(XMLNode node) {
- String[] path = node.getPath().split("/");
+ String[] path = node.getPathAsArray();
if (path.length <= 1){
return new String[0];
}
return Arrays.copyOfRange(path, 0, path.length - 1);
}
- private String getNodeName(XMLNode node) {
- String[] path = node.getPath().split("/");
- return path[path.length - 1];
- }
-
@Override
public void describeTo(Description description) {
description.appendText("file containing nodes: " + nodes);
14 years, 4 months
JBoss Tools SVN: r36528 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-22 07:06:33 -0500 (Tue, 22 Nov 2011)
New Revision: 36528
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ProjectFacetsMatcher.java
Log:
small refactoring
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ProjectFacetsMatcher.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ProjectFacetsMatcher.java 2011-11-22 11:32:37 UTC (rev 36527)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ProjectFacetsMatcher.java 2011-11-22 12:06:33 UTC (rev 36528)
@@ -28,7 +28,9 @@
@Override
public boolean matchesSafely(String project) {
showPropertyDialog(project);
- return checkFacets();
+ boolean result = checkFacets();
+ performInnerTask(new ProjectPropertyDialogCloseTask());
+ return result;
}
private void showPropertyDialog(String project) {
@@ -45,7 +47,6 @@
}
performInnerTask(task);
- performInnerTask(new ProjectPropertyDialogCloseTask());
return task.allChecked;
}
14 years, 4 months
JBoss Tools SVN: r36527 - in trunk/ws: plugins/org.jboss.tools.ws.jaxrs.ui/META-INF and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2011-11-22 06:32:37 -0500 (Tue, 22 Nov 2011)
New Revision: 36527
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/META-INF/MANIFEST.MF
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/META-INF/MANIFEST.MF
Log:
fixing the MANIFEST version to match with the maven/tycho ones
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF 2011-11-22 10:54:37 UTC (rev 36526)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF 2011-11-22 11:32:37 UTC (rev 36527)
@@ -4,7 +4,7 @@
Bundle-Name: %PLUGIN_NAME
Bundle-Vendor: %PLUGIN_PROVIDER
Bundle-SymbolicName: org.jboss.tools.ws.jaxrs.core;singleton:=true
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.2.2.qualifier
Bundle-Activator: org.jboss.tools.ws.jaxrs.core.JBossJaxrsCorePlugin
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0";visibility:=reexport,
org.eclipse.core.resources;bundle-version="3.7.100";visibility:=reexport,
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/META-INF/MANIFEST.MF 2011-11-22 10:54:37 UTC (rev 36526)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/META-INF/MANIFEST.MF 2011-11-22 11:32:37 UTC (rev 36527)
@@ -4,7 +4,7 @@
Bundle-Name: %PLUGIN_NAME
Bundle-Vendor: %PLUGIN_PROVIDER
Bundle-SymbolicName: org.jboss.tools.ws.jaxrs.ui;singleton:=true
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.2.2.qualifier
Bundle-Activator: org.jboss.tools.ws.jaxrs.ui.JBossJaxrsUIPlugin
Require-Bundle: org.eclipse.ui;bundle-version="3.6.0",
org.eclipse.core.runtime;visibility:=reexport,
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/META-INF/MANIFEST.MF 2011-11-22 10:54:37 UTC (rev 36526)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/META-INF/MANIFEST.MF 2011-11-22 11:32:37 UTC (rev 36527)
@@ -4,7 +4,7 @@
Bundle-Name: %PLUGIN_NAME
Bundle-Vendor: %PLUGIN_PROVIDER
Bundle-SymbolicName: org.jboss.tools.ws.jaxrs.core.test;singleton:=true
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.2.2.qualifier
Bundle-Activator: org.jboss.tools.ws.jaxrs.core.JBossJaxrsCoreTestsPlugin
Require-Bundle: org.jboss.tools.ws.jaxrs.core;bundle-version="1.2.0",
org.eclipse.ui.ide;bundle-version="3.7.0";visibility:=reexport,
14 years, 4 months
JBoss Tools SVN: r36526 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2011-11-22 05:54:37 -0500 (Tue, 22 Nov 2011)
New Revision: 36526
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-9975 - fixed NPE when css url equals "\"
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2011-11-22 10:30:28 UTC (rev 36525)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2011-11-22 10:54:37 UTC (rev 36526)
@@ -800,10 +800,9 @@
if (uri == null || !uri.isAbsolute()) {
String decodedUrl = decodeUrl(resolvedUrl);
Path path = new Path(decodedUrl);
- if (decodedUrl.startsWith("/") //$NON-NLS-1$
+ if (decodedUrl.startsWith("/") && (null != path.segment(0))//$NON-NLS-1$
&& path.segment(0).equals(baseFile.getProject().getName())) {
- decodedUrl = "/" //$NON-NLS-1$
- + path.removeFirstSegments(1).toPortableString();
+ decodedUrl = "/" + path.removeFirstSegments(1).toPortableString(); //$NON-NLS-1$
}
IFile file = FileUtil.getFile(decodedUrl, baseFile);
if (file != null && file.getLocation() != null) {
14 years, 4 months
JBoss Tools SVN: r36525 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-22 05:30:28 -0500 (Tue, 22 Nov 2011)
New Revision: 36525
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogOpenTask.java
Log:
changed the way of opening view
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogOpenTask.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogOpenTask.java 2011-11-22 10:14:19 UTC (rev 36524)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogOpenTask.java 2011-11-22 10:30:28 UTC (rev 36525)
@@ -14,9 +14,8 @@
@Override
public void perform() {
- SWTBotFactory.getOpen().viewOpen(ActionItem.View.JavaPackageExplorer.LABEL);
-
PackageExplorer projectExplorer = SWTBotFactory.getPackageexplorer();
+ projectExplorer.show();
projectExplorer.selectProject(project);
ContextMenuHelper.clickContextMenu(projectExplorer.bot().tree(),
14 years, 4 months
JBoss Tools SVN: r36524 - in trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test: entity and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-22 05:14:19 -0500 (Tue, 22 Nov 2011)
New Revision: 36524
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/EntityFactory.java
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/ExistingFileMatcher.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java
Log:
Created entity factory, changed ExistingFileMatcher to use WorkspaceFile and added splitting functionality to WorkspaceFile
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java 2011-11-22 10:07:39 UTC (rev 36523)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java 2011-11-22 10:14:19 UTC (rev 36524)
@@ -1,11 +1,11 @@
package org.jboss.tools.portlet.ui.bot.test.create;
import static org.jboss.tools.portlet.ui.bot.test.create.CreateJavaPortletProject.PROJECT_NAME;
+import static org.jboss.tools.portlet.ui.bot.test.entity.EntityFactory.file;
import static org.jboss.tools.portlet.ui.bot.test.matcher.problems.ProblemViewMatchersFactory.isNumberOfErrors;
import static org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.containsNodes;
-import static org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.existsInProject;
+import static org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.exists;
-import org.jboss.tools.portlet.ui.bot.test.entity.WorkspaceFile;
import org.jboss.tools.portlet.ui.bot.test.entity.XMLNode;
import org.jboss.tools.portlet.ui.bot.test.task.SWTTask;
import org.jboss.tools.portlet.ui.bot.test.task.wizard.web.jboss.PortletCreationTask;
@@ -35,10 +35,10 @@
doPerform(getCreatePortletTask());
doAssertThat(0, isNumberOfErrors());
- doAssertThat(CLASS_FILE, existsInProject(PROJECT_NAME));
- doAssertThat("WebContent/WEB-INF/default-object.xml", existsInProject(PROJECT_NAME));
- doAssertThat("WebContent/WEB-INF/portlet-instances.xml", existsInProject(PROJECT_NAME));
- doAssertThat(new WorkspaceFile(PROJECT_NAME, "WebContent/WEB-INF/portlet.xml"), containsNodes(new XMLNode("portlet-app/portlet/portlet-class", FULL_CLASS_NAME)));
+ doAssertThat(file(PROJECT_NAME, CLASS_FILE), exists());
+ doAssertThat(file(PROJECT_NAME, "WebContent/WEB-INF/default-object.xml"), exists());
+ doAssertThat(file(PROJECT_NAME, "WebContent/WEB-INF/portlet-instances.xml"), exists());
+ doAssertThat(file(PROJECT_NAME, "WebContent/WEB-INF/portlet.xml"), containsNodes(new XMLNode("portlet-app/portlet/portlet-class", FULL_CLASS_NAME)));
System.out.println("");
}
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java 2011-11-22 10:07:39 UTC (rev 36523)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java 2011-11-22 10:14:19 UTC (rev 36524)
@@ -1,7 +1,8 @@
package org.jboss.tools.portlet.ui.bot.test.create;
+import static org.jboss.tools.portlet.ui.bot.test.entity.EntityFactory.file;
import static org.jboss.tools.portlet.ui.bot.test.matcher.problems.ProblemViewMatchersFactory.isNumberOfErrors;
-import static org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.existsInProject;
+import static org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.exists;
import static org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.hasFacets;
import static org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.isExistingProject;
@@ -40,8 +41,8 @@
doAssertThat(0, isNumberOfErrors());
doAssertThat(PROJECT_NAME, isExistingProject());
- doAssertThat("WebContent/WEB-INF/portlet.xml", existsInProject(PROJECT_NAME));
- doAssertThat("JBoss Portlet Libraries", existsInProject(PROJECT_NAME));
+ doAssertThat(file(PROJECT_NAME, "WebContent/WEB-INF/portlet.xml"), exists());
+ doAssertThat(file(PROJECT_NAME, "JBoss Portlet Libraries"), exists());
doAssertThat(PROJECT_NAME, hasFacets(new FacetDefinition(FACET_NAME, FACET_CATEGORY)));
}
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/EntityFactory.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/EntityFactory.java (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/EntityFactory.java 2011-11-22 10:14:19 UTC (rev 36524)
@@ -0,0 +1,18 @@
+package org.jboss.tools.portlet.ui.bot.test.entity;
+
+/**
+ * Convenient factory method for creating entity objects.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class EntityFactory {
+
+ private EntityFactory() {
+ // static factory methods
+ }
+
+ public static WorkspaceFile file(String project, String filePath){
+ return new WorkspaceFile(project, filePath);
+ }
+}
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java 2011-11-22 10:07:39 UTC (rev 36523)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java 2011-11-22 10:14:19 UTC (rev 36524)
@@ -2,16 +2,26 @@
public class WorkspaceFile {
+ public static final String FILE_SEPARATOR = "/";
+
private String project;
-
- private String file;
- public WorkspaceFile(String project, String file) {
+ private String filePath;
+
+ public WorkspaceFile(String project, String filePath) {
super();
this.project = project;
- this.file = file;
+ this.filePath = filePath;
}
+ public String getFileName(){
+ return getFilePathAsArray()[getFilePathAsArray().length - 1];
+ }
+
+ public String[] getFilePathAsArray(){
+ return getFilePath().split(FILE_SEPARATOR);
+ }
+
public String getProject() {
return project;
}
@@ -20,16 +30,16 @@
this.project = project;
}
- public String getFile() {
- return file;
+ public String getFilePath() {
+ return filePath;
}
- public void setFile(String file) {
- this.file = file;
+ public void setFilePath(String file) {
+ this.filePath = file;
}
-
+
@Override
public String toString() {
- return "Workspace file: " + getProject() + "/" + getFile();
+ return "Workspace file: " + getProject() + FILE_SEPARATOR + getFilePath();
}
}
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java 2011-11-22 10:07:39 UTC (rev 36523)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java 2011-11-22 10:14:19 UTC (rev 36524)
@@ -25,8 +25,8 @@
return new ExistingProjectMatcher();
}
- public static SWTMatcher<String> existsInProject(String project){
- return new ExistingFileMatcher(project);
+ public static SWTMatcher<WorkspaceFile> exists(){
+ return new ExistingFileMatcher();
}
public static SWTMatcher<String> hasFacets(FacetDefinition... facets){
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/ExistingFileMatcher.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/ExistingFileMatcher.java 2011-11-22 10:07:39 UTC (rev 36523)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/ExistingFileMatcher.java 2011-11-22 10:14:19 UTC (rev 36524)
@@ -1,6 +1,7 @@
package org.jboss.tools.portlet.ui.bot.test.matcher.workspace.file;
import org.hamcrest.Description;
+import org.jboss.tools.portlet.ui.bot.test.entity.WorkspaceFile;
import org.jboss.tools.portlet.ui.bot.test.matcher.AbstractSWTMatcher;
import org.jboss.tools.ui.bot.ext.SWTBotFactory;
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
@@ -11,20 +12,12 @@
* @author Lucia Jelinkova
*
*/
-public class ExistingFileMatcher extends AbstractSWTMatcher<String> {
+public class ExistingFileMatcher extends AbstractSWTMatcher<WorkspaceFile> {
- private static final String FILE_SEPARATOR = "/";
-
- private String project;
-
- public ExistingFileMatcher(String project) {
- this.project = project;
- }
-
@Override
- public boolean matchesSafely(String path) {
+ public boolean matchesSafely(WorkspaceFile file) {
SWTBotFactory.getOpen().perspective(ActionItem.Perspective.JAVA.LABEL);
- return SWTBotFactory.getPackageexplorer().isFilePresent(project, path.split(FILE_SEPARATOR));
+ return SWTBotFactory.getPackageexplorer().isFilePresent(file.getProject(), file.getFilePathAsArray());
}
@Override
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java 2011-11-22 10:07:39 UTC (rev 36523)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java 2011-11-22 10:14:19 UTC (rev 36524)
@@ -31,9 +31,8 @@
@Override
public boolean matchesSafely(WorkspaceFile file) {
- String[] filePath = file.getFile().split("/");
- SWTBotFactory.getPackageexplorer().openFile(file.getProject(), filePath);
- SWTBotEditorExt editor = SWTBotFactory.getBot().swtBotEditorExtByTitle(filePath[filePath.length - 1]);
+ SWTBotFactory.getPackageexplorer().openFile(file.getProject(), file.getFilePathAsArray());
+ SWTBotEditorExt editor = SWTBotFactory.getBot().swtBotEditorExtByTitle(file.getFileName());
SWTBotTree tree = editor.bot().tree();
for (XMLNode node : nodes){
14 years, 4 months
JBoss Tools SVN: r36522 - in trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test: entity and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-22 04:53:40 -0500 (Tue, 22 Nov 2011)
New Revision: 36522
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java
Log:
changed generics and constructor of Matcher
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java 2011-11-22 09:39:01 UTC (rev 36521)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java 2011-11-22 09:53:40 UTC (rev 36522)
@@ -2,9 +2,10 @@
import static org.jboss.tools.portlet.ui.bot.test.create.CreateJavaPortletProject.PROJECT_NAME;
import static org.jboss.tools.portlet.ui.bot.test.matcher.problems.ProblemViewMatchersFactory.isNumberOfErrors;
-import static org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.areInFile;
+import static org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.containsNodes;
import static org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.existsInProject;
+import org.jboss.tools.portlet.ui.bot.test.entity.WorkspaceFile;
import org.jboss.tools.portlet.ui.bot.test.entity.XMLNode;
import org.jboss.tools.portlet.ui.bot.test.task.SWTTask;
import org.jboss.tools.portlet.ui.bot.test.task.wizard.web.jboss.PortletCreationTask;
@@ -37,7 +38,7 @@
doAssertThat(CLASS_FILE, existsInProject(PROJECT_NAME));
doAssertThat("WebContent/WEB-INF/default-object.xml", existsInProject(PROJECT_NAME));
doAssertThat("WebContent/WEB-INF/portlet-instances.xml", existsInProject(PROJECT_NAME));
- doAssertThat(nodes(new XMLNode("portlet-app/portlet/portlet-class", FULL_CLASS_NAME)), areInFile(PROJECT_NAME, "WebContent/WEB-INF/portlet.xml"));
+ doAssertThat(new WorkspaceFile(PROJECT_NAME, "WebContent/WEB-INF/portlet.xml"), containsNodes(new XMLNode("portlet-app/portlet/portlet-class", FULL_CLASS_NAME)));
System.out.println("");
}
@@ -48,8 +49,4 @@
task.setClassName(CLASS_NAME);
return task;
}
-
- private XMLNode[] nodes(XMLNode... nodes){
- return nodes;
- }
}
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java 2011-11-22 09:53:40 UTC (rev 36522)
@@ -0,0 +1,35 @@
+package org.jboss.tools.portlet.ui.bot.test.entity;
+
+public class WorkspaceFile {
+
+ private String project;
+
+ private String file;
+
+ public WorkspaceFile(String project, String file) {
+ super();
+ this.project = project;
+ this.file = file;
+ }
+
+ public String getProject() {
+ return project;
+ }
+
+ public void setProject(String project) {
+ this.project = project;
+ }
+
+ public String getFile() {
+ return file;
+ }
+
+ public void setFile(String file) {
+ this.file = file;
+ }
+
+ @Override
+ public String toString() {
+ return "Workspace file: " + getProject() + "/" + getFile();
+ }
+}
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java 2011-11-22 09:39:01 UTC (rev 36521)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java 2011-11-22 09:53:40 UTC (rev 36522)
@@ -1,6 +1,9 @@
package org.jboss.tools.portlet.ui.bot.test.matcher.workspace;
+import java.util.Arrays;
+
import org.jboss.tools.portlet.ui.bot.test.entity.FacetDefinition;
+import org.jboss.tools.portlet.ui.bot.test.entity.WorkspaceFile;
import org.jboss.tools.portlet.ui.bot.test.entity.XMLNode;
import org.jboss.tools.portlet.ui.bot.test.matcher.SWTMatcher;
import org.jboss.tools.portlet.ui.bot.test.matcher.workspace.file.ExistingFileMatcher;
@@ -30,7 +33,7 @@
return new ProjectFacetsMatcher(facets);
}
- public static SWTMatcher<XMLNode[]> areInFile(String project, String file){
- return new XMLFileNodeContentMatcher(project, file);
+ public static SWTMatcher<WorkspaceFile> containsNodes(XMLNode... nodes){
+ return new XMLFileNodeContentMatcher(Arrays.asList(nodes));
}
}
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java 2011-11-22 09:39:01 UTC (rev 36521)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java 2011-11-22 09:53:40 UTC (rev 36522)
@@ -1,11 +1,13 @@
package org.jboss.tools.portlet.ui.bot.test.matcher.workspace.file.xml;
import java.util.Arrays;
+import java.util.List;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.hamcrest.Description;
+import org.jboss.tools.portlet.ui.bot.test.entity.WorkspaceFile;
import org.jboss.tools.portlet.ui.bot.test.entity.XMLNode;
import org.jboss.tools.portlet.ui.bot.test.matcher.AbstractSWTMatcher;
import org.jboss.tools.ui.bot.ext.SWTBotFactory;
@@ -18,22 +20,19 @@
* @author Lucia Jelinkova
*
*/
-public class XMLFileNodeContentMatcher extends AbstractSWTMatcher<XMLNode[]> {
+public class XMLFileNodeContentMatcher extends AbstractSWTMatcher<WorkspaceFile> {
- private String project;
+ private List<XMLNode> nodes;
- private String file;
-
- public XMLFileNodeContentMatcher(String project, String file) {
+ public XMLFileNodeContentMatcher(List<XMLNode> nodes) {
super();
- this.project = project;
- this.file = file;
+ this.nodes = nodes;
}
@Override
- public boolean matchesSafely(XMLNode[] nodes) {
- String[] filePath = file.split("/");
- SWTBotFactory.getPackageexplorer().openFile(project, filePath);
+ public boolean matchesSafely(WorkspaceFile file) {
+ String[] filePath = file.getFile().split("/");
+ SWTBotFactory.getPackageexplorer().openFile(file.getProject(), filePath);
SWTBotEditorExt editor = SWTBotFactory.getBot().swtBotEditorExtByTitle(filePath[filePath.length - 1]);
SWTBotTree tree = editor.bot().tree();
@@ -46,10 +45,6 @@
}
private boolean containsNode(SWTBot bot, SWTBotTree tree, XMLNode node) {
- for (String s : getNodePath(node)){
- System.out.println("Path element: " + s);
- }
- System.out.println("Name: " + getNodeName(node));
SWTBotTreeItem item = SWTEclipseExt.getTreeItemOnPathStartsWith(bot, tree, 0, getNodeName(node), getNodePath(node));
return item.cell(1).contains(node.getContent());
}
@@ -69,7 +64,7 @@
@Override
public void describeTo(Description description) {
- description.appendText("file " + project + "/" + file + " contains the node(s)");
+ description.appendText("file containing nodes: " + nodes);
}
}
14 years, 4 months