Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 8995 invoked from network); 30 Mar 2010 20:36:24 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Mar 2010 20:36:24 -0000 Received: (qmail 84624 invoked by uid 500); 30 Mar 2010 20:36:24 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 84582 invoked by uid 500); 30 Mar 2010 20:36:24 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 84575 invoked by uid 99); 30 Mar 2010 20:36:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Mar 2010 20:36:24 +0000 X-ASF-Spam-Status: No, hits=-1043.5 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Mar 2010 20:36:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 92B0E2388A36; Tue, 30 Mar 2010 20:36:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r929263 - in /cxf/trunk/rt/core/src: main/java/org/apache/cxf/databinding/source/ test/java/org/apache/cxf/interceptor/ test/resources/org/apache/cxf/interceptor/resources/ Date: Tue, 30 Mar 2010 20:36:02 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100330203602.92B0E2388A36@eris.apache.org> Author: dkulp Date: Tue Mar 30 20:36:02 2010 New Revision: 929263 URL: http://svn.apache.org/viewvc?rev=929263&view=rev Log: [CXF-2732] In source databinding, consume the END_ELEMENT event to match the other databindings Added: cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/DocLiteralInInterceptorTest.java cxf/trunk/rt/core/src/test/resources/org/apache/cxf/interceptor/resources/multiPartDocLitBareReq.xml Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java?rev=929263&r1=929262&r2=929263&view=diff ============================================================================== --- cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java (original) +++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java Tue Mar 30 20:36:02 2010 @@ -213,6 +213,10 @@ public class XMLStreamDataReader impleme return o; } else { Document document = StaxUtils.read(reader); + if (reader.hasNext()) { + //need to actually consume the END_ELEMENT + reader.next(); + } return new DOMSource(document); } } catch (XMLStreamException e) { Added: cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/DocLiteralInInterceptorTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/DocLiteralInInterceptorTest.java?rev=929263&view=auto ============================================================================== --- cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/DocLiteralInInterceptorTest.java (added) +++ cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/DocLiteralInInterceptorTest.java Tue Mar 30 20:36:02 2010 @@ -0,0 +1,152 @@ +/** + * 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.cxf.interceptor; + +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import javax.xml.transform.dom.DOMSource; + +import org.apache.cxf.databinding.source.SourceDataBinding; +import org.apache.cxf.endpoint.Endpoint; +import org.apache.cxf.message.Exchange; +import org.apache.cxf.message.ExchangeImpl; +import org.apache.cxf.message.Message; +import org.apache.cxf.message.MessageContentsList; +import org.apache.cxf.message.MessageImpl; +import org.apache.cxf.service.Service; +import org.apache.cxf.service.model.BindingInfo; +import org.apache.cxf.service.model.BindingOperationInfo; +import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.service.model.InterfaceInfo; +import org.apache.cxf.service.model.MessageInfo; +import org.apache.cxf.service.model.MessageInfo.Type; +import org.apache.cxf.service.model.MessagePartInfo; +import org.apache.cxf.service.model.OperationInfo; +import org.apache.cxf.service.model.ServiceInfo; +import org.apache.cxf.staxutils.PartialXMLStreamReader; +import org.apache.cxf.staxutils.StaxUtils; +import org.easymock.classextension.EasyMock; +import org.easymock.classextension.IMocksControl; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Unit test for testing DocLiteralInInterceptor to use Source Data Binding + * + */ +public class DocLiteralInInterceptorTest extends Assert { + + protected IMocksControl control; + + @Before + public void setUp() throws Exception { + control = EasyMock.createNiceControl(); + } + + @After + public void tearDown() throws Exception { + control.verify(); + } + + @Test + public void testUnmarshalSourceData() throws Exception { + XMLStreamReader reader = StaxUtils.createXMLStreamReader(getClass() + .getResourceAsStream("resources/multiPartDocLitBareReq.xml")); + + assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag()); + + XMLStreamReader filteredReader = new PartialXMLStreamReader(reader, + new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body")); + + // advance the xml reader to the message parts + StaxUtils.read(filteredReader); + assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag()); + + Message m = new MessageImpl(); + Exchange exchange = new ExchangeImpl(); + + Service service = control.createMock(Service.class); + exchange.put(Service.class, service); + EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding()); + EasyMock.expect(service.size()).andReturn(0).anyTimes(); + + Endpoint endpoint = control.createMock(Endpoint.class); + exchange.put(Endpoint.class, endpoint); + + OperationInfo operationInfo = new OperationInfo(); + MessageInfo messageInfo = new MessageInfo(operationInfo, Type.INPUT, + new QName("http://foo.com", "bar")); + messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo1"), null)); + messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo2"), null)); + messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo3"), null)); + messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo4"), null)); + operationInfo.setInput("inputName", messageInfo); + + BindingOperationInfo boi = new BindingOperationInfo(null, operationInfo); + exchange.put(BindingOperationInfo.class, boi); + + EndpointInfo endpointInfo = control.createMock(EndpointInfo.class); + BindingInfo binding = control.createMock(BindingInfo.class); + EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes(); + EasyMock.expect(endpointInfo.getBinding()).andReturn(binding).anyTimes(); + EasyMock.expect(binding.getProperties()).andReturn(new HashMap()).anyTimes(); + EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap()).anyTimes(); + EasyMock.expect(endpoint.size()).andReturn(0).anyTimes(); + + ServiceInfo serviceInfo = control.createMock(ServiceInfo.class); + EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).anyTimes(); + + EasyMock.expect(serviceInfo.getName()).andReturn(new QName("http://foo.com", "service")).anyTimes(); + InterfaceInfo interfaceInfo = control.createMock(InterfaceInfo.class); + EasyMock.expect(serviceInfo.getInterface()).andReturn(interfaceInfo).anyTimes(); + EasyMock.expect(interfaceInfo.getName()) + .andReturn(new QName("http://foo.com", "interface")).anyTimes(); + + EasyMock.expect(endpointInfo.getName()).andReturn(new QName("http://foo.com", "endpoint")).anyTimes(); + EasyMock.expect(endpointInfo.getProperty("URI", URI.class)).andReturn(new URI("dummy")).anyTimes(); + + List operations = new ArrayList(); + EasyMock.expect(interfaceInfo.getOperations()).andReturn(operations).anyTimes(); + + m.setExchange(exchange); + m.put(Message.SCHEMA_VALIDATION_ENABLED, false); + m.setContent(XMLStreamReader.class, reader); + + control.replay(); + + new DocLiteralInInterceptor().handleMessage(m); + + MessageContentsList params = (MessageContentsList)m.getContent(List.class); + + assertEquals(4, params.size()); + assertEquals("StringDefaultInputElem", + ((DOMSource)params.get(0)).getNode().getFirstChild().getNodeName()); + assertEquals("IntParamInElem", + ((DOMSource)params.get(1)).getNode().getFirstChild().getNodeName()); + } +} Added: cxf/trunk/rt/core/src/test/resources/org/apache/cxf/interceptor/resources/multiPartDocLitBareReq.xml URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/resources/org/apache/cxf/interceptor/resources/multiPartDocLitBareReq.xml?rev=929263&view=auto ============================================================================== --- cxf/trunk/rt/core/src/test/resources/org/apache/cxf/interceptor/resources/multiPartDocLitBareReq.xml (added) +++ cxf/trunk/rt/core/src/test/resources/org/apache/cxf/interceptor/resources/multiPartDocLitBareReq.xml Tue Mar 30 20:36:02 2010 @@ -0,0 +1,27 @@ + + + + + foo + 0 + 0 + 0 + +