You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ba...@apache.org on 2009/09/23 00:46:32 UTC
svn commit: r817877 - in /webservices/axis2/trunk/java/modules/jaxws:
src/org/apache/axis2/jaxws/message/impl/ test-resources/
test/org/apache/axis2/jaxws/message/impl/
Author: barrettj
Date: Tue Sep 22 22:46:32 2009
New Revision: 817877
URL: http://svn.apache.org/viewvc?rev=817877&view=rev
Log:
Don't NPE if the transport headers collection contains a null value. Add test for same.
Also, turn off debug when running JAXWS tests.
Added:
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/impl/
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/impl/MessageImplTest.java
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java
webservices/axis2/trunk/java/modules/jaxws/test-resources/log4j.properties
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java?rev=817877&r1=817876&r2=817877&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java Tue Sep 22 22:46:32 2009
@@ -223,7 +223,14 @@
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
String key = (String) entry.getKey();
- if (entry.getValue() instanceof String) {
+ if (entry.getValue() == null) {
+ // This is not necessarily a problem; log it and make sure not to NPE
+ if (log.isDebugEnabled()) {
+ log.debug(" Not added to transport header. header =" + key +
+ " because value is null;");
+ }
+ }
+ else if (entry.getValue() instanceof String) {
// Normally there is one value per key
if (log.isDebugEnabled()) {
log.debug(" add transport header. header =" + key +
Modified: webservices/axis2/trunk/java/modules/jaxws/test-resources/log4j.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test-resources/log4j.properties?rev=817877&r1=817876&r2=817877&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test-resources/log4j.properties (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test-resources/log4j.properties Tue Sep 22 22:46:32 2009
@@ -28,7 +28,7 @@
# The example below adds debug trace for StAXUtils or jaxws server to
# the axis2.small.log.
# You can add this without changing the root category.
-log4j.category.org.apache.axis2.jaxws.message=DEBUG, SMALL
+#log4j.category.org.apache.axis2.jaxws.message=DEBUG, SMALL
# Enable the following to get JAXWS TestLogger trace.
#log4j.category.JAXWS-Tests=DEBUG, SMALL
Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/impl/MessageImplTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/impl/MessageImplTest.java?rev=817877&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/impl/MessageImplTest.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/impl/MessageImplTest.java Tue Sep 22 22:46:32 2009
@@ -0,0 +1,60 @@
+package org.apache.axis2.jaxws.message.impl;
+
+/*
+ * 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.
+ */
+
+import org.apache.axis2.jaxws.message.Message;
+import org.apache.axis2.jaxws.message.Protocol;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.ws.WebServiceException;
+
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+/**
+ * Test some low-level specifics of the MessageImpl class. Note that this is testing specific
+ * low level methods and IS NOT representative of the way MessageImpl should be used.
+ * The MessageFactory should be used to create MessageImpl instances.
+ */
+public class MessageImplTest extends TestCase {
+
+ /**
+ * Verify that if the TransportHeaders Map contains keys with null values that it doesn't
+ * cause any problems in the getAsSOAPMessage() method.
+ */
+ public void testGetAsSOAPMessageTransportHeadersWithNullValues() {
+ try {
+ Message msg = new MessageImpl(Protocol.soap11);
+ HashMap map = new HashMap();
+ map.put("key1", null);
+ map.put("key2", null);
+ msg.setMimeHeaders(map);
+ msg.getAsSOAPMessage();
+ } catch (WebServiceException e) {
+ e.printStackTrace();
+ fail("Caught unexpected exception " + e.toString());
+ } catch (XMLStreamException e) {
+ e.printStackTrace();
+ fail("Caught unexpected exception " + e.toString());
+ }
+ }
+
+}