Author: sagara Date: Mon May 21 09:23:24 2012 New Revision: 1340949 URL: http://svn.apache.org/viewvc?rev=1340949&view=rev Log: Further improvements on AXIS2-5322. * Added test casees. * Added headers * Few improvements.
Added: axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/framework/ axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtensionTest.java (with props) Modified: axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployerSupport.java axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtension.java axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/AbstractServiceBuilderExtension.java axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilderExtension.java axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/WSDLServiceBuilderExtension.java Modified: axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployerSupport.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployerSupport.java?rev=1340949&r1=1340948&r2=1340949&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployerSupport.java (original) +++ axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployerSupport.java Mon May 21 09:23:24 2012 @@ -1,3 +1,22 @@ +/* + * 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.framework; import java.net.URL; Modified: axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtension.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtension.java?rev=1340949&r1=1340948&r2=1340949&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtension.java (original) +++ axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtension.java Mon May 21 09:23:24 2012 @@ -1,3 +1,22 @@ +/* + * 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.framework; import java.net.MalformedURLException; @@ -124,13 +143,7 @@ public class JAXWSServiceBuilderExtensio // if only one <service> present. return checkMessageReceivers(metaDataEle); } else if (DeploymentConstants.TAG_SERVICE_GROUP.equals(metaDataEle.getLocalName())) { - // if <serviceGroup> present. - OMElement groupMrs = metaDataEle.getFirstChildWithName(new QName( - DeploymentConstants.TAG_MESSAGE_RECEIVERS)); - // check MRs direct under <serviceGroup>. - if (groupMrs != null && !checkMessageReceivers(metaDataEle)) { - return false; - } + // if <serviceGroup> present. for (Iterator<OMElement> serviceItr = metaDataEle .getChildrenWithLocalName(DeploymentConstants.TAG_SERVICE); serviceItr .hasNext();) { @@ -151,18 +164,27 @@ public class JAXWSServiceBuilderExtensio if (mrsElement != null) { Iterator<OMElement> eleItr = (mrsElement) .getChildrenWithLocalName(DeploymentConstants.TAG_MESSAGE_RECEIVERS); - for (Iterator<OMElement> mrItr = eleItr.next().getChildrenWithLocalName( - DeploymentConstants.TAG_MESSAGE_RECEIVER); mrItr.hasNext();) { - OMElement mrEle = mrItr.next(); - String mrCalssName = mrEle.getAttributeValue(new QName( - DeploymentConstants.ATTRIBUTE_CLASS)); - if (mrCalssName != null - && !JAXWSMessageReceiver.class.getName().equals(mrCalssName)) { + if (eleItr != null) { + try { + for (Iterator<OMElement> mrItr = eleItr.next().getChildrenWithLocalName( + DeploymentConstants.TAG_MESSAGE_RECEIVER); mrItr.hasNext();) { + OMElement mrEle = mrItr.next(); + String mrCalssName = mrEle.getAttributeValue(new QName( + DeploymentConstants.ATTRIBUTE_CLASS)); + if (mrCalssName == null + || !JAXWSMessageReceiver.class.getName().equals(mrCalssName)) { + return false; + } else { + checkOK = true; + } + } + + } catch (Exception e) { return false; - } else { - checkOK = true; } + } + } return checkOK; } Added: axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtensionTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtensionTest.java?rev=1340949&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtensionTest.java (added) +++ axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtensionTest.java Mon May 21 09:23:24 2012 @@ -0,0 +1,252 @@ +/* + * 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.framework; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; + +import junit.framework.TestCase; + +public class JAXWSServiceBuilderExtensionTest extends TestCase { + + JAXWSServiceBuilderExtension builderExtension; + + @Override + protected void setUp() throws Exception { + super.setUp(); + builderExtension = new JAXWSServiceBuilderExtension(); + } + + @Override + protected void tearDown() throws Exception { + builderExtension = null; + super.tearDown(); + } + + public void testCheckPreconditionsNull() throws Exception { + boolean result = builderExtension.checkPreconditions(null); + assertEquals(false, result); + } + + public void testCheckPreconditionsStringValue() throws Exception { + boolean result = builderExtension.checkPreconditions("StringValue"); + assertEquals(false, result); + } + + public void testCheckPreconditionsOMElement() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = getOMElement(factory, "my-service"); + boolean result = builderExtension.checkPreconditions(element); + assertEquals(false, result); + } + + public void testCheckPreconditionsServiceWithNoMessageReceivers() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = getOMElement(factory, "service"); + element.addAttribute("name", "EchoService", null); + boolean result = builderExtension.checkPreconditions(element); + assertEquals(false, result); + } + + public void testCheckPreconditionsServiceGroupWithNoMessageReceivers() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = getOMElement(factory, "serviceGroup"); + boolean result = builderExtension.checkPreconditions(element); + assertEquals(false, result); + } + + public void testCheckPreconditionsServiceWithEmptyMessageReceivers1() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = getOMElement(factory, "service"); + element.addAttribute("name", "EchoService", null); + element.addChild(getOMElement(factory, "messageReceivers")); + boolean result = builderExtension.checkPreconditions(element); + assertEquals(false, result); + } + + public void testCheckPreconditionsServiceWithEmptyMessageReceivers2() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = getOMElement(factory, "service"); + element.addAttribute("name", "EchoService", null); + OMElement mrs = getOMElement(factory, "messageReceivers"); + mrs.addChild(getOMElement(factory, "messageReceiver")); + mrs.addChild(getOMElement(factory, "messageReceiver")); + element.addChild(mrs); + boolean result = builderExtension.checkPreconditions(element); + assertEquals(false, result); + } + + public void testCheckPreconditionsServiceWithWrongMessageReceivers1() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = getOMElement(factory, "service"); + element.addAttribute("name", "EchoService", null); + OMElement mrs = getOMElement(factory, "messageReceivers"); + OMElement mr1 = getOMElement(factory, "messageReceiver"); + OMElement mr2 = getOMElement(factory, "messageReceiver"); + mr1.addAttribute("class", "DummyCalss", null); + mr2.addAttribute("class", "DummyCalss", null); + mrs.addChild(mr1); + mrs.addChild(mr2); + element.addChild(mrs); + boolean result = builderExtension.checkPreconditions(element); + assertEquals(false, result); + } + + public void testCheckPreconditionsServiceWithWrongMessageReceivers2() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = getOMElement(factory, "service"); + element.addAttribute("name", "EchoService", null); + OMElement mrs = getOMElement(factory, "messageReceivers"); + OMElement mr1 = getOMElement(factory, "messageReceiver"); + OMElement mr2 = getOMElement(factory, "messageReceiver"); + mr1.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mr2.addAttribute("class", "DummyCalss", null); + mrs.addChild(mr1); + mrs.addChild(mr2); + element.addChild(mrs); + boolean result = builderExtension.checkPreconditions(element); + assertEquals(false, result); + } + + public void testCheckPreconditionsServiceWithMessageReceivers() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = getOMElement(factory, "service"); + element.addAttribute("name", "EchoService", null); + OMElement mrs = getOMElement(factory, "messageReceivers"); + OMElement mr1 = getOMElement(factory, "messageReceiver"); + OMElement mr2 = getOMElement(factory, "messageReceiver"); + mr1.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mr2.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mrs.addChild(mr1); + mrs.addChild(mr2); + element.addChild(mrs); + boolean result = builderExtension.checkPreconditions(element); + assertEquals(true, result); + } + + public void testCheckPreconditionsServiceGroupWithWrongMessageReceivers() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = getOMElement(factory, "serviceGroup"); + element.addAttribute("name", "EchoService", null); + OMElement mrs = getOMElement(factory, "messageReceivers"); + OMElement mr1 = getOMElement(factory, "messageReceiver"); + OMElement mr2 = getOMElement(factory, "messageReceiver"); + mr1.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mr2.addAttribute("class", "DummyCalss", null); + mrs.addChild(mr1); + mrs.addChild(mr2); + element.addChild(mrs); + boolean result = builderExtension.checkPreconditions(element); + assertEquals(false, result); + } + + public void testCheckPreconditionsServiceGroupWithMessageReceivers() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = getOMElement(factory, "serviceGroup"); + element.addAttribute("name", "EchoService", null); + OMElement mrs = getOMElement(factory, "messageReceivers"); + OMElement mr1 = getOMElement(factory, "messageReceiver"); + OMElement mr2 = getOMElement(factory, "messageReceiver"); + mr1.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mr2.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mrs.addChild(mr1); + mrs.addChild(mr2); + element.addChild(mrs); + boolean result = builderExtension.checkPreconditions(element); + assertEquals(false, result); + } + + public void testCheckPreconditionsServiceGroupWithMessageReceivers2() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement group = getOMElement(factory, "serviceGroup"); + OMElement element1 = getOMElement(factory, "service"); + element1.addAttribute("name", "EchoService", null); + OMElement mrs = getOMElement(factory, "messageReceivers"); + OMElement mr1 = getOMElement(factory, "messageReceiver"); + OMElement mr2 = getOMElement(factory, "messageReceiver"); + mr1.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mr2.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mrs.addChild(mr1); + mrs.addChild(mr2); + element1.addChild(mrs); + group.addChild(element1); + + OMElement element2 = getOMElement(factory, "service"); + element2.addAttribute("name", "EchoService2", null); + OMElement mrs2 = getOMElement(factory, "messageReceivers"); + OMElement mr12 = getOMElement(factory, "messageReceiver"); + OMElement mr22 = getOMElement(factory, "messageReceiver"); + mr12.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mr22.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mrs2.addChild(mr12); + mrs2.addChild(mr22); + element2.addChild(mrs2); + + group.addChild(element1); + group.addChild(element2); + + boolean result = builderExtension.checkPreconditions(group); + assertEquals(true, result); + } + + public void testCheckPreconditionsServiceGroupWithMessageReceivers3() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement group = getOMElement(factory, "serviceGroup"); + OMElement element1 = getOMElement(factory, "service"); + element1.addAttribute("name", "EchoService", null); + OMElement mrs = getOMElement(factory, "messageReceivers"); + OMElement mr1 = getOMElement(factory, "messageReceiver"); + OMElement mr2 = getOMElement(factory, "messageReceiver"); + mr1.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mr2.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mrs.addChild(mr1); + mrs.addChild(mr2); + element1.addChild(mrs); + group.addChild(element1); + + OMElement element2 = getOMElement(factory, "service"); + element2.addAttribute("name", "EchoService2", null); + OMElement mrs2 = getOMElement(factory, "messageReceivers"); + OMElement mr12 = getOMElement(factory, "messageReceiver"); + OMElement mr22 = getOMElement(factory, "messageReceiver"); + mr12.addAttribute("class", "org.apache.axis2.jaxws.server.JAXWSMessageReceiver", null); + mr22.addAttribute("class", "Dummy", null); + mrs2.addChild(mr12); + mrs2.addChild(mr22); + element2.addChild(mrs2); + + group.addChild(element1); + group.addChild(element2); + + boolean result = builderExtension.checkPreconditions(group); + assertEquals(false, result); + } + + private OMElement getOMElement(OMFactory factory, String elementName) { + if (factory == null) { + factory = OMAbstractFactory.getOMFactory(); + } + return factory.createOMElement(new QName(elementName)); + } + +} Propchange: axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtensionTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/AbstractServiceBuilderExtension.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/AbstractServiceBuilderExtension.java?rev=1340949&r1=1340948&r2=1340949&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/AbstractServiceBuilderExtension.java (original) +++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/AbstractServiceBuilderExtension.java Mon May 21 09:23:24 2012 @@ -1,3 +1,22 @@ +/* + * 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.deployment; import org.apache.axis2.context.ConfigurationContext; Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java?rev=1340949&r1=1340948&r2=1340949&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java (original) +++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java Mon May 21 09:23:24 2012 @@ -940,9 +940,6 @@ public abstract class DeploymentEngine i * JAXWSServiceBuilderExtension to ServiceDeployer, but * this need to be moved to axis2.xml. */ - ServiceBuilderExtension wsdlExt = new WSDLServiceBuilderExtension(); - wsdlExt.init(configContext); - serviceDeployer.addServiceBuilderExtensions(wsdlExt); String jaxwsExtClass = "org.apache.axis2.jaxws.framework.JAXWSServiceBuilderExtension"; try { Class<?> clazz = Class.forName(jaxwsExtClass); @@ -959,6 +956,9 @@ public abstract class DeploymentEngine i log.info("Can not instantiate " + jaxwsExtClass + ", not abale to use JAX-WS with ServiceDeployer"); } + ServiceBuilderExtension wsdlExt = new WSDLServiceBuilderExtension(); + wsdlExt.init(configContext); + serviceDeployer.addServiceBuilderExtensions(wsdlExt); for (Map<String, Deployer> extensionMap : deployerMap.values()) { for (Deployer deployer : extensionMap.values()) { Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilderExtension.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilderExtension.java?rev=1340949&r1=1340948&r2=1340949&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilderExtension.java (original) +++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilderExtension.java Mon May 21 09:23:24 2012 @@ -1,3 +1,22 @@ +/* + * 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.deployment; import java.util.Map; Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/WSDLServiceBuilderExtension.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/WSDLServiceBuilderExtension.java?rev=1340949&r1=1340948&r2=1340949&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/WSDLServiceBuilderExtension.java (original) +++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/WSDLServiceBuilderExtension.java Mon May 21 09:23:24 2012 @@ -1,3 +1,22 @@ +/* + * 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.deployment; import java.util.Iterator;