forked from eclipse-ee4j/jaxb-ri
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com> (cherry picked from commit db536c9)
- Loading branch information
Showing
4 changed files
with
86 additions
and
0 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
24 changes: 24 additions & 0 deletions
24
jaxb-ri/runtime/impl/src/test/java/com/sun/xml/bind/v2/runtime/ChildDTO.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,24 @@ | ||
/* | ||
* 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 Distribution License v. 1.0, which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
package com.sun.xml.bind.v2.runtime; | ||
|
||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
@XmlRootElement(name = "child") | ||
public class ChildDTO extends ParentDTO { | ||
|
||
@Override | ||
@XmlElement(name="childName") | ||
public String getName() { | ||
return name; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
jaxb-ri/runtime/impl/src/test/java/com/sun/xml/bind/v2/runtime/InheritanceTest.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,33 @@ | ||
/* | ||
* 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 Distribution License v. 1.0, which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
package com.sun.xml.bind.v2.runtime; | ||
|
||
import java.io.StringWriter; | ||
import javax.xml.bind.JAXBContext; | ||
import javax.xml.bind.Marshaller; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class InheritanceTest { | ||
|
||
@Test | ||
public void aTest() throws Throwable { | ||
ChildDTO child = new ChildDTO(); | ||
child.setName("aaa"); | ||
|
||
final Marshaller marshaller = JAXBContext.newInstance(ChildDTO.class).createMarshaller(); | ||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); | ||
StringWriter stringWriter = new StringWriter(); | ||
marshaller.marshal(child, stringWriter); | ||
String xmlAsString = stringWriter.toString(); | ||
Assert.assertFalse(xmlAsString.contains("parent")); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
jaxb-ri/runtime/impl/src/test/java/com/sun/xml/bind/v2/runtime/ParentDTO.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,28 @@ | ||
/* | ||
* 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 Distribution License v. 1.0, which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
package com.sun.xml.bind.v2.runtime; | ||
|
||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
@XmlRootElement(name = "parent") | ||
public class ParentDTO { | ||
protected String name; | ||
|
||
@XmlElement(name="parentName") | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |