Skip to content

Commit

Permalink
[master] Maven build (MOXy) - JMockit dependency removal (eclipse-ee4…
Browse files Browse the repository at this point in the history
…j#1109)

Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
  • Loading branch information
rfelcman committed May 5, 2021
1 parent 2bcbb67 commit 436f5ff
Show file tree
Hide file tree
Showing 22 changed files with 669 additions and 821 deletions.
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, 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 @@ -76,8 +76,5 @@ jboss-logging.jar=jboss-logging-3.3.0.Final.jar
javax.el.jar=javax.el-3.0.1-b08.jar
classmate.jar=classmate-1.3.1.jar

#JMockit
jmockit.jar=jmockit-1.35.jar

#JaCoCo
jacocoagent.jar=jacocoagent.jar
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2018, 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 @@ -97,7 +97,6 @@
<property name="jboss-logging.lib" value="${extensions.depend.dir}/${jboss-logging.jar}"/>
<property name="javax.el.lib" value="${extensions.depend.dir}/${javax.el.jar}"/>
<property name="classmate.lib" value="${extensions.depend.dir}/${classmate.jar}"/>
<property name="jmockit.lib" value="${extensions.depend.dir}/${jmockit.jar}"/>
<property name="jacocoagent.lib" value="${extensions.depend.dir}/${jacocoagent.jar}"/>

<condition property="validate.jar.exists">
Expand Down Expand Up @@ -141,7 +140,6 @@
<pathelement path="${moxytest.2.common.plugins.dir}/${jaxrs.jar}"/>
<pathelement path="${moxytest.2.common.plugins.dir}/${asm.jar}"/>
<pathelement path="${oep.nosql.lib}"/>
<pathelement path="${jmockit.lib}"/>
<pathelement path="${junit.lib}"/>
<pathelement path="${moxytest.2.moxy.dir}/target/${classes.dir}"/>
<pathelement path="${moxytest.2.core.dir}/target/${classes.dir}"/>
Expand All @@ -165,7 +163,6 @@
<pathelement path="${moxytest.2.common.plugins.dir}/org.eclipse.persistence.asm"/>
<pathelement path="${build.dir}/${classes.dir}"/>
<pathelement path="${jaxb-core.lib}"/>
<pathelement path="${jmockit.lib}"/>
<pathelement path="${jacocoagent.lib}"/>
<pathelement path="${junit.lib}"/>
<pathelement path="${validation-impl.lib}"/>
Expand All @@ -184,7 +181,6 @@
<pathelement path="${moxytest.2.common.plugins.dir}/${transaction.jar}"/>
<pathelement path="${moxytest.2.common.plugins.dir}/${mail.jar}"/>
<pathelement path="${oep.nosql.lib}"/>
<pathelement path="${jmockit.lib}"/>
<pathelement path="${junit.lib}"/>
<pathelement path="${moxytest.2.moxy.dir}/target/${classes.dir}"/>
<pathelement path="${moxytest.2.core.dir}/target/${classes.dir}"/>
Expand All @@ -202,15 +198,13 @@
<pathelement path="${build.dir}/${classes.dir}"/>
<pathelement path="${moxytest.2.core.dir}/target/${classes.dir}"/>
<pathelement path="${jacocoagent.lib}"/>
<pathelement path="${jmockit.lib}"/>
<pathelement path="${junit.lib}"/>
<pathelement path="${moxytest.2.common.plugins.dir}/${activation.jar}"/>
</path>

<!-- The following compile/run paths reference eclipselink.jar for non-test classes and resources -->
<path id="jaxb.compile.against.jar.path">
<path refid="xml.parser.path"/>
<pathelement path="${jmockit.lib}"/>
<pathelement path="${junit.lib}"/>
<pathelement path="${jaxb-api.lib}"/>
<pathelement path="${moxytest.2.common.plugins.dir}/${json-api.jar}"/>
Expand All @@ -230,7 +224,6 @@
<path id="jaxb.run.against.jar.path">
<path refid="xml.parser.path"/>
<pathelement path="${jacocoagent.lib}"/>
<pathelement path="${jmockit.lib}"/>
<pathelement path="${junit.lib}"/>
<pathelement path="${jaxb-api.lib}"/>
<pathelement path="${moxytest.2.common.plugins.dir}/${json-api.jar}"/>
Expand All @@ -252,7 +245,6 @@
<path id="oxm.compile.against.jar.path">
<path refid="xml.parser.path"/>
<pathelement path="${jaxb-api.lib}"/>
<pathelement path="${jmockit.lib}"/>
<pathelement path="${junit.lib}"/>
<pathelement path="${moxytest.2.common.plugins.dir}/${resource.jar}"/>
<pathelement path="${moxytest.2.common.plugins.dir}/${ejb.jar}"/>
Expand All @@ -266,7 +258,6 @@
<path id="oxm.run.against.jar.path">
<path refid="xml.parser.path"/>
<pathelement path="${jacocoagent.lib}"/>
<pathelement path="${jmockit.lib}"/>
<pathelement path="${junit.lib}"/>
<pathelement path="${jaxb-api.lib}"/>
<pathelement path="${moxytest.2.common.plugins.dir}/${json-api.jar}"/>
Expand Down Expand Up @@ -527,7 +518,6 @@
<!--<jvmarg value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"/>-->
<jvmarg value="-ea"/>
<jvmarg line="${test.junit.jvm.modules.prop}"/>
<jvmarg value="-javaagent:${jmockit.lib}"/>
<jvmarg line="${additional.jvmargs}"/>
<env key="T_WORK" value="${tmp.dir}"/>
<sysproperty key="platformType" value="SAX"/>
Expand Down
34 changes: 26 additions & 8 deletions moxy/org.eclipse.persistence.moxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<scope>test</scope>
</dependency>
<!--APIs and other libs used in test classes-->
<dependency>
<groupId>com.sun.xml.bind</groupId>
Expand Down Expand Up @@ -242,8 +237,6 @@
<goal>test</goal>
</goals>
<configuration>
<!---javaagent:${org.jmockit:jmockit:jar} is required for JDK 9 and higher.-->
<argLine>-javaagent:${org.jmockit:jmockit:jar}</argLine>
<skipTests>${test-skip-moxy-jaxb}</skipTests>
<reportNameSuffix>test-moxy-jaxb</reportNameSuffix>
<forkCount>1</forkCount>
Expand All @@ -266,11 +259,36 @@
<include>org.eclipse.persistence.testing.jaxb.json.JSONTestSuite</include>
<include>org.eclipse.persistence.testing.jaxb.rs.RESTfulTestSuite</include>
<include>org.eclipse.persistence.testing.moxy.unit.**.*TestCase</include>
<include>org.eclipse.persistence.testing.jaxb.annotations.xmlidref.XmlIdSystemPropertyTestCase</include>
<include>org.eclipse.persistence.testing.jaxb.annotations.xmlidref.XmlIdSystemPropertyNotSetTestCase</include>
<include>org.eclipse.persistence.testing.jaxb.annotations.xmlvalue.XmlValueSystemPropertyNotSetTestCase</include>
<include>org.eclipse.persistence.testing.jaxb.annotations.xmlvalue.XmlValueSystemPropertyTestCase</include>
</includes>
<excludes>
<exclude>org.eclipse.persistence.testing.moxy.unit.**.*NonDefaultTestCase</exclude>
<exclude>org.eclipse.persistence.testing.jaxb.**.*NonDefaultTestCase</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>test-moxy-jaxb-non-default-system-properties</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>${test-skip-moxy-jaxb}</skipTests>
<reportNameSuffix>test-moxy-jaxb-non-default-system-properties</reportNameSuffix>
<systemPropertyVariables>
<org.eclipse.persistence.moxy.annotation.xml-id-extension>true</org.eclipse.persistence.moxy.annotation.xml-id-extension>
<org.eclipse.persistence.moxy.annotation.xml-value-extension>true</org.eclipse.persistence.moxy.annotation.xml-value-extension>
<org.eclipse.persistence.json.type-compatibility>true</org.eclipse.persistence.json.type-compatibility>
<org.eclipse.persistence.json.use-xsd-types-prefix>true</org.eclipse.persistence.json.use-xsd-types-prefix>
<eclipselink.logging.level.moxy>FINE</eclipselink.logging.level.moxy>
<eclipselink.logging.payload.moxy>true</eclipselink.logging.payload.moxy>
</systemPropertyVariables>
<includes>
<include>org.eclipse.persistence.testing.moxy.unit.**.*NonDefaultTestCase</include>
<include>org.eclipse.persistence.testing.jaxb.**.*NonDefaultTestCase</include>
</includes>
</configuration>
</execution>
<execution>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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
*/

// Contributors:
// Oracle - initial API and implementation
package org.eclipse.persistence.testing.jaxb.annotations.xmlidref;

import jakarta.xml.bind.annotation.XmlIDREF;
import jakarta.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "owner")
public class OwnerIntegerId {

@XmlIDREF
public ThingIntegerId m_calendar;

public String m_activityId;

public boolean equals(Object obj){
if(obj instanceof OwnerIntegerId){
OwnerIntegerId ownerObject = (OwnerIntegerId)obj;
if(!this.m_activityId.equals(ownerObject.m_activityId)){
return false;
}
if(m_calendar == null){
return ownerObject.m_calendar ==null;
}else{
return m_calendar.equals(ownerObject.m_calendar);
}
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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
*/

// Contributors:
// Oracle - initial API and implementation
package org.eclipse.persistence.testing.jaxb.annotations.xmlidref;

import jakarta.xml.bind.annotation.XmlID;
import jakarta.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class ThingIntegerId extends BaseThing {

@XmlID
public Integer m_calendarId;

public boolean equals(Object obj) {
if(obj instanceof ThingIntegerId){
return m_calendarId.equals(((ThingIntegerId)obj).m_calendarId);
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2014, 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
*/

// Contributors:
// Oracle - initial API and implementation
package org.eclipse.persistence.testing.jaxb.annotations.xmlidref;

import org.eclipse.persistence.jaxb.MOXySystemProperties;
import org.eclipse.persistence.testing.jaxb.JAXBWithJSONTestCases;

/**
* Tests verify, that marshalling/unmarshalling works for field with @XmlID annotation if type is different, than String and system property org.eclipse.persistence.moxy.annotation.xml-id-extension is set.
*/
public class XmlIdSystemPropertyNonDefaultTestCase extends JAXBWithJSONTestCases {

private static final String XML_RESOURCE="org/eclipse/persistence/testing/jaxb/annotations/xmlidref/missing_id.xml";
private static final String JSON_RESOURCE="org/eclipse/persistence/testing/jaxb/annotations/xmlidref/missing_id_integer_id.json";

static {
System.setProperty(MOXySystemProperties.XML_ID_EXTENSION, "true");
}

public XmlIdSystemPropertyNonDefaultTestCase(String name) throws Exception {
super(name);
setClasses(new Class[]{OwnerIntegerId.class, ThingIntegerId.class});
setControlDocument(XML_RESOURCE);
setControlJSON(JSON_RESOURCE);
}

@Override
protected Object getControlObject() {
OwnerIntegerId owner = new OwnerIntegerId();
owner.m_activityId = "1";
ThingIntegerId theThing = new ThingIntegerId();
theThing.m_calendarId = 2;
owner.m_calendar = theThing;
return owner;
}

@Override
public Object getReadControlObject() {
OwnerIntegerId owner = new OwnerIntegerId();
owner.m_activityId = "1";
owner.m_calendar = null;
return owner;
}

//Not applicable
public void testRoundTrip() { }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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 @@ -11,50 +11,30 @@
*/

// Contributors:
// Martin Vojtek - 2.6 - initial implementation
// Oracle - initial API and implementation
package org.eclipse.persistence.testing.jaxb.annotations.xmlidref;

import jakarta.xml.bind.JAXBException;
import org.eclipse.persistence.jaxb.JAXBContextFactory;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import mockit.Deencapsulation;
import mockit.Expectations;
import mockit.Mocked;
import mockit.integration.junit4.JMockit;

import org.eclipse.persistence.exceptions.JAXBException;
import org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor;
import org.eclipse.persistence.jaxb.compiler.Property;
import org.eclipse.persistence.jaxb.javamodel.Helper;
import org.eclipse.persistence.jaxb.javamodel.JavaClass;
import org.eclipse.persistence.jaxb.javamodel.JavaHasAnnotations;
import org.eclipse.persistence.oxm.annotations.XmlIDExtension;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* Tests useXmlIdExtension method when system property org.eclipse.persistence.moxy.annotation.xml-id-extension is not set.
* Tests verify, that expected MOXy ErrorCode (50016) is returned during JAXBContext creation when system property org.eclipse.persistence.moxy.annotation.xml-id-extension is not set.
*/
@RunWith(JMockit.class)
public class XmlIdSystemPropertyNotSetTestCase {
public class XmlIdSystemPropertyNotSetTestCase{

@Test
public void testSystemXmlIdExtensionNotSet(final @Mocked Property property, final @Mocked Helper helper, final @Mocked JavaClass javaClass) {
new Expectations(System.class) {{
property.getActualType(); result = javaClass;
javaClass.getQualifiedName(); result = "java.lang.Integer";
System.getProperty("org.eclipse.persistence.moxy.annotation.xml-id-extension"); result = "false";
helper.isAnnotationPresent((JavaHasAnnotations)any, XmlIDExtension.class); result = false;
property.isXmlIdExtension(); result = false;
}};
private static final Class<?>[] DOMAIN_CLASSES = new Class<?>[]{OwnerIntegerId.class, ThingIntegerId.class};

AnnotationsProcessor processor = new AnnotationsProcessor(helper);
@Test
public void testSystemXmlIdExtensionNotSet() {
try {
Deencapsulation.invoke(processor, "validateXmlIdStringType", property);
JAXBContextFactory.createContext(DOMAIN_CLASSES, null);
fail("Expected JAXBException.");
} catch (JAXBException expected) {
assertEquals(50016, expected.getErrorCode());
assertEquals(50016, ((org.eclipse.persistence.exceptions.JAXBException)expected.getLinkedException()).getErrorCode());
}

}

}
Loading

0 comments on commit 436f5ff

Please sign in to comment.