Replaced easymock by mockito.
[utils] / system / general / src / test / java / org / wamblee / system / container / ContainerTest.java
index e61c023ca0e35ae66908b04259a0d99bee520a28..120548cb8b0063f30ab3e7c3a69e3a83b5d98ed5 100644 (file)
  */
 package org.wamblee.system.container;
 
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
+
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
 import junit.framework.TestCase;
 
-import org.easymock.classextension.ConstructorArgs;
-import org.easymock.classextension.EasyMock;
-import org.easymock.classextension.IMocksControl;
 import org.wamblee.general.Pair;
 import org.wamblee.system.core.Component;
 import org.wamblee.system.core.DefaultProvidedInterface;
@@ -36,7 +36,6 @@ import org.wamblee.system.core.Scope;
 import org.wamblee.system.core.StringComponent;
 import org.wamblee.system.core.SystemAssemblyException;
 import org.wamblee.test.AssertionUtils;
-import org.wamblee.test.EasyMockMatchers;
 import org.wamblee.test.EventTracker;
 
 public class ContainerTest extends TestCase {
@@ -280,17 +279,14 @@ public class ContainerTest extends TestCase {
 
        public void testEnvironmentApplicationRollbackOnException()
                        throws Exception {
-               IMocksControl control = EasyMock.createStrictControl();
-
                Environment environment = new Environment(_tracker);
-               Application application = control.createMock(Application.class,
-                               new ConstructorArgs(Application.class.getConstructor()),
-                               Application.class.getDeclaredMethod("doStart", Scope.class));
-
-               application.doStart(EasyMockMatchers.anyObject(Scope.class));
-               EasyMock.expectLastCall().andThrow(new RuntimeException());
-               control.replay();
-
+               Application application = new Application() { 
+                       @Override
+                       public Object doStart(Scope aScope) {
+                               throw new RuntimeException();
+                       }
+               };
+               
                try {
                        Container container = new Container("root", new Component[] {
                                        environment, application }, new ProvidedInterface[0],
@@ -308,27 +304,22 @@ public class ContainerTest extends TestCase {
 
        public void testEnvironmentApplicationRollbackOnExceptionWithExceptionOnStop()
                        throws Exception {
-               IMocksControl control = EasyMock.createControl();
 
                Environment environment = new Environment(_tracker);
                // Application 1 will throw an exception while stopping.
-               Application application1 = control.createMock(Application.class,
-                               new ConstructorArgs(Application.class.getConstructor()),
-                               Application.class.getDeclaredMethod("doStop", Object.class));
-
-               application1.doStop(EasyMock.anyObject());
-               EasyMock.expectLastCall().andThrow(new RuntimeException());
+               Application application1 = new Application("app1")  {
+                       @Override
+                       public void doStop(Object aRuntime) {
+                               throw new RuntimeException();
+                       }
+               };
 
                // application 2 will throw an exception while starting
-               Application application2 = control.createMock(Application.class,
-                               new ConstructorArgs(Application.class
-                                               .getConstructor(String.class), "application2"),
-                               Application.class.getDeclaredMethod("doStart", Scope.class));
-
-               application2.doStart(EasyMockMatchers.anyObject(Scope.class));
-               EasyMock.expectLastCall().andThrow(new RuntimeException());
-
-               control.replay();
+               Application application2 = new Application("app2") {
+                       public Object doStart(Scope aScope) { 
+                               throw new RuntimeException();
+                       }
+               };
 
                try {
                        Container container = new Container("root", new Component[] {