timothyjward commented on code in PR #403:
URL: https://github.com/apache/felix-dev/pull/403#discussion_r2037051280


##########
framework/src/test/java/org/apache/felix/framework/EventDispatcherTest.java:
##########
@@ -106,51 +108,46 @@ public void serviceChanged(ServiceEvent arg0)
         ed.addListener(b3.getBundleContext(), ServiceListener.class, sl3, 
null);
 
         // --- make the invocation
-        ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
-        EasyMock.expect(sr.getProperty(Constants.OBJECTCLASS)).andReturn(new 
String[]
+        ServiceReference sr = Mockito.mock(ServiceReference.class);
+        Mockito.when(sr.getProperty(Constants.OBJECTCLASS)).thenReturn(new 
String[]
             {
                 "java.lang.String"
-            }).anyTimes();
-        sr.isAssignableTo(b1, String.class.getName());
-        EasyMock.expectLastCall().andReturn(Boolean.TRUE).anyTimes();
-        sr.isAssignableTo(b2, String.class.getName());
-        EasyMock.expectLastCall().andReturn(Boolean.TRUE).anyTimes();
-        sr.isAssignableTo(b3, String.class.getName());
-        EasyMock.expectLastCall().andReturn(Boolean.TRUE).anyTimes();
-        EasyMock.replay(new Object[]
-            {
-                sr
             });
+        
+        Mockito.when(sr.isAssignableTo(b1, 
String.class.getName())).thenReturn(true);
+        Mockito.when(sr.isAssignableTo(b2, 
String.class.getName())).thenReturn(true);
+        Mockito.when(sr.isAssignableTo(b3, 
String.class.getName())).thenReturn(true);
+//        sr.isAssignableTo(b1, String.class.getName());
+//        Mockito.expectLastCall().thenReturn(Boolean.TRUE);
+//        sr.isAssignableTo(b2, String.class.getName());
+//        Mockito.expectLastCall().thenReturn(Boolean.TRUE);
+//        sr.isAssignableTo(b3, String.class.getName());
+//        Mockito.expectLastCall().thenReturn(Boolean.TRUE);
 
         ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, sr);
 
-        assertEquals("Precondition failed", 0, fired.size());
+        assertThat(fired.size()).as("Precondition failed").isEqualTo(0);
 
         Felix framework = new Felix(new HashMap());
 
         ed.fireServiceEvent(event, null, framework);
-        assertEquals(1, fired.size());
-        assertSame(sl3, fired.iterator().next());
+        assertThat(fired).hasSize(1);
+        assertThat(fired.iterator().next()).isSameAs(sl3);
 
-        assertEquals(2, calledHooks.size());
-        assertTrue(calledHooks.contains(eh1));
-        assertTrue(calledHooks.contains(eh2));
+        assertThat(calledHooks).hasSize(2);
+        assertThat(calledHooks).contains(eh1);
+        assertThat(calledHooks).contains(eh2);
     }
 
     private Bundle getMockBundle()
     {
-        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-        Bundle b = EasyMock.createNiceMock(Bundle.class);
-        EasyMock.expect(b.getBundleContext()).andReturn(bc).anyTimes();
-        b.getState();
-        
EasyMock.expectLastCall().andReturn(Integer.valueOf(Bundle.ACTIVE)).anyTimes();
-
-        EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
-
-        EasyMock.replay(new Object[]
-            {
-                bc, b
-            });
+        BundleContext bc = Mockito.mock(BundleContext.class);
+        Bundle b = Mockito.mock(Bundle.class);
+        Mockito.when(b.getBundleContext()).thenReturn(bc);
+//        b.getState();

Review Comment:
   More comments to clear



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@felix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to