Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Clarke2013-01-21 13:02:46 -0500
committerDoug Clarke2013-01-21 13:02:46 -0500
commit3b89fd2f27bdaf33d5367bc62e4c7bca8a523922 (patch)
tree2c74ba6897887b4681f0d1d3749cf834e4e4ff2b
parentbadd453cd7b94b68b024d9e3f0666eb2e5240373 (diff)
downloadmysports-3b89fd2f27bdaf33d5367bc62e4c7bca8a523922.tar.gz
mysports-3b89fd2f27bdaf33d5367bc62e4c7bca8a523922.tar.xz
mysports-3b89fd2f27bdaf33d5367bc62e4c7bca8a523922.zip
Minor changes for test compilation and execution
-rw-r--r--admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java218
-rw-r--r--application/pom.xml1
-rw-r--r--application/src/test/java/eclipselink/example/mysports/application/test/TestCreateTenantEMF.java6
-rw-r--r--application/src/test/java/eclipselink/example/mysports/examples/ExampleLeague.java (renamed from application/src/main/java/eclipselink/example/mysports/examples/ExampleLeague.java)0
-rw-r--r--application/src/test/java/eclipselink/example/mysports/examples/HighTechHockey.java (renamed from application/src/main/java/eclipselink/example/mysports/examples/HighTechHockey.java)0
-rw-r--r--application/src/test/java/eclipselink/example/mysports/examples/KidsFootballLeague.java (renamed from application/src/main/java/eclipselink/example/mysports/examples/KidsFootballLeague.java)0
-rw-r--r--application/src/test/java/eclipselink/example/mysports/examples/MinorHockeyLeague.java (renamed from application/src/main/java/eclipselink/example/mysports/examples/MinorHockeyLeague.java)0
-rw-r--r--application/src/test/java/eclipselink/example/mysports/examples/OttawaSoccerLeague.java (renamed from application/src/main/java/eclipselink/example/mysports/examples/OttawaSoccerLeague.java)0
-rw-r--r--application/src/test/java/eclipselink/example/mysports/examples/PlayerFactory.java (renamed from application/src/main/java/eclipselink/example/mysports/examples/PlayerFactory.java)0
-rw-r--r--parent/pom.xml8
10 files changed, 110 insertions, 123 deletions
diff --git a/admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java b/admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java
index 214d3e2..2c2905c 100644
--- a/admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java
+++ b/admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java
@@ -19,8 +19,6 @@ import java.io.StringWriter;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
-import org.junit.Assert;
-
import eclipselink.example.mysports.admin.model.HostedLeague;
import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
@@ -32,122 +30,104 @@ import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
*/
public abstract class ExampleLeagueDefinition {
- private HostedLeague league;
-
- public ExampleLeagueDefinition(String id, String name, String scheme,
- String logoUrl, String dataSource) {
- this.league = new HostedLeague(id, name, scheme);
- this.league.setLogoUrl(logoUrl);
- this.league.setDatasourceName(dataSource);
- addExtensions();
- }
-
- public HostedLeague getLeague() {
- return league;
- }
-
- protected abstract void addExtensions();
-
- public static ExampleLeagueDefinition OSL = new ExampleLeagueDefinition(
- "OSL", "Ottawa Soccer League", "black", "/logos/osl.png",
- "jdbc/MySports") {
- @Override
- protected void addExtensions() {
- getLeague().addPlayerExtension("allergies", "java.lang.String",
- "FLEX_1");
- }
- };
-
- public static ExampleLeagueDefinition HTHL = new ExampleLeagueDefinition(
- "HTHL", "High Tech Hockey League", "red", "/logos/hthl.png",
- "jdbc/MySports") {
- @Override
- protected void addExtensions() {
- getLeague().addPlayerExtension("position", "java.lang.String",
- "FLEX_1");
- getLeague().addPlayerExtension("penaltyMinutes",
- "java.lang.Integer", "FLEX_2");
- }
- };
-
- public static ExampleLeagueDefinition KFL = new ExampleLeagueDefinition(
- "KFL", "Kid's Football League", "green", "/logos/kfl.png",
- "jdbc/MySports") {
- @Override
- protected void addExtensions() {
- getLeague().addPlayerExtension("position", "java.lang.String",
- "FLEX_1");
- }
- };
-
- public static ExampleLeagueDefinition MHL = new ExampleLeagueDefinition(
- "MHL", "Minor Hockey League", "red", "/logos/mhl.png",
- "jdbc/MySportsMHL") {
- @Override
- protected void addExtensions() {
- getLeague().addPlayerExtension("position", "java.lang.String",
- "FLEX_1");
- }
- };
-
- public static void populateAll(HostedLeagueRepository repository) {
- repository.create(OSL.getLeague());
- repository.create(KFL.getLeague());
- repository.create(MHL.getLeague());
- repository.create(HTHL.getLeague());
- createStyles(repository);
- }
-
- public static void clearDatabase(EntityManagerFactory emf) {
- EntityManager em = emf.createEntityManager();
-
- try {
- em.getTransaction().begin();
- em.createNativeQuery("DELETE FROM mys_admin_player_ext")
- .executeUpdate();
- em.createNativeQuery("DELETE FROM mys_admin_team_ext")
- .executeUpdate();
- em.createNativeQuery("DELETE FROM mys_admin_div_ext")
- .executeUpdate();
- em.createQuery("DELETE FROM HostedLeague").executeUpdate();
- em.createQuery("DELETE FROM Style").executeUpdate();
- em.getTransaction().commit();
- } finally {
- em.close();
- }
- }
-
- public static void createStyles(HostedLeagueRepository repository) {
- repository.createStyle("default", load("blue"));
- repository.createStyle("red", load("red"));
- repository.createStyle("black", load("black"));
- repository.createStyle("blue", load("blue"));
- repository.createStyle("green", load("green"));
- }
-
- private static String load(String name) {
- String resource = name + ".css";
- InputStream in = Thread.currentThread().getContextClassLoader()
- .getResourceAsStream(resource);
-
- if (in == null) {
- Assert.fail("Could not find CSS for '" + name + " @ " + resource);
- }
- try {
- StringWriter writer = new StringWriter(in.available());
- for (int ch = in.read(); ch >= 0; ch = in.read()) {
- writer.write(ch);
- }
- return writer.toString();
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- } finally {
- try {
- in.close();
- } catch (IOException e) {
- }
- }
-
- }
+ private HostedLeague league;
+
+ public ExampleLeagueDefinition(String id, String name, String scheme, String logoUrl, String dataSource) {
+ this.league = new HostedLeague(id, name, scheme);
+ this.league.setLogoUrl(logoUrl);
+ this.league.setDatasourceName(dataSource);
+ addExtensions();
+ }
+
+ public HostedLeague getLeague() {
+ return league;
+ }
+
+ protected abstract void addExtensions();
+
+ public static ExampleLeagueDefinition OSL = new ExampleLeagueDefinition("OSL", "Ottawa Soccer League", "black", "/logos/osl.png", "jdbc/MySports") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("allergies", "java.lang.String", "FLEX_1");
+ }
+ };
+
+ public static ExampleLeagueDefinition HTHL = new ExampleLeagueDefinition("HTHL", "High Tech Hockey League", "red", "/logos/hthl.png", "jdbc/MySports") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("position", "java.lang.String", "FLEX_1");
+ getLeague().addPlayerExtension("penaltyMinutes", "java.lang.Integer", "FLEX_2");
+ }
+ };
+
+ public static ExampleLeagueDefinition KFL = new ExampleLeagueDefinition("KFL", "Kid's Football League", "green", "/logos/kfl.png", "jdbc/MySports") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("position", "java.lang.String", "FLEX_1");
+ }
+ };
+
+ public static ExampleLeagueDefinition MHL = new ExampleLeagueDefinition("MHL", "Minor Hockey League", "red", "/logos/mhl.png", "jdbc/MySportsMHL") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("position", "java.lang.String", "FLEX_1");
+ }
+ };
+
+ public static void populateAll(HostedLeagueRepository repository) {
+ repository.create(OSL.getLeague());
+ repository.create(KFL.getLeague());
+ repository.create(MHL.getLeague());
+ repository.create(HTHL.getLeague());
+ createStyles(repository);
+ }
+
+ public static void clearDatabase(EntityManagerFactory emf) {
+ EntityManager em = emf.createEntityManager();
+
+ try {
+ em.getTransaction().begin();
+ em.createNativeQuery("DELETE FROM mys_admin_player_ext").executeUpdate();
+ em.createNativeQuery("DELETE FROM mys_admin_team_ext").executeUpdate();
+ em.createNativeQuery("DELETE FROM mys_admin_div_ext").executeUpdate();
+ em.createQuery("DELETE FROM HostedLeague").executeUpdate();
+ em.createQuery("DELETE FROM Style").executeUpdate();
+ em.getTransaction().commit();
+ } finally {
+ em.close();
+ }
+ }
+
+ public static void createStyles(HostedLeagueRepository repository) {
+ repository.createStyle("default", load("blue"));
+ repository.createStyle("red", load("red"));
+ repository.createStyle("black", load("black"));
+ repository.createStyle("blue", load("blue"));
+ repository.createStyle("green", load("green"));
+ }
+
+ private static String load(String name) {
+ String resource = name + ".css";
+ InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
+
+ if (in == null) {
+ throw new IllegalArgumentException("Could not find CSS for '" + name + " @ " + resource);
+ }
+ try {
+ StringWriter writer = new StringWriter(in.available());
+ for (int ch = in.read(); ch >= 0; ch = in.read()) {
+ writer.write(ch);
+ }
+ return writer.toString();
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ } finally {
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ }
+
+ }
}
diff --git a/application/pom.xml b/application/pom.xml
index 6dea47a..5df8aff 100644
--- a/application/pom.xml
+++ b/application/pom.xml
@@ -19,7 +19,6 @@
<groupId>${project.groupId}</groupId>
<artifactId>persistence</artifactId>
<version>${project.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
diff --git a/application/src/test/java/eclipselink/example/mysports/application/test/TestCreateTenantEMF.java b/application/src/test/java/eclipselink/example/mysports/application/test/TestCreateTenantEMF.java
index 245de14..a0b94a7 100644
--- a/application/src/test/java/eclipselink/example/mysports/application/test/TestCreateTenantEMF.java
+++ b/application/src/test/java/eclipselink/example/mysports/application/test/TestCreateTenantEMF.java
@@ -102,9 +102,9 @@ public class TestCreateTenantEMF {
@BeforeClass
public static void setup() {
- repository = new TestingLeagueRepository();
- repository.setLeagueId(LEAGUE.getId(), null);
- LEAGUE.populate(repository);
+ repository = new TestingLeagueRepository(LEAGUE.getId());
+ repository.createSharedMySportsSchema();
+ LEAGUE.populate(repository);
}
@AfterClass
diff --git a/application/src/main/java/eclipselink/example/mysports/examples/ExampleLeague.java b/application/src/test/java/eclipselink/example/mysports/examples/ExampleLeague.java
index b05845a..b05845a 100644
--- a/application/src/main/java/eclipselink/example/mysports/examples/ExampleLeague.java
+++ b/application/src/test/java/eclipselink/example/mysports/examples/ExampleLeague.java
diff --git a/application/src/main/java/eclipselink/example/mysports/examples/HighTechHockey.java b/application/src/test/java/eclipselink/example/mysports/examples/HighTechHockey.java
index 1f69f51..1f69f51 100644
--- a/application/src/main/java/eclipselink/example/mysports/examples/HighTechHockey.java
+++ b/application/src/test/java/eclipselink/example/mysports/examples/HighTechHockey.java
diff --git a/application/src/main/java/eclipselink/example/mysports/examples/KidsFootballLeague.java b/application/src/test/java/eclipselink/example/mysports/examples/KidsFootballLeague.java
index 8dc6ef1..8dc6ef1 100644
--- a/application/src/main/java/eclipselink/example/mysports/examples/KidsFootballLeague.java
+++ b/application/src/test/java/eclipselink/example/mysports/examples/KidsFootballLeague.java
diff --git a/application/src/main/java/eclipselink/example/mysports/examples/MinorHockeyLeague.java b/application/src/test/java/eclipselink/example/mysports/examples/MinorHockeyLeague.java
index 32b1217..32b1217 100644
--- a/application/src/main/java/eclipselink/example/mysports/examples/MinorHockeyLeague.java
+++ b/application/src/test/java/eclipselink/example/mysports/examples/MinorHockeyLeague.java
diff --git a/application/src/main/java/eclipselink/example/mysports/examples/OttawaSoccerLeague.java b/application/src/test/java/eclipselink/example/mysports/examples/OttawaSoccerLeague.java
index 35af2a4..35af2a4 100644
--- a/application/src/main/java/eclipselink/example/mysports/examples/OttawaSoccerLeague.java
+++ b/application/src/test/java/eclipselink/example/mysports/examples/OttawaSoccerLeague.java
diff --git a/application/src/main/java/eclipselink/example/mysports/examples/PlayerFactory.java b/application/src/test/java/eclipselink/example/mysports/examples/PlayerFactory.java
index 116044b..116044b 100644
--- a/application/src/main/java/eclipselink/example/mysports/examples/PlayerFactory.java
+++ b/application/src/test/java/eclipselink/example/mysports/examples/PlayerFactory.java
diff --git a/parent/pom.xml b/parent/pom.xml
index 32d4a40..51cb6dc 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -16,4 +16,12 @@
<module>../persistence</module>
</modules>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project> \ No newline at end of file

Back to the top