Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 84274 invoked from network); 11 Nov 2007 20:55:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Nov 2007 20:55:00 -0000 Received: (qmail 88619 invoked by uid 500); 11 Nov 2007 20:54:46 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 88565 invoked by uid 500); 11 Nov 2007 20:54:46 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 88552 invoked by uid 99); 11 Nov 2007 20:54:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Nov 2007 12:54:46 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Nov 2007 20:54:57 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 92EFC1A9832; Sun, 11 Nov 2007 12:54:37 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r593955 - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/test/ javascript/src/test/java/org/apache/cxf/javascript/service/ javascript/src/test/java/org/apache/cxf/javascript/types/ Date: Sun, 11 Nov 2007 20:54:37 -0000 To: cxf-commits@incubator.apache.org From: bimargulies@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071111205437.92EFC1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bimargulies Date: Sun Nov 11 12:54:36 2007 New Revision: 593955 URL: http://svn.apache.org/viewvc?rev=593955&view=rev Log: AbstractDependencyInjectingBlahBlah, on the one hand, introduces annoying JUnit 3 behavior, and on the other hand exists to provide a feature of dubious use: injecting dependencies \into the test/. Add a new test Abstract class that provides a more declarative mechanism for building tests that are wired with Spring, and which avoids this JUnit 3 confusion. And use it for the Javascript tests. Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFSpringTest.java Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTest.java Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFSpringTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFSpringTest.java?rev=593955&view=auto ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFSpringTest.java (added) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFSpringTest.java Sun Nov 11 12:54:36 2007 @@ -0,0 +1,74 @@ +/** + * 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.test; + +import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.GenericApplicationContext; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; + +/** + * Base class for tests that use a Spring bean specification to load up components for testing. + * Unlike the classes that come with Spring, it doesn't drag in the JUnit 3 hierarchy, and it + * doesn't inject into the test itself from the beans. + */ +public abstract class AbstractCXFSpringTest extends AbstractCXFTest { + + private GenericApplicationContext applicationContext; + private DefaultResourceLoader resourceLoader; + + /** + * Load up all the beans from the XML files returned by the getConfigLocations method. + */ + protected AbstractCXFSpringTest() { + applicationContext = new GenericApplicationContext(); + resourceLoader = new DefaultResourceLoader(getClass().getClassLoader()); + for (String beanDefinitionPath : getConfigLocations()) { + XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(applicationContext); + Resource resource = resourceLoader.getResource(beanDefinitionPath); + reader.loadBeanDefinitions(resource); + } + applicationContext.refresh(); + } + + /** + * Return an array of resource specifications. + * @see org.springframework.core.io.DefaultResourceLoader for the syntax. + * @return array of resource specifications. + */ + protected abstract String[] getConfigLocations(); + + protected ApplicationContext getApplicationContext() { + return applicationContext; + } + + /** + * Convenience method for the common case of retrieving a bean from the context. + * One would expect Spring to have this. + * @param Type of the bean object. + * @param type Type of the bean object. + * @param beanName ID of the bean. + * @return The Bean. + */ + protected T getBean(Class type, String beanName) { + return type.cast(applicationContext.getBean(beanName)); + } +} Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java?rev=593955&r1=593954&r2=593955&view=diff ============================================================================== --- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java (original) +++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java Sun Nov 11 12:54:36 2007 @@ -43,13 +43,12 @@ import org.apache.cxf.service.model.MessagePartInfo; import org.apache.cxf.service.model.SchemaInfo; import org.apache.cxf.service.model.ServiceInfo; +import org.apache.cxf.test.AbstractCXFSpringTest; import org.junit.Ignore; import org.junit.Test; import org.mozilla.javascript.Scriptable; -import org.springframework.test.AbstractDependencyInjectionSpringContextTests; -@Ignore -public class DocLitWrappedTest extends AbstractDependencyInjectionSpringContextTests { +public class DocLitWrappedTest extends AbstractCXFSpringTest { private static final Logger LOG = LogUtils.getL7dLogger(DocLitWrappedTest.class); private static final String BASIC_TYPE_FUNCTION_RETURN_STRING_SERIALIZER_NAME = "org_apache_cxf_javascript_fortest_basicTypeFunctionReturnString_serializeInput"; @@ -73,6 +72,7 @@ return new String[] {"classpath:serializationTestBeans.xml"}; } + @Ignore @Test public void testMessageSerialization() throws Exception { setupClientAndRhino("simple-dlwu-proxy-factory"); @@ -118,12 +118,12 @@ } private void setupClientAndRhino(String clientProxyFactoryBeanId) throws IOException { - testUtilities.setBus((Bus)applicationContext.getBean("cxf")); + testUtilities.setBus(getBean(Bus.class, "cxf")); testUtilities.initializeRhino(); testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/cxf-utils.js"); - clientProxyFactory = (JaxWsProxyFactoryBean)applicationContext.getBean(clientProxyFactoryBeanId); + clientProxyFactory = getBean(JaxWsProxyFactoryBean.class, clientProxyFactoryBeanId); client = clientProxyFactory.getClientFactoryBean().create(); serviceInfos = client.getEndpoint().getService().getServiceInfos(); // there can only be one. Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTest.java?rev=593955&r1=593954&r2=593955&view=diff ============================================================================== --- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTest.java (original) +++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTest.java Sun Nov 11 12:54:36 2007 @@ -44,11 +44,11 @@ import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.apache.cxf.service.model.SchemaInfo; import org.apache.cxf.service.model.ServiceInfo; +import org.apache.cxf.test.AbstractCXFSpringTest; import org.apache.cxf.wsdl.EndpointReferenceUtils; import org.junit.Test; -import org.springframework.test.AbstractDependencyInjectionSpringContextTests; -public class SerializationTest extends AbstractDependencyInjectionSpringContextTests { +public class SerializationTest extends AbstractCXFSpringTest { private JavascriptTestUtilities testUtilities; private XMLInputFactory xmlInputFactory; private XMLOutputFactory xmlOutputFactory; @@ -179,12 +179,12 @@ } private void setupClientAndRhino(String clientProxyFactoryBeanId) throws IOException { - testUtilities.setBus((Bus)applicationContext.getBean("cxf")); + testUtilities.setBus(getBean(Bus.class, "cxf")); testUtilities.initializeRhino(); testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/cxf-utils.js"); - clientProxyFactory = (JaxWsProxyFactoryBean)applicationContext.getBean(clientProxyFactoryBeanId); + clientProxyFactory = getBean(JaxWsProxyFactoryBean.class, clientProxyFactoryBeanId); client = clientProxyFactory.getClientFactoryBean().create(); serviceInfos = client.getEndpoint().getService().getServiceInfos(); // there can only be one.