View Javadoc
1   package com.wpollock.manualdidemo;
2   
3   import static org.junit.jupiter.api.Assertions.*;
4   
5   class InjectedControllerTest {
6       private static PropInjectedController pic;
7       private static SetterInjectedController sic;
8       private static ConstructorInjectedController cic;
9   
10      @org.junit.jupiter.api.BeforeAll
11      static void setUp() {
12          final GreetingServiceImpl gsi = new GreetingServiceImpl();
13          pic = new PropInjectedController();
14          pic.greetingService = gsi;      // Property Injection
15          sic = new SetterInjectedController();
16          sic.setGreetingService( gsi );  // Setter Injection
17          cic = new ConstructorInjectedController( gsi);  // Ctor Injection
18      }
19  
20      @org.junit.jupiter.api.Test
21      void testPropertyInjectedSayHello() {
22          System.out.print("Testing Property Injection: ");
23          pic.sayHello();
24      }
25  
26      @org.junit.jupiter.api.Test
27      void testSetterInjectedSayHello() {
28          System.out.print("Testing Setter Injection: ");
29          sic.sayHello();
30      }
31      @org.junit.jupiter.api.Test
32      void testConstructorInjectedSayHello() {
33          System.out.print("Testing Constructor Injection: ");
34          cic.sayHello();
35      }
36  }