Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] DatasourceAccessor ReentrantLock fix plus new SpringBoot test #2328

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions etc/jenkins/pr_verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ spec:
}
}
}
stage('JPA Spring, JPA Spring Boot') {
steps {
container('el-build') {
sh """
mvn -B -V verify -pl :org.eclipse.persistence.jpa.spring.test,:org.eclipse.persistence.jpa.springboot.test -P staging,mysql
"""
}
}
}
stage('JPA Modelgen, JPA JSE, WDF, JPARS, DBWS, DBWS Builder, Distribution') {
steps {
container('el-build') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public abstract class DatasourceAccessor implements Accessor {

protected ConnectionPool pool;

private final Lock instanceLock = new ReentrantLock();
private Lock instanceLock = new ReentrantLock();

/**
* Default Constructor.
Expand All @@ -174,6 +174,7 @@ protected DatasourceAccessor() {
public Object clone() {
try {
DatasourceAccessor accessor = (DatasourceAccessor)super.clone();
accessor.instanceLock = new ReentrantLock();
if(accessor.customizer != null) {
accessor.customizer.setAccessor(accessor);
}
Expand Down
21 changes: 0 additions & 21 deletions jpa/eclipselink.jpa.spring.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
<dbURL>${db.url}</dbURL>
<!--Log level-->
<loglevel>${logging.level}</loglevel>

<test-skip-jpa-spring>true</test-skip-jpa-spring> <!-- Spring 4 is not supported with jakarta.persistence -->
</properties>

<dependencies>
Expand Down Expand Up @@ -119,17 +117,6 @@
</testResources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<delimiters>
<!--TODO Update project/module files to use standard pattern @*@ -->
<delimiter>%%*%%</delimiter>
</delimiters>
<useDefaultDelimiters>true</useDefaultDelimiters>
</configuration>
</plugin>
<!--Required for EL Weaving (-javaagent:${org.eclipse.persistence:org.eclipse.persistence.jpa:jar})-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -180,7 +167,6 @@
...SpringJunitTestCase.testAddressVH:182 Exception when Address value holder retrieved-->
<!--<argLine>-Dignore</argLine>-->
<argLine>-javaagent:${org.eclipse.persistence:org.eclipse.persistence.jpa:jar}</argLine>
<skipTests>${test-skip-jpa-spring}</skipTests>
<reportNameSuffix>test-jpa-spring</reportNameSuffix>
<includes>
<include>**.spring.TestLocalEMF</include>
Expand All @@ -200,7 +186,6 @@
When it will be disabled by -Dignore it leads into test errors
...SpringJunitTestCase.testAddressVH:182 Exception when Address value holder retrieved-->
<!--<argLine>-Dignore</argLine>-->
<skipTests>${test-skip-jpa-spring}</skipTests>
<reportNameSuffix>test-jpa-spring</reportNameSuffix>
<includes>
<include>**.spring.TestContainerEMF</include>
Expand Down Expand Up @@ -255,11 +240,5 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>test-jpa-spring</id>
<properties>
<test-skip-jpa-spring>false</test-skip-jpa-spring>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2024 Oracle and/or its affiliates. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -14,13 +14,13 @@
#Properties for Spring Container application context files.

#jdbc driver
jdbc.driverClassName=%%driverClass%%
jdbc.url=%%dbURL%%
jdbc.username=%%dbUser%%
jdbc.password=%%dbPassword%%
jdbc.driverClassName=@driverClass@
jdbc.url=@dbURL@
jdbc.username=@dbUser@
jdbc.password=@dbPassword@

#platform
platform=%%dbPlatform%%
platform=@dbPlatform@

#persistence.xml location
#persistence.location=resource/foundation/spring/META-INF/persistence.xml
Expand Down
175 changes: 175 additions & 0 deletions jpa/eclipselink.jpa.springboot.test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0,
or the Eclipse Distribution License v. 1.0 which is available at
http://www.eclipse.org/org/documents/edl-v10.php.

SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

-->

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<name>EclipseLink JPA Spring Boot Test</name>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.springboot.test</artifactId>
<packaging>jar</packaging>

<parent>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.parent</artifactId>
<version>4.0.5-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<properties>
<comp.xlint>-Xlint:all</comp.xlint>
<comp.xdoclint>-Xdoclint:all,-missing</comp.xdoclint>
<comp.test.xlint>-Xlint:all</comp.test.xlint>

<!--Properties used for test resources filtering/replacement-->
<!--DB connection properties-->
<dbPlatform>${db.platform}</dbPlatform>
<dbUser>${db.user}</dbUser>
<dbPassword>${db.pwd}</dbPassword>
<driverClass>${db.driver}</driverClass>
<dbURL>${db.url}</dbURL>
<!--Log level-->
<loglevel>${logging.level}</loglevel>
</properties>

<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>test</scope>
</dependency>
<!--Other modules-->
<!--EclipseLink JPA-->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<scope>test</scope>
</dependency>
<!--API dependencies-->
<dependency>
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
<scope>test</scope>
</dependency>
<!--Other libraries dependencies-->
<!-- Spring Boot Data JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Spring Boot Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring FW -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>

<!--JDBC driver (test dependency)-->
<dependency>
<groupId>${db.driver.groupId}</groupId>
<artifactId>${db.driver.artifactId}</artifactId>
<version>${db.driver.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<!--Filtering enables generate/substitute test properties from Maven into *.xml files.-->
<testResources>
<testResource>
<directory>${integration.test.resources.directory}</directory>
<filtering>true</filtering>
</testResource>
</testResources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<workingDirectory>${project.build.directory}/test-run</workingDirectory>
<!--Set system properties required for tests-->
<systemPropertiesFile>${test.properties.file}</systemPropertiesFile>
</configuration>
<executions>
<execution>
<id>test-jpa-springboot</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<reportNameSuffix>test-jpa-springboot</reportNameSuffix>
<includes>
<include>org.eclipse.persistence.testing.tests.jpa.springboot.TestPersonRepository</include>
</includes>
</configuration>
</execution>
<execution>
<id>verify-integration-tests</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.carlspring.maven</groupId>
<artifactId>derby-maven-plugin</artifactId>
<executions>
<execution>
<id>start-derby</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-derby</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/

// Contributors:
// Oracle - initial API and implementation
package org.eclipse.persistence.testing.models.jpa.springboot;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import java.util.Objects;

@Entity
@Table(name="SPRINGBOOT_PERSON")
public class Person {

@Id
private Integer id;
private String firstName;
private String lastName;

public Person() {
}

public Person(Integer id, String firstName, String lastName) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
}

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

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;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Person person = (Person) o;
return Objects.equals(id, person.id) && Objects.equals(firstName, person.firstName) && Objects.equals(lastName, person.lastName);
}

@Override
public int hashCode() {
return Objects.hash(id, firstName, lastName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/

// Contributors:
// Oracle - initial API and implementation
package org.eclipse.persistence.testing.models.jpa.springboot;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PersonRepository extends JpaRepository<Person, Integer> {

Person findPersonById(Integer id);

List<Person> queryAllByIdGreaterThan(Integer idIsGreaterThan);
}
Loading
Loading