You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2015/11/20 21:25:13 UTC

svn commit: r1715411 - in /axis/axis2/java/core/branches/1_6: ./ modules/jaxws/ modules/jaxws/pom.xml modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java

Author: veithen
Date: Fri Nov 20 20:25:13 2015
New Revision: 1715411

URL: http://svn.apache.org/viewvc?rev=1715411&view=rev
Log:
Merge r1715078, r1715079 and r1715120 to the 1.6 branch to collect more information about a sporadic test failure.

Modified:
    axis/axis2/java/core/branches/1_6/   (props changed)
    axis/axis2/java/core/branches/1_6/modules/jaxws/   (props changed)
    axis/axis2/java/core/branches/1_6/modules/jaxws/pom.xml
    axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java   (contents, props changed)

Propchange: axis/axis2/java/core/branches/1_6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 20 20:25:13 2015
@@ -1 +1 @@
-/axis/axis2/java/core/trunk:1068985,1069659,1069898,1070439,1072077,1072271,1072296,1072499,1072510,1075057,1078242,1081563,1081587,1081590,1082316,1082322,1082600,1082702,1082726,1082738,1083180,1083192,1083379,1083381,1083425,1083433,1083446,1084753,1085157,1085173,1085514,1085889,1085927,1085931,1087073,1088239,1088248-1088249,1088251,1088268,1088730,1088904,1089225,1089989,1090429,1090457,1091178,1091191,1094117,1096134,1096136,1096530,1096557,1099385,1099389,1100628,1101037,1103013,1103336,1103606,1103760,1127327,1128580,1128584,1128618,1128645,1130590,1131425,1134438,1134616,1136156,1136159,1136177,1137153,1137159,1138144,1138203,1139448,1139484,1147485,1149224,1149491,1149578,1150055,1153072,1154615,1156305,1156382,1157211,1157265,1157373,1157415,1157424,1157501,1157517,1157522,1157535,1157767,1162649,1163389,1166038,1166040,1166132,1167045,1173869,1174618,1184808,1184810,1184816,1185504,1190469,1190499,1195893,1195972,1195982,1198288,1201467,1201863,1201957,1202867,1203424,1
 205716,1205939,1208901,1209034,1213180,1213639,1214118,1220630,1220888,1221716,1222510,1225161,1231465,1231470,1241031,1242238,1242249,1242511,1243469,1243831,1290999,1291158,1294991,1295084,1295479,1296159,1297132,1297344,1297348,1297744,1297765,1298550,1298688,1299356,1299392,1299645,1299667,1300358,1305728,1307410,1326968,1327005,1328228,1328733,1328921,1329084,1331616,1332362,1332402,1332545,1332587,1337975,1340970,1341090,1341780,1341805,1343353,1343543,1348340,1351218,1352413,1352423,1352428,1354438,1354834,1355706,1355710,1356080,1358413,1358494,1358508,1358691,1359499,1359504,1360573,1362377,1364536,1372622,1382245,1383043,1384482,1409145,1409389,1410313,1410499,1410577,1426464,1426467,1426469,1434104,1435330,1438985,1441907,1442712,1443222,1479068,1479351,1480969,1509409,1509438,1510122,1576937,1577055,1577119,1577125,1577191,1577342-1577345,1577347-1577348,1593690,1593765,1594378,1594701,1601455,1608843,1609578,1609866,1621171-1621172,1626559,1631608,1649688,1677432,168382
 7,1683831,1686316,1686321,1686538,1686544,1686553,1686630,1686643,1686742,1687894-1687895,1687902,1687961,1693147,1693802,1693808,1694745,1697181,1697205,1697514,1701352,1701354,1702667,1702678,1709481,1715061
