-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29132 from KyleAure/28366-recreate-jakarta-data-e…
…clipselink-issues
- Loading branch information
Showing
32 changed files
with
2,650 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...com.ibm.ws.jpa.tests.jpa_32_fat/fat/src/com/ibm/ws/jpa/jpa32/JakartaDataRecreateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package com.ibm.ws.jpa.jpa32; | ||
|
||
import org.jboss.shrinkwrap.api.Filters; | ||
import org.jboss.shrinkwrap.api.GenericArchive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.importer.ExplodedImporter; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.runner.RunWith; | ||
import org.testcontainers.containers.JdbcDatabaseContainer; | ||
|
||
import com.ibm.websphere.simplicity.ShrinkHelper; | ||
import com.ibm.ws.jpa.FATSuite; | ||
|
||
import componenttest.annotation.MinimumJavaLevel; | ||
import componenttest.annotation.Server; | ||
import componenttest.annotation.TestServlet; | ||
import componenttest.custom.junit.runner.FATRunner; | ||
import componenttest.topology.database.container.DatabaseContainerType; | ||
import componenttest.topology.database.container.DatabaseContainerUtil; | ||
import componenttest.topology.impl.LibertyServer; | ||
import componenttest.topology.utils.PrivHelper; | ||
import io.openliberty.jpa.data.tests.web.JakartaDataRecreateServlet; | ||
|
||
/** | ||
* Recreate issues found during development of Jakarta Data with EclipseLink | ||
* using pure Jakarta Persistence. | ||
* | ||
* These tests should be contributed back to EclipseLink as these issues are resovled. | ||
*/ | ||
@RunWith(FATRunner.class) | ||
@MinimumJavaLevel(javaLevel = 17) | ||
public class JakartaDataRecreateTest { | ||
public static final String APP_NAME = "jakartadata"; | ||
public static final String SERVLET = "JakartaDataRecreate"; | ||
public static final String SPECLEVEL = "3.2"; | ||
|
||
@Server("JakartaDataRecreateServer") | ||
@TestServlet(servlet = JakartaDataRecreateServlet.class, path = APP_NAME + "_" + SPECLEVEL + "/" + SERVLET) | ||
public static LibertyServer server; | ||
|
||
public static final JdbcDatabaseContainer<?> testContainer = FATSuite.testContainer; | ||
|
||
@BeforeClass | ||
public static void setUp() throws Exception { | ||
PrivHelper.generateCustomPolicy(server, PrivHelper.JAXB_PERMISSION); | ||
|
||
//Get driver name | ||
server.addEnvVar("DB_DRIVER", DatabaseContainerType.valueOf(testContainer).getDriverName()); | ||
|
||
//Setup server DataSource properties | ||
DatabaseContainerUtil.setupDataSourceProperties(server, testContainer); | ||
|
||
createApplication(SPECLEVEL); | ||
server.startServer(); | ||
} | ||
|
||
private static void createApplication(String specLevel) throws Exception { | ||
final String resPath = "test-applications/" + APP_NAME + "/resources/jpa-" + specLevel + "/web/"; | ||
|
||
WebArchive app = ShrinkWrap.create(WebArchive.class, APP_NAME + "_" + specLevel + ".war"); | ||
app.addPackage("io.openliberty.jpa.data.tests.models"); | ||
app.addPackage("io.openliberty.jpa.data.tests.web"); | ||
app.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class).importDirectory(resPath).as(GenericArchive.class), | ||
"/", | ||
Filters.includeAll()); | ||
ShrinkHelper.exportDropinAppToServer(server, app); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDown() throws Exception { | ||
server.stopServer("CWWJP9991W", | ||
"WTRN0074E: Exception caught from before_completion synchronization operation", // RuntimeException test, expected | ||
"Missing PostgreSQL10JsonPlatform"); // Generated with postgres db, since we don't include the postgres plugin); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...bm.ws.jpa.tests.jpa_32_fat/publish/servers/JakartaDataRecreateServer/bootstrap.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
############################################################################### | ||
# Copyright (c) 2024 IBM Corporation and others. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License 2.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# IBM Corporation - initial API and implementation | ||
############################################################################### | ||
bootstrap.include=../testports.properties | ||
# Test requires JPA trace to be enabled, do not disable! | ||
com.ibm.ws.logging.trace.specification=*=info:JPA=all:eclipselink=all |
46 changes: 46 additions & 0 deletions
46
dev/com.ibm.ws.jpa.tests.jpa_32_fat/publish/servers/JakartaDataRecreateServer/server.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!-- | ||
Copyright (c) 2024 IBM Corporation and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License 2.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
--> | ||
<server description="new server"> | ||
|
||
<featureManager> | ||
<feature>persistence-3.2</feature> | ||
<feature>servlet-6.1</feature> | ||
<!-- DO NOT ADD data-1.0 feature --> | ||
<feature>componenttest-2.0</feature> | ||
</featureManager> | ||
|
||
<include location="../fatTestPorts.xml"/> | ||
<dataSource id="DefaultDataSource" fat.modify="true"> | ||
<jdbcDriver libraryRef="JDBCLib"/> | ||
<properties.derby.embedded databaseName="memory:ds1" createDatabase="create" user="dbuser1" password="{xor}Oz0vKDtu" /> | ||
</dataSource> | ||
|
||
<library id="JDBCLib"> | ||
<fileset dir="${shared.resource.dir}/jdbc" includes="${env.DB_DRIVER}"/> | ||
</library> | ||
|
||
<!-- JDBC driver --> | ||
<javaPermission codebase="${shared.resource.dir}/jdbc/${env.DB_DRIVER}" className="java.security.AllPermission"/> | ||
|
||
<!-- Permission needed for Postgres driver --> | ||
<javaPermission className="java.util.PropertyPermission" name="org.postgresql.forceBinary" actions="read"/> | ||
|
||
<!-- Permission needed for SQLServer driver --> | ||
<javaPermission className="java.net.SocketPermission" name="*" actions="connect,resolve"/> | ||
|
||
<!-- Permission needed for Oracle driver --> | ||
<javaPermission className="java.lang.RuntimePermission" name="accessDeclaredMembers" /> | ||
|
||
<!-- File read write permissions --> | ||
<javaPermission className="java.util.PropertyPermission" name="user.dir" actions="read"/> | ||
<javaPermission className="java.io.FilePermission" name="files/timertestoutput.txt" actions="read,write"/> | ||
<javaPermission className="java.io.FilePermission" name="files" actions="write"/> | ||
|
||
</server> |
28 changes: 28 additions & 0 deletions
28
...t-applications/jakartadata/resources/jpa-3.2/web/WEB-INF/classes/META-INF/persistence.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
--> | ||
<persistence xmlns="https://jakarta.ee/xml/ns/persistence" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_2.xsd" | ||
version="3.2"> | ||
|
||
<persistence-unit name="RecreatePersistenceUnit"> | ||
<properties> | ||
<!-- EclipseLink should create the database schema automatically --> | ||
<property name="jakarta.persistence.schema-generation.database.action" value="create" /> | ||
<property name="eclipselink.logging.parameters" value="true"/> | ||
</properties> | ||
</persistence-unit> | ||
</persistence> |
46 changes: 46 additions & 0 deletions
46
...2_fat/test-applications/jakartadata/src/io/openliberty/jpa/data/tests/models/Account.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package io.openliberty.jpa.data.tests.models; | ||
|
||
import jakarta.persistence.EmbeddedId; | ||
import jakarta.persistence.Entity; | ||
|
||
/** | ||
* Recreate from io.openliberty.data.internal_fat_jpa | ||
*/ | ||
@Entity | ||
public class Account { | ||
|
||
@EmbeddedId | ||
public AccountId accountId; | ||
|
||
public double balance; | ||
|
||
public String bankName; | ||
|
||
public boolean checking; | ||
|
||
public String owner; | ||
|
||
public static Account of(long accountNum, long routingNum, String bankName, boolean checking, double balance, String owner) { | ||
Account inst = new Account(); | ||
inst.accountId = AccountId.of(accountNum, routingNum); | ||
inst.bankName = bankName; | ||
inst.checking = checking; | ||
inst.balance = balance; | ||
inst.owner = owner; | ||
return inst; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return bankName + ' ' + accountId + " $" + balance + " owned by " + owner + (checking ? " with checking" : ""); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...fat/test-applications/jakartadata/src/io/openliberty/jpa/data/tests/models/AccountId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package io.openliberty.jpa.data.tests.models; | ||
|
||
import jakarta.persistence.Embeddable; | ||
|
||
@Embeddable | ||
public class AccountId { | ||
|
||
public long accountNum; | ||
public long routingNum; | ||
|
||
public AccountId() { | ||
} | ||
|
||
public AccountId(long accountNum, long routingNum) { | ||
this.accountNum = accountNum; | ||
this.routingNum = routingNum; | ||
} | ||
|
||
public static AccountId of(long accountNum, long routingNum) { | ||
return new AccountId(accountNum, routingNum); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AccountId:" + accountNum + ":" + routingNum; | ||
} | ||
} |
Oops, something went wrong.