You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2014/05/27 00:48:20 UTC
svn commit: r1597661 - in
/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it:
components/ tests/
Author: pderop
Date: Mon May 26 22:48:20 2014
New Revision: 1597661
URL: http://svn.apache.org/r1597661
Log:
Added the last remaining aspect annotation tests
Added:
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectAnnotation.java
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectLifecycleAnnotation.java
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectLifecycleWithDynamicProxyAnnotation.java
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectAnnotationTest.java
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectLifecycleAnnotationTest.java
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectLifecycleWithDynamicProxyAnnotationTest.java
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectAnnotation.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectAnnotation.java?rev=1597661&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectAnnotation.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectAnnotation.java Mon May 26 22:48:20 2014
@@ -0,0 +1,229 @@
+/*
+ * 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 dm.runtime.it.components;
+
+import dm.DependencyManager;
+import dm.annotation.api.*;
+import dm.it.Ensure;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class AspectAnnotation {
+ public interface ServiceInterface {
+ public void invoke(Runnable run);
+ }
+
+ @Component
+ public static class ServiceProvider implements ServiceInterface {
+ public final static String ENSURE = "AspectAnnotation.ServiceProvider";
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ protected volatile Ensure m_sequencer;
+ // Injected by reflection.
+ protected volatile ServiceRegistration m_sr;
+
+ @Init
+ void init() {
+ System.out.println("ServiceProvider.init");
+ }
+
+ @Destroy
+ void destroy() {
+ System.out.println("ServiceProvider.destroy");
+ }
+
+ public void invoke(Runnable run) {
+ run.run();
+ m_sequencer.step(6);
+ }
+ }
+
+ @AspectService(ranking = 20)
+ public static class ServiceAspect2 implements ServiceInterface {
+ public final static String ENSURE = "AspectAnnotation.ServiceAspect2";
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ protected volatile Ensure m_sequencer;
+ // Injected by reflection.
+ private volatile ServiceInterface m_parentService;
+
+ // Check auto config injections
+ @Inject
+ volatile BundleContext m_bc;
+ BundleContext m_bcNotInjected;
+
+ @Inject
+ volatile DependencyManager m_dm;
+ DependencyManager m_dmNotInjected;
+
+ @Inject
+ volatile dm.Component m_component;
+ dm.Component m_componentNotInjected;
+
+ @Init
+ void init() {
+ System.out.println("ServiceAspect2.init");
+ }
+
+ @Destroy
+ void destroy() {
+ System.out.println("ServiceAspect2.destroy");
+ }
+
+ public void invoke(Runnable run) {
+ checkInjectedFields();
+ m_sequencer.step(3);
+ m_parentService.invoke(run);
+ }
+
+ private void checkInjectedFields() {
+ if (m_bc == null) {
+ m_sequencer.throwable(new Exception("Bundle Context not injected"));
+ return;
+ }
+ if (m_bcNotInjected != null) {
+ m_sequencer.throwable(new Exception("Bundle Context must not be injected"));
+ return;
+ }
+
+ if (m_dm == null) {
+ m_sequencer.throwable(new Exception("DependencyManager not injected"));
+ return;
+ }
+ if (m_dmNotInjected != null) {
+ m_sequencer.throwable(new Exception("DependencyManager must not be injected"));
+ return;
+ }
+
+ if (m_component == null) {
+ m_sequencer.throwable(new Exception("Component not injected"));
+ return;
+ }
+ if (m_componentNotInjected != null) {
+ m_sequencer.throwable(new Exception("Component must not be injected"));
+ return;
+ }
+ }
+ }
+
+ @AspectService(ranking = 30, added = "add")
+ public static class ServiceAspect3 implements ServiceInterface {
+ public final static String ENSURE = "AspectAnnotation.ServiceAspect3";
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ protected volatile Ensure m_sequencer;
+ // Injected using add callback.
+ private volatile ServiceInterface m_parentService;
+
+ @Init
+ void init() {
+ System.out.println("ServiceAspect3.init");
+ }
+
+ @Destroy
+ void destroy() {
+ System.out.println("ServiceAspect3.destroy");
+ }
+
+ void add(ServiceInterface si) {
+ m_parentService = si;
+ }
+
+ public void invoke(Runnable run) {
+ m_sequencer.step(2);
+ m_parentService.invoke(run);
+ }
+ }
+
+ @AspectService(ranking = 10, added = "added", removed = "removed")
+ public static class ServiceAspect1 implements ServiceInterface {
+ public final static String ENSURE = "AspectAnnotation.ServiceAspect1";
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ protected volatile Ensure m_sequencer;
+ // Injected by reflection.
+ private volatile ServiceInterface m_parentService;
+
+ @Init
+ void init() {
+ System.out.println("ServiceAspect1.init");
+ }
+
+ @Destroy
+ void destroy() {
+ System.out.println("ServiceAspect1.destroy");
+ }
+
+ void added(ServiceInterface si) {
+ m_parentService = si;
+ }
+
+ @Stop
+ void stop() {
+ m_sequencer.step(7);
+ }
+
+ void removed(ServiceInterface si) {
+ m_sequencer.step(8);
+ }
+
+ public void invoke(Runnable run) {
+ m_sequencer.step(4);
+ m_parentService.invoke(run);
+ }
+ }
+
+ @Component
+ public static class ServiceConsumer implements Runnable {
+ public final static String ENSURE = "AspectAnnotation.ServiceConsumer";
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ protected volatile Ensure m_sequencer;
+
+ @ServiceDependency
+ private volatile ServiceInterface m_service;
+
+ private Thread m_thread;
+
+ @Init
+ public void init() {
+ m_thread = new Thread(this, "ServiceConsumer");
+ m_thread.start();
+ }
+
+ public void run() {
+ m_sequencer.waitForStep(1, 2000);
+ m_service.invoke(new Runnable() {
+ public void run() {
+ m_sequencer.step(5);
+ }
+ });
+ }
+
+ @Destroy
+ void destroy() {
+ m_thread.interrupt();
+ try {
+ m_thread.join();
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectLifecycleAnnotation.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectLifecycleAnnotation.java?rev=1597661&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectLifecycleAnnotation.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectLifecycleAnnotation.java Mon May 26 22:48:20 2014
@@ -0,0 +1,93 @@
+/*
+ * 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 dm.runtime.it.components;
+
+import dm.annotation.api.*;
+import dm.it.Ensure;
+
+public class AspectLifecycleAnnotation {
+ public interface ServiceInterface {
+ public void run();
+ }
+
+ /**
+ * Tests an aspect service, and ensure that its lifecycle methods are properly invoked (init/start/stop/destroy)
+ */
+ @Component
+ public static class AspectLifecycleTest {
+ @ServiceDependency
+ void bind(ServiceInterface service) {
+ service.run();
+ }
+ }
+
+ @Component
+ public static class ServiceProvider implements ServiceInterface {
+ public final static String ENSURE = "AspectLifecycleAnnotation.ServiceProvider";
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ protected volatile Ensure m_sequencer;
+
+ public void run() {
+ m_sequencer.step();
+ }
+ }
+
+ @AspectService(ranking = 10)
+ public static class ServiceProviderAspect implements ServiceInterface {
+ public final static String ENSURE = "AspectLifecycleAnnotation.ServiceProviderAspect";
+
+ protected volatile boolean m_initCalled;
+ protected volatile Ensure m_sequencer;
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ protected void bind(Ensure sequencer) {
+ m_sequencer = sequencer;
+ m_sequencer.step(2);
+ }
+
+ @Init
+ void init() {
+ m_initCalled = true;
+ }
+
+ @Start
+ void start() {
+ if (!m_initCalled) {
+ throw new IllegalStateException("start method called, but init method was not called");
+ }
+ m_sequencer.step(3);
+ }
+
+ public void run() {
+ m_sequencer.step(4);
+ }
+
+ @Stop()
+ void stop() {
+ // At this point, the AspectLifecycleTest class has been rebound to the original ServiceProvider.
+ m_sequencer.step(6);
+ }
+
+ @Destroy
+ void destroy() {
+ m_sequencer.step(7);
+ }
+ }
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectLifecycleWithDynamicProxyAnnotation.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectLifecycleWithDynamicProxyAnnotation.java?rev=1597661&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectLifecycleWithDynamicProxyAnnotation.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/AspectLifecycleWithDynamicProxyAnnotation.java Mon May 26 22:48:20 2014
@@ -0,0 +1,110 @@
+/*
+* 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 dm.runtime.it.components;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import dm.annotation.api.*;
+import dm.it.Ensure;
+
+public class AspectLifecycleWithDynamicProxyAnnotation {
+ public interface ServiceInterface {
+ public void run();
+ }
+
+ /**
+ * Tests an aspect service, and ensure that its lifecycle methods are properly invoked (init/start/stop/destroy)
+ */
+ @Component
+ public static class AspectLifecycleTest {
+ @ServiceDependency
+ void bind(ServiceInterface service) {
+ service.run();
+ }
+ }
+
+ @Component
+ public static class ServiceProvider implements ServiceInterface {
+ public final static String ENSURE = "AspectLifecycleWithDynamicProxyAnnotation.ServiceProvider";
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ protected volatile Ensure m_sequencer;
+
+ public void run() {
+ m_sequencer.step();
+ }
+ }
+
+ @AspectService(ranking = 10, service = ServiceInterface.class, factoryMethod = "create")
+ public static class ServiceProviderAspect implements InvocationHandler {
+ public final static String ENSURE = "AspectLifecycleWithDynamicProxyAnnotation.ServiceProviderAspect";
+
+ protected volatile boolean m_initCalled;
+ protected volatile Ensure m_sequencer;
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ protected void bind(Ensure sequencer) {
+ m_sequencer = sequencer;
+ m_sequencer.step(2);
+ }
+
+ public static Object create() {
+ return Proxy.newProxyInstance(ServiceProviderAspect.class.getClassLoader(),
+ new Class[]{ServiceInterface.class}, new ServiceProviderAspect());
+ }
+
+ @Init
+ void init() {
+ m_initCalled = true;
+ }
+
+ @Start
+ void start() {
+ if (!m_initCalled) {
+ throw new IllegalStateException("start method called, but init method was not called");
+ }
+ m_sequencer.step(3);
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (method.getName().equals("toString")) {
+ return "ServiceProviderAspect@" + System.identityHashCode(this);
+ }
+
+ if (!method.getName().equals("run")) {
+ throw new IllegalStateException("wrong invoked method: " + method);
+ }
+ m_sequencer.step(4);
+ return null;
+ }
+
+ @Stop()
+ void stop() {
+ // At this point, the AspectLifecycleTest class has been rebound to the original ServiceProvider.
+ m_sequencer.step(6);
+ }
+
+ @Destroy
+ void destroy() {
+ m_sequencer.step(7);
+ }
+ }
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectAnnotationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectAnnotationTest.java?rev=1597661&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectAnnotationTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectAnnotationTest.java Mon May 26 22:48:20 2014
@@ -0,0 +1,62 @@
+/*
+* 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.AspectAnnotation.ServiceAspect1;
+import dm.runtime.it.components.AspectAnnotation.ServiceAspect2;
+import dm.runtime.it.components.AspectAnnotation.ServiceAspect3;
+import dm.runtime.it.components.AspectAnnotation.ServiceConsumer;
+import dm.runtime.it.components.AspectAnnotation.ServiceProvider;
+
+/**
+ * Use case: Verify Aspect Annotations usage.
+ */
+public class AspectAnnotationTest extends TestBase {
+ public void testAspectChain() throws Throwable {
+ Ensure e = new Ensure();
+ // Activate service consumer
+ ServiceRegistration scSequencer = register(e, ServiceConsumer.ENSURE);
+ // Activate service provider
+ ServiceRegistration spSequencer = register(e, ServiceProvider.ENSURE);
+ // Activate service aspect 2
+ ServiceRegistration sa2Sequencer = register(e, ServiceAspect2.ENSURE);
+ // Activate service aspect 3
+ ServiceRegistration sa3Sequencer = register(e, ServiceAspect3.ENSURE);
+ // Activate service aspect 1
+ ServiceRegistration sa1Sequencer = register(e, ServiceAspect1.ENSURE);
+
+ e.step();
+ e.waitForStep(6, 10000);
+
+ // Deactivate service provider
+ spSequencer.unregister();
+ // Make sure that service aspect 1 has been called in ts removed and stop callbacks
+ e.waitForStep(8, 10000);
+ e.ensure();
+
+ scSequencer.unregister();
+ sa1Sequencer.unregister();
+ sa2Sequencer.unregister();
+ sa3Sequencer.unregister();
+ }
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectLifecycleAnnotationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectLifecycleAnnotationTest.java?rev=1597661&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectLifecycleAnnotationTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectLifecycleAnnotationTest.java Mon May 26 22:48:20 2014
@@ -0,0 +1,49 @@
+/*
+* 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.AspectLifecycleAnnotation.ServiceProvider;
+import dm.runtime.it.components.AspectLifecycleAnnotation.ServiceProviderAspect;
+
+/**
+ * Use case: Tests an aspect service, and ensure that its lifecycle methods are properly invoked
+ * (init/start/stop/destroy methods).
+ */
+public class AspectLifecycleAnnotationTest extends TestBase {
+ public void testAnnotatedAspect() {
+ Ensure e = new Ensure();
+ // Provide the Sequencer server to the ServiceProvider service
+ ServiceRegistration sr1 = register(e, ServiceProvider.ENSURE);
+ // Check if the ServiceProvider has been injected in the AspectTest service.
+ e.waitForStep(1, 10000);
+ // Provide the Sequencer server to the ServiceProviderAspect service
+ ServiceRegistration sr2 = register(e, ServiceProviderAspect.ENSURE);
+ // Check if the AspectTest has been injected with the aspect
+ e.waitForStep(3, 10000);
+ // Stop the ServiceProviderAspect service.
+ sr2.unregister();
+ // And check if the aspect has been called in its stop/destroy methods.
+ e.waitForStep(7, 10000);
+ sr1.unregister();
+ }
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectLifecycleWithDynamicProxyAnnotationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectLifecycleWithDynamicProxyAnnotationTest.java?rev=1597661&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectLifecycleWithDynamicProxyAnnotationTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AspectLifecycleWithDynamicProxyAnnotationTest.java Mon May 26 22:48:20 2014
@@ -0,0 +1,49 @@
+/*
+* 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.AspectLifecycleWithDynamicProxyAnnotation.ServiceProvider;
+import dm.runtime.it.components.AspectLifecycleWithDynamicProxyAnnotation.ServiceProviderAspect;
+
+/**
+ * Use case: Tests an aspect service implemented as a dynamic proxy, and ensure that its lifecycle methods are properly invoked
+ * (init/start/stop/destroy methods).
+ */
+public class AspectLifecycleWithDynamicProxyAnnotationTest extends TestBase {
+ public void testAnnotatedAspect() {
+ Ensure e = new Ensure();
+ // Provide the Sequencer server to the ServiceProvider service
+ ServiceRegistration sr1 = register(e, ServiceProvider.ENSURE);
+ // Check if the ServiceProvider has been injected in the AspectTest service.
+ e.waitForStep(1, 10000);
+ // Provide the Sequencer server to the ServiceProviderAspect service
+ ServiceRegistration sr2 = register(e, ServiceProviderAspect.ENSURE);
+ // Check if the AspectTest has been injected with the aspect
+ e.waitForStep(3, 10000);
+ // Remove the ServiceProviderAspect service
+ sr2.unregister();
+ // And check if the aspect has been called in its stop/destroy methods.
+ e.waitForStep(7, 10000);
+ sr1.unregister();
+ }
+}