+/axis/axis2/java/core/trunk:1068985,1069659,1069898,1070439,1072077,1072271,1072296,1072499,1072510,1075057,1078242,1081563,1081587,1081590,1082316,1082322,1082600,1082702,1082726,1082738,1083180,1083192,1083379,1083381,1083425,1083433,1083446,1084753,1085157,1085173,1085514,1085889,1085927,1085931,1087073,1088239,1088248-1088249,1088251,1088268,1088730,1088904,1089225,1089989,1090429,1090457,1091178,1091191,1094117,1096134,1096136,1096530,1096557,1099385,1099389,1100628,1101037,1103013,1103336,1103606,1103760,1127327,1128580,1128584,1128618,1128645,1130590,1131425,1134438,1134616,1136156,1136159,1136177,1137153,1137159,1138144,1138203,1139448,1139484,1147485,1149224,1149491,1149578,1150055,1153072,1154615,1156305,1156382,1157211,1157265,1157373,1157415,1157424,1157501,1157517,1157522,1157535,1157767,1162649,1163389,1166038,1166040,1166132,1167045,1173869,1174618,1184808,1184810,1184816,1185504,1190469,1190499,1195893,1195972,1195982,1198288,1201467,1201863,1201957,1202867,1203424,1
 205716,1205939,1208901,1209034,1213180,1213639,1214118,1220630,1220888,1221716,1222510,1225161,1231465,1231470,1241031,1242238,1242249,1242511,1243469,1243831,1290999,1291158,1294991,1295084,1295479,1296159,1297132,1297344,1297348,1297744,1297765,1298550,1298688,1299356,1299392,1299645,1299667,1300358,1305728,1307410,1326968,1327005,1328228,1328733,1328921,1329084,1331616,1332362,1332402,1332545,1332587,1337975,1340970,1341090,1341780,1341805,1343353,1343543,1348340,1351218,1352413,1352423,1352428,1354438,1354834,1355706,1355710,1356080,1358413,1358494,1358508,1358691,1359499,1359504,1360573,1362377,1364536,1372622,1382245,1383043,1384482,1409145,1409389,1410313,1410499,1410577,1426464,1426467,1426469,1434104,1435330,1438985,1441907,1442712,1443222,1479068,1479351,1480969,1509409,1509438,1510122,1576937,1577055,1577119,1577125,1577191,1577342-1577345,1577347-1577348,1593690,1593765,1594378,1594701,1601455,1608843,1609578,1609866,1621171-1621172,1626559,1631608,1649688,1677432,168382
 7,1683831,1686316,1686321,1686538,1686544,1686553,1686630,1686643,1686742,1687894-1687895,1687902,1687961,1693147,1693802,1693808,1694745,1697181,1697205,1697514,1701352,1701354,1702667,1702678,1709481,1715061,1715078-1715079,1715120

Propchange: axis/axis2/java/core/branches/1_6/modules/jaxws/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 20 20:25:13 2015
@@ -1 +1 @@
-/axis/axis2/java/core/trunk/modules/jaxws:1068985,1069659,1069898,1070439,1072077,1072271,1072296,1072499,1072510,1075057,1078242,1081563,1081587,1081590,1082316,1082322,1082600,1082702,1082726,1082738,1083180,1083192,1083379,1083381,1083425,1083433,1083446,1084753,1085157,1085173,1085514,1085889,1085927,1085931,1087073,1088239,1088248-1088249,1088251,1088268,1088730,1088904,1089225,1089989,1090429,1090457,1091178,1091191,1094117,1096134,1096136,1096530,1096557,1099385,1099389,1100628,1101037,1103013,1103336,1103606,1103760,1127327,1128580,1128584,1128618,1128645,1130590,1131425,1134438,1134616,1136156,1136159,1136177,1137153,1137159,1138144,1138203,1139448,1139484,1147485,1149224,1149491,1149578,1150055,1153072,1154615,1156305,1156382,1157211,1157265,1157373,1157415,1157424,1157501,1157517,1157522,1157535,1157767,1162649,1163389,1166038,1166040,1166132,1167045,1173869,1174618,1184808,1184810,1184816,1185504,1190469,1190499,1195893,1195972,1195982,1198288,1201467,1201863,1201957,120
 2867,1203424,1205716,1205939,1208901,1209034,1213180,1213639,1214118,1220630,1220888,1221716,1222510,1225161,1231465,1231470,1241031,1242238,1242249,1242511,1243469,1243831,1290999,1291158,1294991,1295084,1295479,1296159,1297132,1297344,1297348,1297744,1297765,1298550,1298688,1299356,1299392,1299645,1299667,1300358,1305728,1307410,1326968,1327005,1328228,1328733,1328921,1329084,1331616,1332362,1332402,1332545,1332587,1337975,1340970,1341090,1341780,1341805,1343353,1343543,1348340,1351218,1352413,1352423,1354438,1354834,1355706,1355710,1356080,1358413,1358494,1358508,1358691,1359499,1359504,1360573,1362377,1364536,1372622,1382245,1383043,1384482,1409145,1409389,1410313,1410499,1410577,1426464,1426467,1426469,1434104,1435330,1438985,1441907,1442712,1479068,1479351,1480969,1509409,1509438,1510122,1576937,1577055,1577119,1577125,1577191,1577342-1577345,1577347-1577348,1593690,1593765,1594378,1594701,1601455-1601456,1608843,1609578,1609866,1649688,1683827,1683831,1686316,1701352,1701354
