Skip to content

Commit

Permalink
[master] OXM Tests move from MOXy to Core module (#1341)
Browse files Browse the repository at this point in the history
Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
  • Loading branch information
rfelcman committed Oct 25, 2021
1 parent d64a494 commit 2a414ff
Show file tree
Hide file tree
Showing 2,218 changed files with 799 additions and 535 deletions.
4 changes: 2 additions & 2 deletions bundles/nightly/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2019, 2021 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 Down Expand Up @@ -181,7 +181,7 @@
</fileSet>
<fileSet>
<sourceFile>
../../moxy/org.eclipse.persistence.moxy/target/${project.build.testReports.subdirectory}/${project.build.testReports.summaryFile}.html
../../foundation/org.eclipse.persistence.core/target/${project.build.testReports.subdirectory}/${project.build.testReports.summaryFile}.html
</sourceFile>
<destinationFile>
${project.build.directory}${nightlyDir}/Eclipse/eclipselink-oxm-lrg${nightlyVersion}.html
Expand Down
9 changes: 9 additions & 0 deletions etc/jenkins/pr_verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ spec:
}
}
}
stage('OXM LRG') {
steps {
container('el-build') {
sh """
mvn -B -V verify -pl :org.eclipse.persistence.core -P test-core-lrg
"""
}
}
}
stage('MOXy LRG') {
steps {
container('el-build') {
Expand Down
22 changes: 22 additions & 0 deletions foundation/eclipselink.core.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,33 @@
<artifactId>jakarta.persistence-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<scope>test</scope>
</dependency>
<!--Test dependencies-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!--Other modules-->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.asm</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
Expand Down Expand Up @@ -116,6 +131,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<workingDirectory>${project.build.directory}/test-run</workingDirectory>
<systemPropertyVariables>
<eclipselink.xml.platform>${test.xml.platform}</eclipselink.xml.platform>
<parser>${test.xml.parser}</parser>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<id>default-test</id>
Expand Down
360 changes: 360 additions & 0 deletions foundation/org.eclipse.persistence.core/pom.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2021 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
*/


open module org.eclipse.persistence.core.test {

requires java.compiler;
requires java.logging;
requires java.sql;

requires jakarta.mail;
requires jakarta.json;
requires jakarta.xml.bind;
requires org.eclipse.persistence.asm;
requires org.eclipse.persistence.core;
requires junit;

exports org.eclipse.persistence.testing.oxm;
exports org.eclipse.persistence.testing.oxm.classloader;
exports org.eclipse.persistence.testing.oxm.mappings;
exports org.eclipse.persistence.testing.oxm.mappings.choice;
exports org.eclipse.persistence.testing.oxm.xmlconversionmanager;
exports org.eclipse.persistence.testing.oxm.xmlmarshaller;
exports org.eclipse.persistence.testing.oxm.xmlroot;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2021 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
*/

package org.eclipse.persistence.testing.oxm;

import org.eclipse.persistence.platform.xml.XMLComparer;
import org.w3c.dom.*;

public class OXMXMLComparer extends XMLComparer{

public OXMXMLComparer() {
super();
}

/**
* Compares two XML documents which represent XML Schemas. Order of declarations should
* be ignored.
*/
public boolean isSchemaEqual(Document control, Document test) {
Element controlRoot = control.getDocumentElement();
Element testRoot = test.getDocumentElement();

if(!(controlRoot.getChildNodes().getLength() == testRoot.getChildNodes().getLength())) {
return false;
}

//compare attributes:
NamedNodeMap controlAttributes = controlRoot.getAttributes();
NamedNodeMap testAttributes = testRoot.getAttributes();
int numberOfControlAttributes = controlAttributes.getLength();
int numberOfTestAttributes = testAttributes.getLength();
if (numberOfControlAttributes != numberOfTestAttributes) {
return false;
}
Attr controlAttribute;
Attr testAttribute;
for (int x = 0; x < numberOfControlAttributes; x++) {
controlAttribute = (Attr)controlAttributes.item(x);
if (null == controlAttribute.getNamespaceURI()) {
testAttribute = (Attr)testAttributes.getNamedItem(controlAttribute.getNodeName());
} else {
testAttribute = (Attr)testAttributes.getNamedItemNS(controlAttribute.getNamespaceURI(), controlAttribute.getLocalName());
}
if (null == testAttribute) {
return false;
} else if (!isAttributeEqual(controlAttribute, testAttribute)) {
return false;
}
}

//compare definitions ignoring order and text
NodeList controlChildren = controlRoot.getChildNodes();
for(int i = 0; i < controlChildren.getLength(); i++) {
Node controlChild = controlChildren.item(i);
if(controlChild.getNodeType() == Node.TEXT_NODE) {
continue;
}
NamedNodeMap controlChildAttributes = controlChild.getAttributes();
Node testChild = null;
//Find the equivalent node in the test children.
NodeList testChildren = testRoot.getElementsByTagNameNS(controlChild.getNamespaceURI(), controlChild.getLocalName());
for(int j = 0; j < testChildren.getLength(); j++) {
Node next = testChildren.item(j);
NamedNodeMap testChildAttributes = next.getAttributes();
numberOfControlAttributes = controlChildAttributes.getLength();
numberOfTestAttributes = testChildAttributes.getLength();
boolean equalAttributes = true;
if(numberOfControlAttributes != numberOfTestAttributes) {
equalAttributes = false;
}
for (int x = 0; x < numberOfControlAttributes; x++) {
controlAttribute = (Attr)controlChildAttributes.item(x);
if (null == controlAttribute.getNamespaceURI()) {
testAttribute = (Attr)testChildAttributes.getNamedItem(controlAttribute.getNodeName());
} else {
testAttribute = (Attr)testChildAttributes.getNamedItemNS(controlAttribute.getNamespaceURI(), controlAttribute.getLocalName());
}
if (testAttribute == null) {
equalAttributes = false;
} else if (!isAttributeEqual(controlAttribute, testAttribute)) {
equalAttributes = false;
}
}
if(equalAttributes) {
//if the attributes are all equal, then these are the same definition
testChild = next;
break;
}
}
if(testChild == null || !isNodeEqual(controlChild, testChild)) {
return false;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021 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 @@ -17,15 +17,11 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.persistence.testing.oxm.converter.jaxbenum.JAXBEnumTypeConverterTestCases;
import org.eclipse.persistence.testing.oxm.converter.typesafeenum.TypeSafeEnumConverterTestCases;

public class ConverterTestSuite extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite("Object Type Converter");
TestSuite suite = new TestSuite("OXM Object Type Converter");
suite.addTestSuite(ObjectTypeConverterTestCases.class);
suite.addTestSuite(TypeSafeEnumConverterTestCases.class);
suite.addTestSuite(JAXBEnumTypeConverterTestCases.class);
return suite;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@
package org.eclipse.persistence.testing.oxm.inheritance.typetests;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import org.eclipse.persistence.internal.oxm.record.namespaces.MapNamespacePrefixMapper;
import org.eclipse.persistence.jaxb.MarshallerProperties;
import org.eclipse.persistence.oxm.NamespacePrefixMapper;
import org.eclipse.persistence.oxm.NamespaceResolver;
import org.eclipse.persistence.oxm.XMLRoot;
import org.eclipse.persistence.testing.oxm.mappings.XMLWithJSONMappingTestCases;

Expand Down

0 comments on commit 2a414ff

Please sign in to comment.