You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ro...@apache.org on 2019/12/04 15:31:07 UTC

[aries-cdi] branch master updated: ARIES-1955 Upgrade spifly

This is an automated email from the ASF dual-hosted git repository.

rotty3000 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-cdi.git


The following commit(s) were added to refs/heads/master by this push:
     new bdea331  ARIES-1955 Upgrade spifly
     new 38eddb7  Merge pull request #14 from rotty3000/ARIES-1955
bdea331 is described below

commit bdea331dee852876e1d50b03358a2242d6f612b6
Author: Raymond Augé <ro...@apache.org>
AuthorDate: Tue Dec 3 14:09:21 2019 -0500

    ARIES-1955 Upgrade spifly
    
    Signed-off-by: Raymond Augé <ro...@apache.org>
---
 cdi-bom/pom.xml                                    |   2 +-
 cdi-executable/owb-executable.bndrun               |   2 +-
 cdi-executable/weld-executable.bndrun              |   2 +-
 .../internal/phase/ContainerBootstrapTest.java     |   1 +
 .../cdi/container/test/ContainerListenerTest.java  | 335 +++++++++++----------
 cdi-extra/pom.xml                                  |   1 -
 cdi-itests/owb-itest.bndrun                        |   2 +-
 cdi-itests/weld-itest.bndrun                       |   2 +-
 8 files changed, 174 insertions(+), 173 deletions(-)

diff --git a/cdi-bom/pom.xml b/cdi-bom/pom.xml
index a0cc023..f1b0a15 100644
--- a/cdi-bom/pom.xml
+++ b/cdi-bom/pom.xml
@@ -102,7 +102,7 @@
 			<dependency>
 				<groupId>org.apache.aries.spifly</groupId>
 				<artifactId>org.apache.aries.spifly.dynamic.framework.extension</artifactId>
-				<version>1.2</version>
+				<version>1.2.3</version>
 				<scope>runtime</scope>
 			</dependency>
 			<dependency>
diff --git a/cdi-executable/owb-executable.bndrun b/cdi-executable/owb-executable.bndrun
index bb3372f..3a0c023 100644
--- a/cdi-executable/owb-executable.bndrun
+++ b/cdi-executable/owb-executable.bndrun
@@ -54,7 +54,7 @@
 	org.apache.aries.cdi.extra;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.owb;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.spi;version='[1.1.0,1.1.1)',\
-	org.apache.aries.spifly.dynamic.framework.extension;version='[1.2.0,1.2.1)',\
+	org.apache.aries.spifly.dynamic.framework.extension;version='[1.2.3,1.2.4)',\
 	org.apache.felix.configadmin;version='[1.9.10,1.9.11)',\
 	org.apache.felix.converter;version='[1.0.12,1.0.13)',\
 	org.apache.felix.gogo.command;version='[1.1.0,1.1.1)',\
diff --git a/cdi-executable/weld-executable.bndrun b/cdi-executable/weld-executable.bndrun
index 2d9478a..a8b5d95 100644
--- a/cdi-executable/weld-executable.bndrun
+++ b/cdi-executable/weld-executable.bndrun
@@ -54,7 +54,7 @@
 	org.apache.aries.cdi.extender;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.spi;version='[1.1.0,1.1.1)',\
 	org.apache.aries.cdi.weld;version='[1.1.0,1.1.1)',\
-	org.apache.aries.spifly.dynamic.framework.extension;version='[1.2.0,1.2.1)',\
+	org.apache.aries.spifly.dynamic.framework.extension;version='[1.2.3,1.2.4)',\
 	org.apache.felix.configadmin;version='[1.9.10,1.9.11)',\
 	org.apache.felix.converter;version='[1.0.12,1.0.13)',\
 	org.apache.felix.gogo.command;version='[1.1.0,1.1.1)',\