+/axis/axis2/java/core/trunk/modules/jaxws:1068985,1069659,1069898,1070439,1072077,1072271,1072296,1072499,1072510,1075057,1078242,1081563,1081587,1081590,1082316,1082322,1082600,1082702,1082726,1082738,1083180,1083192,1083379,1083381,1083425,1083433,1083446,1084753,1085157,1085173,1085514,1085889,1085927,1085931,1087073,1088239,1088248-1088249,1088251,1088268,1088730,1088904,1089225,1089989,1090429,1090457,1091178,1091191,1094117,1096134,1096136,1096530,1096557,1099385,1099389,1100628,1101037,1103013,1103336,1103606,1103760,1127327,1128580,1128584,1128618,1128645,1130590,1131425,1134438,1134616,1136156,1136159,1136177,1137153,1137159,1138144,1138203,1139448,1139484,1147485,1149224,1149491,1149578,1150055,1153072,1154615,1156305,1156382,1157211,1157265,1157373,1157415,1157424,1157501,1157517,1157522,1157535,1157767,1162649,1163389,1166038,1166040,1166132,1167045,1173869,1174618,1184808,1184810,1184816,1185504,1190469,1190499,1195893,1195972,1195982,1198288,1201467,1201863,1201957,120
 2867,1203424,1205716,1205939,1208901,1209034,1213180,1213639,1214118,1220630,1220888,1221716,1222510,1225161,1231465,1231470,1241031,1242238,1242249,1242511,1243469,1243831,1290999,1291158,1294991,1295084,1295479,1296159,1297132,1297344,1297348,1297744,1297765,1298550,1298688,1299356,1299392,1299645,1299667,1300358,1305728,1307410,1326968,1327005,1328228,1328733,1328921,1329084,1331616,1332362,1332402,1332545,1332587,1337975,1340970,1341090,1341780,1341805,1343353,1343543,1348340,1351218,1352413,1352423,1354438,1354834,1355706,1355710,1356080,1358413,1358494,1358508,1358691,1359499,1359504,1360573,1362377,1364536,1372622,1382245,1383043,1384482,1409145,1409389,1410313,1410499,1410577,1426464,1426467,1426469,1434104,1435330,1438985,1441907,1442712,1479068,1479351,1480969,1509409,1509438,1510122,1576937,1577055,1577119,1577125,1577191,1577342-1577345,1577347-1577348,1593690,1593765,1594378,1594701,1601455-1601456,1608843,1609578,1609866,1649688,1683827,1683831,1686316,1701352,1701354,
 1715078-1715079,1715120

Modified: axis/axis2/java/core/branches/1_6/modules/jaxws/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/jaxws/pom.xml?rev=1715411&r1=1715410&r2=1715411&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/jaxws/pom.xml (original)
+++ axis/axis2/java/core/branches/1_6/modules/jaxws/pom.xml Fri Nov 20 20:25:13 2015
@@ -115,6 +115,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>xml-truth</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>log4j</groupId>
             <artifactId>log4j</artifactId>
             <scope>test</scope>

