From 95d8b94e75406a3fb6b91d9313ddb6ebf10b1708 Mon Sep 17 00:00:00 2001 From: in28minutes Date: Sat, 21 Nov 2015 08:32:52 +0530 Subject: [PATCH] Delete TodoBusinessTest_Final.java --- 0.FirstExample/TodoBusinessTest_Final.java | 76 ---------------------- 1 file changed, 76 deletions(-) delete mode 100644 0.FirstExample/TodoBusinessTest_Final.java diff --git a/0.FirstExample/TodoBusinessTest_Final.java b/0.FirstExample/TodoBusinessTest_Final.java deleted file mode 100644 index 4af53d0..0000000 --- a/0.FirstExample/TodoBusinessTest_Final.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.in28minutes.spring.example1; - -import static org.junit.Assert.assertEquals; - -import java.sql.Connection; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@Configuration -@ComponentScan(basePackages = { "com.in28minutes" }) -class SpringContext { -} - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = SpringContext.class) -public class TodoBusinessTest { - - @Autowired - TodoBusinessServiceImpl todoBusinessServiceImpl; - - @Test - public void testGetTodosAboutSpring(){ - - List todosAboutSpring = todoBusinessServiceImpl.getTodosAboutSpring(); - assertEquals(1,todosAboutSpring.size()); - } -} - -@Component -class TodoBusinessServiceImpl { - - @Autowired - TodoDataService todoDataServiceImpl; - - List getTodosAboutSpring(){ - List todos = todoDataServiceImpl.getTodos(); - List todosAboutSpring = new ArrayList(); - for(String todo:todos){ - if(todo.contains("Spring")) - todosAboutSpring.add(todo); - } - return todosAboutSpring; - } -} - -interface TodoDataService { - List getTodos(); -} - -@Component -class TodoDataServiceStubImpl implements TodoDataService{ - Connection jdbcConnection; - public List getTodos() { - //make a call; - return new ArrayList(); - } -} - -@Component -class TodoDataServiceRealImpl implements TodoDataService { - Connection jdbcConnection; - public List getTodos() { - return Arrays.asList("Learn Spring","Learn Struts"); - } -} -