Skip to content

Commit

Permalink
Add persistence.xml 3.1 schema support
Browse files Browse the repository at this point in the history
Signed-off-by: Will Dazey <[email protected]>
  • Loading branch information
dazey3 committed Apr 19, 2022
1 parent f772522 commit a04b75e
Show file tree
Hide file tree
Showing 4 changed files with 371 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<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_0.xsd"
version="3.0">
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_1.xsd"
version="3.1">
<persistence-unit name="beanvalidation" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.eclipse.persistence.testing.models.jpa.beanvalidation.Employee</class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<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_0.xsd"
version="3.0">
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_1.xsd"
version="3.1">
<persistence-unit name="@default@" transaction-type="@transaction-type@">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<@datasource-type@>@data-source-name@</@datasource-type@>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,37 +65,41 @@ public static void prepare() throws IOException {
@Test
public void testProc() throws Exception {
testProc("testProc3030", PXML30, OXML30);
testProc("testProc3031", PXML30, OXML31);
testProc("testProc3131", PXML31, OXML31);
}

@Test
public void testGenerateComment() throws Exception {
testGenerateComment("testGenerateComment3030", PXML30, OXML30);
testGenerateComment("testGenerateComment3031", PXML30, OXML31);
testGenerateComment("testGenerateComment3131", PXML31, OXML31);
}

@Test
public void testGenerate() throws Exception {
testGenerate("testGenerate3030", PXML30, OXML30);
testGenerate("testGenerate3031", PXML30, OXML31);
testGenerate("testGenerate3131", PXML31, OXML31);
}

@Test
public void testTypeUse() throws Exception {
testTypeUse("testTypeUse3030", PXML30, OXML30);
testTypeUse("testTypeUse3031", PXML30, OXML31);
testTypeUse("testTypeUse3131", PXML31, OXML31);
}

@Test
public void testProcessorLoggingOffFromCmdLine() throws Exception {
verifyLogging("testProcessorLoggingOffFromCmdLine", PXML30, false,
"-Aeclipselink.logging.level.processor=OFF");
verifyLogging("testProcessorLoggingOffFromCmdLine", PXML31, false,
"-Aeclipselink.logging.level.processor=OFF");
}

@Test
public void testGlobalLoggingOffFromCmdLine() throws Exception {
verifyLogging("testGlobalLoggingOffFromCmdLine", PXML30, false,
"-Aeclipselink.logging.level=OFF");
verifyLogging("testGlobalLoggingOffFromCmdLine", PXML31, false,
"-Aeclipselink.logging.level=OFF");
}

@Test
Expand All @@ -118,12 +122,16 @@ public void testGlobalLoggingOffFromPU() throws Exception {
public void testProcessorLoggingFinestFromCmdLine() throws Exception {
verifyLogging("testProcessorLoggingFinestFromCmdLine", PXML30, true,
"-Aeclipselink.logging.level.processor=FINEST");
verifyLogging("testProcessorLoggingFinestFromCmdLine", PXML31, true,
"-Aeclipselink.logging.level.processor=FINEST");
}

@Test
public void testGlobalLoggingFinestFromCmdLine() throws Exception {
verifyLogging("testGlobalLoggingFinestFromCmdLine", PXML30, true,
"-Aeclipselink.logging.level=FINEST");
verifyLogging("testGlobalLoggingFinestFromCmdLine", PXML31, true,
"-Aeclipselink.logging.level=FINEST");
}

@Test
Expand Down Expand Up @@ -355,6 +363,19 @@ private static class Result {
" </persistence-unit>\n" +
"</persistence>";

private static final String PXML31 = "<persistence xmlns=\"https://jakarta.ee/xml/ns/persistence\"\n" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
" xsi:schemaLocation=\"https://jakarta.ee/xml/ns/persistence\n" +
" https://jakarta.ee/xml/ns/persistence/persistence_3_1.xsd\"\n" +
" version=\"3.1\">\n" +
" <persistence-unit name=\"sample-pu\" transaction-type=\"RESOURCE_LOCAL\">\n" +
" <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>\n" +
" <exclude-unlisted-classes>false</exclude-unlisted-classes>\n" +
" <properties>\n" +
" </properties>\n" +
" </persistence-unit>\n" +
"</persistence>";

private static final String OXML30 = "<entity-mappings xmlns=\"https://jakarta.ee/xml/ns/persistence/orm\"\n" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
" xsi:schemaLocation=\"https://jakarta.ee/xml/ns/persistence/orm https://jakarta.ee/xml/ns/persistence/orm/orm_3_0.xsd\"\n" +
Expand Down
Loading

0 comments on commit a04b75e

Please sign in to comment.