Modified: axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java?rev=1715411&r1=1715410&r2=1715411&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java (original)
+++ axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java Fri Nov 20 20:25:13 2015
@@ -1,225 +1,228 @@
-/*
- * 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.handler;
-
-import junit.framework.TestCase;
-import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.handler.factory.HandlerPostInvokerFactory;
-import org.apache.axis2.jaxws.handler.factory.HandlerPreInvokerFactory;
-import org.apache.axis2.jaxws.message.Block;
-import org.apache.axis2.jaxws.message.Message;
-import org.apache.axis2.jaxws.message.Protocol;
-import org.apache.axis2.jaxws.message.factory.MessageFactory;
-import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
-import org.apache.axis2.jaxws.registry.FactoryRegistry;
-
-import javax.xml.ws.handler.Handler;
-import javax.xml.ws.handler.soap.SOAPHandler;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-import java.util.ArrayList;
-import java.util.Set;
-
-/**
- * HandlerPrePostInvokerTests verifies that the mechanisms for finding the implementation classes to 
- * call before and after handler.handleMessage work, and that the calls are actually made.  Simple as that.
- */
-public class HandlerPrePostInvokerTests extends TestCase {
-
-	private MessageContext mc = null;
-	private boolean preInvokerCalled = false;
-	private boolean postInvokerCalled = false;
-    private boolean messageAccessed = false;
-	
-	private static final String soap11env = "http://schemas.xmlsoap.org/soap/envelope/";
-	
-    public static final String SOAP11_ENVELOPE = 
-        "<?xml version='1.0' encoding='utf-8'?>" + 
-        "<soapenv:Envelope xmlns:soapenv=\"" + soap11env + "\">" +
-        "<soapenv:Header />" + 
-        "<soapenv:Body>" +
-        "</soapenv:Body>" + 
-        "</soapenv:Envelope>";
-
-	@Override
-	protected void setUp() throws Exception {
-
-        // Create a SOAP 1.1 Message and MessageContext
-		// I just grabbed this code from the JAXWS MessageTests
-        MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
-        Message m = mf.create(Protocol.soap11);
-        XMLStringBlockFactory f =
-                (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
-        Block block = f.createFrom(SOAP11_ENVELOPE, null, null);
-        m.setBodyBlock(block);
-
-        mc = new MessageContext();
-        mc.setMessage(m);
-        mc.setMEPContext(new MEPContext(mc));
-	}
-
-	/**
-	 * make sure the defaults are as expected
-	 *
-	 */
-	public void testFactoryRegistry() {
-		HandlerPreInvokerFactory preFact = (HandlerPreInvokerFactory)FactoryRegistry.getFactory(HandlerPreInvokerFactory.class);
-		HandlerPostInvokerFactory postFact = (HandlerPostInvokerFactory)FactoryRegistry.getFactory(HandlerPostInvokerFactory.class);
-		HandlerPreInvoker preInvoker = preFact.createHandlerPreInvoker();
-		HandlerPostInvoker postInvoker = postFact.createHandlerPostInvoker();
-		assertTrue("preInvoker should be instanceof " + org.apache.axis2.jaxws.handler.impl.HandlerPreInvokerImpl.class.getCanonicalName(), preInvoker instanceof org.apache.axis2.jaxws.handler.impl.HandlerPreInvokerImpl);
-		assertTrue("postInvoker should be instanceof " + org.apache.axis2.jaxws.handler.impl.HandlerPostInvokerImpl.class.getCanonicalName(), postInvoker instanceof org.apache.axis2.jaxws.handler.impl.HandlerPostInvokerImpl);
-	}
-	
-	/**
-	 * make sure the registered factories are used, and the calls are made in the places we expect
-	 *
-	 */
-	public void testFactoryPrePost() {
-		
-		FactoryRegistry.setFactory(HandlerPreInvokerFactory.class, new HandlerPreInvokerFactoryImpl());
-		FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, new HandlerPostInvokerFactoryImpl());
-		
-		ArrayList<Handler> handlers = new ArrayList<Handler>();
-		handlers.add(new SOAPHandler1());
-        HandlerChainProcessor processor =
-                new HandlerChainProcessor(handlers, Protocol.soap11);
-        boolean success = true;
-        try {
-            // server-side incoming request
-            success = processor.processChain(mc.getMEPContext(),
-                                    HandlerChainProcessor.Direction.IN,
-                                    HandlerChainProcessor.MEP.REQUEST,
-                                    true);
-        } catch (Exception e) {
-            assertNull(e);  // should not get exception
-        }
-        
-        assertTrue("processChain should have succeeded", success);
-        assertTrue("preInvoker should have been called", preInvokerCalled);
-        assertTrue("postInvoker should have been called", postInvokerCalled);
-        assertTrue("Handler did not access message but messageAccessed property is true.", !messageAccessed);
-
-	}
-
-    public void testPostInvokerMessageAccessed() {
-        
-        FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, new HandlerPostInvokerFactoryImpl());
-        
-        ArrayList<Handler> handlers = new ArrayList<Handler>();
-        handlers.add(new SOAPHandlerGetsMessage());
-        HandlerChainProcessor processor =
-                new HandlerChainProcessor(handlers, Protocol.soap11);
-        boolean success = true;
-        try {
-            // server-side incoming request
-            success = processor.processChain(mc.getMEPContext(),
-                                    HandlerChainProcessor.Direction.IN,
-                                    HandlerChainProcessor.MEP.REQUEST,
-                                    true);
-        } catch (Exception e) {
-            assertNull(e);  // should not get exception
-        }
-        
-        assertTrue("processChain should have succeeded", success);
-        assertTrue("postInvoker should have been called", postInvokerCalled);
-        assertTrue("Handler did access message but messageAccessed property is false.", messageAccessed);
-
-
-    }
-
-    /*****************************************
-     * Classes needed for junit testcase     *
-     *****************************************/
-    
-    private class SOAPHandler1 implements SOAPHandler<SOAPMessageContext> {
-
-        public Set getHeaders() {
-            return null;
-        }
-
-        public void close(javax.xml.ws.handler.MessageContext messagecontext) {
-        }
-
-        public boolean handleFault(SOAPMessageContext messagecontext) {
-            return true;
-        }
-
-        public boolean handleMessage(SOAPMessageContext messagecontext) {
-            return true;
-        }
-
-    }
-    /*****************************************
-     * Classes needed for junit testcase     *
-     *****************************************/
-    
-    private class SOAPHandlerGetsMessage implements SOAPHandler<SOAPMessageContext> {
-
-        public Set getHeaders() {
-            return null;
-        }
-
-        public void close(javax.xml.ws.handler.MessageContext messagecontext) {
-        }
-
-        public boolean handleFault(SOAPMessageContext messagecontext) {
-            return true;
-        }
-
-        public boolean handleMessage(SOAPMessageContext messagecontext) {
-            messagecontext.getMessage();
-            return true;
-        }
-
-    }
-    
-    private class HandlerPreInvokerFactoryImpl implements HandlerPreInvokerFactory {
-		public HandlerPreInvoker createHandlerPreInvoker() {
-			return new HandlerPreInvokerImpl();
-		}
-    }
-    
-    private class HandlerPostInvokerFactoryImpl implements HandlerPostInvokerFactory {
-    	public HandlerPostInvoker createHandlerPostInvoker() {
-    		return new HandlerPostInvokerImpl();
-    	}
-    }
-    
-    private class HandlerPreInvokerImpl implements HandlerPreInvoker {
-		public void preInvoke(javax.xml.ws.handler.MessageContext mc) {
-			preInvokerCalled = true;
-		}
-    }
-    
-    private class HandlerPostInvokerImpl implements HandlerPostInvoker {
-		public void postInvoke(javax.xml.ws.handler.MessageContext mc) {
-			postInvokerCalled = true;
-            if (mc instanceof SoapMessageContext) {
-                SoapMessageContext smc = (SoapMessageContext) mc;
-                // PK96521 - before getting the message (which is expensive) check first to 
-                // see if it was actually accessed by the handlers
-                messageAccessed = false;
-                if (smc.containsKey("jaxws.isMessageAccessed")) {
-                    messageAccessed = (Boolean)(smc.get("jaxws.isMessageAccessed"));
-                }
-            }
-		}
-    }
-}
+/*
+ * 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.handler;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.handler.factory.HandlerPostInvokerFactory;
+import org.apache.axis2.jaxws.handler.factory.HandlerPreInvokerFactory;
+import org.apache.axis2.jaxws.message.Block;
+import org.apache.axis2.jaxws.message.Message;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+/**
+ * HandlerPrePostInvokerTests verifies that the mechanisms for finding the implementation classes to 
+ * call before and after handler.handleMessage work, and that the calls are actually made.  Simple as that.
+ */
+public class HandlerPrePostInvokerTests extends TestCase {
+
+    private MessageContext mc = null;
+    private boolean preInvokerCalled = false;
+    private boolean postInvokerCalled = false;
+    private boolean messageAccessed = false;
+    
+    private static final String soap11env = "http://schemas.xmlsoap.org/soap/envelope/";
+    
+    public static final String SOAP11_ENVELOPE = 
+        "<?xml version='1.0' encoding='utf-8'?>" + 
+        "<soapenv:Envelope xmlns:soapenv=\"" + soap11env + "\">" +
+        "<soapenv:Header />" + 
+        "<soapenv:Body>" +
+        "</soapenv:Body>" + 
+        "</soapenv:Envelope>";
+
+    @Override
+    protected void setUp() throws Exception {
+
+        // Create a SOAP 1.1 Message and MessageContext
+        // I just grabbed this code from the JAXWS MessageTests
+        MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap11);
+        XMLStringBlockFactory f =
+                (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        Block block = f.createFrom(SOAP11_ENVELOPE, null, null);
+        m.setBodyBlock(block);
+
+        mc = new MessageContext();
+        mc.setMessage(m);
+        mc.setMEPContext(new MEPContext(mc));
+    }
+
+    /**
+     * make sure the defaults are as expected
+     *
+     */
+    public void testFactoryRegistry() {
+        HandlerPreInvokerFactory preFact = (HandlerPreInvokerFactory)FactoryRegistry.getFactory(HandlerPreInvokerFactory.class);
+        HandlerPostInvokerFactory postFact = (HandlerPostInvokerFactory)FactoryRegistry.getFactory(HandlerPostInvokerFactory.class);
+        HandlerPreInvoker preInvoker = preFact.createHandlerPreInvoker();
+        HandlerPostInvoker postInvoker = postFact.createHandlerPostInvoker();
+        assertThat(preInvoker).named("preInvoker").isInstanceOf(org.apache.axis2.jaxws.handler.impl.HandlerPreInvokerImpl.class);
+        assertThat(postInvoker).named("postInvoker").isInstanceOf(org.apache.axis2.jaxws.handler.impl.HandlerPostInvokerImpl.class);
+    }
+    
+    /**
+     * make sure the registered factories are used, and the calls are made in the places we expect
+     *
+     */
+    public void testFactoryPrePost() {
+        
+        FactoryRegistry.setFactory(HandlerPreInvokerFactory.class, new HandlerPreInvokerFactoryImpl());
+        FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, new HandlerPostInvokerFactoryImpl());
+        
+        ArrayList<Handler> handlers = new ArrayList<Handler>();
+        handlers.add(new SOAPHandler1());
+        HandlerChainProcessor processor =
+                new HandlerChainProcessor(handlers, Protocol.soap11);
+        boolean success = true;
+        try {
+            // server-side incoming request
+            success = processor.processChain(mc.getMEPContext(),
+                                    HandlerChainProcessor.Direction.IN,
+                                    HandlerChainProcessor.MEP.REQUEST,
+                                    true);
+        } catch (Exception e) {
+            assertNull(e);  // should not get exception
+        }
+        
+        assertTrue("processChain should have succeeded", success);
+        assertTrue("preInvoker should have been called", preInvokerCalled);
+        assertTrue("postInvoker should have been called", postInvokerCalled);
+        assertTrue("Handler did not access message but messageAccessed property is true.", !messageAccessed);
+
+    }
+
+    public void testPostInvokerMessageAccessed() {
+        
+        FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, new HandlerPostInvokerFactoryImpl());
+        
+        ArrayList<Handler> handlers = new ArrayList<Handler>();
+        handlers.add(new SOAPHandlerGetsMessage());
+        HandlerChainProcessor processor =
+                new HandlerChainProcessor(handlers, Protocol.soap11);
+        boolean success = true;
+        try {
+            // server-side incoming request
+            success = processor.processChain(mc.getMEPContext(),
+                                    HandlerChainProcessor.Direction.IN,
+                                    HandlerChainProcessor.MEP.REQUEST,
+                                    true);
+        } catch (Exception e) {
+            assertNull(e);  // should not get exception
+        }
+        
+        assertTrue("processChain should have succeeded", success);
+        assertTrue("postInvoker should have been called", postInvokerCalled);
+        assertTrue("Handler did access message but messageAccessed property is false.", messageAccessed);
+
+
+    }
+
+    /*****************************************
+     * Classes needed for junit testcase     *
+     *****************************************/
+    
+    private class SOAPHandler1 implements SOAPHandler<SOAPMessageContext> {
+
+        public Set getHeaders() {
+            return null;
+        }
+
+        public void close(javax.xml.ws.handler.MessageContext messagecontext) {
+        }
+
+        public boolean handleFault(SOAPMessageContext messagecontext) {
+            return true;
+        }
+
+        public boolean handleMessage(SOAPMessageContext messagecontext) {
+            return true;
+        }
+
+    }
+    /*****************************************
+     * Classes needed for junit testcase     *
+     *****************************************/
+    
+    private class SOAPHandlerGetsMessage implements SOAPHandler<SOAPMessageContext> {
+
+        public Set getHeaders() {
+            return null;
+        }
+
+        public void close(javax.xml.ws.handler.MessageContext messagecontext) {
+        }
+
+        public boolean handleFault(SOAPMessageContext messagecontext) {
+            return true;
+        }
+
+        public boolean handleMessage(SOAPMessageContext messagecontext) {
+            messagecontext.getMessage();
+            return true;
+        }
+
+    }
+    
+    private class HandlerPreInvokerFactoryImpl implements HandlerPreInvokerFactory {
+        public HandlerPreInvoker createHandlerPreInvoker() {
+            return new HandlerPreInvokerImpl();
+        }
+    }
+    
+    private class HandlerPostInvokerFactoryImpl implements HandlerPostInvokerFactory {
+        public HandlerPostInvoker createHandlerPostInvoker() {
+            return new HandlerPostInvokerImpl();
+        }
+    }
+    
+    private class HandlerPreInvokerImpl implements HandlerPreInvoker {
+        public void preInvoke(javax.xml.ws.handler.MessageContext mc) {
+            preInvokerCalled = true;
+        }
+    }
+    
+    private class HandlerPostInvokerImpl implements HandlerPostInvoker {
+        public void postInvoke(javax.xml.ws.handler.MessageContext mc) {
+            postInvokerCalled = true;
+            if (mc instanceof SoapMessageContext) {
+                SoapMessageContext smc = (SoapMessageContext) mc;
+                // PK96521 - before getting the message (which is expensive) check first to 
+                // see if it was actually accessed by the handlers
+                messageAccessed = false;
+                if (smc.containsKey("jaxws.isMessageAccessed")) {
+                    messageAccessed = (Boolean)(smc.get("jaxws.isMessageAccessed"));
+                }
+            }
+        }
+    }
+}

Propchange: axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java
------------------------------------------------------------------------------
    svn:eol-style = native