diff options
Diffstat (limited to 'jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyAttributeMappingTests.java')
-rw-r--r-- | jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyAttributeMappingTests.java | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyAttributeMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyAttributeMappingTests.java deleted file mode 100644 index e82e700eb3..0000000000 --- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyAttributeMappingTests.java +++ /dev/null @@ -1,153 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.tests.internal.context.java; - -import java.util.Iterator; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute; -import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.common.core.utility.jdt.Member; -import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator; -import org.eclipse.jpt.jaxb.core.MappingKeys; -import org.eclipse.jpt.jaxb.core.context.JaxbClass; -import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; -import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping; -import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping; -import org.eclipse.jpt.jaxb.core.context.XmlElementMapping; -import org.eclipse.jpt.jaxb.core.resource.java.JAXB; -import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation; -import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase; - - -@SuppressWarnings("nls") -public class GenericJavaXmlAnyAttributeMappingTests extends JaxbContextModelTestCase -{ - - public GenericJavaXmlAnyAttributeMappingTests(String name) { - super(name); - } - - private ICompilationUnit createTypeWithXmlAnyAttribute() throws Exception { - return this.createTestType(new DefaultAnnotationWriter() { - @Override - public Iterator<String> imports() { - return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ANY_ATTRIBUTE); - } - @Override - public void appendTypeAnnotationTo(StringBuilder sb) { - sb.append("@XmlType"); - } - @Override - public void appendIdFieldAnnotationTo(StringBuilder sb) { - sb.append("@XmlAnyAttribute"); - } - }); - } - - public void testChangeMappingType() throws Exception { - createTypeWithXmlAnyAttribute(); - - JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0); - JaxbClassMapping classMapping = jaxbClass.getMapping(); - JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0); - XmlAnyAttributeMapping attributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping(); - JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute(); - - assertNotNull(attributeMapping); - assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ATTRIBUTE)); - - persistentAttribute.setMappingKey(MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY); - XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping(); - assertNotNull(xmlAttributeMapping); - assertNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ATTRIBUTE)); - assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE)); - - persistentAttribute.setMappingKey(MappingKeys.XML_ANY_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY); - attributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping(); - assertNotNull(attributeMapping); - assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ATTRIBUTE)); - assertNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE)); - - - persistentAttribute.setMappingKey(MappingKeys.XML_ELEMENT_ATTRIBUTE_MAPPING_KEY); - XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping(); - assertNotNull(xmlElementMapping); - assertNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ATTRIBUTE)); - assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT)); - - persistentAttribute.setMappingKey(MappingKeys.XML_ANY_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY); - attributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping(); - assertNotNull(attributeMapping); - assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ATTRIBUTE)); - assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT)); - } - - public void testModifyXmlJavaTypeAdapter() throws Exception { - createTypeWithXmlAnyAttribute(); - - JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0); - JaxbClassMapping classMapping = jaxbClass.getMapping(); - JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0); - XmlAnyAttributeMapping attributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping(); - JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute(); - - XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER); - assertNull(attributeMapping.getXmlJavaTypeAdapter()); - assertNull(xmlJavaTypeAdapterAnnotation); - - attributeMapping.addXmlJavaTypeAdapter(); - xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER); - assertNotNull(attributeMapping.getXmlJavaTypeAdapter()); - assertNotNull(xmlJavaTypeAdapterAnnotation); - - attributeMapping.removeXmlJavaTypeAdapter(); - xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER); - } - - public void testUpdateXmlJavaTypeAdapter() throws Exception { - createTypeWithXmlAnyAttribute(); - - JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0); - JaxbClassMapping classMapping = jaxbClass.getMapping(); - JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0); - XmlAnyAttributeMapping attributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping(); - JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute(); - - XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER); - assertNull(attributeMapping.getXmlJavaTypeAdapter()); - assertNull(xmlJavaTypeAdapterAnnotation); - - - //add an XmlJavaTypeAdapter annotation - AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute); - annotatedElement.edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - GenericJavaXmlAnyAttributeMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_JAVA_TYPE_ADAPTER); - } - }); - xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER); - assertNotNull(attributeMapping.getXmlJavaTypeAdapter()); - assertNotNull(xmlJavaTypeAdapterAnnotation); - - //remove the XmlJavaTypeAdapter annotation - annotatedElement.edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - GenericJavaXmlAnyAttributeMappingTests.this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER); - } - }); - xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER); - assertNull(attributeMapping.getXmlJavaTypeAdapter()); - assertNull(xmlJavaTypeAdapterAnnotation); - } - -}
\ No newline at end of file |