File tree Expand file tree Collapse file tree 8 files changed +58
-7
lines changed
Expand file tree Collapse file tree 8 files changed +58
-7
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,7 @@ on: [push]
44
55jobs :
66 build :
7-
87 runs-on : ubuntu-latest
9-
108 steps :
119 - uses : actions/checkout@v2
1210 - name : Set up JDK 1.8
1715 uses : actions/setup-node@v1
1816 with :
1917 node-version : ' 10.x'
20- - name : Grant execute permission for gradlew
21- run : chmod +x gradlew
18+ - name : Grant execute permissions
19+ run : |
20+ chmod +x ./scripts/moveFiles.sh
21+ chmod +x gradlew
22+ chmod +x source
2223 - name : Build with Gradle
2324 run : ./gradlew build --info
Original file line number Diff line number Diff line change @@ -53,8 +53,16 @@ dependencies {
5353 */
5454 compile(" org.springframework.boot:spring-boot-starter-security" )
5555
56+
5657 compile ' io.jsonwebtoken:jjwt:0.9.1'
5758
59+
60+ /**
61+ * Adding SMTP Mail Sending Capabilities
62+ */
63+ compile ' org.springframework.boot:spring-boot-starter-mail'
64+
65+
5866 /**
5967 * Requires Cloud Stream Dependency Management
6068 * Adding Kafka Cloud Stream Support
Original file line number Diff line number Diff line change @@ -62,4 +62,9 @@ services:
6262 ADMINER_DESIGN : nette
6363 ADMINER_PLUGINS : tables-filter tinymce
6464 ports :
65- - " 9999:8080"
65+ - " 9999:8080"
66+ mailhog :
67+ image : mailhog/mailhog
68+ ports :
69+ - 1025:1025 # smtp server
70+ - 9998:8025 # web ui
Original file line number Diff line number Diff line change 77import org .springframework .boot .autoconfigure .SpringBootApplication ;
88import org .springframework .cloud .stream .annotation .EnableBinding ;
99import org .springframework .context .annotation .Bean ;
10+ import org .springframework .mail .SimpleMailMessage ;
11+ import org .springframework .mail .javamail .JavaMailSender ;
1012import springboot .messaging .KafkaEventChannels ;
1113import springboot .messaging .PaymentMessagingChannel ;
1214import springboot .services .InvoicingService ;
1315
1416@ SpringBootApplication
1517@ EnableBinding ({PaymentMessagingChannel .class , KafkaEventChannels .class })
16- //@EnableWebMvc
1718public class Application {
1819
20+ @ Autowired
21+ private JavaMailSender javaMailSender ;
22+
1923 @ Bean
2024 CommandLineRunner commandLineRunner (
2125 @ Autowired InvoicingService invoicingService ,
2226 @ Autowired ObjectMapper objectMapper
2327 ){
2428 return args -> {
29+
30+ SimpleMailMessage msg = new SimpleMailMessage ();
31+ msg .setFrom ("ExampleApplication@example.com" );
32+ msg .setTo ("to_1@gmail.com" , "to_2@gmail.com" , "to_3@yahoo.com" );
33+
34+ msg .setSubject ("Testing from Spring Boot" );
35+ msg .setText ("Hello World \n Spring Boot Email" );
36+
37+ javaMailSender .send (msg );
2538//
2639// /**
2740// * Creating a Invoice
Original file line number Diff line number Diff line change @@ -38,8 +38,19 @@ custom:
3838 private :
3939 path : /banana
4040
41-
4241spring :
42+ mail :
43+ host : localhost
44+ port : 1025
45+ username :
46+ password :
47+ properties :
48+ mail :
49+ smtp :
50+ auth : false
51+ connectiontimeout : 5000
52+ timeout : timeout
53+ writetimeout : 5000
4354 security :
4455 xtype : BASIC
4556 user :
Original file line number Diff line number Diff line change 55import org .junit .runner .RunWith ;
66import org .springframework .beans .factory .annotation .Autowired ;
77import org .springframework .boot .test .context .SpringBootTest ;
8+ import org .springframework .boot .test .mock .mockito .MockBean ;
9+ import org .springframework .mail .javamail .JavaMailSender ;
810import org .springframework .test .context .junit4 .SpringRunner ;
911import springboot .dtos .ProductDTO ;
1012import springboot .entities .Product ;
2123@ RunWith (SpringRunner .class )
2224public class ApplicationTest {
2325
26+ @ MockBean
27+ JavaMailSender javaMailSender ;
2428
2529 @ Autowired
2630 private ProductsRepository productsRepository ;
Original file line number Diff line number Diff line change 1010import org .springframework .boot .test .context .SpringBootTest ;
1111import org .springframework .boot .test .mock .mockito .MockBean ;
1212import org .springframework .http .MediaType ;
13+ import org .springframework .mail .javamail .JavaMailSender ;
1314import org .springframework .test .context .junit4 .SpringRunner ;
1415import org .springframework .test .web .servlet .MockMvc ;
1516import org .springframework .test .web .servlet .request .MockMvcRequestBuilders ;
@@ -40,6 +41,9 @@ public class ProductsControllerTest {
4041 @ Autowired
4142 private MockMvc mockMvc ;
4243
44+ @ MockBean
45+ JavaMailSender javaMailSender ;
46+
4347 @ Autowired
4448 private ObjectMapper objectMapper ;
4549
Original file line number Diff line number Diff line change 44import org .junit .runner .RunWith ;
55import org .springframework .beans .factory .annotation .Autowired ;
66import org .springframework .boot .test .context .SpringBootTest ;
7+ import org .springframework .boot .test .mock .mockito .MockBean ;
8+ import org .springframework .mail .javamail .JavaMailSender ;
79import org .springframework .test .context .junit4 .SpringRunner ;
810import springboot .dtos .ProductDTO ;
911import springboot .entities .Product ;
2022@ RunWith (SpringRunner .class )
2123public class ProductsServiceTest {
2224
25+ @ MockBean
26+ JavaMailSender javaMailSender ;
27+
2328 @ Autowired
2429 private ProductsService productsService ;
2530
You can’t perform that action at this time.
0 commit comments