-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 2.0 for Bug 404069 - MOXy should not append .0 to time info for …
…dateTime and time formats + unit test (#1403) This new feature optionally add suffix/decimal part to time part/seconds in case of conversion from supported date/time formats into String. This suffix is controlled by new "org.eclipse.persistence.xml.time.suffix" system property. It happens only if source time doesn't contain fraction of seconds and for XML, JSON conversion. E.g.: For -Dorg.eclipse.persistence.xml.time.suffix=.0 Source value: 2003-08-29T03:00:00-04:00 -> Output string: 2003-08-29T03:00:00.0-04:00 Source value: 1975-02-21T07:47:15 -> Output string: 1975-02-21T07:47:15.0 In case of fraction of seconds in the input behavior is still same e.g.: Source value: 1975-02-21T07:47:15.123 -> Output string: 1975-02-21T07:47:15.123 It simplifies migration from WebLogic Server 11g to 12c. Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
- Loading branch information
Showing
7 changed files
with
206 additions
and
37 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
27 changes: 27 additions & 0 deletions
27
.../org/eclipse/persistence/testing/oxm/systemproperties/DateAndTimeNonDefaultTestCases.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,27 @@ | ||
/* | ||
* Copyright (c) 2022 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 from Oracle TopLink | ||
package org.eclipse.persistence.testing.oxm.systemproperties; | ||
|
||
|
||
import org.eclipse.persistence.testing.oxm.xmlconversionmanager.DateAndTimeTestCases; | ||
|
||
public class DateAndTimeNonDefaultTestCases extends DateAndTimeTestCases { | ||
|
||
public DateAndTimeNonDefaultTestCases(String name) { | ||
super(name); | ||
super.controlXmlConversionTimeSuffix = ".0"; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
...ipse/persistence/testing/oxm/systemproperties/OXMSystemPropertiesNonDefaultTestCases.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,51 @@ | ||
/* | ||
* Copyright (c) 2022 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.oxm.systemproperties; | ||
|
||
import org.eclipse.persistence.internal.oxm.OXMSystemProperties; | ||
import org.eclipse.persistence.internal.oxm.XMLConversionManager; | ||
import org.eclipse.persistence.oxm.XMLConstants; | ||
import org.junit.Test; | ||
|
||
import java.sql.Timestamp; | ||
import java.util.TimeZone; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* Tests OXMSystemProperties class. With default non-values. It requires to be isolated JVM to avoid impact to others tests or it should be executed with other tests with same system properties. | ||
*/ | ||
public class OXMSystemPropertiesNonDefaultTestCases { | ||
|
||
static { | ||
System.setProperty(OXMSystemProperties.JSON_TYPE_COMPATIBILITY, "true"); | ||
System.setProperty(OXMSystemProperties.JSON_USE_XSD_TYPES_PREFIX, "true"); | ||
System.setProperty(OXMSystemProperties.JSON_TYPE_ATTRIBUTE_NAME, "jsonTestType"); | ||
System.setProperty(OXMSystemProperties.JSON_DISABLE_NESTED_ARRAY_NAME, "true"); | ||
System.setProperty(OXMSystemProperties.XML_CONVERSION_TIME_SUFFIX, ".0"); | ||
} | ||
|
||
|
||
@Test | ||
public void testNonDefaultProperties() { | ||
assertTrue(OXMSystemProperties.jsonTypeCompatiblity); | ||
assertTrue(OXMSystemProperties.jsonUseXsdTypesPrefix); | ||
assertEquals("jsonTestType", OXMSystemProperties.jsonTypeAttributeName); | ||
assertTrue(OXMSystemProperties.jsonDisableNestedArrayName); | ||
assertEquals(".0", OXMSystemProperties.xmlConversionTimeSuffix); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...va/org/eclipse/persistence/testing/oxm/systemproperties/OXMSystemPropertiesTestCases.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) 2022 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.oxm.systemproperties; | ||
|
||
import org.eclipse.persistence.internal.oxm.OXMSystemProperties; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
|
||
/** | ||
* Tests OXMSystemProperties class. With default values. | ||
*/ | ||
public class OXMSystemPropertiesTestCases { | ||
|
||
@Test | ||
public void testProperties() { | ||
assertFalse(OXMSystemProperties.jsonTypeCompatiblity); | ||
assertFalse(OXMSystemProperties.jsonUseXsdTypesPrefix); | ||
assertEquals("type", OXMSystemProperties.jsonTypeAttributeName); | ||
assertFalse(OXMSystemProperties.jsonDisableNestedArrayName); | ||
assertEquals("", OXMSystemProperties.xmlConversionTimeSuffix); | ||
} | ||
} |
Oops, something went wrong.