Home | History | Annotate | Download | only in invokers
      1 package org.testng.internal.invokers;
      2 
      3 import org.testng.Assert;
      4 import org.testng.IInvokedMethod;
      5 import org.testng.IInvokedMethodListener;
      6 import org.testng.IInvokedMethodListener2;
      7 import org.testng.ITestContext;
      8 import org.testng.ITestResult;
      9 import org.testng.annotations.Test;
     10 
     11 @Test
     12 public class InvokedMethodListenerSubtypeTest {
     13 
     14   @Test
     15   public void testFromListenerUsingSimpleListenerInstance() {
     16     final IInvokedMethodListener simpleListenerInstance = new SimpleInvokedMethodListenerDummy();
     17 
     18     InvokedMethodListenerSubtype listenerSubtype =
     19         InvokedMethodListenerSubtype.fromListener(simpleListenerInstance);
     20 
     21     Assert.assertEquals(listenerSubtype, InvokedMethodListenerSubtype.SIMPLE_LISTENER);
     22   }
     23 
     24   @Test
     25   public void testFromListenerUsingExtendedListenerInstance() {
     26     IInvokedMethodListener2 extendedListenerInstance = new ExtendedInvokedMethodListenerDummy();
     27 
     28     InvokedMethodListenerSubtype listenerSubtype =
     29         InvokedMethodListenerSubtype.fromListener(extendedListenerInstance);
     30 
     31     Assert.assertEquals(listenerSubtype, InvokedMethodListenerSubtype.EXTENDED_LISTENER);
     32   }
     33 
     34   static class SimpleInvokedMethodListenerDummy implements IInvokedMethodListener {
     35 
     36     public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
     37     }
     38 
     39     public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
     40     }
     41   }
     42 
     43   static class ExtendedInvokedMethodListenerDummy implements IInvokedMethodListener2 {
     44 
     45     public void beforeInvocation(IInvokedMethod method, ITestResult testResult,
     46                                  ITestContext context) {
     47     }
     48 
     49     public void afterInvocation(IInvokedMethod method, ITestResult testResult,
     50                                 ITestContext context) {
     51     }
     52 
     53     public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
     54     }
     55 
     56     public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
     57     }
     58   }
     59 }
     60