Skip to content

Commit 3e2b065

Browse files
matthewhillierReidWeb
authored andcommitted
Moved the database code to Spring JDBC & introduced maven failsafe to separate unit from integration tests.
1 parent ed43bb4 commit 3e2b065

5 files changed

Lines changed: 190 additions & 201 deletions

File tree

pom.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,24 @@
9191
</execution>
9292
</executions>
9393
</plugin>
94+
<plugin>
95+
<groupId>org.apache.maven.plugins</groupId>
96+
<artifactId>maven-failsafe-plugin</artifactId>
97+
<executions>
98+
<execution>
99+
<id>integration-test</id>
100+
<goals>
101+
<goal>integration-test</goal>
102+
</goals>
103+
</execution>
104+
<execution>
105+
<id>verify</id>
106+
<goals>
107+
<goal>verify</goal>
108+
</goals>
109+
</execution>
110+
</executions>
111+
</plugin>
94112
<plugin>
95113
<groupId>org.apache.maven.plugins</groupId>
96114
<artifactId>maven-javadoc-plugin</artifactId>
@@ -113,6 +131,16 @@
113131
</exclusion>
114132
</exclusions>
115133
</dependency>
134+
<dependency>
135+
<groupId>org.springframework.boot</groupId>
136+
<artifactId>spring-boot-starter-jdbc</artifactId>
137+
<exclusions>
138+
<exclusion>
139+
<groupId>org.apache.tomcat</groupId>
140+
<artifactId>tomcat-jdbc</artifactId>
141+
</exclusion>
142+
</exclusions>
143+
</dependency>
116144
<dependency>
117145
<groupId>org.springframework.boot</groupId>
118146
<artifactId>spring-boot-starter-log4j</artifactId>

src/main/java/com/ffxivcensus/gatherer/Gatherer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public PlayerBeanDAO getDao() {
7676
return dao;
7777
}
7878

79-
public void setPlayerBeanDAO(@Autowired final PlayerBeanDAO playerBeanDAO) {
79+
@Autowired
80+
public void setPlayerBeanDAO(final PlayerBeanDAO playerBeanDAO) {
8081
this.dao = playerBeanDAO;
8182
}
8283

src/main/java/com/ffxivcensus/gatherer/GathererController.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
import java.util.concurrent.ExecutorService;
44
import java.util.concurrent.Executors;
55

6-
import javax.sql.DataSource;
7-
86
import org.slf4j.Logger;
97
import org.slf4j.LoggerFactory;
108
import org.springframework.beans.factory.annotation.Autowired;
119
import org.springframework.stereotype.Service;
1210

1311
import com.ffxivcensus.gatherer.config.ApplicationConfig;
14-
import com.ffxivcensus.gatherer.player.PlayerBeanDAO;
1512
import com.ffxivcensus.gatherer.player.PlayerBuilder;
1613

1714
/**
@@ -29,7 +26,6 @@ public class GathererController {
2926
private static final Logger LOG = LoggerFactory.getLogger(GathererController.class);
3027
private final ApplicationConfig appConfig;
3128
private final GathererFactory gathererFactory;
32-
private DataSource dataSource;
3329
/**
3430
* List of playable realms (used when splitting tables).
3531
*/
@@ -47,11 +43,9 @@ public class GathererController {
4743
*
4844
* @param config Configuration Bean
4945
*/
50-
public GathererController(@Autowired final ApplicationConfig config, @Autowired final GathererFactory gathererFactory,
51-
@Autowired DataSource dataSource) {
46+
public GathererController(@Autowired final ApplicationConfig config, @Autowired final GathererFactory gathererFactory) {
5247
this.appConfig = config;
5348
this.gathererFactory = gathererFactory;
54-
this.dataSource = dataSource;
5549
}
5650

5751
/**
@@ -126,7 +120,6 @@ private void gatherRange() {
126120

127121
while(nextID <= appConfig.getEndId()) {
128122
Gatherer worker = gathererFactory.createGatherer();
129-
worker.setPlayerBeanDAO(new PlayerBeanDAO(appConfig, dataSource));
130123
worker.setPlayerId(nextID);
131124
executor.execute(worker);
132125

0 commit comments

Comments
 (0)