This is an automated email from the ASF dual-hosted git repository. dkulp pushed a commit to branch 3.1.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 23d43fd15eaa28dd55cf6b426cd03b23ae4c236f Author: Daniel Kulp <[email protected]> AuthorDate: Wed Jan 3 17:40:44 2018 -0500 Start adjusting import orders to match what checkstyle 8.x requires. :( (cherry picked from commit 7b44ad9a1f63e729622cdc0378eda4c268eefa44) # Conflicts: # core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java # core/src/test/java/org/apache/cxf/bus/osgi/OSGiBusListenerTest.java # core/src/test/java/org/apache/cxf/feature/transform/XSLTInterceptorsTest.java --- .../bus/managers/ConduitInitiatorManagerImpl.java | 1 - .../BusApplicationContextResourceResolver.java | 1 - .../cxf/bus/spring/BusExtensionPostProcessor.java | 1 - .../cxf/common/injection/ResourceInjector.java | 1 + .../common/util/ReflectionInvokationHandler.java | 1 - .../jsse/MultiKeyPasswordKeyManager.java | 1 + .../apache/cxf/helpers/MapNamespaceContext.java | 1 + .../cxf/interceptor/ClientFaultConverter.java | 1 + .../cxf/interceptor/LoggingOutInterceptor.java | 1 + .../apache/cxf/resource/ClassLoaderResolver.java | 1 - .../cxf/security/transport/TLSSessionInfo.java | 1 + .../apache/cxf/staxutils/W3CDOMStreamReader.java | 1 - .../org/apache/cxf/staxutils/WoodstoxHelper.java | 1 + .../transport/AbstractMultiplexDestination.java | 1 + .../java/org/apache/cxf/ws/addressing/Names.java | 1 + .../cxf/ws/addressing/VersionTransformer.java | 5 - .../cxf/attachment/AttachmentSerializerTest.java | 1 + .../java/org/apache/cxf/bus/CXFBusImplTest.java | 2 +- .../cxf/bus/extension/ExtensionManagerTest.java | 1 + .../managers/EndpointResolverRegistryImplTest.java | 2 +- .../ServiceContractResolverRegistryImplTest.java | 1 + .../apache/cxf/bus/osgi/OSGiBusListenerTest.java | 423 +++++++++++---------- .../cxf/bus/spring/BusApplicationListenerTest.java | 3 +- .../cxf/bus/spring/BusDefinitionParserTest.java | 4 +- .../cxf/bus/spring/SpringBusFactoryTest.java | 1 + .../buslifecycle/CXFBusLifeCycleManagerTest.java | 1 + .../common/annotation/AnnotatedGreeterImpl.java | 1 + .../common/annotation/AnnotationProcessorTest.java | 2 + .../org/apache/cxf/common/i18n/MessageTest.java | 1 + .../cxf/common/injection/ResourceInjectorTest.java | 2 - .../apache/cxf/common/util/PackageUtilsTest.java | 1 + .../configuration/spring/ConfigurerImplTest.java | 2 - .../SuspendedInvocationExceptionTest.java | 1 + .../feature/transform/XSLTInterceptorsTest.java | 303 +++++++-------- .../org/apache/cxf/helpers/ServiceUtilsTest.java | 1 + .../cxf/interceptor/LoggingInInterceptorTest.java | 1 - .../cxf/interceptor/LoggingOutInterceptorTest.java | 2 +- .../interceptor/OutgoingChainInterceptorTest.java | 1 + .../interceptor/ServiceInvokerInterceptorTest.java | 1 + .../security/JAASLoginInterceptorTest.java | 1 + .../OperationInfoAuthorizingInterceptorTest.java | 2 +- .../security/SecureAnnotationsInterceptorTest.java | 2 +- .../security/SimpleAuthorizingInterceptorTest.java | 2 +- .../org/apache/cxf/io/CachedStreamTestBase.java | 1 + .../cxf/phase/PhaseInterceptorChainTest.java | 2 +- .../org/apache/cxf/resource/URIResolverTest.java | 1 + .../PropertiesExpandingStreamReaderTest.java | 1 + .../validation/Stax2ValidationUtilsTest.java | 2 + .../cxf/transport/ChainInitiationObserverTest.java | 1 + .../common/gzip/GZIPAcceptEncodingTest.java | 2 +- .../apache/cxf/ws/addressing/ContextUtilsTest.java | 1 + .../corba/maven/plugins/IDLToWSDLPlugin.java | 1 - 52 files changed, 409 insertions(+), 388 deletions(-) diff --git a/core/src/main/java/org/apache/cxf/bus/managers/ConduitInitiatorManagerImpl.java b/core/src/main/java/org/apache/cxf/bus/managers/ConduitInitiatorManagerImpl.java index 073d4bf..e035338 100644 --- a/core/src/main/java/org/apache/cxf/bus/managers/ConduitInitiatorManagerImpl.java +++ b/core/src/main/java/org/apache/cxf/bus/managers/ConduitInitiatorManagerImpl.java @@ -20,7 +20,6 @@ package org.apache.cxf.bus.managers; import java.util.Map; - import java.util.ResourceBundle; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; diff --git a/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java b/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java index 434a851..53a7967 100644 --- a/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java +++ b/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java @@ -24,7 +24,6 @@ import java.net.URL; import org.apache.cxf.common.injection.NoJSR250Annotations; import org.apache.cxf.resource.ResourceResolver; - import org.springframework.beans.BeansException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.context.ApplicationContext; diff --git a/core/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java b/core/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java index 3c6369d..2905842 100644 --- a/core/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java +++ b/core/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java @@ -22,7 +22,6 @@ package org.apache.cxf.bus.spring; import org.apache.cxf.Bus; import org.apache.cxf.common.injection.NoJSR250Annotations; import org.apache.cxf.extension.BusExtension; - import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.ApplicationContext; diff --git a/core/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java b/core/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java index c83b32b..9ec5864 100644 --- a/core/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java +++ b/core/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java @@ -30,6 +30,7 @@ import java.util.LinkedList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; + import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.annotation.Resource; diff --git a/core/src/main/java/org/apache/cxf/common/util/ReflectionInvokationHandler.java b/core/src/main/java/org/apache/cxf/common/util/ReflectionInvokationHandler.java index ed2c396..fa2fb29 100644 --- a/core/src/main/java/org/apache/cxf/common/util/ReflectionInvokationHandler.java +++ b/core/src/main/java/org/apache/cxf/common/util/ReflectionInvokationHandler.java @@ -27,7 +27,6 @@ import java.lang.annotation.Target; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; - import java.lang.reflect.Proxy; import java.util.Iterator; diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/MultiKeyPasswordKeyManager.java b/core/src/main/java/org/apache/cxf/configuration/jsse/MultiKeyPasswordKeyManager.java index c6dcbc9..f507ffe 100644 --- a/core/src/main/java/org/apache/cxf/configuration/jsse/MultiKeyPasswordKeyManager.java +++ b/core/src/main/java/org/apache/cxf/configuration/jsse/MultiKeyPasswordKeyManager.java @@ -26,6 +26,7 @@ import java.security.Principal; import java.security.PrivateKey; import java.security.cert.Certificate; import java.security.cert.X509Certificate; + import javax.net.ssl.X509KeyManager; public class MultiKeyPasswordKeyManager implements X509KeyManager { diff --git a/core/src/main/java/org/apache/cxf/helpers/MapNamespaceContext.java b/core/src/main/java/org/apache/cxf/helpers/MapNamespaceContext.java index 6e1c92d..49cdb59 100644 --- a/core/src/main/java/org/apache/cxf/helpers/MapNamespaceContext.java +++ b/core/src/main/java/org/apache/cxf/helpers/MapNamespaceContext.java @@ -21,6 +21,7 @@ package org.apache.cxf.helpers; import java.util.HashMap; import java.util.Iterator; import java.util.Map; + import javax.xml.XMLConstants; import javax.xml.namespace.NamespaceContext; diff --git a/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java b/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java index a5edceb..628b073 100644 --- a/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java +++ b/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java @@ -39,6 +39,7 @@ import javax.xml.xpath.XPathConstants; import org.w3c.dom.Element; import org.w3c.dom.Node; + import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.common.util.ReflectionUtil; import org.apache.cxf.common.util.StringUtils; diff --git a/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java index 438076a..bcab20a 100644 --- a/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java +++ b/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java @@ -27,6 +27,7 @@ import java.io.StringWriter; import java.io.Writer; import java.util.logging.Level; import java.util.logging.Logger; + import org.apache.cxf.common.injection.NoJSR250Annotations; import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.io.CacheAndWriteOutputStream; diff --git a/core/src/main/java/org/apache/cxf/resource/ClassLoaderResolver.java b/core/src/main/java/org/apache/cxf/resource/ClassLoaderResolver.java index 7f03fe6..ae6a215 100644 --- a/core/src/main/java/org/apache/cxf/resource/ClassLoaderResolver.java +++ b/core/src/main/java/org/apache/cxf/resource/ClassLoaderResolver.java @@ -20,7 +20,6 @@ package org.apache.cxf.resource; import java.io.InputStream; - import java.net.URL; import org.apache.cxf.common.injection.NoJSR250Annotations; diff --git a/core/src/main/java/org/apache/cxf/security/transport/TLSSessionInfo.java b/core/src/main/java/org/apache/cxf/security/transport/TLSSessionInfo.java index 34918c7..d289a99 100644 --- a/core/src/main/java/org/apache/cxf/security/transport/TLSSessionInfo.java +++ b/core/src/main/java/org/apache/cxf/security/transport/TLSSessionInfo.java @@ -20,6 +20,7 @@ package org.apache.cxf.security.transport; import java.security.cert.Certificate; + import javax.net.ssl.SSLSession; /** diff --git a/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java b/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java index 0836379..64f006f 100644 --- a/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java +++ b/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java @@ -26,7 +26,6 @@ import javax.xml.stream.Location; import javax.xml.stream.XMLStreamException; import org.w3c.dom.Attr; - import org.w3c.dom.Comment; import org.w3c.dom.Document; import org.w3c.dom.DocumentFragment; diff --git a/core/src/main/java/org/apache/cxf/staxutils/WoodstoxHelper.java b/core/src/main/java/org/apache/cxf/staxutils/WoodstoxHelper.java index 8b901bc..9d711d0 100644 --- a/core/src/main/java/org/apache/cxf/staxutils/WoodstoxHelper.java +++ b/core/src/main/java/org/apache/cxf/staxutils/WoodstoxHelper.java @@ -25,6 +25,7 @@ import javax.xml.stream.XMLStreamReader; import com.ctc.wstx.stax.WstxEventFactory; import com.ctc.wstx.stax.WstxInputFactory; + import org.codehaus.stax2.XMLStreamReader2; /** diff --git a/core/src/main/java/org/apache/cxf/transport/AbstractMultiplexDestination.java b/core/src/main/java/org/apache/cxf/transport/AbstractMultiplexDestination.java index ecc690b..7488b3a 100644 --- a/core/src/main/java/org/apache/cxf/transport/AbstractMultiplexDestination.java +++ b/core/src/main/java/org/apache/cxf/transport/AbstractMultiplexDestination.java @@ -29,6 +29,7 @@ import org.apache.cxf.ws.addressing.AddressingProperties; import org.apache.cxf.ws.addressing.EndpointReferenceType; import org.apache.cxf.ws.addressing.EndpointReferenceUtils; import org.apache.cxf.ws.addressing.ReferenceParametersType; + import static org.apache.cxf.ws.addressing.JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND; public abstract class AbstractMultiplexDestination extends AbstractDestination implements diff --git a/core/src/main/java/org/apache/cxf/ws/addressing/Names.java b/core/src/main/java/org/apache/cxf/ws/addressing/Names.java index 51d2c80..c3da5d1 100644 --- a/core/src/main/java/org/apache/cxf/ws/addressing/Names.java +++ b/core/src/main/java/org/apache/cxf/ws/addressing/Names.java @@ -23,6 +23,7 @@ package org.apache.cxf.ws.addressing; import java.util.Collections; import java.util.HashSet; import java.util.Set; + import javax.xml.namespace.QName; diff --git a/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java b/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java index 345fcac..49615fc 100644 --- a/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java +++ b/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java @@ -31,14 +31,9 @@ import javax.xml.namespace.QName; //import javax.xml.ws.EndpointReference; //import javax.xml.ws.wsaddressing.W3CEndpointReference; - - import org.w3c.dom.Element; import org.apache.cxf.common.jaxb.JAXBUtils; -// importation convention: if the same class name is used for -// 2005/08 and 2004/08, then the former version is imported -// and the latter is fully qualified when used import org.apache.cxf.helpers.DOMUtils; import org.apache.cxf.ws.addressing.v200408.AttributedQName; import org.apache.cxf.ws.addressing.v200408.AttributedURI; diff --git a/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java b/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java index 661b69f..b707a51 100644 --- a/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java +++ b/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java @@ -38,6 +38,7 @@ import org.apache.cxf.helpers.IOUtils; import org.apache.cxf.message.Attachment; import org.apache.cxf.message.Message; import org.apache.cxf.message.MessageImpl; + import org.junit.Assert; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/bus/CXFBusImplTest.java b/core/src/test/java/org/apache/cxf/bus/CXFBusImplTest.java index 1c93eb2..ee6edc7 100644 --- a/core/src/test/java/org/apache/cxf/bus/CXFBusImplTest.java +++ b/core/src/test/java/org/apache/cxf/bus/CXFBusImplTest.java @@ -33,9 +33,9 @@ import org.apache.cxf.management.InstrumentationManager; import org.apache.cxf.phase.PhaseManager; import org.apache.cxf.transport.ConduitInitiatorManager; import org.apache.cxf.transport.DestinationFactoryManager; + import org.easymock.EasyMock; import org.easymock.IMocksControl; - import org.junit.Assert; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java b/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java index 057200d..1e9e547 100644 --- a/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java +++ b/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java @@ -26,6 +26,7 @@ import org.apache.cxf.resource.DefaultResourceManager; import org.apache.cxf.resource.ResourceManager; import org.apache.cxf.resource.ResourceResolver; import org.apache.cxf.resource.SinglePropertyResolver; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/bus/managers/EndpointResolverRegistryImplTest.java b/core/src/test/java/org/apache/cxf/bus/managers/EndpointResolverRegistryImplTest.java index 25c6163..d7a2812 100644 --- a/core/src/test/java/org/apache/cxf/bus/managers/EndpointResolverRegistryImplTest.java +++ b/core/src/test/java/org/apache/cxf/bus/managers/EndpointResolverRegistryImplTest.java @@ -23,9 +23,9 @@ import javax.xml.namespace.QName; import org.apache.cxf.endpoint.EndpointResolver; import org.apache.cxf.ws.addressing.EndpointReferenceType; + import org.easymock.EasyMock; import org.easymock.IMocksControl; - import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/core/src/test/java/org/apache/cxf/bus/managers/ServiceContractResolverRegistryImplTest.java b/core/src/test/java/org/apache/cxf/bus/managers/ServiceContractResolverRegistryImplTest.java index 836ec65..5ef0a9a 100644 --- a/core/src/test/java/org/apache/cxf/bus/managers/ServiceContractResolverRegistryImplTest.java +++ b/core/src/test/java/org/apache/cxf/bus/managers/ServiceContractResolverRegistryImplTest.java @@ -25,6 +25,7 @@ import java.net.URISyntaxException; import javax.xml.namespace.QName; import org.apache.cxf.endpoint.ServiceContractResolver; + import org.easymock.EasyMock; import org.easymock.IMocksControl; import org.junit.After; diff --git a/core/src/test/java/org/apache/cxf/bus/osgi/OSGiBusListenerTest.java b/core/src/test/java/org/apache/cxf/bus/osgi/OSGiBusListenerTest.java index 9f901d6..e99359d 100644 --- a/core/src/test/java/org/apache/cxf/bus/osgi/OSGiBusListenerTest.java +++ b/core/src/test/java/org/apache/cxf/bus/osgi/OSGiBusListenerTest.java @@ -1,210 +1,213 @@ -/** - * 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.bus.osgi; - -import java.util.ArrayList; -import java.util.Collection; - -import org.apache.cxf.Bus; -import org.apache.cxf.buslifecycle.BusLifeCycleManager; -import org.apache.cxf.common.util.StringUtils; -import org.apache.cxf.endpoint.ClientLifeCycleListener; -import org.apache.cxf.endpoint.ClientLifeCycleManager; -import org.apache.cxf.endpoint.ServerLifeCycleListener; -import org.apache.cxf.endpoint.ServerLifeCycleManager; -import org.apache.cxf.feature.Feature; -import org.easymock.EasyMock; -import org.easymock.IMocksControl; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -/** - * - */ -public class OSGiBusListenerTest extends Assert { - private static final String[] SERVICE_BUNDLE_NAMES = new String[]{"me.temp.foo.test", "me.temp.bar.sample"}; - private static final String EXCLUDES = "me\\.temp\\.bar\\..*"; - private static final String RESTRICTED = "me\\.my\\.app\\..*"; - private static final String BUNDLE_NAME = "me.my.app"; - - private IMocksControl control; - private Bus bus; - private BundleContext bundleContext; - private Bundle bundle; - - - @Before - public void setUp() { - control = EasyMock.createNiceControl(); - bus = control.createMock(Bus.class); - BusLifeCycleManager blcManager = control.createMock(BusLifeCycleManager.class); - EasyMock.expect(bus.getExtension(BusLifeCycleManager.class)).andReturn(blcManager).anyTimes(); - - blcManager.registerLifeCycleListener(EasyMock.isA(OSGIBusListener.class)); - EasyMock.expectLastCall(); - bundleContext = control.createMock(BundleContext.class); - - BundleContext app = control.createMock(BundleContext.class); - EasyMock.expect(bus.getExtension(BundleContext.class)).andReturn(app).anyTimes(); - bundle = control.createMock(Bundle.class); - EasyMock.expect(app.getBundle()).andReturn(bundle).anyTimes(); - EasyMock.expect(bundle.getSymbolicName()).andReturn(BUNDLE_NAME).anyTimes(); - } - - @Test - public void testRegistratioWithNoServices() throws Exception { - control.replay(); - new OSGIBusListener(bus, new Object[]{bundleContext}); - - control.verify(); - } - - @Test - public void testRegistratioWithServices() throws Exception { - setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, null); - setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, null); - Collection<Feature> lst = new ArrayList<Feature>(); - setFeatures(SERVICE_BUNDLE_NAMES, new String[]{null, null}, lst); - - control.replay(); - new OSGIBusListener(bus, new Object[]{bundleContext}); - - assertEquals(countServices(SERVICE_BUNDLE_NAMES, new String[]{null, null}, null), lst.size()); - - control.verify(); - } - - @Test - public void testRegistratioWithServicesExcludes() throws Exception { - setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, EXCLUDES); - setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, EXCLUDES); - Collection<Feature> lst = new ArrayList<Feature>(); - setFeatures(SERVICE_BUNDLE_NAMES, new String[]{null, null}, lst); - EasyMock.expect(bus.getProperty("bus.extension.bundles.excludes")).andReturn(EXCLUDES); - control.replay(); - new OSGIBusListener(bus, new Object[]{bundleContext}); - - assertEquals(countServices(SERVICE_BUNDLE_NAMES, new String[]{null, null}, EXCLUDES), lst.size()); - - control.verify(); - } - - @Test - public void testRegistratioWithServicesExcludesAndRestricted() throws Exception { - setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, EXCLUDES); - setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, EXCLUDES); - Collection<Feature> lst = new ArrayList<Feature>(); - setFeatures(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, lst); - EasyMock.expect(bus.getProperty("bus.extension.bundles.excludes")).andReturn(EXCLUDES); - control.replay(); - new OSGIBusListener(bus, new Object[]{bundleContext}); - - assertEquals(countServices(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, EXCLUDES), lst.size()); - - control.verify(); - } - - private void setUpClientLifeCycleListeners(String[] names, String[] restricted, String excludes) throws Exception { - ServiceReference[] svcrefs = createTestServiceReferences(names, restricted); - EasyMock.expect(bundleContext.getServiceReferences(ClientLifeCycleListener.class.getName(), null)) - .andReturn(svcrefs); - ClientLifeCycleManager lcmanager = control.createMock(ClientLifeCycleManager.class); - EasyMock.expect(bus.getExtension(ClientLifeCycleManager.class)).andReturn(lcmanager).anyTimes(); - for (int i = 0; i < names.length; i++) { - ClientLifeCycleListener cl = control.createMock(ClientLifeCycleListener.class); - EasyMock.expect(bundleContext.getService(svcrefs[i])).andReturn(cl).anyTimes(); - if (!isExcluded(BUNDLE_NAME, names[i], restricted[i], excludes)) { - lcmanager.registerListener(cl); - EasyMock.expectLastCall(); - } - } - } - - private void setUpServerLifeCycleListeners(String[] names, String[] restricted, String excludes) throws Exception { - ServiceReference[] svcrefs = createTestServiceReferences(names, restricted); - EasyMock.expect(bundleContext.getServiceReferences(ServerLifeCycleListener.class.getName(), null)) - .andReturn(svcrefs); - ServerLifeCycleManager lcmanager = control.createMock(ServerLifeCycleManager.class); - EasyMock.expect(bus.getExtension(ServerLifeCycleManager.class)).andReturn(lcmanager).anyTimes(); - for (int i = 0; i < names.length; i++) { - ServerLifeCycleListener cl = control.createMock(ServerLifeCycleListener.class); - EasyMock.expect(bundleContext.getService(svcrefs[i])).andReturn(cl).anyTimes(); - if (!isExcluded(BUNDLE_NAME, names[i], restricted[i], excludes)) { - lcmanager.registerListener(cl); - EasyMock.expectLastCall(); - } - } - } - - private void setFeatures(String[] names, String[] restricted, - Collection<Feature> lst) throws Exception { - ServiceReference[] svcrefs = createTestServiceReferences(names, restricted); - EasyMock.expect(bundleContext.getServiceReferences(Feature.class.getName(), null)) - .andReturn(svcrefs); - for (int i = 0; i < names.length; i++) { - Feature f = control.createMock(Feature.class); - EasyMock.expect(bundleContext.getService(svcrefs[i])).andReturn(f).anyTimes(); - } - EasyMock.expect(bus.getFeatures()).andReturn(lst).anyTimes(); - - } - - // Creates test service references with the specified symbolic names and the restricted extension properties. - private ServiceReference[] createTestServiceReferences(String[] names, String[] restricted) { - ServiceReference[] refs = new ServiceReference[names.length]; - for (int i = 0; i < names.length; i++) { - refs[i] = createTestServiceReference(names[i], restricted[i]); - } - return refs; - } - - - // Creates a test service reference with the specified symbolic name and the restricted extension property. - private ServiceReference createTestServiceReference(String name, String rst) { - ServiceReference ref = control.createMock(ServiceReference.class); - Bundle b = control.createMock(Bundle.class); - EasyMock.expect(b.getSymbolicName()).andReturn(name).anyTimes(); - EasyMock.expect(ref.getBundle()).andReturn(b).anyTimes(); - EasyMock.expect(ref.getProperty("org.apache.cxf.bus.restricted.extension")).andReturn(rst).anyTimes(); - return ref; - } - - private static boolean isExcluded(String aname, String sname, String rst, String exc) { - if (!StringUtils.isEmpty(rst) && !aname.matches(rst)) { - return true; - } - return exc != null && sname.matches(exc); - } - - private static int countServices(String[] names, String[] restricted, String excluded) { - int c = 0; - for (int i = 0; i < names.length; i++) { - if (!isExcluded(BUNDLE_NAME, names[i], restricted[i], excluded)) { - c++; - } - } - return c; - } -} +/** + * 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.bus.osgi; + +import java.util.ArrayList; +import java.util.Collection; + +import org.apache.cxf.Bus; +import org.apache.cxf.buslifecycle.BusLifeCycleManager; +import org.apache.cxf.common.util.StringUtils; +import org.apache.cxf.endpoint.ClientLifeCycleListener; +import org.apache.cxf.endpoint.ClientLifeCycleManager; +import org.apache.cxf.endpoint.ServerLifeCycleListener; +import org.apache.cxf.endpoint.ServerLifeCycleManager; +import org.apache.cxf.feature.Feature; +import org.easymock.EasyMock; +import org.easymock.IMocksControl; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; + + +/** + * + */ +public class OSGiBusListenerTest extends Assert { + private static final String[] SERVICE_BUNDLE_NAMES = new String[]{"me.temp.foo.test", "me.temp.bar.sample"}; + private static final String EXCLUDES = "me\\.temp\\.bar\\..*"; + private static final String RESTRICTED = "me\\.my\\.app\\..*"; + private static final String BUNDLE_NAME = "me.my.app"; + + private IMocksControl control; + private Bus bus; + private BundleContext bundleContext; + private Bundle bundle; + + + @Before + public void setUp() { + control = EasyMock.createNiceControl(); + bus = control.createMock(Bus.class); + BusLifeCycleManager blcManager = control.createMock(BusLifeCycleManager.class); + EasyMock.expect(bus.getExtension(BusLifeCycleManager.class)).andReturn(blcManager).anyTimes(); + + blcManager.registerLifeCycleListener(EasyMock.isA(OSGIBusListener.class)); + EasyMock.expectLastCall(); + bundleContext = control.createMock(BundleContext.class); + + BundleContext app = control.createMock(BundleContext.class); + EasyMock.expect(bus.getExtension(BundleContext.class)).andReturn(app).anyTimes(); + bundle = control.createMock(Bundle.class); + EasyMock.expect(app.getBundle()).andReturn(bundle).anyTimes(); + EasyMock.expect(bundle.getSymbolicName()).andReturn(BUNDLE_NAME).anyTimes(); + } + + @Test + public void testRegistratioWithNoServices() throws Exception { + control.replay(); + new OSGIBusListener(bus, new Object[]{bundleContext}); + + control.verify(); + } + + @Test + public void testRegistratioWithServices() throws Exception { + setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, null); + setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, null); + Collection<Feature> lst = new ArrayList<>(); + setFeatures(SERVICE_BUNDLE_NAMES, new String[]{null, null}, lst); + + control.replay(); + new OSGIBusListener(bus, new Object[]{bundleContext}); + + assertEquals(countServices(SERVICE_BUNDLE_NAMES, new String[]{null, null}, null), lst.size()); + + control.verify(); + } + + @Test + public void testRegistratioWithServicesExcludes() throws Exception { + setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, EXCLUDES); + setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, EXCLUDES); + Collection<Feature> lst = new ArrayList<>(); + setFeatures(SERVICE_BUNDLE_NAMES, new String[]{null, null}, lst); + EasyMock.expect(bus.getProperty("bus.extension.bundles.excludes")).andReturn(EXCLUDES); + control.replay(); + new OSGIBusListener(bus, new Object[]{bundleContext}); + + assertEquals(countServices(SERVICE_BUNDLE_NAMES, new String[]{null, null}, EXCLUDES), lst.size()); + + control.verify(); + } + + @Test + public void testRegistratioWithServicesExcludesAndRestricted() throws Exception { + setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, EXCLUDES); + setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, EXCLUDES); + Collection<Feature> lst = new ArrayList<>(); + setFeatures(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, lst); + EasyMock.expect(bus.getProperty("bus.extension.bundles.excludes")).andReturn(EXCLUDES); + control.replay(); + new OSGIBusListener(bus, new Object[]{bundleContext}); + + assertEquals(countServices(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, EXCLUDES), lst.size()); + + control.verify(); + } + + private void setUpClientLifeCycleListeners(String[] names, String[] restricted, String excludes) throws Exception { + ServiceReference<Object>[] svcrefs = createTestServiceReferences(names, restricted); + EasyMock.expect(bundleContext.getServiceReferences(ClientLifeCycleListener.class.getName(), null)) + .andReturn(svcrefs); + ClientLifeCycleManager lcmanager = control.createMock(ClientLifeCycleManager.class); + EasyMock.expect(bus.getExtension(ClientLifeCycleManager.class)).andReturn(lcmanager).anyTimes(); + for (int i = 0; i < names.length; i++) { + ClientLifeCycleListener cl = control.createMock(ClientLifeCycleListener.class); + EasyMock.expect(bundleContext.getService(svcrefs[i])).andReturn(cl).anyTimes(); + if (!isExcluded(BUNDLE_NAME, names[i], restricted[i], excludes)) { + lcmanager.registerListener(cl); + EasyMock.expectLastCall(); + } + } + } + + private void setUpServerLifeCycleListeners(String[] names, String[] restricted, String excludes) throws Exception { + ServiceReference<Object>[] svcrefs = createTestServiceReferences(names, restricted); + EasyMock.expect(bundleContext.getServiceReferences(ServerLifeCycleListener.class.getName(), null)) + .andReturn(svcrefs); + ServerLifeCycleManager lcmanager = control.createMock(ServerLifeCycleManager.class); + EasyMock.expect(bus.getExtension(ServerLifeCycleManager.class)).andReturn(lcmanager).anyTimes(); + for (int i = 0; i < names.length; i++) { + ServerLifeCycleListener cl = control.createMock(ServerLifeCycleListener.class); + EasyMock.expect(bundleContext.getService(svcrefs[i])).andReturn(cl).anyTimes(); + if (!isExcluded(BUNDLE_NAME, names[i], restricted[i], excludes)) { + lcmanager.registerListener(cl); + EasyMock.expectLastCall(); + } + } + } + + private void setFeatures(String[] names, String[] restricted, + Collection<Feature> lst) throws Exception { + ServiceReference<Object>[] svcrefs = createTestServiceReferences(names, restricted); + EasyMock.expect(bundleContext.getServiceReferences(Feature.class.getName(), null)) + .andReturn(svcrefs); + for (int i = 0; i < names.length; i++) { + Feature f = control.createMock(Feature.class); + EasyMock.expect(bundleContext.getService(svcrefs[i])).andReturn(f).anyTimes(); + } + EasyMock.expect(bus.getFeatures()).andReturn(lst).anyTimes(); + + } + + // Creates test service references with the specified symbolic names and the restricted extension properties. + private ServiceReference<Object>[] createTestServiceReferences(String[] names, String[] restricted) { + @SuppressWarnings("unchecked") + ServiceReference<Object>[] refs = new ServiceReference[names.length]; + for (int i = 0; i < names.length; i++) { + refs[i] = createTestServiceReference(names[i], restricted[i]); + } + return refs; + } + + + // Creates a test service reference with the specified symbolic name and the restricted extension property. + private ServiceReference<Object> createTestServiceReference(String name, String rst) { + @SuppressWarnings("unchecked") + ServiceReference<Object> ref = control.createMock(ServiceReference.class); + Bundle b = control.createMock(Bundle.class); + EasyMock.expect(b.getSymbolicName()).andReturn(name).anyTimes(); + EasyMock.expect(ref.getBundle()).andReturn(b).anyTimes(); + EasyMock.expect(ref.getProperty("org.apache.cxf.bus.restricted.extension")).andReturn(rst).anyTimes(); + return ref; + } + + private static boolean isExcluded(String aname, String sname, String rst, String exc) { + if (!StringUtils.isEmpty(rst) && !aname.matches(rst)) { + return true; + } + return exc != null && sname.matches(exc); + } + + private static int countServices(String[] names, String[] restricted, String excluded) { + int c = 0; + for (int i = 0; i < names.length; i++) { + if (!isExcluded(BUNDLE_NAME, names[i], restricted[i], excluded)) { + c++; + } + } + return c; + } +} + diff --git a/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java b/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java index 9b0b7a3..2717154 100644 --- a/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java +++ b/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java @@ -21,14 +21,15 @@ package org.apache.cxf.bus.spring; import org.apache.cxf.Bus; import org.apache.cxf.bus.managers.CXFBusLifeCycleManager; import org.apache.cxf.buslifecycle.BusLifeCycleListener; + import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; + import org.springframework.context.support.AbstractRefreshableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; - public class BusApplicationListenerTest extends Assert { @Test diff --git a/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java b/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java index 2c63150..ea8be84 100644 --- a/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java +++ b/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java @@ -33,12 +33,12 @@ import org.apache.cxf.feature.Feature; import org.apache.cxf.interceptor.Interceptor; import org.apache.cxf.interceptor.LoggingInInterceptor; import org.apache.cxf.message.Message; - import org.junit.Assert; import org.junit.Test; - import org.springframework.context.support.ClassPathXmlApplicationContext; + + public class BusDefinitionParserTest extends Assert { @Test diff --git a/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java b/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java index bf4a96a..a48fb72 100644 --- a/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java +++ b/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java @@ -48,6 +48,7 @@ import org.apache.cxf.resource.ResourceManager; import org.apache.cxf.transport.ConduitInitiatorManager; import org.apache.cxf.transport.DestinationFactoryManager; import org.apache.cxf.workqueue.WorkQueueManager; + import org.easymock.EasyMock; import org.junit.After; import org.junit.Assert; diff --git a/core/src/test/java/org/apache/cxf/buslifecycle/CXFBusLifeCycleManagerTest.java b/core/src/test/java/org/apache/cxf/buslifecycle/CXFBusLifeCycleManagerTest.java index cd68169..a9064b2 100644 --- a/core/src/test/java/org/apache/cxf/buslifecycle/CXFBusLifeCycleManagerTest.java +++ b/core/src/test/java/org/apache/cxf/buslifecycle/CXFBusLifeCycleManagerTest.java @@ -20,6 +20,7 @@ package org.apache.cxf.buslifecycle; import org.apache.cxf.bus.managers.CXFBusLifeCycleManager; + import org.easymock.EasyMock; import org.easymock.IMocksControl; import org.junit.Assert; diff --git a/core/src/test/java/org/apache/cxf/common/annotation/AnnotatedGreeterImpl.java b/core/src/test/java/org/apache/cxf/common/annotation/AnnotatedGreeterImpl.java index fca985f..6bff143 100644 --- a/core/src/test/java/org/apache/cxf/common/annotation/AnnotatedGreeterImpl.java +++ b/core/src/test/java/org/apache/cxf/common/annotation/AnnotatedGreeterImpl.java @@ -23,6 +23,7 @@ package org.apache.cxf.common.annotation; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; + import javax.annotation.Resource; import javax.jws.HandlerChain; import javax.jws.WebMethod; diff --git a/core/src/test/java/org/apache/cxf/common/annotation/AnnotationProcessorTest.java b/core/src/test/java/org/apache/cxf/common/annotation/AnnotationProcessorTest.java index 28335b6..dc40ceb 100644 --- a/core/src/test/java/org/apache/cxf/common/annotation/AnnotationProcessorTest.java +++ b/core/src/test/java/org/apache/cxf/common/annotation/AnnotationProcessorTest.java @@ -26,10 +26,12 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; + import javax.annotation.Resource; import javax.jws.WebMethod; import javax.jws.WebService; import javax.xml.ws.WebServiceContext; + import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; diff --git a/core/src/test/java/org/apache/cxf/common/i18n/MessageTest.java b/core/src/test/java/org/apache/cxf/common/i18n/MessageTest.java index 1fe7428..7563415 100644 --- a/core/src/test/java/org/apache/cxf/common/i18n/MessageTest.java +++ b/core/src/test/java/org/apache/cxf/common/i18n/MessageTest.java @@ -27,6 +27,7 @@ import java.util.ResourceBundle; import java.util.logging.Logger; import org.apache.cxf.common.logging.LogUtils; + import org.junit.Assert; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java b/core/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java index 4736663..567e813 100644 --- a/core/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java +++ b/core/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java @@ -24,7 +24,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Proxy; - import java.util.ArrayList; import java.util.List; @@ -36,7 +35,6 @@ import javax.annotation.Resources; import net.sf.cglib.proxy.Enhancer; import net.sf.cglib.proxy.MethodInterceptor; import net.sf.cglib.proxy.MethodProxy; - import org.apache.cxf.resource.ResourceManager; import org.apache.cxf.resource.ResourceResolver; diff --git a/core/src/test/java/org/apache/cxf/common/util/PackageUtilsTest.java b/core/src/test/java/org/apache/cxf/common/util/PackageUtilsTest.java index ace5282..7168d71 100644 --- a/core/src/test/java/org/apache/cxf/common/util/PackageUtilsTest.java +++ b/core/src/test/java/org/apache/cxf/common/util/PackageUtilsTest.java @@ -28,6 +28,7 @@ import java.util.Collections; import org.apache.cxf.validation.BeanValidationProvider; import org.apache.cxf.validation.ValidationConfiguration; + import org.junit.Assert; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java b/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java index 5c156c4..535144f 100644 --- a/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java +++ b/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java @@ -38,8 +38,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; - - public class ConfigurerImplTest extends Assert { static { diff --git a/core/src/test/java/org/apache/cxf/continuations/SuspendedInvocationExceptionTest.java b/core/src/test/java/org/apache/cxf/continuations/SuspendedInvocationExceptionTest.java index 2be4854..8d13579 100644 --- a/core/src/test/java/org/apache/cxf/continuations/SuspendedInvocationExceptionTest.java +++ b/core/src/test/java/org/apache/cxf/continuations/SuspendedInvocationExceptionTest.java @@ -20,6 +20,7 @@ package org.apache.cxf.continuations; import org.apache.cxf.common.i18n.UncheckedException; + import org.junit.Assert; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/feature/transform/XSLTInterceptorsTest.java b/core/src/test/java/org/apache/cxf/feature/transform/XSLTInterceptorsTest.java index c841937..b879db3 100644 --- a/core/src/test/java/org/apache/cxf/feature/transform/XSLTInterceptorsTest.java +++ b/core/src/test/java/org/apache/cxf/feature/transform/XSLTInterceptorsTest.java @@ -1,150 +1,153 @@ -/** - * 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.feature.transform; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.stream.StreamSource; - -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import org.apache.cxf.common.classloader.ClassLoaderUtils; -import org.apache.cxf.helpers.IOUtils; -import org.apache.cxf.io.CachedOutputStream; -import org.apache.cxf.io.CachedWriter; -import org.apache.cxf.message.Message; -import org.apache.cxf.message.MessageImpl; -import org.apache.cxf.staxutils.StaxUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/* Provides XSLT transformation of incoming message. - * Interceptor breaks streaming (can be fixed in further versions when XSLT engine supports XML stream) - */ -public class XSLTInterceptorsTest { - - private static final String TRANSFORMATION_XSL = "transformation.xsl"; - private static final String MESSAGE_FILE = "message.xml"; - - private InputStream messageIS; - private Message message; - private XSLTInInterceptor inInterceptor; - private XSLTOutInterceptor outInterceptor; - - @Before - public void setUp() throws TransformerConfigurationException { - messageIS = ClassLoaderUtils.getResourceAsStream(MESSAGE_FILE, this.getClass()); - if (messageIS == null) { - throw new IllegalArgumentException("Cannot load message from path: " + MESSAGE_FILE); - } - message = new MessageImpl(); - inInterceptor = new XSLTInInterceptor(TRANSFORMATION_XSL); - outInterceptor = new XSLTOutInterceptor(TRANSFORMATION_XSL); - } - - @Test - public void inStreamTest() throws Exception { - message.setContent(InputStream.class, messageIS); - inInterceptor.handleMessage(message); - InputStream transformedIS = message.getContent(InputStream.class); - Document doc = StaxUtils.read(transformedIS); - Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); - } - - @Test - public void inXMLStreamTest() throws XMLStreamException { - XMLStreamReader xReader = StaxUtils.createXMLStreamReader(messageIS); - message.setContent(XMLStreamReader.class, xReader); - inInterceptor.handleMessage(message); - XMLStreamReader transformedXReader = message.getContent(XMLStreamReader.class); - Document doc = StaxUtils.read(transformedXReader); - Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); - } - - @Test - public void inReaderTest() throws Exception { - Reader reader = new InputStreamReader(messageIS); - message.setContent(Reader.class, reader); - inInterceptor.handleMessage(message); - Reader transformedReader = message.getContent(Reader.class); - Document doc = StaxUtils.read(transformedReader); - Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); - } - - @Test - public void outStreamTest() throws Exception { - CachedOutputStream cos = new CachedOutputStream(); - cos.holdTempFile(); - message.setContent(OutputStream.class, cos); - outInterceptor.handleMessage(message); - OutputStream os = message.getContent(OutputStream.class); - IOUtils.copy(messageIS, os); - os.close(); - cos.releaseTempFileHold(); - Document doc = StaxUtils.read(cos.getInputStream()); - Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); - } - - @Test - public void outXMLStreamTest() throws XMLStreamException, SAXException, IOException, ParserConfigurationException { - CachedWriter cWriter = new CachedWriter(); - cWriter.holdTempFile(); - XMLStreamWriter xWriter = StaxUtils.createXMLStreamWriter(cWriter); - message.setContent(XMLStreamWriter.class, xWriter); - outInterceptor.handleMessage(message); - XMLStreamWriter tXWriter = message.getContent(XMLStreamWriter.class); - StaxUtils.copy(new StreamSource(messageIS), tXWriter); - tXWriter.close(); - cWriter.releaseTempFileHold(); - Document doc = StaxUtils.read(cWriter.getReader()); - Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); - } - - @Test - public void outWriterStreamTest() throws Exception { - CachedWriter cWriter = new CachedWriter(); - message.setContent(Writer.class, cWriter); - outInterceptor.handleMessage(message); - Writer tWriter = message.getContent(Writer.class); - IOUtils.copy(new InputStreamReader(messageIS), tWriter, IOUtils.DEFAULT_BUFFER_SIZE); - tWriter.close(); - Document doc = StaxUtils.read(cWriter.getReader()); - Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); - } - - private boolean checkTransformedXML(Document doc) { - NodeList list = doc.getDocumentElement() - .getElementsByTagNameNS("http://customerservice.example.com/", "getCustomersByName1"); - return list.getLength() == 1; - } -} +/** + * 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.feature.transform; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.stream.StreamSource; + +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; + +import org.xml.sax.SAXException; + +import org.apache.cxf.common.classloader.ClassLoaderUtils; +import org.apache.cxf.helpers.IOUtils; +import org.apache.cxf.io.CachedOutputStream; +import org.apache.cxf.io.CachedWriter; +import org.apache.cxf.message.Message; +import org.apache.cxf.message.MessageImpl; +import org.apache.cxf.staxutils.StaxUtils; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/* Provides XSLT transformation of incoming message. + * Interceptor breaks streaming (can be fixed in further versions when XSLT engine supports XML stream) + */ +public class XSLTInterceptorsTest { + + private static final String TRANSFORMATION_XSL = "transformation.xsl"; + private static final String MESSAGE_FILE = "message.xml"; + + private InputStream messageIS; + private Message message; + private XSLTInInterceptor inInterceptor; + private XSLTOutInterceptor outInterceptor; + + @Before + public void setUp() throws TransformerConfigurationException { + messageIS = ClassLoaderUtils.getResourceAsStream(MESSAGE_FILE, this.getClass()); + if (messageIS == null) { + throw new IllegalArgumentException("Cannot load message from path: " + MESSAGE_FILE); + } + message = new MessageImpl(); + inInterceptor = new XSLTInInterceptor(TRANSFORMATION_XSL); + outInterceptor = new XSLTOutInterceptor(TRANSFORMATION_XSL); + } + + @Test + public void inStreamTest() throws Exception { + message.setContent(InputStream.class, messageIS); + inInterceptor.handleMessage(message); + InputStream transformedIS = message.getContent(InputStream.class); + Document doc = StaxUtils.read(transformedIS); + Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); + } + + @Test + public void inXMLStreamTest() throws XMLStreamException { + XMLStreamReader xReader = StaxUtils.createXMLStreamReader(messageIS); + message.setContent(XMLStreamReader.class, xReader); + inInterceptor.handleMessage(message); + XMLStreamReader transformedXReader = message.getContent(XMLStreamReader.class); + Document doc = StaxUtils.read(transformedXReader); + Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); + } + + @Test + public void inReaderTest() throws Exception { + Reader reader = new InputStreamReader(messageIS); + message.setContent(Reader.class, reader); + inInterceptor.handleMessage(message); + Reader transformedReader = message.getContent(Reader.class); + Document doc = StaxUtils.read(transformedReader); + Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); + } + + @Test + public void outStreamTest() throws Exception { + CachedOutputStream cos = new CachedOutputStream(); + cos.holdTempFile(); + message.setContent(OutputStream.class, cos); + outInterceptor.handleMessage(message); + OutputStream os = message.getContent(OutputStream.class); + IOUtils.copy(messageIS, os); + os.close(); + cos.releaseTempFileHold(); + Document doc = StaxUtils.read(cos.getInputStream()); + Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); + } + + @Test + public void outXMLStreamTest() throws XMLStreamException, SAXException, IOException, ParserConfigurationException { + CachedWriter cWriter = new CachedWriter(); + cWriter.holdTempFile(); + XMLStreamWriter xWriter = StaxUtils.createXMLStreamWriter(cWriter); + message.setContent(XMLStreamWriter.class, xWriter); + outInterceptor.handleMessage(message); + XMLStreamWriter tXWriter = message.getContent(XMLStreamWriter.class); + StaxUtils.copy(new StreamSource(messageIS), tXWriter); + tXWriter.close(); + cWriter.releaseTempFileHold(); + Document doc = StaxUtils.read(cWriter.getReader()); + Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); + } + + @Test + public void outWriterStreamTest() throws Exception { + CachedWriter cWriter = new CachedWriter(); + message.setContent(Writer.class, cWriter); + outInterceptor.handleMessage(message); + Writer tWriter = message.getContent(Writer.class); + IOUtils.copy(new InputStreamReader(messageIS), tWriter, IOUtils.DEFAULT_BUFFER_SIZE); + tWriter.close(); + Document doc = StaxUtils.read(cWriter.getReader()); + Assert.assertTrue("Message was not transformed", checkTransformedXML(doc)); + } + + private boolean checkTransformedXML(Document doc) { + NodeList list = doc.getDocumentElement() + .getElementsByTagNameNS("http://customerservice.example.com/", "getCustomersByName1"); + return list.getLength() == 1; + } +} + diff --git a/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java b/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java index bb0d5ec..257d731 100644 --- a/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java +++ b/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java @@ -23,6 +23,7 @@ package org.apache.cxf.helpers; import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType; import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.message.Message; + import org.easymock.EasyMock; import org.easymock.IMocksControl; import org.junit.Assert; diff --git a/core/src/test/java/org/apache/cxf/interceptor/LoggingInInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/LoggingInInterceptorTest.java index ccf9aee..d2e981c 100644 --- a/core/src/test/java/org/apache/cxf/interceptor/LoggingInInterceptorTest.java +++ b/core/src/test/java/org/apache/cxf/interceptor/LoggingInInterceptorTest.java @@ -31,7 +31,6 @@ import org.apache.cxf.message.MessageImpl; import org.easymock.EasyMock; import org.easymock.IAnswer; import org.easymock.IMocksControl; - import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java index 88019e0..1b85b41 100644 --- a/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java +++ b/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java @@ -35,9 +35,9 @@ import org.apache.cxf.message.Message; import org.apache.cxf.message.MessageImpl; import org.apache.cxf.service.model.BindingInfo; import org.apache.cxf.service.model.EndpointInfo; + import org.easymock.EasyMock; import org.easymock.IMocksControl; - import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java index 270b16b..75e515e 100644 --- a/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java +++ b/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java @@ -37,6 +37,7 @@ import org.apache.cxf.service.model.BindingMessageInfo; import org.apache.cxf.service.model.BindingOperationInfo; import org.apache.cxf.service.model.MessageInfo; import org.apache.cxf.service.model.OperationInfo; + import org.easymock.EasyMock; import org.easymock.IMocksControl; import org.junit.After; diff --git a/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java index cb6c604..30f37f5 100644 --- a/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java +++ b/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java @@ -31,6 +31,7 @@ import org.apache.cxf.message.MessageImpl; import org.apache.cxf.service.ServiceImpl; import org.apache.cxf.service.invoker.Invoker; import org.apache.cxf.service.model.ServiceInfo; + import org.easymock.EasyMock; import org.easymock.IMocksControl; import org.junit.Assert; diff --git a/core/src/test/java/org/apache/cxf/interceptor/security/JAASLoginInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/security/JAASLoginInterceptorTest.java index 462efc1..c96a1b5 100644 --- a/core/src/test/java/org/apache/cxf/interceptor/security/JAASLoginInterceptorTest.java +++ b/core/src/test/java/org/apache/cxf/interceptor/security/JAASLoginInterceptorTest.java @@ -38,6 +38,7 @@ import org.apache.cxf.interceptor.security.callback.CertKeyToUserNameMapper; import org.apache.cxf.message.Message; import org.apache.cxf.message.MessageImpl; import org.apache.cxf.security.transport.TLSSessionInfo; + import org.easymock.EasyMock; import org.easymock.IMocksControl; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/interceptor/security/OperationInfoAuthorizingInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/security/OperationInfoAuthorizingInterceptorTest.java index a0c5697..f4acf13 100755 --- a/core/src/test/java/org/apache/cxf/interceptor/security/OperationInfoAuthorizingInterceptorTest.java +++ b/core/src/test/java/org/apache/cxf/interceptor/security/OperationInfoAuthorizingInterceptorTest.java @@ -28,8 +28,8 @@ import org.apache.cxf.service.Service; import org.apache.cxf.service.invoker.MethodDispatcher; import org.apache.cxf.service.model.BindingOperationInfo; import org.apache.cxf.service.model.OperationInfo; -import org.easymock.EasyMock; +import org.easymock.EasyMock; import org.junit.Before; public class OperationInfoAuthorizingInterceptorTest extends SimpleAuthorizingInterceptorTest { diff --git a/core/src/test/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptorTest.java index aa02d2e..178745e 100644 --- a/core/src/test/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptorTest.java +++ b/core/src/test/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptorTest.java @@ -34,8 +34,8 @@ import org.apache.cxf.security.SecurityContext; import org.apache.cxf.service.Service; import org.apache.cxf.service.invoker.MethodDispatcher; import org.apache.cxf.service.model.BindingOperationInfo; -import org.easymock.EasyMock; +import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java index ad9b5c0..455015f 100644 --- a/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java +++ b/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java @@ -31,8 +31,8 @@ import org.apache.cxf.security.SecurityContext; import org.apache.cxf.service.Service; import org.apache.cxf.service.invoker.MethodDispatcher; import org.apache.cxf.service.model.BindingOperationInfo; -import org.easymock.EasyMock; +import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java b/core/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java index 9d69fe3..ec56639 100755 --- a/core/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java +++ b/core/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java @@ -31,6 +31,7 @@ import java.nio.charset.StandardCharsets; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; import org.apache.cxf.helpers.IOUtils; + import org.easymock.EasyMock; import org.easymock.IMocksControl; import org.junit.Assert; diff --git a/core/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java b/core/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java index 1c8f808..c6b16f5 100644 --- a/core/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java +++ b/core/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java @@ -34,9 +34,9 @@ import org.apache.cxf.interceptor.InterceptorChain; import org.apache.cxf.logging.FaultListener; import org.apache.cxf.message.FaultMode; import org.apache.cxf.message.Message; + import org.easymock.EasyMock; import org.easymock.IMocksControl; - import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/core/src/test/java/org/apache/cxf/resource/URIResolverTest.java b/core/src/test/java/org/apache/cxf/resource/URIResolverTest.java index d5b60ff..5997abb 100644 --- a/core/src/test/java/org/apache/cxf/resource/URIResolverTest.java +++ b/core/src/test/java/org/apache/cxf/resource/URIResolverTest.java @@ -23,6 +23,7 @@ import java.io.InputStream; import java.net.URL; import org.apache.cxf.helpers.IOUtils; + import org.junit.Assert; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/staxutils/PropertiesExpandingStreamReaderTest.java b/core/src/test/java/org/apache/cxf/staxutils/PropertiesExpandingStreamReaderTest.java index c975895..4381dda 100644 --- a/core/src/test/java/org/apache/cxf/staxutils/PropertiesExpandingStreamReaderTest.java +++ b/core/src/test/java/org/apache/cxf/staxutils/PropertiesExpandingStreamReaderTest.java @@ -29,6 +29,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.apache.cxf.helpers.DOMUtils; + import org.junit.Assert; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/staxutils/validation/Stax2ValidationUtilsTest.java b/core/src/test/java/org/apache/cxf/staxutils/validation/Stax2ValidationUtilsTest.java index e21bbf9..d6cc958 100644 --- a/core/src/test/java/org/apache/cxf/staxutils/validation/Stax2ValidationUtilsTest.java +++ b/core/src/test/java/org/apache/cxf/staxutils/validation/Stax2ValidationUtilsTest.java @@ -26,6 +26,7 @@ import java.io.StringReader; import java.util.ArrayList; import java.util.Collection; import java.util.List; + import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -35,6 +36,7 @@ import org.apache.cxf.endpoint.Endpoint; import org.apache.cxf.service.model.SchemaInfo; import org.apache.cxf.service.model.ServiceInfo; import org.apache.ws.commons.schema.XmlSchemaCollection; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/transport/ChainInitiationObserverTest.java b/core/src/test/java/org/apache/cxf/transport/ChainInitiationObserverTest.java index dc17467..3a3124d 100644 --- a/core/src/test/java/org/apache/cxf/transport/ChainInitiationObserverTest.java +++ b/core/src/test/java/org/apache/cxf/transport/ChainInitiationObserverTest.java @@ -25,6 +25,7 @@ import java.util.TreeSet; import org.apache.cxf.message.Message; import org.apache.cxf.phase.Phase; import org.apache.cxf.phase.PhaseInterceptorChain; + import org.easymock.EasyMock; import org.easymock.IMocksControl; import org.junit.After; diff --git a/core/src/test/java/org/apache/cxf/transport/common/gzip/GZIPAcceptEncodingTest.java b/core/src/test/java/org/apache/cxf/transport/common/gzip/GZIPAcceptEncodingTest.java index cd86280..0764e97 100644 --- a/core/src/test/java/org/apache/cxf/transport/common/gzip/GZIPAcceptEncodingTest.java +++ b/core/src/test/java/org/apache/cxf/transport/common/gzip/GZIPAcceptEncodingTest.java @@ -34,8 +34,8 @@ import org.apache.cxf.message.Exchange; import org.apache.cxf.message.ExchangeImpl; import org.apache.cxf.message.Message; import org.apache.cxf.message.MessageImpl; -import org.easymock.EasyMock; +import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/org/apache/cxf/ws/addressing/ContextUtilsTest.java b/core/src/test/java/org/apache/cxf/ws/addressing/ContextUtilsTest.java index 54d5856..a905183 100644 --- a/core/src/test/java/org/apache/cxf/ws/addressing/ContextUtilsTest.java +++ b/core/src/test/java/org/apache/cxf/ws/addressing/ContextUtilsTest.java @@ -24,6 +24,7 @@ import java.util.Random; import org.apache.cxf.message.ExchangeImpl; import org.apache.cxf.message.Message; import org.apache.cxf.message.MessageImpl; + import org.junit.Test; import static org.apache.cxf.ws.addressing.ContextUtils.getAttributedURI; diff --git a/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/IDLToWSDLPlugin.java b/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/IDLToWSDLPlugin.java index dd6e172..4509305 100644 --- a/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/IDLToWSDLPlugin.java +++ b/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/IDLToWSDLPlugin.java @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.List; import org.apache.cxf.tools.corba.IDLToWSDL; - import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