diff --git a/cdi-extender/src/test/java/org/apache/aries/cdi/container/internal/phase/ContainerBootstrapTest.java b/cdi-extender/src/test/java/org/apache/aries/cdi/container/internal/phase/ContainerBootstrapTest.java
index be14d4a..822b04c 100644
--- a/cdi-extender/src/test/java/org/apache/aries/cdi/container/internal/phase/ContainerBootstrapTest.java
+++ b/cdi-extender/src/test/java/org/apache/aries/cdi/container/internal/phase/ContainerBootstrapTest.java
@@ -83,6 +83,7 @@ public class ContainerBootstrapTest extends BaseCDIBundleTest {
 		@SuppressWarnings("unchecked")
 		ServiceTracker<CDIContainerInitializer, ServiceObjects<CDIContainerInitializer>> serviceTracker = mock(ServiceTracker.class);
 
+		@SuppressWarnings("unchecked")
 		ContainerBootstrap containerBootstrap = new ContainerBootstrap(
 			containerState, serviceTracker,
 			new ConfigurationListener.Builder(containerState),
diff --git a/cdi-extender/src/test/java/org/apache/aries/cdi/container/test/ContainerListenerTest.java b/cdi-extender/src/test/java/org/apache/aries/cdi/container/test/ContainerListenerTest.java
index 20ba3af..aaf15e5 100644
--- a/cdi-extender/src/test/java/org/apache/aries/cdi/container/test/ContainerListenerTest.java
+++ b/cdi-extender/src/test/java/org/apache/aries/cdi/container/test/ContainerListenerTest.java
@@ -47,171 +47,172 @@ import org.osgi.service.cdi.runtime.dto.ComponentDTO;
 import org.osgi.util.tracker.ServiceTracker;
 
 public class ContainerListenerTest extends BaseCDIBundleTest {
-    private enum State {
-        BEFORE_START, STARTED, STOPPED
-    }
-
-    @Test
-    public void ensureListenerIsCalledForSuccesses() throws Exception {
-        final EmptyCdiContainer cdiContainer = new EmptyCdiContainer();
-        doRun(cdiContainer, (containerBootstrap, listenerCalls) -> {
-            assertTrue(listenerCalls.isEmpty());
-            assertEquals(State.BEFORE_START, cdiContainer.state);
-            containerBootstrap.open();
-            assertEquals(singletonList("onStartSuccess"), listenerCalls);
-            assertEquals(State.STARTED, cdiContainer.state);
-            assertTrue(containerBootstrap.close());
-            assertEquals(asList("onStartSuccess", "onStopSuccess"), listenerCalls);
-            assertEquals(State.STOPPED, cdiContainer.state);
-        });
-    }
-
-    @Test
-    public void ensureListenerIsCalledForFailedStop() throws Exception {
-        final EmptyCdiContainer cdiContainer = new EmptyCdiContainer();
-        cdiContainer.failAtState = State.STOPPED;
-        doRun(cdiContainer, (containerBootstrap, listenerCalls) -> {
-            assertTrue(listenerCalls.isEmpty());
-            assertEquals(State.BEFORE_START, cdiContainer.state);
-            containerBootstrap.open();
-            assertEquals(singletonList("onStartSuccess"), listenerCalls);
-            assertEquals(State.STARTED, cdiContainer.state);
-            assertFalse(containerBootstrap.close());
-            assertEquals(asList("onStartSuccess", "onStopError"), listenerCalls);
-        });
-    }
-
-    @Test
-    public void ensureListenerIsCalledForFailedStartup() throws Exception {
-        final EmptyCdiContainer cdiContainer = new EmptyCdiContainer();
-        cdiContainer.failAtState = State.STARTED;
-        doRun(cdiContainer, (containerBootstrap, listenerCalls) -> {
-            assertTrue(listenerCalls.isEmpty());
-            assertEquals(State.BEFORE_START, cdiContainer.state);
-            try {
-                containerBootstrap.open();
-                fail();
-            } catch (final RuntimeException re) {
-                // expected
-            }
-            assertEquals(singletonList("onStartError"), listenerCalls);
-        });
-    }
-
-    private void doRun(EmptyCdiContainer cdiContainer, final BiConsumer<ContainerBootstrap, List<String>> test) throws Exception {
-        ContainerState containerState = new ContainerState(
-                bundle, ccrBundle, ccrChangeCount, promiseFactory, TestUtil.mockCaSt(bundle),
-                new Logs.Builder(bundle.getBundleContext()).build());
-
-        // ensure it starts, this is not really used in this test but required due to current open() impl
-        ComponentDTO componentDTO = new ComponentDTO();
-        componentDTO.enabled = false;
-        containerState.containerDTO().components.add(componentDTO);
-
-        List<String> listenerCalls = new ArrayList<>();
-        ContainerListener listenerSpy = ContainerListener.class.cast(Proxy.newProxyInstance(
-                Thread.currentThread().getContextClassLoader(),
-                new Class<?>[]{ContainerListener.class},
-                (proxy, method, args) -> {
-                    listenerCalls.add(method.getName());
-                    return null; // all methods return void
-                }));
-
-        final MockServiceRegistration<ContainerListener> initializer = new MockServiceRegistration<>(
-                new MockServiceReference<>(bundle, listenerSpy, new String[]{CDIContainerInitializer.class.getName()}),
-                TestUtil.serviceRegistrations,
-                TestUtil.serviceListeners);
-        final MockServiceRegistration<ContainerListener> listener = new MockServiceRegistration<>(
-                new MockServiceReference<>(bundle, listenerSpy, new String[]{ContainerListener.class.getName()}),
-                TestUtil.serviceRegistrations,
-                TestUtil.serviceListeners);
-        ContainerBootstrap containerBootstrap = new ContainerBootstrap(
-                containerState,
-                new ServiceTracker<CDIContainerInitializer, ServiceObjects<CDIContainerInitializer>>(
-                        bundle.getBundleContext(), CDIContainerInitializer.class, null) {
-                    @Override
-                    public ServiceObjects<CDIContainerInitializer> getService() {
-                        return cdiContainer;
-                    }
-                },
-                new ConfigurationListener.Builder(containerState),
-                new SingleComponent.Builder(containerState, null),
-                new FactoryComponent.Builder(containerState, null),
-                new ServiceTracker<ContainerListener, ContainerListener>(bundle.getBundleContext(), ContainerListener.class, null) {
-                    @Override
-                    public ServiceReference<ContainerListener>[] getServiceReferences() {
-                        return new ServiceReference[] { listener.getReference() };
-                    }
-                });
-
-        try {
-            test.accept(containerBootstrap, listenerCalls);
-        } finally {
-            Stream.of(initializer, listener).forEach(TestUtil.serviceRegistrations::remove);
-        }
-    }
-
-    private static class EmptyCdiContainer implements ServiceObjects<CDIContainerInitializer> {
-        private State state = State.BEFORE_START;
-        private State failAtState;
-
-        @Override
-        public CDIContainerInitializer getService() {
-            return new CDIContainerInitializer() {
-                @Override
-                public CDIContainerInitializer addBeanClasses(Class<?>... classes) {
-                    return this;
-                }
-
-                @Override
-                public CDIContainerInitializer addBeanXmls(URL... beanXmls) {
-                    return this;
-                }
-
-                @Override
-                public CDIContainerInitializer addExtension(Extension extension, Map<String, Object> properties) {
-                    return this;
-                }
-
-                @Override
-                public CDIContainerInitializer addProperty(String key, Object value) {
-                    return this;
-                }
-
-                @Override
-                public CDIContainerInitializer setClassLoader(SpiLoader spiLoader) {
-                    return this;
-                }
-
-                @Override
-                public CDIContainerInitializer setBundleContext(BundleContext bundleContext) {
-                    return this;
-                }
-
-                @Override
-                public AutoCloseable initialize() {
-                    state = State.STARTED;
-                    if (failAtState != null && failAtState == State.STARTED) {
-                        throw new RuntimeException("failed for test");
-                    }
-                    return () -> {
-                        if (failAtState != null && failAtState == State.STOPPED) {
-                            throw new RuntimeException("failed for test");
-                        }
-                        state = State.STOPPED;
-                    };
-                }
-            };
-        }
-
-        @Override
-        public void ungetService(final CDIContainerInitializer service) {
-            // no-op
-        }
-
-        @Override
-        public ServiceReference<CDIContainerInitializer> getServiceReference() {
-            return null;
-        }
-    }
+	private enum State {
+		BEFORE_START, STARTED, STOPPED
+	}
+
+	@Test
+	public void ensureListenerIsCalledForSuccesses() throws Exception {
+		final EmptyCdiContainer cdiContainer = new EmptyCdiContainer();
+		doRun(cdiContainer, (containerBootstrap, listenerCalls) -> {
+			assertTrue(listenerCalls.isEmpty());
+			assertEquals(State.BEFORE_START, cdiContainer.state);
+			containerBootstrap.open();
+			assertEquals(singletonList("onStartSuccess"), listenerCalls);
+			assertEquals(State.STARTED, cdiContainer.state);
+			assertTrue(containerBootstrap.close());
+			assertEquals(asList("onStartSuccess", "onStopSuccess"), listenerCalls);
+			assertEquals(State.STOPPED, cdiContainer.state);
+		});
+	}
+
+	@Test
+	public void ensureListenerIsCalledForFailedStop() throws Exception {
+		final EmptyCdiContainer cdiContainer = new EmptyCdiContainer();
+		cdiContainer.failAtState = State.STOPPED;
+		doRun(cdiContainer, (containerBootstrap, listenerCalls) -> {
+			assertTrue(listenerCalls.isEmpty());
+			assertEquals(State.BEFORE_START, cdiContainer.state);
+			containerBootstrap.open();
+			assertEquals(singletonList("onStartSuccess"), listenerCalls);
+			assertEquals(State.STARTED, cdiContainer.state);
+			assertFalse(containerBootstrap.close());
+			assertEquals(asList("onStartSuccess", "onStopError"), listenerCalls);
+		});
+	}
+
+	@Test
+	public void ensureListenerIsCalledForFailedStartup() throws Exception {
+		final EmptyCdiContainer cdiContainer = new EmptyCdiContainer();
+		cdiContainer.failAtState = State.STARTED;
+		doRun(cdiContainer, (containerBootstrap, listenerCalls) -> {
+			assertTrue(listenerCalls.isEmpty());
+			assertEquals(State.BEFORE_START, cdiContainer.state);
+			try {
+				containerBootstrap.open();
+				fail();
+			} catch (final RuntimeException re) {
+				// expected
+			}
+			assertEquals(singletonList("onStartError"), listenerCalls);
+		});
+	}
+
+	private void doRun(EmptyCdiContainer cdiContainer, final BiConsumer<ContainerBootstrap, List<String>> test) throws Exception {
+		ContainerState containerState = new ContainerState(
+				bundle, ccrBundle, ccrChangeCount, promiseFactory, TestUtil.mockCaSt(bundle),
+				new Logs.Builder(bundle.getBundleContext()).build());
+
+		// ensure it starts, this is not really used in this test but required due to current open() impl
+		ComponentDTO componentDTO = new ComponentDTO();
+		componentDTO.enabled = false;
+		containerState.containerDTO().components.add(componentDTO);
+
+		List<String> listenerCalls = new ArrayList<>();
+		ContainerListener listenerSpy = ContainerListener.class.cast(Proxy.newProxyInstance(
+				Thread.currentThread().getContextClassLoader(),
+				new Class<?>[]{ContainerListener.class},
+				(proxy, method, args) -> {
+					listenerCalls.add(method.getName());
+					return null; // all methods return void
+				}));
+
+		final MockServiceRegistration<ContainerListener> initializer = new MockServiceRegistration<>(
+				new MockServiceReference<>(bundle, listenerSpy, new String[]{CDIContainerInitializer.class.getName()}),
+				TestUtil.serviceRegistrations,
+				TestUtil.serviceListeners);
+		final MockServiceRegistration<ContainerListener> listener = new MockServiceRegistration<>(
+				new MockServiceReference<>(bundle, listenerSpy, new String[]{ContainerListener.class.getName()}),
+				TestUtil.serviceRegistrations,
+				TestUtil.serviceListeners);
+		ContainerBootstrap containerBootstrap = new ContainerBootstrap(
+				containerState,
+				new ServiceTracker<CDIContainerInitializer, ServiceObjects<CDIContainerInitializer>>(
+						bundle.getBundleContext(), CDIContainerInitializer.class, null) {
+					@Override
+					public ServiceObjects<CDIContainerInitializer> getService() {
+						return cdiContainer;
+					}
+				},
+				new ConfigurationListener.Builder(containerState),
+				new SingleComponent.Builder(containerState, null),
+				new FactoryComponent.Builder(containerState, null),
+				new ServiceTracker<ContainerListener, ContainerListener>(bundle.getBundleContext(), ContainerListener.class, null) {
+					@Override
+					@SuppressWarnings("unchecked")
+					public ServiceReference<ContainerListener>[] getServiceReferences() {
+						return new ServiceReference[] { listener.getReference() };
+					}
+				});
+
+		try {
+			test.accept(containerBootstrap, listenerCalls);
+		} finally {
+			Stream.of(initializer, listener).forEach(TestUtil.serviceRegistrations::remove);
+		}
+	}
+
+	private static class EmptyCdiContainer implements ServiceObjects<CDIContainerInitializer> {
+		private State state = State.BEFORE_START;
+		private State failAtState;
+
+		@Override
+		public CDIContainerInitializer getService() {
+			return new CDIContainerInitializer() {
+				@Override
+				public CDIContainerInitializer addBeanClasses(Class<?>... classes) {
+					return this;
+				}
+
+				@Override
+				public CDIContainerInitializer addBeanXmls(URL... beanXmls) {
+					return this;
+				}
+
+				@Override
+				public CDIContainerInitializer addExtension(Extension extension, Map<String, Object> properties) {
+					return this;
+				}
+
+				@Override
+				public CDIContainerInitializer addProperty(String key, Object value) {
+					return this;
+				}
+
+				@Override
+				public CDIContainerInitializer setClassLoader(SpiLoader spiLoader) {
+					return this;
+				}
+
+				@Override
+				public CDIContainerInitializer setBundleContext(BundleContext bundleContext) {
+					return this;
+				}
+
+				@Override
+				public AutoCloseable initialize() {
+					state = State.STARTED;
+					if (failAtState != null && failAtState == State.STARTED) {
+						throw new RuntimeException("failed for test");
+					}
+					return () -> {
+						if (failAtState != null && failAtState == State.STOPPED) {
+							throw new RuntimeException("failed for test");
+						}
+						state = State.STOPPED;
+					};
+				}
+			};
+		}
+
+		@Override
+		public void ungetService(final CDIContainerInitializer service) {
+			// no-op
+		}
+
+		@Override
+		public ServiceReference<CDIContainerInitializer> getServiceReference() {
+			return null;
+		}
+	}
 }
diff --git a/cdi-extra/pom.xml b/cdi-extra/pom.xml
index 3e4455e..21a354f 100644
--- a/cdi-extra/pom.xml
+++ b/cdi-extra/pom.xml
@@ -101,7 +101,6 @@
 		<dependency>
 			<groupId>org.osgi</groupId>
 			<artifactId>org.osgi.service.jaxrs</artifactId>
-			<version>1.0.0</version>
 			<scope>provided</scope>
 		</dependency>
 		<dependency>
diff --git a/cdi-itests/owb-itest.bndrun b/cdi-itests/owb-itest.bndrun
index 2ff1325..ce498f4 100644
--- a/cdi-itests/owb-itest.bndrun
+++ b/cdi-itests/owb-itest.bndrun
@@ -37,7 +37,7 @@
 	org.apache.aries.cdi.spi;version='[1.1.0,1.1.1)',\
 	org.apache.aries.jndi.api;version='[1.1.0,1.1.1)',\
 	org.apache.aries.jndi.core;version='[1.0.2,1.0.3)',\
-	org.apache.aries.spifly.dynamic.framework.extension;version='[1.2.0,1.2.1)',\
+	org.apache.aries.spifly.dynamic.framework.extension;version='[1.2.3,1.2.4)',\
 	org.apache.aries.util;version='[1.0.0,1.0.1)',\
 	org.apache.commons.logging;version='[1.2.0,1.2.1)',\
 	org.apache.felix.configadmin;version='[1.9.10,1.9.11)',\
diff --git a/cdi-itests/weld-itest.bndrun b/cdi-itests/weld-itest.bndrun
index 8eb172b..45ee863 100644
--- a/cdi-itests/weld-itest.bndrun
+++ b/cdi-itests/weld-itest.bndrun
@@ -46,7 +46,7 @@
 	org.apache.aries.cdi.weld;version='[1.1.0,1.1.1)',\
 	org.apache.aries.jndi.api;version='[1.1.0,1.1.1)',\
 	org.apache.aries.jndi.core;version='[1.0.2,1.0.3)',\
-	org.apache.aries.spifly.dynamic.framework.extension;version='[1.2.0,1.2.1)',\
+	org.apache.aries.spifly.dynamic.framework.extension;version='[1.2.3,1.2.4)',\
 	org.apache.aries.util;version='[1.0.0,1.0.1)',\
 	org.apache.commons.logging;version='[1.2.0,1.2.1)',\
 	org.apache.felix.configadmin;version='[1.9.10,1.9.11)',\