Skip to content

Commit

Permalink
Removing unnecessary dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Ranga Rao Karanam authored and Ranga Rao Karanam committed Nov 21, 2015
1 parent caac587 commit a9c079d
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 112 deletions.
76 changes: 76 additions & 0 deletions 0.FirstExample/TodoBusinessTestFinal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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 TodoBusinessTestFinal {

@Autowired
TodoBusinessServiceImpl todoBusinessServiceImpl;

@Test
public void testGetTodosAboutSpring(){

List<String> todosAboutSpring = todoBusinessServiceImpl.getTodosAboutSpring();
assertEquals(1,todosAboutSpring.size());
}
}

@Component
class TodoBusinessServiceImpl {

@Autowired
TodoDataService todoDataServiceImpl;

List<String> getTodosAboutSpring(){
List<String> todos = todoDataServiceImpl.getTodos();
List<String> todosAboutSpring = new ArrayList<String>();
for(String todo:todos){
if(todo.contains("Spring"))
todosAboutSpring.add(todo);
}
return todosAboutSpring;
}
}

interface TodoDataService {
List<String> getTodos();
}

@Component
class TodoDataServiceStubImpl implements TodoDataService{
Connection jdbcConnection;
public List<String> getTodos() {
//make a call;
return new ArrayList<String>();
}
}

@Component
class TodoDataServiceRealImpl implements TodoDataService {
Connection jdbcConnection;
public List<String> getTodos() {
return Arrays.asList("Learn Spring","Learn Struts");
}
}

160 changes: 48 additions & 112 deletions 0.FirstExample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,125 +3,61 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<groupId>com.in28minutes.example.layering</groupId>
<groupId>com.in28minutes.example.first</groupId>
<artifactId>spring-basic-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>This pom acts as the parent pom for the entire project.</description>

<properties>
<spring-core-version>4.1.6.RELEASE</spring-core-version>
<spring-aop-version>4.1.6.RELEASE</spring-aop-version>
</properties>


<scm>
<developerConnection>
scm:svn:URL TO SVN REPOSITORY
</developerConnection>
<connection>
scm:svn:URL TO SVN REPOSITORY
</connection>
<url>URL TO SVN REPOSITORY</url>
</scm>

<dependencies>

<!-- A number of dependencies here are unnecessary for our example but
leaving them here to act as a good start for spring based projects -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring-core-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-core-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring-core-version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-core-version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring-aop-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring-aop-version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-core-version}</version>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>

<!-- Unit Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring-core-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.0-rc1</version>
<scope>test</scope>
</dependency>


</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<verbose>true</verbose>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
</plugins>
</build>

<distributionManagement>
<repository>
<id>releases</id>
<name>Corporate Releases</name>
<url>Repository Name for releasing</url>
</repository>
<snapshotRepository>
<id>snapshot</id>
<name>Corporate Snapshots</name>
<url>Repository Name for releasing</url>
</snapshotRepository>
</distributionManagement>
<dependencies>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-core-version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-core-version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring-core-version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring-core-version}</version>
</dependency>


<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>

<!-- Unit Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring-core-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

0 comments on commit a9c079d

Please sign in to comment.