Bugs: #273698, #275565, #277016, #277227. Code cleanup/refactoring.
diff --git a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java
index c1eba8f..4b36312 100644
--- a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java
+++ b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java
@@ -17,6 +17,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBufferManager;
@@ -72,6 +73,10 @@
import org.eclipse.text.edits.TextEdit;
import org.eclipse.text.edits.TextEditGroup;
+import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
+import com.sun.mirror.declaration.AnnotationValue;
+
/**
* Utility class for adding, removing and updating annotations and member value pairs.
* <p>
@@ -1144,4 +1149,26 @@
image, proposal, null, null);
}
+ /**
+ * Searches the passed <code>AnnotationMirror</code> for an <code>AnnotationTypeElementDeclaration</code>
+ * that matches the elementName. If a match is made the string representation of the
+ * <code>AnnotationValue</code> value object is returned. If no match is made a zero length String is
+ * returned.
+ * @param mirror
+ * @param elementName
+ * @return
+ */
+ public static String findAnnotationValue(AnnotationMirror mirror, String elementName) {
+ Map<AnnotationTypeElementDeclaration, AnnotationValue> values = mirror.getElementValues();
+ Set<Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue>> entrySet = values.entrySet();
+ for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> entry : entrySet) {
+ AnnotationTypeElementDeclaration element = entry.getKey();
+ if (element.getSimpleName().equals(elementName)) {
+ AnnotationValue annotationValue = entry.getValue();
+ return annotationValue.getValue().toString();
+ }
+ }
+ return "";
+ }
+
}
diff --git a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/SpringUtils.java b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/SpringUtils.java
index f8f2727..5fcb4f5 100644
--- a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/SpringUtils.java
+++ b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/SpringUtils.java
@@ -16,7 +16,6 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -292,19 +291,30 @@
}
private static String convertPortTypeName(String portTypeName) {
- String[] segments = portTypeName.split("[\\-\\.\\:\\_\\u00b7\\u0387\\u06dd\\u06de]");
- StringBuilder stringBuilder = new StringBuilder();
- for (String segment : segments) {
- if (segment.length() == 0) {
- continue;
- }
- char firstCharacter = segment.charAt(0);
- if (!Character.isDigit(firstCharacter) && !Character.isUpperCase(firstCharacter)) {
- segment = segment.substring(0, 1).toUpperCase(Locale.getDefault()) + segment.substring(1);
- }
- stringBuilder.append(segment);
- }
- return stringBuilder.toString();
+ String[] segments = portTypeName.split("[\\-\\.\\:\\_\\u00b7\\u0387\\u06dd\\u06de]");
+
+ StringBuilder stringBuilder = new StringBuilder();
+ for (String segment : segments) {
+ if (segment.length() == 0) {
+ continue;
+ }
+ char firstCharacter = segment.charAt(0);
+ if (!Character.isDigit(firstCharacter) && Character.isLowerCase(firstCharacter)) {
+ segment = segment.substring(0, 1).toUpperCase() + segment.substring(1);
+ }
+
+ for (int i = 1; i < segment.length(); i++) {
+ char currentChar = segment.charAt(i);
+ char precedingChar = segment.charAt(i - 1);
+ if (Character.isLetter(currentChar) && Character.isDigit(precedingChar)
+ && Character.isLowerCase(currentChar)) {
+ segment = segment.substring(0, i) + segment.substring(i, i + 1).toUpperCase()
+ + segment.substring(i + 1, segment.length());
+ }
+ }
+ stringBuilder.append(segment);
+ }
+ return stringBuilder.toString();
}
public static void createJAXWSEndpoint(CXFDataModel model) throws IOException {
@@ -372,25 +382,16 @@
}
private static String getJAXWSEndpointID(CXFDataModel model) {
- String id = ""; //$NON-NLS-1$
- String implementor = model.getFullyQualifiedJavaClassName();
+ String implementor = model.getFullyQualifiedJavaClassName();
if (implementor.indexOf(".") != -1) { //$NON-NLS-1$
- if (implementor.indexOf("Impl") != -1) { //$NON-NLS-1$
- id = implementor.substring(implementor.lastIndexOf(".") + 1, //$NON-NLS-1$
- implementor.lastIndexOf("Impl")).toLowerCase(Locale.getDefault()); //$NON-NLS-1$
- } else {
- id = implementor.substring(implementor.lastIndexOf(".") + 1) //$NON-NLS-1$
- .toLowerCase(Locale.getDefault());
- }
- } else {
- if (implementor.indexOf("Impl") != -1) { //$NON-NLS-1$
- id = implementor.substring(0, implementor.lastIndexOf("Impl")).toLowerCase( //$NON-NLS-1$
- Locale.getDefault());
- } else {
- id = implementor.toLowerCase(Locale.getDefault());
- }
+ implementor = implementor.substring(implementor.lastIndexOf(".") + 1, implementor.length());
}
- return id;
+ if (!implementor.startsWith("Impl") && implementor.indexOf("Impl") != -1) {
+ implementor = implementor.substring(0, implementor.indexOf("Impl")).toLowerCase(); //$NON-NLS-1$;
+ } else {
+ implementor = implementor.toLowerCase();
+ }
+ return implementor;
}
private static void writeConfig(Document document, IFile springConfigFile) throws IOException {
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/JAXWSAnnotateJavaWidget.java b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/JAXWSAnnotateJavaWidget.java
index 7cca867..b7550ba 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/JAXWSAnnotateJavaWidget.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/JAXWSAnnotateJavaWidget.java
@@ -240,8 +240,7 @@
for (int i = 0; i < parameterTypes.length; i++) {
regex.append("\\s*?");
- String typeName = Signature.toString(Signature.getTypeErasure(
- parameterTypes[i]));
+ String typeName = Signature.toString(parameterTypes[i]);
regex.append(typeName);
regex.append("\\s*?");
regex.append(paramterNames[i]);
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/plugin.properties b/bundles/org.eclipse.jst.ws.jaxws.core/plugin.properties
index 1e7e460..8ea6a5e 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/plugin.properties
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/plugin.properties
@@ -25,4 +25,6 @@
SOAPBINDING_METHOD_STYLE_DOCUMENT_RULE=@SOAPBinding annotation may be placed on a method if and only if the SOAPBinding.style is DOCUMENT.
WEBMETHOD_EXCLUDE_SPECIFIED_RULE=@WebMethod exclude attribute is not allowed in SEI's. If specified in an implementation class, then other attributes in the @WebMethod annotation are not allowed
SOAPBINDING_NO_PARAMETERSTYLE_WHEN_ENCODED_RULE=A method that has a SOAPBinding.use of ENCODED cannot have a SOAPBinding.parameterStyle present.
+SOAPBINDING_DOCUMENT_BARE_RULES=Document Bare operations are subject to a number of restrictions. Combinations of @Oneway. Not @Oneway. Void Return. Non-Void Return. @WebParam Modes IN, OUT, INOUT. Header parameters.
+HOLDER_TYPES_PARAMETERS_RULE=Parameters that conform to the definition of Holder Types must be annotated with @WebParam.Mode.OUT or @WebParam.Mode.INOUT.
JAXWS_CATEGORY_NAME=JAX-WS
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/plugin.xml b/bundles/org.eclipse.jst.ws.jaxws.core/plugin.xml
index e756a68..aefa2be 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/plugin.xml
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/plugin.xml
@@ -180,6 +180,13 @@
<extension point="org.eclipse.jst.ws.annotations.core.annotationProcessor">
<processor
annotation="javax.jws.WebService"
+ class="org.eclipse.jst.ws.internal.jaxws.core.annotations.validation.HolderTypeParametersRule">
+ <description>
+ %HOLDER_TYPES_PARAMETERS_RULE
+ </description>
+ </processor>
+ <processor
+ annotation="javax.jws.WebService"
class="org.eclipse.jst.ws.internal.jaxws.core.annotations.validation.WebServiceDefaultPublicConstructorRule">
<description>
%WEBSERVICE_CLASS_DEFAULT_PUBLIC_CONSTRUCTOR_RULE
@@ -243,7 +250,7 @@
</processor>
<processor
annotation="javax.jws.Oneway"
- class="org.eclipse.jst.ws.internal.jaxws.core.annotations.validation.OnewayNoReturnValueRule">
+ class="org.eclipse.jst.ws.internal.jaxws.core.annotations.validation.OnewayRules">
<description>
%ONEWAY_NO_RETURN_VALUE
</description>
@@ -262,6 +269,13 @@
%SOAPBINDING_NO_PARAMETERSTYLE_WHEN_ENCODED_RULE
</description>
</processor>
+ <processor
+ annotation="javax.jws.soap.SOAPBinding"
+ class="org.eclipse.jst.ws.internal.jaxws.core.annotations.validation.SOAPBindingDocumentBareRules">
+ <description>
+ %SOAPBINDING_DOCUMENT_BARE_RULES
+ </description>
+ </processor>
</extension>
</plugin>
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java
index 7eca759..c49eeed 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java
@@ -26,7 +26,21 @@
public static String TYPE_WITH_NAME_ALREADY_EXISTS;
public static String ONEWAY_NO_RETURN_VALUE_ERROR_MESSAGE;
-
+ public static String ONEWAY_NO_CHECKED_EXCEPTIONS_ERROR_MESSAGE;
+ public static String ONEWAY_NO_OUT_PARAMETERS;
+ public static String ONEWAY_NO_INOUT_PARAMETERS;
+
+ public static String HOLDER_TYPE_PARAMETER_ERROR_MESSAGE;
+ public static String WEBPARAM_MODE_OUT_INOUT_HOLDER_TYPE_ERROR_MESSAGE;
+
+// public static String DOC_BARE_ONE_NON_HEADER_IN_PARAMETER_ERROR_MESSAGE;
+ public static String DOC_BARE_NON_VOID_RETURN_NO_INOUT_OUT_PARAMETER;
+ public static String DOC_BARE_ONLY_ONE_NON_HEADER_IN_PARAMETER_ERROR_MESSAGE;
+ public static String DOC_BARE_VOID_RETURN_ONE_IN_PARAMETER;
+ public static String DOC_BARE_VOID_RETURN_ONE_OUT_PARAMETER;
+
+ public static String WEBPARAM_NAME_REQUIRED_WHEN_DOC_BARE_OUT_INOUT;
+
public static String WEBMETHOD_ONLY_SUPPORTED_ON_CLASSES_WITH_WEBSERVICE_MESSAGE;
public static String WEBMETHOD_ONLY_ON_PUBLIC_METHODS_MESSAGE;
public static String WEBMETHOD_NO_FINAL_MODIFIER_ALLOWED_MESSAGE;
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.properties b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.properties
index 35c220b..088adec 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.properties
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.properties
@@ -28,5 +28,16 @@
WEBSERVICE_ENPOINTINTERFACE_NO_WEBMETHOS_ERROR_MESSAGE=@WebService annotation contains an endpointInterface attribute. No methods annotated with @WebMethod allowed on implementation class in this instance
WEBSERVICE_WEBSERVICEPROVIDER_COMBINATION_ERROR_MESSAGE=@WebService and @WebServiceProvider annotations cannot both be present on the same class
ONEWAY_NO_RETURN_VALUE_ERROR_MESSAGE=@Oneway methods must not return a value
+ONEWAY_NO_CHECKED_EXCEPTIONS_ERROR_MESSAGE=@Oneway methods must not declare any checked exceptions
+ONEWAY_NO_OUT_PARAMETERS=@Oneway methods cannot have any @WebParam.Mode.OUT parameters
+ONEWAY_NO_INOUT_PARAMETERS=@Oneway methods cannot have any @WebParam.Mode.INOUT parameters
+HOLDER_TYPE_PARAMETER_ERROR_MESSAGE=Parameters that conform to the definition of Holder Types must be annotated with @WebParam.Mode.OUT or @WebParam.Mode.INOUT
+WEBPARAM_MODE_OUT_INOUT_HOLDER_TYPE_ERROR_MESSAGE=The @WebParam.Mode.OUT and @WebParam.Mode.INOUT modes may only be specified for javax.xml.ws.Holder<T> parameters
SOAPBINDING_ON_METHOD_STYLE_DOCUMENT_ONLY_MESSAGE=The @SOAPBinding annotation may be placed on a method if and only if the SOAPBinding.style is DOCUMENT
-SOAPBINDING_NO_PARAMETERSTYLE_WHEN_ENCODED_MESSAGE=A method that has a SOAPBinding.use of ENCODED cannot have a SOAPBinding.parameterStyle present
\ No newline at end of file
+SOAPBINDING_NO_PARAMETERSTYLE_WHEN_ENCODED_MESSAGE=A method that has a SOAPBinding.use of ENCODED cannot have a SOAPBinding.parameterStyle present
+#DOC_BARE_ONE_NON_HEADER_IN_PARAMETER_ERROR_MESSAGE=Document literal bare methods must have one non-header IN parameter
+DOC_BARE_ONLY_ONE_NON_HEADER_IN_PARAMETER_ERROR_MESSAGE=Document literal bare methods may have only one non-header IN parameter
+DOC_BARE_NON_VOID_RETURN_NO_INOUT_OUT_PARAMETER=Document literal bare methods that declare a non-void return value may not have any OUT or INOUT parameters
+DOC_BARE_VOID_RETURN_ONE_IN_PARAMETER=Document literal bare methods that declare a void return value may have only one IN/INOUT parameter
+DOC_BARE_VOID_RETURN_ONE_OUT_PARAMETER=Document literal bare methods that declare a void return value may have only one OUT/INOUT parameter
+WEBPARAM_NAME_REQUIRED_WHEN_DOC_BARE_OUT_INOUT=The @WebParam name attribute is required when the operation is Document Bare and the mode is OUT or INOUT
\ No newline at end of file
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/HolderTypeParametersRule.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/HolderTypeParametersRule.java
new file mode 100644
index 0000000..eea5dd8
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/HolderTypeParametersRule.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.jaxws.core.annotations.validation;
+
+import java.util.Collection;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+
+import org.eclipse.jst.ws.annotations.core.processor.AbstractAnnotationProcessor;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
+
+import com.sun.mirror.apt.Messager;
+import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.AnnotationTypeDeclaration;
+import com.sun.mirror.declaration.ClassDeclaration;
+import com.sun.mirror.declaration.Declaration;
+import com.sun.mirror.declaration.InterfaceDeclaration;
+import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.ParameterDeclaration;
+import com.sun.mirror.declaration.TypeDeclaration;
+import com.sun.mirror.type.TypeMirror;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public class HolderTypeParametersRule extends AbstractAnnotationProcessor {
+
+ private static final String MODE = "mode";
+
+ @Override
+ public void process() {
+ AnnotationTypeDeclaration annotationDeclaration = (AnnotationTypeDeclaration) environment
+ .getTypeDeclaration("javax.jws.WebService"); //$NON-NLS-1$
+
+ Collection<Declaration> annotatedTypes = environment
+ .getDeclarationsAnnotatedWith(annotationDeclaration);
+
+ for (Declaration declaration : annotatedTypes) {
+ if (declaration instanceof ClassDeclaration) {
+ Collection<AnnotationMirror> annotationMirrors = declaration.getAnnotationMirrors();
+ for (AnnotationMirror mirror : annotationMirrors) {
+ if (AnnotationUtils.findAnnotationValue(mirror, "endpointInterface").length() > 0) {
+ break;
+ } else {
+ validateParameters((ClassDeclaration)declaration);
+ }
+ }
+ }
+ if (declaration instanceof InterfaceDeclaration) {
+ validateParameters((InterfaceDeclaration) declaration);
+ }
+ }
+ }
+
+
+ private void validateParameters(TypeDeclaration typeDeclaration) {
+ Messager messager = environment.getMessager();
+ Collection<? extends MethodDeclaration> methods = typeDeclaration.getMethods();
+ for (MethodDeclaration methodDeclaration : methods) {
+ Collection<ParameterDeclaration> parameters = methodDeclaration.getParameters();
+ for (ParameterDeclaration parameter : parameters) {
+ TypeMirror typeMirror = environment.getTypeUtils().getErasure(parameter.getType());
+ if (hasWebParamModeOutOrInOut(parameter)) {
+ if (!typeMirror.toString().equals(Holder.class.getCanonicalName())) {
+ messager.printError(parameter.getPosition(),
+ JAXWSCoreMessages.WEBPARAM_MODE_OUT_INOUT_HOLDER_TYPE_ERROR_MESSAGE);
+ }
+ } else {
+// if (typeMirror.toString().equals(Holder.class.getCanonicalName())) {
+// messager.printError(parameter.getPosition(),
+// JAXWSCoreMessages.HOLDER_TYPE_PARAMETER_ERROR_MESSAGE);
+// }
+ }
+ }
+ }
+
+ }
+ private boolean hasWebParamModeOutOrInOut(ParameterDeclaration parameter) {
+ Collection<AnnotationMirror> annotatinMirrors = parameter.getAnnotationMirrors();
+ for (AnnotationMirror mirror : annotatinMirrors) {
+ AnnotationTypeDeclaration annotationTypeDeclaration = mirror.getAnnotationType().getDeclaration();
+ if (annotationTypeDeclaration.getQualifiedName().equals(WebParam.class.getCanonicalName())) {
+ String mode = AnnotationUtils.findAnnotationValue(mirror, MODE); //$NON-NLS-1$
+ if (mode.equals(WebParam.Mode.OUT.toString())) {
+ return true;
+ }
+ if (mode.equals(WebParam.Mode.INOUT.toString())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/OnewayNoReturnValueRule.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/OnewayNoReturnValueRule.java
deleted file mode 100644
index 3f88996..0000000
--- a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/OnewayNoReturnValueRule.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IONA Technologies PLC
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IONA Technologies PLC - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.ws.internal.jaxws.core.annotations.validation;
-
-import java.util.Collection;
-
-import org.eclipse.jst.ws.annotations.core.processor.AbstractAnnotationProcessor;
-import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
-
-import com.sun.mirror.apt.Messager;
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-
-/**
- *
- * @author sclarke
- *
- */
-public class OnewayNoReturnValueRule extends AbstractAnnotationProcessor {
-
- public OnewayNoReturnValueRule() {
- }
-
- @Override
- public void process() {
- Messager messager = environment.getMessager();
-
- AnnotationTypeDeclaration annotationDeclaration = (AnnotationTypeDeclaration) environment
- .getTypeDeclaration("javax.jws.Oneway"); //$NON-NLS-1$
-
- Collection<Declaration> annotatedTypes = environment
- .getDeclarationsAnnotatedWith(annotationDeclaration);
-
- for (Declaration declaration : annotatedTypes) {
-
- if (declaration instanceof MethodDeclaration) {
- MethodDeclaration methodDeclaration = (MethodDeclaration) declaration;
- if (!methodDeclaration.getReturnType().equals(environment.getTypeUtils()
- .getVoidType())) {
- Collection<AnnotationMirror> annotationMirrors = declaration.getAnnotationMirrors();
- for (AnnotationMirror mirror : annotationMirrors) {
- if ( mirror.getAnnotationType().toString().equals(annotationDeclaration
- .getQualifiedName())) {
- messager.printError(mirror.getPosition(), JAXWSCoreMessages
- .ONEWAY_NO_RETURN_VALUE_ERROR_MESSAGE);
- }
- }
- }
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/OnewayRules.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/OnewayRules.java
new file mode 100644
index 0000000..79fce8a
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/OnewayRules.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IONA Technologies PLC
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IONA Technologies PLC - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.jaxws.core.annotations.validation;
+
+import java.util.Collection;
+
+import javax.jws.WebParam;
+
+import org.eclipse.jst.ws.annotations.core.processor.AbstractAnnotationProcessor;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
+
+import com.sun.mirror.apt.Messager;
+import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.AnnotationTypeDeclaration;
+import com.sun.mirror.declaration.Declaration;
+import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.ParameterDeclaration;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public class OnewayRules extends AbstractAnnotationProcessor {
+
+ public OnewayRules() {
+ }
+
+ @Override
+ public void process() {
+ AnnotationTypeDeclaration annotationDeclaration = (AnnotationTypeDeclaration) environment
+ .getTypeDeclaration("javax.jws.Oneway"); //$NON-NLS-1$
+
+ Collection<Declaration> annotatedTypes = environment
+ .getDeclarationsAnnotatedWith(annotationDeclaration);
+
+ for (Declaration declaration : annotatedTypes) {
+ if (declaration instanceof MethodDeclaration) {
+ MethodDeclaration methodDeclaration = (MethodDeclaration) declaration;
+ if (!methodDeclaration.getReturnType().equals(environment.getTypeUtils().getVoidType())) {
+ printError(annotationDeclaration, methodDeclaration,
+ JAXWSCoreMessages.ONEWAY_NO_RETURN_VALUE_ERROR_MESSAGE);
+ }
+ if (methodDeclaration.getThrownTypes().size() > 0) {
+ printError(annotationDeclaration, methodDeclaration,
+ JAXWSCoreMessages.ONEWAY_NO_CHECKED_EXCEPTIONS_ERROR_MESSAGE);
+ }
+ checkParameters(methodDeclaration);
+ }
+ }
+ }
+
+ private void checkParameters(MethodDeclaration methodDeclaration) {
+ Collection<ParameterDeclaration> parameters = methodDeclaration.getParameters();
+ for (ParameterDeclaration parameter : parameters) {
+ Collection<AnnotationMirror> annotatinMirrors = parameter.getAnnotationMirrors();
+ for (AnnotationMirror mirror : annotatinMirrors) {
+ AnnotationTypeDeclaration annotationTypeDeclaration = mirror.getAnnotationType()
+ .getDeclaration();
+ if (annotationTypeDeclaration.getQualifiedName().equals(WebParam.class.getCanonicalName())) {
+ String mode = AnnotationUtils.findAnnotationValue(mirror, "mode"); //$NON-NLS-1$
+ if (mode.equals(WebParam.Mode.OUT.toString())) {
+ environment.getMessager().printError(mirror.getPosition(),
+ JAXWSCoreMessages.ONEWAY_NO_OUT_PARAMETERS);
+ }
+ if (mode.equals(WebParam.Mode.INOUT.toString())) {
+ environment.getMessager().printError(mirror.getPosition(),
+ JAXWSCoreMessages.ONEWAY_NO_INOUT_PARAMETERS);
+ }
+
+ }
+ }
+ }
+ }
+
+ private void printError(AnnotationTypeDeclaration annotationDeclaration ,
+ MethodDeclaration methodDeclaration, String errorMessage) {
+ Messager messager = environment.getMessager();
+
+ Collection<AnnotationMirror> annotationMirrors = methodDeclaration.getAnnotationMirrors();
+ for (AnnotationMirror mirror : annotationMirrors) {
+ if ( mirror.getAnnotationType().toString().equals(annotationDeclaration
+ .getQualifiedName())) {
+ messager.printError(mirror.getPosition(), errorMessage);
+ }
+ }
+ }
+
+
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/SOAPBindingDocumentBareRules.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/SOAPBindingDocumentBareRules.java
new file mode 100644
index 0000000..5d89fbd
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/SOAPBindingDocumentBareRules.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.jaxws.core.annotations.validation;
+
+import java.util.Collection;
+
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.jws.soap.SOAPBinding.Use;
+import javax.xml.ws.Holder;
+
+import org.eclipse.jst.ws.annotations.core.processor.AbstractAnnotationProcessor;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
+
+import com.sun.mirror.apt.Messager;
+import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.AnnotationTypeDeclaration;
+import com.sun.mirror.declaration.Declaration;
+import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.ParameterDeclaration;
+import com.sun.mirror.declaration.TypeDeclaration;
+import com.sun.mirror.type.TypeMirror;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public class SOAPBindingDocumentBareRules extends AbstractAnnotationProcessor {
+
+ private static final String SOAP_BINDING_STYLE = "style";
+ private static final String SOAP_BINDING_USE = "use";
+ private static final String SOAP_BINDING_PARAMETER_STYLE = "parameterStyle";
+
+ private static final String WEB_PARAM_MODE = "mode";
+ private static final String WEB_PARAM_MODE_IN = "IN";
+ private static final String WEB_PARAM_MODE_OUT = "OUT";
+ private static final String WEB_PARAM_MODE_INOUT = "INOUT";
+
+ private static final String WEB_PARAM_HEADER = "header";
+
+ private static final String WEBPARAM = "javax.jws.WebParam";
+ private static final String ONEWAY = "javax.jws.Oneway";
+
+ @Override
+ public void process() {
+ AnnotationTypeDeclaration annotationDeclaration = (AnnotationTypeDeclaration) environment
+ .getTypeDeclaration("javax.jws.soap.SOAPBinding"); //$NON-NLS-1$
+
+ Collection<Declaration> annotatedTypes = environment
+ .getDeclarationsAnnotatedWith(annotationDeclaration);
+
+ for (Declaration declaration : annotatedTypes) {
+ if (declaration instanceof TypeDeclaration) {
+ TypeDeclaration typeDeclaration = (TypeDeclaration) declaration;
+ Collection<AnnotationMirror> annotationMirrors = typeDeclaration.getAnnotationMirrors();
+ for (AnnotationMirror mirror : annotationMirrors) {
+ if (isDocumentBare(mirror, annotationDeclaration)) {
+ Collection<? extends MethodDeclaration> methodDeclarations = typeDeclaration.getMethods();
+ for (MethodDeclaration methodDeclaration : methodDeclarations) {
+ processMethod(methodDeclaration);
+ }
+ }
+ }
+ }
+
+ if (declaration instanceof MethodDeclaration) {
+ MethodDeclaration methodDeclaration = (MethodDeclaration) declaration;
+ Collection<AnnotationMirror> annotationMirrors = methodDeclaration.getAnnotationMirrors();
+ for (AnnotationMirror mirror : annotationMirrors) {
+ if (isDocumentBare(mirror, annotationDeclaration)) {
+ processMethod((MethodDeclaration) declaration);
+ }
+ }
+ }
+ }
+ }
+
+ public void processMethod(MethodDeclaration methodDeclaration) {
+ Messager messager = environment.getMessager();
+
+ Collection<ParameterDeclaration> parameters = methodDeclaration.getParameters();
+
+ //@Oneway operations
+ if (isOneway(methodDeclaration) && !isSingleNonHeaderINParameter(parameters)) {
+ messager.printError(methodDeclaration.getPosition(),
+ JAXWSCoreMessages.DOC_BARE_ONLY_ONE_NON_HEADER_IN_PARAMETER_ERROR_MESSAGE);
+ } else {
+ if (isVoidReturnType(methodDeclaration)) {
+ if (countINParameters(parameters) > 1) {
+ messager.printError(methodDeclaration.getPosition(),
+ JAXWSCoreMessages.DOC_BARE_VOID_RETURN_ONE_IN_PARAMETER);
+ }
+ if (countOUTParameters(parameters) > 1) {
+ messager.printError(methodDeclaration.getPosition(),
+ JAXWSCoreMessages.DOC_BARE_VOID_RETURN_ONE_OUT_PARAMETER);
+ }
+ } else {
+ if (countINParameters(parameters) > 1) {
+ messager.printError(methodDeclaration.getPosition(),
+ JAXWSCoreMessages.DOC_BARE_ONLY_ONE_NON_HEADER_IN_PARAMETER_ERROR_MESSAGE);
+ }
+ if (countOUTParameters(parameters) > 0) {
+ messager.printError(methodDeclaration.getPosition(),
+ JAXWSCoreMessages.DOC_BARE_NON_VOID_RETURN_NO_INOUT_OUT_PARAMETER);
+ }
+ }
+ }
+
+ //check for @WebParam.name attribute when @WebParam.Mode = OUT or INOUT
+ for(ParameterDeclaration parameterDeclaration : parameters) {
+ Collection<AnnotationMirror> aannotationMirrors = parameterDeclaration.getAnnotationMirrors();
+ for (AnnotationMirror annotationMirror : aannotationMirrors) {
+ if (annotationMirror.getAnnotationType().getDeclaration().getQualifiedName().equals(WEBPARAM)) {
+ String mode = getWebParamMode(annotationMirror, parameterDeclaration);
+ String name = AnnotationUtils.findAnnotationValue(annotationMirror, "name");
+ if (name.length() == 0 && (mode.equals(WEB_PARAM_MODE_OUT) || mode.equals(WEB_PARAM_MODE_INOUT))) {
+ messager.printError(annotationMirror.getPosition(),
+ JAXWSCoreMessages.WEBPARAM_NAME_REQUIRED_WHEN_DOC_BARE_OUT_INOUT);
+ }
+ }
+ }
+ }
+ }
+
+ private boolean isDocumentBare(AnnotationMirror mirror, AnnotationTypeDeclaration annotationDeclaration) {
+ if (mirror.getAnnotationType().getDeclaration().equals(annotationDeclaration)) {
+ String document = AnnotationUtils.findAnnotationValue(mirror, SOAP_BINDING_STYLE);
+ String use = AnnotationUtils.findAnnotationValue(mirror, SOAP_BINDING_USE);
+ String parameterStyle = AnnotationUtils.findAnnotationValue(mirror, SOAP_BINDING_PARAMETER_STYLE);
+
+ return (document.length() == 0 || document.equals(Style.DOCUMENT.name()))
+ && (use.length() == 0 || use.equals(Use.LITERAL.name()))
+ && (parameterStyle.length() == 0 || parameterStyle.equals(ParameterStyle.BARE.name()));
+ }
+ return false;
+ }
+
+ private boolean isOneway(MethodDeclaration methodDeclaration) {
+ Collection<AnnotationMirror> annotationMirrors = methodDeclaration.getAnnotationMirrors();
+ for (AnnotationMirror mirror : annotationMirrors) {
+ if (mirror.getAnnotationType().getDeclaration().getQualifiedName().equals(ONEWAY)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isVoidReturnType(MethodDeclaration methodDeclaration) {
+ return methodDeclaration.getReturnType().equals(environment.getTypeUtils().getVoidType());
+ }
+
+ private boolean isSingleNonHeaderINParameter(Collection<ParameterDeclaration> parameters) {
+ return countNonHeaderINParameters(parameters) <= 1;
+ }
+
+ private int countNonHeaderINParameters(Collection<ParameterDeclaration> parameters) {
+ int inNonHeaderParameters = 0;
+ for (ParameterDeclaration parameterDeclaration : parameters) {
+ if (isNonHeaderINParameter(parameterDeclaration)) {
+ inNonHeaderParameters++;
+ }
+ }
+ return inNonHeaderParameters;
+ }
+
+ private boolean isNonHeaderINParameter(ParameterDeclaration parameterDeclaration) {
+ Collection<AnnotationMirror> annotationMirrors = parameterDeclaration.getAnnotationMirrors();
+ for (AnnotationMirror annotationMirror : annotationMirrors) {
+ if (annotationMirror.getAnnotationType().getDeclaration().getQualifiedName().equals(WEBPARAM)) {
+ return getWebParamMode(annotationMirror, parameterDeclaration).equals(WEB_PARAM_MODE_IN)
+ && !isHeader(annotationMirror);
+ }
+ }
+
+ if (getDefaultWebParamMode(parameterDeclaration).equals(WEB_PARAM_MODE_IN)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private int countINParameters(Collection<ParameterDeclaration> parameters) {
+ int inNonHeaderParameters = 0;
+ for (ParameterDeclaration parameterDeclaration : parameters) {
+ if (isINParameter(parameterDeclaration)) {
+ inNonHeaderParameters++;
+ }
+ }
+ return inNonHeaderParameters;
+ }
+
+ private boolean isINParameter(ParameterDeclaration parameterDeclaration) {
+ Collection<AnnotationMirror> annotationMirrors = parameterDeclaration.getAnnotationMirrors();
+ for (AnnotationMirror annotationMirror : annotationMirrors) {
+ if (annotationMirror.getAnnotationType().getDeclaration().getQualifiedName().equals(WEBPARAM)) {
+ String mode = getWebParamMode(annotationMirror, parameterDeclaration);
+ return (mode.equals(WEB_PARAM_MODE_IN) || mode.equals(WEB_PARAM_MODE_INOUT))
+ && !isHeader(annotationMirror);
+ }
+ }
+
+ String defaultMode = getDefaultWebParamMode(parameterDeclaration);
+ if (defaultMode.equals(WEB_PARAM_MODE_IN) || defaultMode.equals(WEB_PARAM_MODE_INOUT)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private int countOUTParameters(Collection<ParameterDeclaration> parameters) {
+ int outNonHeaderParameters = 0;
+ for (ParameterDeclaration parameterDeclaration : parameters) {
+ if (isOUTParameter(parameterDeclaration)) {
+ outNonHeaderParameters++;
+ }
+ }
+ return outNonHeaderParameters;
+ }
+
+ private boolean isOUTParameter(ParameterDeclaration parameterDeclaration) {
+ Collection<AnnotationMirror> annotationMirrors = parameterDeclaration.getAnnotationMirrors();
+ for (AnnotationMirror annotationMirror : annotationMirrors) {
+ if (annotationMirror.getAnnotationType().getDeclaration().getQualifiedName().equals(WEBPARAM)) {
+ String mode = getWebParamMode(annotationMirror, parameterDeclaration);
+ return (mode.equals(WEB_PARAM_MODE_OUT) || mode.equals(WEB_PARAM_MODE_INOUT))
+ && !isHeader(annotationMirror);
+ }
+ }
+
+ if (getDefaultWebParamMode(parameterDeclaration).equals(WEB_PARAM_MODE_INOUT)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private boolean isHeader(AnnotationMirror annotationMirror) {
+ String header = AnnotationUtils.findAnnotationValue(annotationMirror, WEB_PARAM_HEADER);
+ if (header.length() == 0) {
+ header = "false";
+ }
+ return Boolean.valueOf(header);
+ }
+
+
+ private String getWebParamMode(AnnotationMirror annotationMirror, ParameterDeclaration parameterDeclaration) {
+ String mode = AnnotationUtils.findAnnotationValue(annotationMirror, WEB_PARAM_MODE);
+ if (mode.length() == 0) {
+ mode = getDefaultWebParamMode(parameterDeclaration);
+ }
+ return mode;
+ }
+
+ private String getDefaultWebParamMode(ParameterDeclaration parameterDeclaration) {
+ TypeMirror typeMirror = environment.getTypeUtils().getErasure(parameterDeclaration.getType());
+ if (typeMirror.toString().equals(Holder.class.getCanonicalName())) {
+ return WEB_PARAM_MODE_INOUT;
+ }
+ return WEB_PARAM_MODE_IN;
+ }
+
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/SOAPBindingMethodStyleDocumentRule.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/SOAPBindingMethodStyleDocumentRule.java
index 7644c94..0ed01c1 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/SOAPBindingMethodStyleDocumentRule.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/SOAPBindingMethodStyleDocumentRule.java
@@ -11,19 +11,15 @@
package org.eclipse.jst.ws.internal.jaxws.core.annotations.validation;
import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
import org.eclipse.jst.ws.annotations.core.processor.AbstractAnnotationProcessor;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
import com.sun.mirror.apt.Messager;
import com.sun.mirror.declaration.AnnotationMirror;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.AnnotationValue;
import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.EnumConstantDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
/**
@@ -32,7 +28,8 @@
*
*/
public class SOAPBindingMethodStyleDocumentRule extends AbstractAnnotationProcessor {
-
+ private static final String STYLE = "style";
+
public SOAPBindingMethodStyleDocumentRule() {
}
@@ -43,7 +40,8 @@
AnnotationTypeDeclaration annotationDeclaration = (AnnotationTypeDeclaration) environment
.getTypeDeclaration("javax.jws.soap.SOAPBinding"); //$NON-NLS-1$
- Collection<Declaration> annotatedTypes = environment.getDeclarationsAnnotatedWith(annotationDeclaration);
+ Collection<Declaration> annotatedTypes = environment.getDeclarationsAnnotatedWith(
+ annotationDeclaration);
for (Declaration declaration : annotatedTypes) {
if (declaration instanceof MethodDeclaration) {
@@ -51,24 +49,11 @@
Collection<AnnotationMirror> annotationMirrors = declaration.getAnnotationMirrors();
for (AnnotationMirror mirror : annotationMirrors) {
- Map<AnnotationTypeElementDeclaration, AnnotationValue> valueMap = mirror
- .getElementValues();
- Set<Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue>> valueSet = valueMap
- .entrySet();
- for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> annotationKeyValue :
- valueSet) {
-
- if (annotationKeyValue.getKey().getSimpleName().equals("style")) { //$NON-NLS-1$
- if (annotationKeyValue.getValue() != null) {
- AnnotationValue annotationValue = annotationKeyValue.getValue();
- EnumConstantDeclaration enumConstantDeclaration =
- (EnumConstantDeclaration) annotationValue.getValue();
- if (!enumConstantDeclaration.getSimpleName().equals(
- javax.jws.soap.SOAPBinding.Style.DOCUMENT.name())) {
- messager.printError(mirror.getPosition(),
- JAXWSCoreMessages.SOAPBINDING_ON_METHOD_STYLE_DOCUMENT_ONLY_MESSAGE);
- }
- }
+ if (mirror.getAnnotationType().getDeclaration().equals(annotationDeclaration)) {
+ String style = AnnotationUtils.findAnnotationValue(mirror, STYLE);
+ if (!style.equals(javax.jws.soap.SOAPBinding.Style.DOCUMENT.toString())) {
+ messager.printError(mirror.getPosition(),
+ JAXWSCoreMessages.SOAPBINDING_ON_METHOD_STYLE_DOCUMENT_ONLY_MESSAGE);
}
}
}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/WebMethodPublicStaticFinalRule.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/WebMethodPublicStaticFinalRule.java
index 7cb9249..0def621 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/WebMethodPublicStaticFinalRule.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/WebMethodPublicStaticFinalRule.java
@@ -74,6 +74,5 @@
messager.printError(mirror.getPosition(), errorMessage);
}
}
-
}
}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractDocumentBareValidationTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractDocumentBareValidationTest.java
new file mode 100644
index 0000000..ebf91ad
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractDocumentBareValidationTest.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.jws.soap.SOAPBinding.Use;
+
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jst.ws.annotations.core.AnnotationsCore;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public abstract class AbstractDocumentBareValidationTest extends AbstractAnnotationValidationTest {
+
+ @Override
+ protected Annotation getAnnotation() {
+ List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>();
+
+ MemberValuePair styleValuePair = AnnotationsCore.createEnumMemberValuePair(ast,
+ "javax.jws.soap.SOAPBinding", "style", Style.DOCUMENT);
+
+ MemberValuePair useValuePair = AnnotationsCore.createEnumMemberValuePair(ast,
+ "javax.jws.soap.SOAPBinding", "use", Use.LITERAL);
+
+ MemberValuePair parameterStyleValuePair = AnnotationsCore.createEnumMemberValuePair(ast,
+ "javax.jws.soap.SOAPBinding", "parameterStyle", ParameterStyle.BARE);
+
+ memberValuePairs.add(styleValuePair);
+ memberValuePairs.add(useValuePair);
+ memberValuePairs.add(parameterStyleValuePair);
+
+ return AnnotationsCore.createAnnotation(ast, javax.jws.soap.SOAPBinding.class,
+ javax.jws.soap.SOAPBinding.class.getSimpleName(), memberValuePairs);
+
+ }
+
+ @Override
+ protected String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("public class MyClass {\n\n\t");
+ classContents.append("public String oneIN(String inOne, String inTwo) {\n\t\treturn \"txt\";\n\t}");
+ classContents.append("\n}");
+ return classContents.toString();
+ }
+
+ @Override
+ protected String getClassName() {
+ return "MyClass.java";
+ }
+
+ @Override
+ protected String getPackageName() {
+ return "com.example";
+ }
+
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractOnewayValidationTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractOnewayValidationTest.java
new file mode 100644
index 0000000..1d6284b
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractOnewayValidationTest.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jst.ws.annotations.core.AnnotationsCore;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public abstract class AbstractOnewayValidationTest extends AbstractAnnotationValidationTest {
+
+ @Override
+ public Annotation getAnnotation() {
+ return AnnotationsCore.createAnnotation(ast, javax.jws.Oneway.class,
+ javax.jws.Oneway.class.getSimpleName(), null);
+ }
+
+ @Override
+ public String getClassName() {
+ return "MyClass.java";
+ }
+
+ @Override
+ public String getPackageName() {
+ return "com.example";
+ }
+
+ public abstract String getErrorMessage();
+
+ public void testOnewayRule() {
+ try {
+ assertNotNull(annotation);
+ assertEquals("Oneway", AnnotationUtils.getAnnotationName(annotation));
+
+ IMethod method = source.findPrimaryType().getMethod("myMethod", new String[]{"I"});
+ assertNotNull(method);
+
+ AnnotationUtils.getImportChange(compilationUnit, javax.jws.Oneway.class, textFileChange, true);
+
+ AnnotationUtils.createMethodAnnotationChange(source, compilationUnit, rewriter, method,
+ annotation, textFileChange);
+
+ assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
+
+ assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
+ .getAnnotationName(annotation)));
+
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+
+ IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
+ IResource.DEPTH_INFINITE);
+
+ assertEquals(1, allmarkers.length);
+
+ IMarker annotationProblemMarker = allmarkers[0];
+
+ assertEquals(source.getResource(), annotationProblemMarker.getResource());
+ assertEquals(getErrorMessage(), annotationProblemMarker.getAttribute(IMarker.MESSAGE));
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ } catch (OperationCanceledException oce) {
+ fail(oce.getLocalizedMessage());
+ } catch (InterruptedException ie) {
+ fail(ie.getLocalizedMessage());
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareNonVoidNoOutParametersRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareNonVoidNoOutParametersRuleTest.java
new file mode 100644
index 0000000..5f856fa
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareNonVoidNoOutParametersRuleTest.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public class DocBareNonVoidNoOutParametersRuleTest extends AbstractDocumentBareValidationTest {
+
+ @Override
+ protected String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("import javax.jws.WebParam;\n");
+ classContents.append("public class MyClass {\n\n\t");
+ classContents.append("public String noOut(String in, @WebParam(name=\"out\", mode=WebParam.Mode.OUT) ");
+ classContents.append("String out) {\n\t\treturn \"txt\";\n\t}\n\n}");
+ return classContents.toString();
+ }
+
+ public void testNonVoidNoOUTParameterRule() {
+ try {
+ assertNotNull(annotation);
+ assertEquals("SOAPBinding", AnnotationUtils.getAnnotationName(annotation));
+
+ IMethod method = source.findPrimaryType().getMethod("noOut", new String[] { "QString;",
+ "QString; "});
+
+ assertNotNull(method);
+
+ AnnotationUtils.getImportChange(compilationUnit, javax.jws.soap.SOAPBinding.class,
+ textFileChange, true);
+
+ AnnotationUtils.createMethodAnnotationChange(source, compilationUnit, rewriter, method,
+ annotation, textFileChange);
+
+ assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
+
+ assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
+ .getAnnotationName(annotation)));
+
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+
+ IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
+ IResource.DEPTH_INFINITE);
+
+ assertEquals(1, allmarkers.length);
+
+ IMarker annotationProblemMarker = allmarkers[0];
+
+ assertEquals(source.getResource(), annotationProblemMarker.getResource());
+ assertEquals(JAXWSCoreMessages.DOC_BARE_NON_VOID_RETURN_NO_INOUT_OUT_PARAMETER,
+ annotationProblemMarker.getAttribute(IMarker.MESSAGE));
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ } catch (OperationCanceledException oce) {
+ fail(oce.getLocalizedMessage());
+ } catch (InterruptedException ie) {
+ fail(ie.getLocalizedMessage());
+ }
+ }
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareOneNonHeaderINParameterRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareOneNonHeaderINParameterRuleTest.java
new file mode 100644
index 0000000..0f02d7a
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareOneNonHeaderINParameterRuleTest.java
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public class DocBareOneNonHeaderINParameterRuleTest extends AbstractDocumentBareValidationTest {
+
+ @Override
+ protected String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("import javax.jws.WebParam;\n\n");
+ classContents.append("public class MyClass {\n\n\t");
+ //classContents.append("public String oneIN() {\n\t\treturn \"txt\";\n\t}\n\n\t");
+ classContents.append("public String oneMore(@WebParam(name=\"inOne\", mode=WebParam.Mode.IN) String ");
+ classContents.append("inOne, @WebParam(name=\"inTwo\", mode=WebParam.Mode.IN)String inTwo) {\n\t\t");
+ classContents.append("return \"txt\";\n\t}\n\n\tpublic String onlyOneIN(String inOne, String inTwo) {");
+ classContents.append("\n\t\treturn \"txt\";\n\t}\n}");
+ return classContents.toString();
+ }
+
+ /*
+ public void testOneNonHeaderINParameterRule() {
+ try {
+ assertNotNull(annotation);
+ assertEquals("SOAPBinding", AnnotationUtils.getAnnotationName(annotation));
+
+ IMethod method = source.findPrimaryType().getMethod("oneIN", new String[0]);
+ assertNotNull(method);
+
+ AnnotationUtils.getImportChange(compilationUnit, javax.jws.soap.SOAPBinding.class,
+ textFileChange, true);
+
+ AnnotationUtils.createMethodAnnotationChange(source, compilationUnit, rewriter, method,
+ annotation, textFileChange);
+
+ assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
+
+ assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
+ .getAnnotationName(annotation)));
+
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+
+ IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
+ IResource.DEPTH_INFINITE);
+
+ assertEquals(1, allmarkers.length);
+
+ IMarker annotationProblemMarker = allmarkers[0];
+
+ assertEquals(source.getResource(), annotationProblemMarker.getResource());
+ assertEquals(JAXWSCoreMessages.DOC_BARE_ONE_NON_HEADER_IN_PARAMETER_ERROR_MESSAGE,
+ annotationProblemMarker.getAttribute(IMarker.MESSAGE));
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ } catch (OperationCanceledException oce) {
+ fail(oce.getLocalizedMessage());
+ } catch (InterruptedException ie) {
+ fail(ie.getLocalizedMessage());
+ }
+ }*/
+
+ public void testOnlyOneNonHeaderINParameterRule() {
+ try {
+ assertNotNull(annotation);
+ assertEquals("SOAPBinding", AnnotationUtils.getAnnotationName(annotation));
+
+ IMethod method = source.findPrimaryType().getMethod("onlyOneIN", new String[] { "QString;",
+ "QString;" });
+
+ assertNotNull(method);
+
+ AnnotationUtils.getImportChange(compilationUnit, javax.jws.soap.SOAPBinding.class,
+ textFileChange, true);
+
+ AnnotationUtils.createMethodAnnotationChange(source, compilationUnit, rewriter, method,
+ annotation, textFileChange);
+
+ assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
+
+ assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
+ .getAnnotationName(annotation)));
+
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+
+ IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
+ IResource.DEPTH_INFINITE);
+
+ assertEquals(1, allmarkers.length);
+
+ IMarker annotationProblemMarker = allmarkers[0];
+
+ assertEquals(source.getResource(), annotationProblemMarker.getResource());
+ assertEquals(JAXWSCoreMessages.DOC_BARE_ONLY_ONE_NON_HEADER_IN_PARAMETER_ERROR_MESSAGE,
+ annotationProblemMarker.getAttribute(IMarker.MESSAGE));
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ } catch (OperationCanceledException oce) {
+ fail(oce.getLocalizedMessage());
+ } catch (InterruptedException ie) {
+ fail(ie.getLocalizedMessage());
+ }
+ }
+
+ public void testOnlyOneNonHeaderINParameterWithWebParamsRule() {
+ try {
+ assertNotNull(annotation);
+ assertEquals("SOAPBinding", AnnotationUtils.getAnnotationName(annotation));
+
+ IMethod method = source.findPrimaryType().getMethod("oneMore", new String[] { "QString;",
+ "QString;" });
+
+ assertNotNull(method);
+
+ AnnotationUtils.getImportChange(compilationUnit, javax.jws.soap.SOAPBinding.class,
+ textFileChange, true);
+
+ AnnotationUtils.createMethodAnnotationChange(source, compilationUnit, rewriter, method,
+ annotation, textFileChange);
+
+ assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
+
+ assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
+ .getAnnotationName(annotation)));
+
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+
+ IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
+ IResource.DEPTH_INFINITE);
+
+ assertEquals(1, allmarkers.length);
+
+ IMarker annotationProblemMarker = allmarkers[0];
+
+ assertEquals(source.getResource(), annotationProblemMarker.getResource());
+ assertEquals(JAXWSCoreMessages.DOC_BARE_ONLY_ONE_NON_HEADER_IN_PARAMETER_ERROR_MESSAGE,
+ annotationProblemMarker.getAttribute(IMarker.MESSAGE));
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ } catch (OperationCanceledException oce) {
+ fail(oce.getLocalizedMessage());
+ } catch (InterruptedException ie) {
+ fail(ie.getLocalizedMessage());
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareVoidOneINOneOutParameterRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareVoidOneINOneOutParameterRuleTest.java
new file mode 100644
index 0000000..29b4a74
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareVoidOneINOneOutParameterRuleTest.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public class DocBareVoidOneINOneOutParameterRuleTest extends AbstractDocumentBareValidationTest {
+ @Override
+ protected String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("import javax.jws.WebParam;\n");
+ classContents.append("import javax.xml.ws.Holder;\n\n");
+ classContents.append("public class MyClass {\n\n\t");
+ classContents.append("public void oneIn(@WebParam(name=\"inOne\", mode=WebParam.Mode.INOUT) ");
+ classContents.append("Holder<String> inOne, @WebParam(name=\"inTwo\", mode=WebParam.Mode.IN) ");
+ classContents.append("String inTwo) {\n\n\t}\n\n\t");
+ classContents.append("public void oneOut(@WebParam(name=\"outOne\", mode=WebParam.Mode.INOUT) ");
+ classContents.append("Holder<String> outOne, @WebParam(name=\"outTwo\", mode=WebParam.Mode.OUT) ");
+ classContents.append("String outTwo) {\n\n\t}\n\n}");
+ return classContents.toString();
+ }
+
+ public void testVoidOneInParameterRule() {
+ try {
+ assertNotNull(annotation);
+ assertEquals("SOAPBinding", AnnotationUtils.getAnnotationName(annotation));
+
+ IMethod method = source.findPrimaryType().getMethod("oneIn", new String[] { "QHolder<QString;>;",
+ "QString; "});
+
+ assertNotNull(method);
+
+ AnnotationUtils.getImportChange(compilationUnit, javax.jws.soap.SOAPBinding.class,
+ textFileChange, true);
+
+ AnnotationUtils.createMethodAnnotationChange(source, compilationUnit, rewriter, method,
+ annotation, textFileChange);
+
+ assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
+
+ assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
+ .getAnnotationName(annotation)));
+
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+
+ IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
+ IResource.DEPTH_INFINITE);
+
+ assertEquals(1, allmarkers.length);
+
+ IMarker annotationProblemMarker = allmarkers[0];
+
+ assertEquals(source.getResource(), annotationProblemMarker.getResource());
+ assertEquals(JAXWSCoreMessages.DOC_BARE_VOID_RETURN_ONE_IN_PARAMETER,
+ annotationProblemMarker.getAttribute(IMarker.MESSAGE));
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ } catch (OperationCanceledException oce) {
+ fail(oce.getLocalizedMessage());
+ } catch (InterruptedException ie) {
+ fail(ie.getLocalizedMessage());
+ }
+ }
+
+ public void testVoidOneOutParameterRule() {
+ try {
+ assertNotNull(annotation);
+ assertEquals("SOAPBinding", AnnotationUtils.getAnnotationName(annotation));
+
+ IMethod method = source.findPrimaryType().getMethod("oneOut", new String[] { "QHolder<QString;>;",
+ "QString; "});
+
+ assertNotNull(method);
+
+ AnnotationUtils.getImportChange(compilationUnit, javax.jws.soap.SOAPBinding.class,
+ textFileChange, true);
+
+ AnnotationUtils.createMethodAnnotationChange(source, compilationUnit, rewriter, method,
+ annotation, textFileChange);
+
+ assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
+
+ assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
+ .getAnnotationName(annotation)));
+
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+
+ IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
+ IResource.DEPTH_INFINITE);
+
+ assertEquals(1, allmarkers.length);
+
+ IMarker annotationProblemMarker = allmarkers[0];
+
+ assertEquals(source.getResource(), annotationProblemMarker.getResource());
+ assertEquals(JAXWSCoreMessages.DOC_BARE_VOID_RETURN_ONE_OUT_PARAMETER,
+ annotationProblemMarker.getAttribute(IMarker.MESSAGE));
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ } catch (OperationCanceledException oce) {
+ fail(oce.getLocalizedMessage());
+ } catch (InterruptedException ie) {
+ fail(ie.getLocalizedMessage());
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/JAXWSAnnotationValidationTestSuite.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/JAXWSAnnotationValidationTestSuite.java
index 46b4606..545df11 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/JAXWSAnnotationValidationTestSuite.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/JAXWSAnnotationValidationTestSuite.java
@@ -26,7 +26,13 @@
public JAXWSAnnotationValidationTestSuite() {
super("JAX-WS Annotation Validation Tests");
+ addTestSuite(DocBareNonVoidNoOutParametersRuleTest.class);
+ addTestSuite(DocBareOneNonHeaderINParameterRuleTest.class);
+ addTestSuite(DocBareVoidOneINOneOutParameterRuleTest.class);
addTestSuite(OnewayNoReturnValueRuleTest.class);
+ addTestSuite(OnewayNoCheckedExceptionsRuleTest.class);
+ addTestSuite(OnewayNoOutParametersRuleTest.class);
+ addTestSuite(OnewayNoInOutParametersRuleTest.class);
addTestSuite(SOAPBindingMethodStyleDocumentRuleTest.class);
addTestSuite(SOAPBindingMethodUseRuleTest.class);
addTestSuite(WebMethodCheckForWebServiceRuleTest.class);
@@ -37,6 +43,7 @@
addTestSuite(WebMethodNoProtectedMethodRuleTest.class);
addTestSuite(WebMethodNoFinalModifierRuleTest.class);
addTestSuite(WebMethodNoStaticModifierRuleTest.class);
+ addTestSuite(WebParamModeHolderTypeRuleTest.class);
addTestSuite(WebServiceDefaultPublicConstructorRuleTest.class);
addTestSuite(WebServiceNoFinalizeMethodRuleTest.class);
addTestSuite(WebServiceNoFinalModiferRuleTest.class);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoCheckedExceptionsRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoCheckedExceptionsRuleTest.java
new file mode 100644
index 0000000..0ebc30a
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoCheckedExceptionsRuleTest.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
+
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public class OnewayNoCheckedExceptionsRuleTest extends AbstractOnewayValidationTest {
+
+ @Override
+ protected String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("public class MyClass {\n\n\tpublic void myMethod(int i) throws Exception {\n\t}\n}");
+ return classContents.toString();
+ }
+
+ @Override
+ public String getErrorMessage() {
+ return JAXWSCoreMessages.ONEWAY_NO_CHECKED_EXCEPTIONS_ERROR_MESSAGE;
+ }
+
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoInOutParametersRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoInOutParametersRuleTest.java
new file mode 100644
index 0000000..a0bf563
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoInOutParametersRuleTest.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
+
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public class OnewayNoInOutParametersRuleTest extends AbstractOnewayValidationTest {
+
+ @Override
+ protected String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("import javax.jws.WebParam;\n\n");
+ classContents.append("public class MyClass {\n\n\tpublic void myMethod(@WebParam(");
+ classContents.append("mode=WebParam.Mode.INOUT) int i) {\n\t}\n}");
+ return classContents.toString();
+ }
+
+ @Override
+ public String getErrorMessage() {
+ return JAXWSCoreMessages.ONEWAY_NO_INOUT_PARAMETERS;
+ }
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoOutParametersRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoOutParametersRuleTest.java
new file mode 100644
index 0000000..ac0bed6
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoOutParametersRuleTest.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
+
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public class OnewayNoOutParametersRuleTest extends AbstractOnewayValidationTest {
+
+ @Override
+ protected String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("import javax.jws.WebParam;\n\n");
+ classContents.append("public class MyClass {\n\n\tpublic void myMethod(@WebParam(");
+ classContents.append("mode=WebParam.Mode.OUT) int i) {\n\t}\n}");
+ return classContents.toString();
+ }
+
+ @Override
+ public String getErrorMessage() {
+ return JAXWSCoreMessages.ONEWAY_NO_OUT_PARAMETERS;
+ }
+
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoReturnValueRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoReturnValueRuleTest.java
index 4298957..76767d4 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoReturnValueRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/OnewayNoReturnValueRuleTest.java
@@ -10,17 +10,6 @@
*******************************************************************************/
package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jst.ws.annotations.core.AnnotationsCore;
-import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
/**
@@ -28,68 +17,17 @@
* @author sclarke
*
*/
-public class OnewayNoReturnValueRuleTest extends AbstractAnnotationValidationTest {
-
- @Override
- public Annotation getAnnotation() {
- return AnnotationsCore.createAnnotation(ast, javax.jws.Oneway.class,
- javax.jws.Oneway.class.getSimpleName(), null);
- }
+public class OnewayNoReturnValueRuleTest extends AbstractOnewayValidationTest {
@Override
public String getClassContents() {
StringBuilder classContents = new StringBuilder("package com.example;\n\n");
- classContents.append("public class MyClass {\n\n\tpublic int myMethod() {\n\t\treturn 0;\n\t}\n}");
+ classContents.append("public class MyClass {\n\n\tpublic int myMethod(int i) {\n\t\treturn 0;\n\t}\n}");
return classContents.toString();
}
- @Override
- public String getClassName() {
- return "MyClass.java";
- }
-
- @Override
- public String getPackageName() {
- return "com.example";
- }
-
- public void testOnewayNoReturnValueRule() {
- try {
- assertNotNull(annotation);
- assertEquals("Oneway", AnnotationUtils.getAnnotationName(annotation));
-
- IMethod method = source.findPrimaryType().getMethod("myMethod", new String[0]);
- assertNotNull(method);
-
- AnnotationUtils.getImportChange(compilationUnit, javax.jws.Oneway.class, textFileChange, true);
-
- AnnotationUtils.createMethodAnnotationChange(source, compilationUnit, rewriter, method,
- annotation, textFileChange);
-
- assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
-
- assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
- .getAnnotationName(annotation)));
-
- Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
-
- IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
- IResource.DEPTH_INFINITE);
-
- assertEquals(1, allmarkers.length);
-
- IMarker annotationProblemMarker = allmarkers[0];
-
- assertEquals(source.getResource(), annotationProblemMarker.getResource());
- assertEquals(JAXWSCoreMessages.ONEWAY_NO_RETURN_VALUE_ERROR_MESSAGE,
- annotationProblemMarker.getAttribute(IMarker.MESSAGE));
- } catch (CoreException ce) {
- fail(ce.getLocalizedMessage());
- } catch (OperationCanceledException oce) {
- fail(oce.getLocalizedMessage());
- } catch (InterruptedException ie) {
- fail(ie.getLocalizedMessage());
- }
+ public String getErrorMessage() {
+ return JAXWSCoreMessages.ONEWAY_NO_RETURN_VALUE_ERROR_MESSAGE;
}
-
+
}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingMethodUseRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingMethodUseRuleTest.java
index 424f472..155ec17 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingMethodUseRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingMethodUseRuleTest.java
@@ -62,8 +62,8 @@
@Override
protected String getClassContents() {
StringBuilder classContents = new StringBuilder("package com.example;\n\n");
- classContents.append("public class MyClass {\n\n\tpublic String myMethod() {");
- classContents.append("\n\t\treturn \"txt\";\n\t}\n}");
+ classContents.append("public class MyClass {\n\n\tpublic String myMethod(String in) {");
+ classContents.append("\n\t\treturn \"txt\";\n\t}\n\n}");
return classContents.toString();
}
@@ -81,8 +81,8 @@
try {
assertNotNull(annotation);
assertEquals("SOAPBinding", AnnotationUtils.getAnnotationName(annotation));
-
- IMethod method = source.findPrimaryType().getMethod("myMethod", new String[0]);
+
+ IMethod method = source.findPrimaryType().getMethod("myMethod", new String[] { "QString;" });
assertNotNull(method);
AnnotationUtils.getImportChange(compilationUnit, javax.jws.soap.SOAPBinding.class,
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebParamModeHolderTypeRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebParamModeHolderTypeRuleTest.java
new file mode 100644
index 0000000..2c68e00
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebParamModeHolderTypeRuleTest.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jws.WebParam.Mode;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.jst.ws.annotations.core.AnnotationsCore;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
+
+/**
+ *
+ * @author sclarke
+ *
+ */
+public class WebParamModeHolderTypeRuleTest extends AbstractAnnotationValidationTest {
+
+ @Override
+ public Annotation getAnnotation() {
+ List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>();
+
+ MemberValuePair modeValuePair = AnnotationsCore.createEnumMemberValuePair(ast,
+ "javax.jws.WebParam", "mode", Mode.OUT);
+
+ memberValuePairs.add(modeValuePair);
+
+ return AnnotationsCore.createAnnotation(ast, javax.jws.WebParam.class, javax.jws.WebParam.class
+ .getSimpleName(), memberValuePairs);
+ }
+
+ @Override
+ public String getPackageName() {
+ return "com.example";
+ }
+
+ @Override
+ public String getClassName() {
+ return "MyClass.java";
+ }
+
+ @Override
+ public String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("import javax.jws.WebService;\n\n");
+ classContents.append("@WebService(name=\"MyClass\")\n");
+ classContents.append("public class MyClass {\n\n\tpublic String myMethod(String param) {");
+ classContents.append("\n\t\treturn \"txt\";\n\t}\n}");
+ return classContents.toString();
+ }
+
+ public void testWebParamModeHolderTypeRule() {
+ try {
+ assertNotNull(annotation);
+ assertEquals("WebParam", AnnotationUtils.getAnnotationName(annotation));
+
+ IMethod method = source.findPrimaryType().getMethod("myMethod", new String[] { "QString;" });
+ assertNotNull(method);
+
+ AnnotationUtils.getImportChange(compilationUnit, javax.jws.WebParam.class, textFileChange, true);
+
+ SingleVariableDeclaration parameter = AnnotationUtils.getMethodParameter(compilationUnit, method,
+ 128);
+
+ AnnotationUtils.createMethodParameterAnnotationChange(source, compilationUnit, rewriter,
+ parameter, method, annotation, textFileChange);
+
+ assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
+
+ // refresh
+ parameter = AnnotationUtils.getMethodParameter(AnnotationUtils.getASTParser(method
+ .getCompilationUnit()), method, 156);
+
+ assertTrue(AnnotationUtils.isAnnotationPresent(parameter, annotation));
+
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+
+ IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
+ IResource.DEPTH_INFINITE);
+
+ assertEquals(1, allmarkers.length);
+
+ IMarker annotationProblemMarker = allmarkers[0];
+
+ assertEquals(source.getResource(), annotationProblemMarker.getResource());
+ assertEquals(JAXWSCoreMessages.WEBPARAM_MODE_OUT_INOUT_HOLDER_TYPE_ERROR_MESSAGE,
+ annotationProblemMarker.getAttribute(IMarker.MESSAGE));
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ }catch (OperationCanceledException oce) {
+ fail(oce.getLocalizedMessage());
+ } catch (InterruptedException ie) {
+ fail(ie.getLocalizedMessage());
+ }
+ }
+}