axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngalla...@apache.org
Subject svn commit: r614296 - in /webservices/axis2/branches/java/jaxws21/modules: kernel/src/org/apache/axis2/ metadata/src/org/apache/axis2/jaxws/description/ metadata/src/org/apache/axis2/jaxws/description/builder/ metadata/src/org/apache/axis2/jaxws/descri...
Date Tue, 22 Jan 2008 19:36:07 GMT
Author: ngallardo
Date: Tue Jan 22 11:36:04 2008
New Revision: 614296

URL: http://svn.apache.org/viewvc?rev=614296&view=rev
Log:
AXIS2-3448

Initial enablement for @MTOM annotation.

Added:
    webservices/axis2/branches/java/jaxws21/modules/metadata/test/org/apache/axis2/jaxws/description/feature/
    webservices/axis2/branches/java/jaxws21/modules/metadata/test/org/apache/axis2/jaxws/description/feature/MTOMFeatureTests.java
Modified:
    webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/Constants.java
    webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
    webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java
    webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/ConverterUtils.java
    webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaClassToDBCConverter.java
    webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
    webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/server/config/MTOMConfigurator.java

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/Constants.java?rev=614296&r1=614295&r2=614296&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/Constants.java
(original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/Constants.java
Tue Jan 22 11:36:04 2008
@@ -265,6 +265,7 @@
 
         //Attachment configurations
         public static final String ENABLE_MTOM = "enableMTOM";
+        public static final String MTOM_THRESHOLD = "mtomThreshold";
         public static final String CACHE_ATTACHMENTS = "cacheAttachments";
         public static final String ATTACHMENT_TEMP_DIR = "attachmentDIR";
         public static final String FILE_SIZE_THRESHOLD = "sizeThreshold";

Modified: webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java?rev=614296&r1=614295&r2=614296&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
(original)
+++ webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
Tue Jan 22 11:36:04 2008
@@ -136,11 +136,27 @@
     public abstract QName getServiceQName();
 
     public abstract Service.Mode getServiceMode();
-
+    
+    /**
+     * Signals whether or not MTOM has been turned on for the endpoint 
+     * based on the annotation configuration.
+     * 
+     * @return a boolean value 
+     */
+    public boolean isMTOMEnabled();
+    
+    /**
+     * If MTOM is enabled, returns the threshold value.
+     * 
+     * @return -1 if MTOM is not enabled, a positive integer value if 
+     * one was configured.
+     */
+    public int getMTOMThreshold();
+    
+    
     /**
      * Return the DescriptionBuilderComposite, if any, used to build this service description.
      * @return
      */
     public DescriptionBuilderComposite getDescriptionBuilderComposite();
-
 }

Modified: webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java?rev=614296&r1=614295&r2=614296&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java
(original)
+++ webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java
Tue Jan 22 11:36:04 2008
@@ -31,6 +31,7 @@
 
 import javax.wsdl.Definition;
 import javax.xml.namespace.QName;
+import javax.xml.ws.spi.WebServiceFeatureAnnotation;
 
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
@@ -82,7 +83,9 @@
     private List<WebServiceRefAnnot> webServiceRefAnnotList;
     private BindingTypeAnnot bindingTypeAnnot;
     private WebServiceContextAnnot webServiceContextAnnot;
-
+    
+    private List<Annotation> features;
+    
     // Class information
     private String className;
     private String[] classModifiers; //public, abstract, final, strictfp...
@@ -91,7 +94,7 @@
     private boolean isInterface = false;
     private QName preferredPort;        // Port to use if no port QName given.  May be null
     private boolean isMTOMEnabled = false;
-
+    
     private List<MethodDescriptionComposite> methodDescriptions;
     private List<FieldDescriptionComposite> fieldDescriptions;
     
@@ -369,7 +372,15 @@
     public WebServiceContextAnnot getWebServiceContextAnnot() {
         return (WebServiceContextAnnot) webServiceContextAnnot;
     }
-
+    
+    public List<Annotation> getWebServiceFeatures() {
+        return features;
+    }
+    
+    public void setWebServiceFeatures(List<Annotation> list) {
+        features = list;
+    }
+    
     /** @return Returns the wsdlDefinition */
     public Definition getWsdlDefinition() {
         if (wsdlDefinition != null) {

Modified: webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/ConverterUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/ConverterUtils.java?rev=614296&r1=614295&r2=614296&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/ConverterUtils.java
(original)
+++ webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/ConverterUtils.java
Tue Jan 22 11:36:04 2008
@@ -33,6 +33,8 @@
 import javax.jws.soap.SOAPBinding;
 import javax.xml.bind.annotation.XmlList;
 import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.spi.WebServiceFeatureAnnotation;
+
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.GenericArrayType;
@@ -41,6 +43,7 @@
 import java.lang.reflect.Type;
 import java.lang.reflect.WildcardType;
 import java.security.PrivilegedAction;
+import java.util.ArrayList;
 import java.util.List;
 
 public class ConverterUtils {
@@ -60,6 +63,40 @@
             }
         });
      }
+    
+    /**
+     * Helper method to retrieve a list of all annotations that match the following
+     * conditions:
+     * 
+     * - Annotations that extend the parameterized type T
+     * - Annotations that themselves are annotated with type T
+     * 
+     * @param annotationClass
+     * @param element
+     * @return
+     */
+    public static <T extends Annotation> List<Annotation> getAnnotations(final
Class<T> annotationClass, final AnnotatedElement element) {
+        List<Annotation> matches = new ArrayList<Annotation>();
+        Annotation[] annotations = null;
+        
+        // Get the complete list of annotations from the class that was provided.
+        annotations = (Annotation[]) AccessController.doPrivileged(new PrivilegedAction()
{
+            public Object run() {
+                return element.getAnnotations();
+            }
+        });
+        
+        for (Annotation a: annotations) {        
+            // If the annotation matches the parameter type we're looking
+            // for, add it to the list.
+            if (a.annotationType().isAnnotationPresent(annotationClass) || 
+                annotationClass.isAssignableFrom(a.annotationType())) {
+                matches.add(a);
+            }
+        }
+        
+        return matches;
+    }
 
     /**
      * This is a helper method to create a <code>HandlerChainAnnot</code> since
the

Modified: webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaClassToDBCConverter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaClassToDBCConverter.java?rev=614296&r1=614295&r2=614296&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaClassToDBCConverter.java
(original)
+++ webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaClassToDBCConverter.java
Tue Jan 22 11:36:04 2008
@@ -18,12 +18,14 @@
  */
 package org.apache.axis2.jaxws.description.builder.converter;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.jws.WebService;
 import javax.xml.ws.BindingType;
@@ -33,6 +35,7 @@
 import javax.xml.ws.WebServiceProvider;
 import javax.xml.ws.WebServiceRef;
 import javax.xml.ws.WebServiceRefs;
+import javax.xml.ws.spi.WebServiceFeatureAnnotation;
 
 import org.apache.axis2.jaxws.description.builder.BindingTypeAnnot;
 import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
@@ -54,7 +57,15 @@
     private String seiClassName;
 
     private List<Class> classes;
-
+    
+    private static final Map<Class, Object> annotationProcessors;
+    
+    static {
+        annotationProcessors = new HashMap<Class, Object>();
+        
+        
+    }
+    
     public JavaClassToDBCConverter(Class serviceClass) {
         this.serviceClass = serviceClass;
         classes = new ArrayList<Class>();
@@ -185,6 +196,7 @@
         attachWebServiceProviderAnnotation(composite);
         attachWebServiceRefsAnnotation(composite);
         attachWebServiceRefAnnotation(composite);
+        attachWebServiceFeatureAnnotations(composite);
     }
 
     /**
@@ -347,6 +359,24 @@
     private void attachWebServiceRefAnnotation(DescriptionBuilderComposite composite) {
         ConverterUtils.attachWebServiceRefAnnotation(composite, serviceClass);
 
+    }
+    
+    /**
+     * Finds the list of WebServiceFeatureAnnotation instances, and set them on the composite.
+     * 
+     * @param composite
+     */
+    private void attachWebServiceFeatureAnnotations(DescriptionBuilderComposite composite)
{
+        List<Annotation> features = ConverterUtils.getAnnotations(
+            WebServiceFeatureAnnotation.class, serviceClass); 
+        
+        if (features.size() > 0) {
+            if (log.isDebugEnabled()) {
+                log.debug("There were [" + features.size() + "] WebServiceFeature annotations
found.");
+            }
+            
+            composite.setWebServiceFeatures(features);
+        }
     }
 
     private void establishClassHierarchy(Class rootClass) {

Modified: webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?rev=614296&r1=614295&r2=614296&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
(original)
+++ webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
Tue Jan 22 11:36:04 2008
@@ -47,13 +47,16 @@
 import javax.xml.ws.WebServiceProvider;
 import javax.xml.ws.handler.PortInfo;
 import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.soap.MTOM;
 import javax.xml.ws.soap.MTOMFeature;
 import javax.xml.ws.soap.SOAPBinding;
 import javax.xml.ws.spi.WebServiceFeatureAnnotation;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants.Configuration;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.deployment.DeploymentException;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.OutInAxisOperation;
 import org.apache.axis2.description.OutOnlyAxisOperation;
@@ -97,11 +100,11 @@
  */
 class EndpointDescriptionImpl
         implements EndpointDescription, EndpointDescriptionJava, EndpointDescriptionWSDL
{
-	private static final ServerConfigurator RESPECT_BINDING_CONFIGURATOR =
+    private static final ServerConfigurator RESPECT_BINDING_CONFIGURATOR =
         new RespectBindingConfigurator();
-	private static final ServerConfigurator ADDRESSING_CONFIGURATOR =
+    private static final ServerConfigurator ADDRESSING_CONFIGURATOR =
         new AddressingConfigurator();
-	private static final ServerConfigurator MTOM_CONFIGURATOR =
+    private static final ServerConfigurator MTOM_CONFIGURATOR =
         new MTOMConfigurator();
 
     private ServiceDescriptionImpl parentServiceDescription;
@@ -491,6 +494,9 @@
                 processor.processTypeLevelAnnotation(this, annotation);
             }
         }
+        
+        // Configure any available WebServiceFeatures on the endpoint.
+        configureWebServiceFeatures();
     }
 
     /**
@@ -589,14 +595,18 @@
 
             if (composite.isDeprecatedServiceProviderConstruction()
                     || !composite.isServiceProvider()) {
+//            if (!getServiceDescriptionImpl().isDBCMap()) {
                 Class seiClass = null;
                 if (DescriptionUtils.isEmpty(seiClassName)) {
-                    // This is the client code path; the @WebServce will not have an endpointInterface
member
-                    // so just build the EndpointInterfaceDesc based on the class itself.
+                    // TODO: (JLB) This is the client code path; the @WebServce will not
have an endpointInterface member
+                    // For now, just build the EndpointInterfaceDesc based on the class itself.
+                    // TODO: The EID ctor doesn't correctly handle anything but an SEI at
this
+                    //       point; e.g. it doesn't publish the correct methods of just an
impl.
                     seiClass = composite.getCorrespondingClass();
                 } else {
-                    // This is the deprecated server-side introspection code for an impl
that references an SEI
+                    // TODO: (JLB) This is the deprecated server-side introspection code
for an impl that references an SEI
                     try {
+                        // TODO: Using Class forName() is probably not the best long-term
way to get the SEI class from the annotation
                         seiClass = ClassLoaderUtils.forName(seiClassName, false,
                                                             ClassLoaderUtils.getContextClassLoader(this.axisService
!= null ? this.axisService.getClassLoader() : null));
                         // Catch Throwable as ClassLoader can throw an NoClassDefFoundError
that
@@ -609,14 +619,17 @@
                 }
                 endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(seiClass,
this);
             } else {
+                //TODO: Determine if we need logic here to determine implied SEI or not.
This logic
+                //		may be handled by EndpointInterfaceDescription
+
                 if (DescriptionUtils.isEmpty(getAnnoWebServiceEndpointInterface())) {
 
-                    // Build the EndpointInterfaceDesc based on the class itself
+                    //TODO: Build the EndpointInterfaceDesc based on the class itself
                     endpointInterfaceDescription =
                             new EndpointInterfaceDescriptionImpl(composite, true, this);
 
                 } else {
-                    // Otherwise, build the EID based on the SEI composite
+                    //Otherwise, build the EID based on the SEI composite
                     endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(
                             getServiceDescriptionImpl().getDBCMap().get(seiClassName),
                             false,
@@ -1364,6 +1377,44 @@
         return handlerChainAnnotation;
     }
 
+    // ===========================================
+    // ANNOTATION: MTOM
+    // ===========================================
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.axis2.jaxws.description.EndpointDescription#isMTOMEnabled()
+     */
+    public boolean isMTOMEnabled() {
+        if (axisService != null) {
+            // We should cache this call here so we don't have to make
+            // it on every pass through.
+            Parameter enableMTOM = axisService.getParameter(Configuration.ENABLE_MTOM);
+            if (enableMTOM != null) {
+                return (Boolean) enableMTOM.getValue();
+            }
+        }
+        
+        return false;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.axis2.jaxws.description.EndpointDescription#getMTOMThreshold()
+     */
+    public int getMTOMThreshold() {
+        if (axisService != null) {
+            // We should cache this call here so we don't have to make
+            // it on every pass through.
+            Parameter mtomThreshold = axisService.getParameter(Configuration.MTOM_THRESHOLD);
+            if (mtomThreshold != null) {
+                return (Integer) mtomThreshold.getValue();
+            }
+        }
+        
+        return -1;
+    }
+    
     // Get the specified WebServiceFeatureAnnotation
     public Annotation getAnnoFeature(String id) {
         return framework.getAnnotation(id);
@@ -1383,17 +1434,26 @@
     		framework.addConfigurator(MTOMFeature.ID, MTOM_CONFIGURATOR);
     	}
     	
-    	//TODO: Need to add support for the DescriptionBuilderComposite?
-    	Annotation[] annotations = composite.getCorrespondingClass().getAnnotations();
-    	
-    	if (annotations != null) {
-    		for (Annotation annotation : annotations) {
-    			if (annotation.annotationType().isAnnotationPresent(WebServiceFeatureAnnotation.class))
-    				framework.addAnnotation(annotation);
-    		}
-        	
-        	framework.configure(this);
-    	}
+        // The feature instances are stored on the composite from either the 
+        // Java class or from something else building the list and setting it there.
+        List<Annotation> features = composite.getWebServiceFeatures();
+        
+        if (features != null && features.size() > 0) {
+            // Add each of the annotation instances to the WebServiceFeature framework
+            Iterator<Annotation> itr = features.iterator();
+            while (itr.hasNext()) {
+                Annotation feature = (Annotation) itr.next();
+                framework.addAnnotation(feature);
+            }
+            
+            // Kick off the configuration of the WebServiceFeature instances.
+            framework.configure(this);
+        }
+        else {
+            if (log.isDebugEnabled()) {
+                log.debug("No WebServiceFeatureAnnotation instances were found on the composite.");
+            }
+        }   
     }
     
     private Definition getWSDLDefinition() {
@@ -1819,6 +1879,20 @@
             return string.toString();
         }
         return string.toString();
+    }
+    
+    /**
+     * Get an annotation.  This is wrappered to avoid a Java2Security violation.
+     * @param cls Class that contains annotation 
+     * @param annotation Class of requrested Annotation
+     * @return annotation or null
+     */
+    private static Annotation getAnnotation(final Class cls, final Class annotation) {
+        return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                return cls.getAnnotation(annotation);
+            }
+        });
     }
 }
 

Modified: webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/server/config/MTOMConfigurator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/server/config/MTOMConfigurator.java?rev=614296&r1=614295&r2=614296&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/server/config/MTOMConfigurator.java
(original)
+++ webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/server/config/MTOMConfigurator.java
Tue Jan 22 11:36:04 2008
@@ -21,20 +21,25 @@
 import javax.xml.ws.soap.MTOM;
 import javax.xml.ws.soap.MTOMFeature;
 
+import org.apache.axis2.Constants;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.EndpointDescriptionJava;
 import org.apache.axis2.jaxws.feature.ServerConfigurator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  *
  */
 public class MTOMConfigurator implements ServerConfigurator {
 
+    private static Log log = LogFactory.getLog(MTOMConfigurator.class);
+    
     /*
-     *  (non-Javadoc)
+     * (non-Javadoc)
      * @see org.apache.axis2.jaxws.feature.WebServiceFeatureConfigurator#configure(org.apache.axis2.jaxws.description.EndpointDescription)
      */
     public void configure(EndpointDescription endpointDescription) {
@@ -43,19 +48,32 @@
     	AxisService service = endpointDescription.getAxisService();
     	
     	//Disable MTOM
-    	Parameter enableMTOM = new Parameter("enableMTOM", Boolean.FALSE);
-
-//      TODO NLS enable.
+    	Parameter enableMTOM = new Parameter(Constants.Configuration.ENABLE_MTOM, Boolean.FALSE);
+    	Parameter threshold = new Parameter(Constants.Configuration.MTOM_THRESHOLD, 0);
+        
+    	//TODO NLS enable.
         if (mtomAnnoation == null)
             throw ExceptionFactory.makeWebServiceException("The MTOM annotation was unspecified.");
     	
         //Enable MTOM.
     	if (mtomAnnoation.enabled()) {
-        	enableMTOM.setValue(Boolean.TRUE);
+            if (log.isDebugEnabled()) {
+                log.debug("Enabling MTOM via annotation.");
+            }
+    	    enableMTOM.setValue(Boolean.TRUE);
     	}
+        
+        //Set the threshold value.
+        if (mtomAnnoation.threshold() > 0) {
+            if (log.isDebugEnabled()) {
+                log.debug("Setting MTOM threshold to [" + mtomAnnoation.threshold() + "].");
+            }
+            threshold.setValue(mtomAnnoation.threshold());
+        }
     	
     	try {
-    		service.addParameter(enableMTOM);
+    	    service.addParameter(enableMTOM);
+            service.addParameter(threshold);
     	}
     	catch (Exception e) {
             //TODO NLS enable.

Added: webservices/axis2/branches/java/jaxws21/modules/metadata/test/org/apache/axis2/jaxws/description/feature/MTOMFeatureTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/metadata/test/org/apache/axis2/jaxws/description/feature/MTOMFeatureTests.java?rev=614296&view=auto
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/metadata/test/org/apache/axis2/jaxws/description/feature/MTOMFeatureTests.java
(added)
+++ webservices/axis2/branches/java/jaxws21/modules/metadata/test/org/apache/axis2/jaxws/description/feature/MTOMFeatureTests.java
Tue Jan 22 11:36:04 2008
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.description.feature;
+
+import org.apache.axis2.jaxws.description.DescriptionFactory;
+import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.soap.MTOM;
+
+import junit.framework.TestCase;
+
+public class MTOMFeatureTests extends TestCase {
+    
+    private static final String ns = "http://jaxws.axis2.apache.org/metadata/feature/mtom";
+    
+    private static final String defaultServicePortName = "DefaultServicePort";
+    private static final String plainServicePortName = "PlainServicePort";
+    private static final String disabledServicePortName = "DisabledServicePort";
+    private static final String thresholdServicePortName = "ThresholdServicePort";
+    private static final String badThresholdServicePortName = "BadThresholdServicePort";
+    
+    public void testNoAnnotation() {
+        ServiceDescription sd = DescriptionFactory.createServiceDescription(DefaultService.class);
+        
+        EndpointDescription ed = sd.getEndpointDescription(new QName(ns, defaultServicePortName));
+        assertTrue("The EndpointDescription should not be null.", ed != null);
+        
+        boolean mtomEnabled = ed.isMTOMEnabled();
+        assertTrue("MTOM should not be enabled by default", mtomEnabled == false);
+    }
+    
+    public void testPlainAnnotation() {
+        ServiceDescription sd = DescriptionFactory.createServiceDescription(PlainService.class);
+        
+        EndpointDescription ed = sd.getEndpointDescription(new QName(ns, plainServicePortName));
+        assertTrue("The EndpointDescription should not be null.", ed != null);
+        
+        boolean mtomEnabled = ed.isMTOMEnabled();
+        assertTrue("@MTOM included, but was not enabled.", mtomEnabled == true);
+        
+        int threshold = ed.getMTOMThreshold();
+        assertTrue("MTOM threshold should be 0 or less.", threshold <= 0);
+    }
+    
+    public void testDisabled() {
+        ServiceDescription sd = DescriptionFactory.createServiceDescription(DisabledService.class);
+        
+        EndpointDescription ed = sd.getEndpointDescription(new QName(ns, disabledServicePortName));
+        assertTrue("The EndpointDescription should not be null.", ed != null);
+        
+        boolean mtomEnabled = ed.isMTOMEnabled();
+        assertTrue("@MTOM included, and should be disabled.", mtomEnabled == false);
+    }
+    
+    public void testThreshold() {
+        ServiceDescription sd = DescriptionFactory.createServiceDescription(ThresholdService.class);
+        
+        EndpointDescription ed = sd.getEndpointDescription(new QName(ns, thresholdServicePortName));
+        assertTrue("The EndpointDescription should not be null.", ed != null);
+        
+        int threshold = ed.getMTOMThreshold();
+        assertTrue("MTOM threshold should be 2000.", threshold == 20000);
+    }
+    
+    public void testBadThreshold() {
+        ServiceDescription sd = DescriptionFactory.createServiceDescription(BadThresholdService.class);
+        
+        EndpointDescription ed = sd.getEndpointDescription(new QName(ns, badThresholdServicePortName));
+        assertTrue("The EndpointDescription should not be null.", ed != null);
+        
+        int threshold = ed.getMTOMThreshold();
+        assertTrue("MTOM threshold should be [0], but was [" + threshold + "].", threshold
== 0);
+    }
+    
+    @WebService(targetNamespace=ns, portName=defaultServicePortName)
+    class DefaultService {
+        public double getQuote(String symbol) {
+            return 101.01;
+        }
+    }
+    
+    @WebService(targetNamespace=ns, portName=plainServicePortName)
+    @MTOM
+    class PlainService {
+        public double getQuote(String symbol) {
+            return 101.01;
+        }
+    }
+    
+    @WebService(targetNamespace=ns, portName=disabledServicePortName)
+    @MTOM(enabled=false)
+    class DisabledService {
+        public double getQuote(String symbol) {
+            return 101.01;
+        }
+    }
+    
+    @WebService(targetNamespace=ns, portName=thresholdServicePortName)
+    @MTOM(threshold=20000)
+    class ThresholdService {
+        public double getQuote(String symbol) {
+            return 101.01;
+        }
+    }
+    
+    @WebService(targetNamespace=ns, portName=badThresholdServicePortName)
+    @MTOM(threshold=-1000)
+    class BadThresholdService {
+        public double getQuote(String symbol) {
+            return 101.01;
+        }
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message