diff --git a/jpa/eclipselink/README.adoc b/jpa/eclipselink/README.adoc
new file mode 100644
index 00000000..59f62957
--- /dev/null
+++ b/jpa/eclipselink/README.adoc
@@ -0,0 +1,20 @@
+# Spring Data JPA - EclipseLink
+
+This project contains an example of how to use Spring Data JPA in combination with Eclipselink. EclipseLink requires the domain types to be instrumented to implement lazy-loading. This can be achieved either through static weaving at compile time or dynamically at class loading time (load-time weaving). The build is set up to allow both modes of execution by selecting a certain build profile.
+
+## Static weaving
+
+To run the project with static weaving enable the corresponding build profile on the command line:
+
+[source, bash]
+----
+$ mvn clean test -Pstatic-weaving
+----
+
+Note, that you need to make sure the weaving process is run by your IDE, before executing test cases either by making sure the declared EclipseLink plugin is executed during compile or running `mvn clean test-compile` before running the tests.
+
+## Load-time weaving
+
+By default, the projects builds and runs with load-time weaving enabled. This is achieved by configuring the Spring instrumentation agent for both the Surefire and Spring Boot Maven plugin. The build profile for load-time weaving is enabled by default.
+
+For execution within the IDE, make sure you configure the Spring instrumentation agent to be applied.
diff --git a/jpa/eclipselink/README.md b/jpa/eclipselink/README.md
deleted file mode 100644
index 65719c40..00000000
--- a/jpa/eclipselink/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# Spring Data JPA - Eclipselink + Static Weaving Example
-
-This project contains an example of using Eclipselink with static weaving with Spring Data. Static weaving is
-accomplished with a maven plugin that requires a persistence.xml, so a persistence.xml exists in this project.
-The persistence.xml is not actually used by the Spring Boot example and is only used at build time for the maven
-plugin. To use the persistence.xml file, please see instructions on how to [use a traditional persistence.xm](http://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html#howto-use-traditional-persistence-xml).
-
diff --git a/jpa/eclipselink/pom.xml b/jpa/eclipselink/pom.xml
index 8c8c935a..cef6cc85 100644
--- a/jpa/eclipselink/pom.xml
+++ b/jpa/eclipselink/pom.xml
@@ -2,44 +2,35 @@
+ 4.0.0
+
org.springframework.data.examples
spring-data-jpa-examples
1.0.0.BUILD-SNAPSHOT
-
-
- com.ethlo.eclipselink.tools
- http://ethlo.com/maven
-
-
+ spring-data-jpa-eclipselink
-
-
- com.ethlo.eclipselink.tools
- http://ethlo.com/maven
-
-
-
- 4.0.0
-
- example.springdata.jpa
- eclipselink
- 0.0.1-SNAPSHOT
- jar
-
- Spring Data JPA - Spring Data JPA w/ Eclipse Link and Static Weaving
- Example Spring Data JPA Project using EclipseLink and Static Weaving
+ Spring Data JPA - EclipseLink setup example
- UTF-8
- example.springdata.jpa.eclipselink.SpringDataJpaEclipseLinkApplication
- 1.8
2.6.0
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.hibernate
+ hibernate-entitymanager
+
+
+
+
org.eclipse.persistence
org.eclipse.persistence.jpa
@@ -47,35 +38,121 @@
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
- com.ethlo.persistence.tools
- eclipselink-maven-plugin
- 1.1-SNAPSHOT
-
-
- process-classes
-
- weave
-
-
-
+
+
-
-
- org.eclipse.persistence
- org.eclipse.persistence.jpa
- ${eclipselink.version}
-
-
-
-
-
+
+
+ static-weaving
+
+
+
+
+
+
+ com.ethlo.persistence.tools
+ eclipselink-maven-plugin
+ 1.1-SNAPSHOT
+
+
+ process-classes
+
+ weave
+
+
+
+
+
+
+ org.eclipse.persistence
+ org.eclipse.persistence.jpa
+ ${eclipselink.version}
+
+
+
+
+
+
+
+
+
+ com.ethlo.eclipselink.tools
+ http://ethlo.com/maven
+
+
+
+
+
+ com.ethlo.eclipselink.tools
+ http://ethlo.com/maven
+
+
+
+
+
+
+
+
+
+ load-time-weaving
+
+
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ org.springframework
+ spring-instrument
+ ${spring.version}
+
+
+
+ -javaagent:${settings.localRepository}/org/springframework/spring-instrument/${spring.version}/spring-instrument-${spring.version}.jar
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ org.springframework
+ spring-instrument
+ ${spring.version}
+
+
+
+ ${settings.localRepository}/org/springframework/spring-instrument/${spring.version}/spring-instrument-${spring.version}.jar
+
+
+
+
+
+
+
diff --git a/jpa/eclipselink/src/main/java/example/eclipselink/Application.java b/jpa/eclipselink/src/main/java/example/eclipselink/Application.java
new file mode 100644
index 00000000..fc14257e
--- /dev/null
+++ b/jpa/eclipselink/src/main/java/example/eclipselink/Application.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2015 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package example.eclipselink;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
+import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter;
+import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
+
+/**
+ * Spring Boot application that uses EclipseLink as the JPA provider.
+ *
+ * @author Oliver Gierke
+ * @author Jeremy Rickard
+ */
+@SpringBootApplication
+public class Application extends JpaBaseConfiguration {
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#createJpaVendorAdapter()
+ */
+ @Override
+ protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
+ return new EclipseLinkJpaVendorAdapter();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#getVendorProperties()
+ */
+ @Override
+ protected Map getVendorProperties() {
+
+ // Turn off dynamic weaving to disable LTW lookup in static weaving mode
+ return Collections.singletonMap("eclipselink.weaving", "false");
+ }
+}
diff --git a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/repositories/RaceRepository.java b/jpa/eclipselink/src/main/java/example/eclipselink/Customer.java
similarity index 51%
rename from jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/repositories/RaceRepository.java
rename to jpa/eclipselink/src/main/java/example/eclipselink/Customer.java
index f8e3f7e4..d4e6e650 100644
--- a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/repositories/RaceRepository.java
+++ b/jpa/eclipselink/src/main/java/example/eclipselink/Customer.java
@@ -13,28 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package example.springdata.jpa.eclipselink.repositories;
+package example.eclipselink;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import lombok.Data;
+import lombok.RequiredArgsConstructor;
/**
- * Repository to manage {@link example.springdata.jpa.eclipselink.domain.Race} instances.
- *
- * @author Jeremy Rickard
+ * @author Oliver Gierke
*/
+@Data
+@Entity
+@RequiredArgsConstructor
+public class Customer {
-import example.springdata.jpa.eclipselink.domain.Race;
-import org.springframework.data.repository.CrudRepository;
+ private @Id @GeneratedValue Long id;
+ private final String firstname, lastname;
-import java.util.Date;
-import java.util.List;
-
-public interface RaceRepository extends CrudRepository {
-
- List findByName(String name);
-
- List findByDate(Date date);
-
- List findByDateBefore(Date date);
-
- List findByDistanceBetween(double start, double end);
+ Customer() {
+ this.firstname = null;
+ this.lastname = null;
+ }
}
diff --git a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/domain/Gender.java b/jpa/eclipselink/src/main/java/example/eclipselink/CustomerRepository.java
similarity index 76%
rename from jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/domain/Gender.java
rename to jpa/eclipselink/src/main/java/example/eclipselink/CustomerRepository.java
index 7e298edf..cee23612 100644
--- a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/domain/Gender.java
+++ b/jpa/eclipselink/src/main/java/example/eclipselink/CustomerRepository.java
@@ -1,5 +1,3 @@
-package example.springdata.jpa.eclipselink.domain;
-
/*
* Copyright 2015 the original author or authors.
*
@@ -15,13 +13,11 @@ package example.springdata.jpa.eclipselink.domain;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package example.eclipselink;
+import org.springframework.data.repository.CrudRepository;
/**
- * @author Jeremy Rickard
+ * @author Oliver Gierke
*/
-
-public enum Gender {
- FEMALE,
- MALE
-}
+public interface CustomerRepository extends CrudRepository {}
diff --git a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/SpringDataJpaEclipseLinkApplication.java b/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/SpringDataJpaEclipseLinkApplication.java
deleted file mode 100644
index 3eb8b6f9..00000000
--- a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/SpringDataJpaEclipseLinkApplication.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2015 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package example.springdata.jpa.eclipselink;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
-import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
-import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
-import org.springframework.orm.jpa.JpaVendorAdapter;
-import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
-import org.springframework.orm.jpa.vendor.Database;
-import org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect;
-import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
-
-import javax.sql.DataSource;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Spring Boot application with Spring Java Config annotations that use EclipseLink as the JPA Provider
- * and turn on Static Weaving of the entity classes by disabling dynamic weaving and utilizing a maven
- * build that includes a static weaving plugin.
- *
- * @author Jeremy Rickard
- */
-
-@SpringBootApplication
-@Configuration
-@EnableJpaRepositories("example.springdata.jpa.eclipselink.repositories")
-public class SpringDataJpaEclipseLinkApplication {
-
- @Bean
- public DataSource dataSource() {
- return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).build();
- }
-
-
- @Bean
- public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
- LocalContainerEntityManagerFactoryBean lemfb = new LocalContainerEntityManagerFactoryBean();
- lemfb.setDataSource(dataSource());
- lemfb.setJpaVendorAdapter(jpaVendorAdapter());
- lemfb.setJpaDialect(eclipseLinkJpaDialect());
- lemfb.setJpaPropertyMap(jpaProperties());
- lemfb.setPackagesToScan("example.springdata.jpa.eclipselink.domain");
- return lemfb;
- }
-
- @Bean
- public EclipseLinkJpaDialect eclipseLinkJpaDialect() {
- return new EclipseLinkJpaDialect();
- }
-
- /*
- * Set this property to disable LoadTimeWeaver (i.e. Dynamic Weaving) for EclipseLink.
- * Otherwise, you'll get: Cannot apply class transformer without LoadTimeWeaver specified
- */
- @Bean
- public Map jpaProperties() {
- Map props = new HashMap<>();
- props.put("eclipselink.weaving", "false");
- return props;
- }
-
- @Bean
- public JpaVendorAdapter jpaVendorAdapter() {
- EclipseLinkJpaVendorAdapter jpaVendorAdapter = new EclipseLinkJpaVendorAdapter();
- jpaVendorAdapter.setDatabase(Database.HSQL);
- jpaVendorAdapter.setGenerateDdl(true);
- return jpaVendorAdapter;
- }
-
-
- public static void main(String[] args) {
- SpringApplication.run(SpringDataJpaEclipseLinkApplication.class, args);
- }
-}
diff --git a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/domain/Participant.java b/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/domain/Participant.java
deleted file mode 100644
index cfcd85bf..00000000
--- a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/domain/Participant.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2015 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package example.springdata.jpa.eclipselink.domain;
-
-/**
- * Entity showing use of {@link org.eclipse.persistence.annotations.UuidGenerator} from
- * the EclipseLink JPA Provider. Does not extend the AbstractPersistable because of the UUID generator
- *
- * @author Jeremy Rickard
- */
-
-import org.eclipse.persistence.annotations.UuidGenerator;
-
-import javax.persistence.*;
-import java.util.List;
-
-@Entity
-public class Participant {
- @Id
- @UuidGenerator(name = "UUID")
- @GeneratedValue(generator = "UUID")
- private String uuid;
-
- private String firstName;
-
- private String lastName;
-
- private String emailAddress;
-
- private String phoneNumber;
-
- private int age;
-
- @Enumerated
- private Gender gender;
-
- @ManyToMany(mappedBy = "registrations")
- private List raceRegistrations;
-
- public String getUuid() {
- return uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public String getEmailAddress() {
- return emailAddress;
- }
-
- public void setEmailAddress(String emailAddress) {
- this.emailAddress = emailAddress;
- }
-
- public String getPhoneNumber() {
- return phoneNumber;
- }
-
- public void setPhoneNumber(String phoneNumber) {
- this.phoneNumber = phoneNumber;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public Gender getGender() {
- return gender;
- }
-
- public void setGender(Gender gender) {
- this.gender = gender;
- }
-
- public List getRaceRegistrations() {
- return raceRegistrations;
- }
-
- public void setRaceRegistrations(List raceRegistrations) {
- this.raceRegistrations = raceRegistrations;
- }
-
- public boolean equals(Object obj) {
- if (null == obj) {
- return false;
- } else if (this == obj) {
- return true;
- } else if (!this.getClass().equals(obj.getClass())) {
- return false;
- } else {
- Participant that = (Participant) obj;
- return null == this.getUuid() ? false : this.getUuid().equals(that.getUuid());
- }
- }
-
- public int hashCode() {
- byte hashCode = 17;
- int hashCode1 = hashCode + (null == this.getUuid() ? 0 : this.getUuid().hashCode() * 31);
- return hashCode1;
- }
-}
diff --git a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/domain/Race.java b/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/domain/Race.java
deleted file mode 100644
index ddc2c845..00000000
--- a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/domain/Race.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2015 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package example.springdata.jpa.eclipselink.domain;
-
-
-/**
- * Entity showing use of {@link org.eclipse.persistence.annotations.UuidGenerator} from
- * the EclipseLink JPA Provider. Does not extend the AbstractPersistable because of the UUID generator
- *
- * @author Jeremy Rickard
- */
-
-import org.eclipse.persistence.annotations.UuidGenerator;
-
-import javax.persistence.*;
-import java.util.Date;
-import java.util.List;
-
-@Entity
-public class Race {
- @Id
- @UuidGenerator(name = "UUID")
- @GeneratedValue(generator = "UUID")
- private String uuid;
-
- private double distance;
-
- @Column(nullable = false)
- @Temporal(TemporalType.DATE)
- private Date date;
-
- @Column(nullable = false)
- private String name;
-
- @Column(nullable = false, length = 5000)
- private String description;
-
- @ManyToMany
- @JoinTable(name = "RACE_REG",
- joinColumns = {@JoinColumn(name = "RACE_ID", referencedColumnName = "uuid")},
- inverseJoinColumns = {@JoinColumn(name = "PART_ID", referencedColumnName = "uuid", unique = true)})
- private List registrations;
-
- public String getUuid() {
- return uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public double getDistance() {
- return distance;
- }
-
- public void setDistance(double distance) {
- this.distance = distance;
- }
-
- public Date getDate() {
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List getRegistrations() {
- return registrations;
- }
-
- public void setRegistrations(List registrations) {
- this.registrations = registrations;
- }
-
- public boolean equals(Object obj) {
- if (null == obj) {
- return false;
- } else if (this == obj) {
- return true;
- } else if (!this.getClass().equals(obj.getClass())) {
- return false;
- } else {
- Race that = (Race) obj;
- return null == this.getUuid() ? false : this.getUuid().equals(that.getUuid());
- }
- }
-
- public int hashCode() {
- byte hashCode = 17;
- int hashCode1 = hashCode + (null == this.getUuid() ? 0 : this.getUuid().hashCode() * 31);
- return hashCode1;
- }
-}
diff --git a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/repositories/ParticipantRepository.java b/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/repositories/ParticipantRepository.java
deleted file mode 100644
index e176e730..00000000
--- a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/repositories/ParticipantRepository.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package example.springdata.jpa.eclipselink.repositories;
-
-
-import example.springdata.jpa.eclipselink.domain.Participant;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.CrudRepository;
-
-import java.util.List;
-
-/**
- * Repository to manage {@link example.springdata.jpa.eclipselink.domain.Participant} instances.
- *
- * @author Jeremy Rickard
- */
-public interface ParticipantRepository extends CrudRepository {
-
- @Query("SELECT p from Participant p")
- List findAll();
-
- List findByLastName(String lastName);
-
- List findByAgeLessThan(int age);
-
- List findByAgeBetween(int age1, int age2);
-}
diff --git a/jpa/eclipselink/src/main/resources/application.properties b/jpa/eclipselink/src/main/resources/application.properties
index e69de29b..4f89f05d 100644
--- a/jpa/eclipselink/src/main/resources/application.properties
+++ b/jpa/eclipselink/src/main/resources/application.properties
@@ -0,0 +1 @@
+spring.jpa.generate-ddl=true
\ No newline at end of file
diff --git a/jpa/eclipselink/src/test/java/example/eclipselink/CustomerRepositoryIntegrationTests.java b/jpa/eclipselink/src/test/java/example/eclipselink/CustomerRepositoryIntegrationTests.java
new file mode 100644
index 00000000..c3f11c0f
--- /dev/null
+++ b/jpa/eclipselink/src/test/java/example/eclipselink/CustomerRepositoryIntegrationTests.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2015 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package example.eclipselink;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * Integration test for {@link CustomerRepository}.
+ *
+ * @author Oliver Gierke
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = Application.class)
+public class CustomerRepositoryIntegrationTests {
+
+ @Autowired CustomerRepository customers;
+
+ @Test
+ public void createsCustomer() {
+
+ Customer dave = customers.save(new Customer("Dave", "Matthews"));
+
+ assertThat(customers.findOne(dave.getId()), is(dave));
+ }
+}
diff --git a/jpa/eclipselink/src/test/java/example/springdata/jpa/eclipselink/SpringDataJpaEclipseLinkApplicationTests.java b/jpa/eclipselink/src/test/java/example/springdata/jpa/eclipselink/SpringDataJpaEclipseLinkApplicationTests.java
deleted file mode 100644
index 0675fc84..00000000
--- a/jpa/eclipselink/src/test/java/example/springdata/jpa/eclipselink/SpringDataJpaEclipseLinkApplicationTests.java
+++ /dev/null
@@ -1,264 +0,0 @@
-package example.springdata.jpa.eclipselink;
-
-import example.springdata.jpa.eclipselink.domain.Gender;
-import example.springdata.jpa.eclipselink.domain.Participant;
-import example.springdata.jpa.eclipselink.domain.Race;
-import example.springdata.jpa.eclipselink.repositories.ParticipantRepository;
-import example.springdata.jpa.eclipselink.repositories.RaceRepository;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.SpringApplicationConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.*;
-
-/**
- * Test for Spring Data JPA EclipseLink w/ Static Weaving example
- *
- * @author Jeremy Rickard
- */
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringApplicationConfiguration(classes = SpringDataJpaEclipseLinkApplication.class)
-public class SpringDataJpaEclipseLinkApplicationTests {
-
- @Autowired
- RaceRepository raceRepository;
-
- @Autowired
- ParticipantRepository participantRepository;
-
- Race pikesPeakAscent;
-
- Race pikesPeakMarathon;
-
- Race summerRoundUp;
-
- Race gardenOfTheGods10Mile;
-
- Participant one;
-
- Participant two;
-
- Participant three;
-
- Date ascentStartDate;
-
- SimpleDateFormat sdf;
-
- double ascentDistanceInKM = 21.4364621;
-
- @Before
- public void setUp() throws Exception {
-
- sdf = new SimpleDateFormat("MM/dd/yyyy HH:MM z");
-
-
- ascentStartDate = sdf.parse("08/15/2015 07:00 MDT");
-
- pikesPeakAscent = new Race();
- pikesPeakAscent.setName("Pikes Peak Ascent");
- pikesPeakAscent.setDistance(ascentDistanceInKM);
- pikesPeakAscent.setDate(ascentStartDate);
- pikesPeakAscent.setDescription("Started in 1956 as a challenge between smokers and non-smokers, " +
- "the Pikes Peak Marathon is #3 on the list of longest running US marathons behind Boston and Yonkers.");
-
- pikesPeakMarathon = new Race();
- pikesPeakMarathon.setName("Pikes Peak Marathon");
- pikesPeakMarathon.setDistance(ascentDistanceInKM * 2);
- pikesPeakMarathon.setDate(ascentStartDate);
- pikesPeakMarathon.setDescription("Started in 1956 as a challenge between smokers and non-smokers, " +
- "the Pikes Peak Marathon is #3 on the list of longest running US marathons behind Boston and Yonkers.");
-
-
- summerRoundUp = new Race();
- summerRoundUp.setName("Summer Round Up");
- summerRoundUp.setDescription("2nd Leg of the Triple Crown of Running");
- summerRoundUp.setDate(sdf.parse("07/12/2015 07:00 MDT"));
- summerRoundUp.setDistance(12.0);
-
- gardenOfTheGods10Mile = new Race();
- gardenOfTheGods10Mile.setName("Garden of the Gods 10 Miler");
- gardenOfTheGods10Mile.setDescription("1st Leg of the Triple Crown of Running");
- gardenOfTheGods10Mile.setDate(sdf.parse("06/15/2015 07:00 MDT"));
- gardenOfTheGods10Mile.setDistance(16.0934);
-
-
- one = new Participant();
- one.setAge(25);
- one.setEmailAddress("john.doe@gmail.com");
- one.setFirstName("John");
- one.setLastName("Doe");
- one.setPhoneNumber("1-123-234-5679");
- one.setGender(Gender.MALE);
-
- two = new Participant();
- two.setAge(21);
- two.setEmailAddress("jane.doe@gmail.com");
- two.setFirstName("Jane");
- two.setLastName("Doe");
- two.setPhoneNumber("1-123-234-5678");
- two.setGender(Gender.FEMALE);
-
- three = new Participant();
- three.setAge(62);
- three.setEmailAddress("sam.smith@gmail.com");
- three.setFirstName("Samantha");
- three.setLastName("Smith");
- three.setPhoneNumber("1-234-911-5678");
- three.setGender(Gender.FEMALE);
-
-
- }
-
-
- @Test
- public void contextLoads() {
- }
-
- @Test
- public void testInsertRace() {
-
- pikesPeakAscent = raceRepository.save(pikesPeakAscent);
- pikesPeakMarathon = raceRepository.save(pikesPeakMarathon);
- summerRoundUp = raceRepository.save(summerRoundUp);
- gardenOfTheGods10Mile = raceRepository.save(gardenOfTheGods10Mile);
-
- assertNotNull(pikesPeakAscent.getUuid());
- assertNotNull(pikesPeakMarathon.getUuid());
- assertNotNull(summerRoundUp.getUuid());
- assertNotNull(gardenOfTheGods10Mile.getUuid());
-
- assertNotEquals(pikesPeakAscent.getUuid(), pikesPeakMarathon.getUuid());
- }
-
- @Test
- public void testFindRacesByDates() {
- pikesPeakAscent = raceRepository.save(pikesPeakAscent);
- pikesPeakMarathon = raceRepository.save(pikesPeakMarathon);
- summerRoundUp = raceRepository.save(summerRoundUp);
- gardenOfTheGods10Mile = raceRepository.save(gardenOfTheGods10Mile);
-
- List races = raceRepository.findByDate(ascentStartDate);
- assertThat(races.contains(pikesPeakAscent), is(true));
- assertThat(races.contains(pikesPeakMarathon), is(true));
-
- races = raceRepository.findByDateBefore(ascentStartDate);
- assertThat(races.contains(pikesPeakAscent), is(false));
- assertThat(races.contains(pikesPeakMarathon), is(false));
- }
-
- @Test
- public void testFindRacesByDistance() {
- pikesPeakAscent = raceRepository.save(pikesPeakAscent);
- pikesPeakMarathon = raceRepository.save(pikesPeakMarathon);
- summerRoundUp = raceRepository.save(summerRoundUp);
- gardenOfTheGods10Mile = raceRepository.save(gardenOfTheGods10Mile);
-
- List races = raceRepository.findByDistanceBetween(20, 100);
- assertThat(races.contains(pikesPeakAscent), is(true));
- assertThat(races.contains(pikesPeakMarathon), is(true));
-
- races = raceRepository.findByDistanceBetween(10, 19);
- assertThat(races.contains(pikesPeakAscent), is(false));
- assertThat(races.contains(pikesPeakMarathon), is(false));
- }
-
-
- @Test
- public void testRaceByName() {
- pikesPeakAscent = raceRepository.save(pikesPeakAscent);
- pikesPeakMarathon = raceRepository.save(pikesPeakMarathon);
- summerRoundUp = raceRepository.save(summerRoundUp);
- gardenOfTheGods10Mile = raceRepository.save(gardenOfTheGods10Mile);
-
- List races = raceRepository.findByName("Summer Round Up");
- assertThat(races.contains(pikesPeakAscent), is(false));
- assertThat(races.contains(pikesPeakMarathon), is(false));
- assertThat(races.contains(summerRoundUp), is(true));
- }
-
-
- @Test
- public void testInsertParticipant() {
-
- one = participantRepository.save(one);
- two = participantRepository.save(two);
- three = participantRepository.save(three);
-
- assertNotNull(one.getUuid());
- assertNotNull(two.getUuid());
- assertNotNull(three.getUuid());
-
- assertNotEquals(one.getUuid(), two.getUuid());
- assertNotEquals(two.getUuid(), three.getUuid());
-
- assertThat(participantRepository.findAll().size(), is(3));
-
- List twentySomethings = participantRepository.findByAgeLessThan(40);
-
- for (Participant participant : twentySomethings) {
- System.err.println(participant.getUuid());
- }
-
- System.err.println(one.getUuid());
- System.err.println(two.getUuid());
- System.err.println(three.getUuid());
-
- assertThat(twentySomethings.contains(one), is(true));
-
- }
-
- @Test
- public void testFindByAgeLessThan() {
-
- one = participantRepository.save(one);
- two = participantRepository.save(two);
- three = participantRepository.save(three);
-
- List twentySomethings = participantRepository.findByAgeLessThan(40);
- assertThat(twentySomethings.contains(one), is(true));
- assertThat(twentySomethings.contains(three), is(false));
- }
-
- @Test
- public void testFindAgeBetween() {
- one = participantRepository.save(one);
- two = participantRepository.save(two);
- three = participantRepository.save(three);
-
- List twentySomethings = participantRepository.findByAgeBetween(40, 70);
- assertThat(twentySomethings.contains(one), is(false));
- assertThat(twentySomethings.contains(three), is(true));
- }
-
- @Test
- public void testFindByLastName() {
-
- one = participantRepository.save(one);
- two = participantRepository.save(two);
- three = participantRepository.save(three);
-
- List theDoes = participantRepository.findByLastName("Doe");
-
- assertThat(theDoes.contains(one), is(true));
- assertThat(theDoes.contains(three), is(false));
-
- }
-
-
- @After
- public void tearDown() {
- participantRepository.deleteAll();
- raceRepository.deleteAll();
- }
-
-
-}