Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java')
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapterTests.java185
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaClassMappingTests.java2142
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaElementFactoryMethodTests.java413
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumConstantTests.java137
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumMappingTests.java381
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java793
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageXmlJavaTypeAdapterTests.java160
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentAttributeTests.java112
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaRegistryTests.java197
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaTypeXmlJavaTypeAdapterTests.java173
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAdapterTests.java112
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyAttributeMappingTests.java153
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyElementMappingTests.java533
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAttributeMappingTests.java731
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementMappingTests.java1055
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefMappingTests.java594
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefsMappingTests.java415
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementsMappingTests.java371
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java169
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTests.java669
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTypeTests.java206
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSeeAlsoTests.java152
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlValueMappingTests.java306
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java52
24 files changed, 0 insertions, 10211 deletions
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapterTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapterTests.java
deleted file mode 100644
index 3d2a980510..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapterTests.java
+++ /dev/null
@@ -1,185 +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.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-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.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
-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 GenericJavaAttributeXmlJavaTypeAdapterTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaAttributeXmlJavaTypeAdapterTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createClassWithXmlTypeAndAttributeXmlJavaTypeAdapter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ATTRIBUTE, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType").append(CR);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlAttribute").append(CR);
- sb.append("@XmlJavaTypeAdapter");
- }
- });
- }
-
- public void testModifyValue() throws Exception {
- createClassWithXmlTypeAndAttributeXmlJavaTypeAdapter();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlAttributeMapping attributeMapping = (XmlAttributeMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = attributeMapping.getXmlJavaTypeAdapter();
- JavaResourceAttribute resourceAttribute = attributeMapping.getJavaResourceAttribute();
-
- assertNull(contextXmlJavaTypeAdapter.getValue());
-
- contextXmlJavaTypeAdapter.setValue("foo");
- XmlJavaTypeAdapterAnnotation javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertEquals("foo", javaTypeAdapterAnnotation.getValue());
- assertEquals("foo", contextXmlJavaTypeAdapter.getValue());
-
- //verify the xml schema type annotation is not removed when the value is set to null
- contextXmlJavaTypeAdapter.setValue(null);
- javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(javaTypeAdapterAnnotation.getValue());
- assertNull(contextXmlJavaTypeAdapter.getValue());
- }
-
- public void testUpdateValue() throws Exception {
- createClassWithXmlTypeAndAttributeXmlJavaTypeAdapter();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlAttributeMapping attributeMapping = (XmlAttributeMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = attributeMapping.getXmlJavaTypeAdapter();
- JavaResourceAttribute resourceAttribute = attributeMapping.getJavaResourceAttribute();
-
- assertNull(contextXmlJavaTypeAdapter.getValue());
-
- //add a value member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaAttributeXmlJavaTypeAdapterTests.this.addXmlJavaTypeAdapterTypeMemberValuePair(declaration, JAXB.XML_JAVA_TYPE_ADAPTER__VALUE, "String");
- }
- });
- assertEquals("String", contextXmlJavaTypeAdapter.getValue());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaAttributeXmlJavaTypeAdapterTests.this.removeXmlJavaTypeAdapterAnnotation(declaration);
- }
- });
- assertNull(attributeMapping.getXmlJavaTypeAdapter());
- }
-
- public void testModifyType() throws Exception {
- createClassWithXmlTypeAndAttributeXmlJavaTypeAdapter();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlAttributeMapping attributeMapping = (XmlAttributeMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = attributeMapping.getXmlJavaTypeAdapter();
- JavaResourceAttribute resourceAttribute = attributeMapping.getJavaResourceAttribute();
-
- assertEquals("int", contextXmlJavaTypeAdapter.getType());
- assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
- assertEquals("int", contextXmlJavaTypeAdapter.getDefaultType());
-
- contextXmlJavaTypeAdapter.setSpecifiedType("foo");
- XmlJavaTypeAdapterAnnotation javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertEquals("foo", javaTypeAdapterAnnotation.getType());
- assertEquals("foo", contextXmlJavaTypeAdapter.getSpecifiedType());
- assertEquals("int", contextXmlJavaTypeAdapter.getDefaultType());
-
- contextXmlJavaTypeAdapter.setSpecifiedType(null);
- javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(javaTypeAdapterAnnotation.getType());
- assertEquals("int", contextXmlJavaTypeAdapter.getType());
- assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
- assertEquals("int", contextXmlJavaTypeAdapter.getDefaultType());
- }
-
- public void testUpdateType() throws Exception {
- createClassWithXmlTypeAndAttributeXmlJavaTypeAdapter();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlAttributeMapping attributeMapping = (XmlAttributeMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = attributeMapping.getXmlJavaTypeAdapter();
- JavaResourceAttribute resourceAttribute = attributeMapping.getJavaResourceAttribute();
-
- assertEquals("int", contextXmlJavaTypeAdapter.getType());
- assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
- assertEquals("int", contextXmlJavaTypeAdapter.getDefaultType());
-
- //add a type member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaAttributeXmlJavaTypeAdapterTests.this.addXmlJavaTypeAdapterTypeMemberValuePair(declaration, JAXB.XML_JAVA_TYPE_ADAPTER__TYPE, "String");
- }
- });
- assertEquals("String", contextXmlJavaTypeAdapter.getSpecifiedType());
- assertEquals("String", contextXmlJavaTypeAdapter.getType());
- assertEquals("int", contextXmlJavaTypeAdapter.getDefaultType());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaAttributeXmlJavaTypeAdapterTests.this.removeXmlJavaTypeAdapterAnnotation(declaration);
- }
- });
- assertNull(attributeMapping.getXmlJavaTypeAdapter());
- }
-
- protected void addXmlJavaTypeAdapterTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlJavaTypeAdapterAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected void addXmlJavaTypeAdapterMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlJavaTypeAdapterAnnotation(declaration), name, value);
- }
-
- protected void removeXmlJavaTypeAdapterAnnotation(ModifiedDeclaration declaration) {
- this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
-
- protected Annotation getXmlJavaTypeAdapterAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_JAVA_TYPE_ADAPTER);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaClassMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaClassMappingTests.java
deleted file mode 100644
index 8cf435e871..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaClassMappingTests.java
+++ /dev/null
@@ -1,2142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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.beans.Introspector;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.IExtendedModifier;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.Modifier;
-import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceMember;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-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.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.core.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
-import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.XmlAccessOrder;
-import org.eclipse.jpt.jaxb.core.context.XmlAccessType;
-import org.eclipse.jpt.jaxb.core.internal.context.java.PropertyAccessor;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorOrderAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlSeeAlsoAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaClassMappingTests
- extends JaxbContextModelTestCase {
-
- public GenericJavaClassMappingTests(String name) {
- super(name);
- }
-
-
- private void createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_TYPE);
- sb.append(";");
- sb.append(CR);
- sb.append("@XmlType");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- private ICompilationUnit createXmlTypeWithAccessorType() throws CoreException {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ACCESS_TYPE, JAXB.XML_ACCESSOR_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType").append(CR);
- sb.append("@XmlAccessorType(value = XmlAccessType.PROPERTY)");
- }
- });
- }
-
- private ICompilationUnit createXmlTypeWithAccessorOrder() throws CoreException {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ACCESS_ORDER, JAXB.XML_ACCESSOR_ORDER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType").append(CR);
- sb.append("@XmlAccessorOrder(value = XmlAccessOrder.ALPHABETICAL)");
- }
- });
- }
-
- private ICompilationUnit createPackageInfoWithAccessorType() throws CoreException {
- return createTestPackageInfo(
- "@XmlAccessorType(value = XmlAccessType.PROPERTY)",
- JAXB.XML_ACCESS_TYPE, JAXB.XML_ACCESSOR_TYPE);
- }
-
- private void createTestXmlTypeWithFieldAndPublicMemberAccess() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_TYPE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_ATTRIBUTE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_TRANSIENT);
- sb.append(";");
- sb.append(CR);
- sb.append("import java.util.List;");
- sb.append(CR);
- sb.append("@XmlType");
- sb.append(CR);
- sb.append("public class ").append(TYPE_NAME).append(" ");
- sb.append("{").append(CR);
- sb.append(" public int foo;").append(CR);
- sb.append(CR).append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestType.java", sourceWriter);
- }
-
- private void createTestXmlTypeWithPropertyAndPublicMemberAccess() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_TYPE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_ATTRIBUTE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_TRANSIENT);
- sb.append(";");
- sb.append(CR);
- sb.append("import java.util.List;");
- sb.append(CR);
- sb.append("@XmlType");
- sb.append(CR);
- sb.append("public class ").append(TYPE_NAME).append(" ");
- sb.append("{").append(CR);
- sb.append(" public int getFoo() {").append(CR);
- sb.append(" return 1;").append(CR).append(" }").append(CR);
- sb.append(" public void setFoo(int foo) {}").append(CR).append(CR);
- sb.append(CR).append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestType.java", sourceWriter);
- }
-
- private void createTestXmlTypeWithPropertyGetterAndPublicMemberAccess() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_TYPE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_ATTRIBUTE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_TRANSIENT);
- sb.append(";");
- sb.append(CR);
- sb.append("import java.util.List;");
- sb.append(CR);
- sb.append("@XmlType");
- sb.append(CR);
- sb.append("public class ").append(TYPE_NAME).append(" ");
- sb.append("{").append(CR);
- sb.append(" public int getFoo() {").append(CR);
- sb.append(" return 1;").append(CR).append(" }").append(CR);
- sb.append(CR).append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestType.java", sourceWriter);
- }
-
- private void createTestXmlTypeWithPropertyGetterListAndPublicMemberAccess() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_TYPE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_ATTRIBUTE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_TRANSIENT);
- sb.append(";");
- sb.append(CR);
- sb.append("import java.util.List;");
- sb.append(CR);
- sb.append("@XmlType");
- sb.append(CR);
- sb.append("public class ").append(TYPE_NAME).append(" ");
- sb.append("{").append(CR);
- sb.append(" public List<?> getFoo() {").append(CR);
- sb.append(" return 1;").append(CR).append(" }").append(CR);
- sb.append(CR).append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestType.java", sourceWriter);
- }
-
- private void createTestXmlTypeWithPropertySetterAndPublicMemberAccess() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_TYPE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_ATTRIBUTE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JAXB.XML_TRANSIENT);
- sb.append(";");
- sb.append(CR);
- sb.append("import java.util.List;");
- sb.append(CR);
- sb.append("@XmlType");
- sb.append(CR);
- sb.append("public class ").append(TYPE_NAME).append(" ");
- sb.append("{").append(CR);
- sb.append(" public void setFoo(int foo) {}").append(CR).append(CR);
- sb.append(CR).append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestType.java", sourceWriter);
- }
-
- public void testModifyFactoryClass() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(classMapping.getSpecifiedFactoryClass());
- assertEquals(JAXB.XML_TYPE__DEFAULT_FACTORY_CLASS, classMapping.getFactoryClass());
-
- classMapping.setSpecifiedFactoryClass("foo");
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getFactoryClass());
- assertEquals("foo", classMapping.getFactoryClass());
-
- classMapping.setSpecifiedFactoryClass(null);
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertNull(xmlTypeAnnotation.getFactoryClass());
- assertNull(classMapping.getSpecifiedFactoryClass());
- assertEquals(JAXB.XML_TYPE__DEFAULT_FACTORY_CLASS, classMapping.getFactoryClass());
-
- //add another annotation so that the context model does not get blown away
- classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
- resourceType.removeAnnotation(JAXB.XML_TYPE);
-
- //set factoryClass again, this time starting with no XmlType annotation
- classMapping.setSpecifiedFactoryClass("foo");
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getFactoryClass());
- assertEquals("foo", classMapping.getFactoryClass());
- }
-
- public void testUpdateFactoryClass() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(classMapping.getSpecifiedFactoryClass());
- assertEquals(JAXB.XML_TYPE__DEFAULT_FACTORY_CLASS, classMapping.getFactoryClass());
-
- //add a factoryClass member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addXmlTypeTypeMemberValuePair(declaration, JAXB.XML_TYPE__FACTORY_CLASS, "Foo");
- }
- });
- assertEquals("Foo", classMapping.getFactoryClass());
-
- //remove the factoryClass member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaClassMappingTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaClassMappingTests.this.values(xmlTypeAnnotation).remove(0);
- }
- });
- assertNull(classMapping.getSpecifiedFactoryClass());
- assertEquals(JAXB.XML_TYPE__DEFAULT_FACTORY_CLASS, classMapping.getFactoryClass());
- }
-
- public void testModifyFactoryMethod() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(classMapping.getFactoryMethod());
-
- classMapping.setFactoryMethod("foo");
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getFactoryMethod());
- assertEquals("foo", classMapping.getFactoryMethod());
-
- classMapping.setFactoryMethod(null);
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertNull(xmlTypeAnnotation.getFactoryMethod());
- assertNull(classMapping.getFactoryMethod());
-
- //add another annotation so that the context model does not get blown away
- classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
- resourceType.removeAnnotation(JAXB.XML_TYPE);
-
- //set factoryMethod again, this time starting with no XmlType annotation
- classMapping.setFactoryMethod("foo");
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getFactoryMethod());
- assertEquals("foo", classMapping.getFactoryMethod());
- }
-
- public void testUpdateFactoryMethod() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(classMapping.getFactoryMethod());
-
- //add a factoryMethod member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__FACTORY_METHOD, "foo");
- }
- });
- assertEquals("foo", classMapping.getFactoryMethod());
-
- //remove the factoryMethod member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaClassMappingTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaClassMappingTests.this.values(xmlTypeAnnotation).remove(0);
- }
- });
- assertNull(classMapping.getFactoryMethod());
- }
-
- public void testModifySchemaTypeName() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
- String defaultXmlTypeName = Introspector.decapitalize(TYPE_NAME);
-
- assertNull(classMapping.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, classMapping.getQName().getDefaultName());
- assertEquals(defaultXmlTypeName, classMapping.getQName().getName());
-
- classMapping.getQName().setSpecifiedName("foo");
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getName());
- assertEquals("foo", classMapping.getQName().getSpecifiedName());
- assertEquals("foo", classMapping.getQName().getName());
-
- classMapping.getQName().setSpecifiedName(null);
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertNull(xmlTypeAnnotation.getName());
- assertNull(classMapping.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, classMapping.getQName().getName());
-
- //add another annotation so that the context model does not get blown away
- classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
- resourceType.removeAnnotation(JAXB.XML_TYPE);
-
- //set name again, this time starting with no XmlType annotation
- classMapping.getQName().setSpecifiedName("foo");
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getName());
- assertEquals("foo", classMapping.getQName().getSpecifiedName());
- assertEquals("foo", classMapping.getQName().getName());
- }
-
- public void testUpdateSchemaTypeName() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
- String defaultXmlTypeName = Introspector.decapitalize(TYPE_NAME);
-
- assertNull(classMapping.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, classMapping.getQName().getDefaultName());
- assertEquals(defaultXmlTypeName, classMapping.getQName().getName());
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAME, "foo");
- }
- });
- assertEquals("foo", classMapping.getQName().getSpecifiedName());
- assertEquals("foo", classMapping.getQName().getName());
-
- //remove the namespace member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaClassMappingTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaClassMappingTests.this.values(xmlTypeAnnotation).remove(0);
- }
- });
- assertNull(classMapping.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, classMapping.getQName().getName());
- }
-
- public void testModifyNamespace() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(classMapping.getQName().getSpecifiedNamespace());
- assertEquals("", classMapping.getQName().getDefaultNamespace());
- assertEquals("", classMapping.getQName().getNamespace());
-
- classMapping.getQName().setSpecifiedNamespace("foo");
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getNamespace());
- assertEquals("foo", classMapping.getQName().getSpecifiedNamespace());
- assertEquals("foo", classMapping.getQName().getNamespace());
-
- classMapping.getQName().setSpecifiedNamespace(null);
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertNull(xmlTypeAnnotation.getNamespace());
- assertNull(classMapping.getQName().getSpecifiedNamespace());
- assertEquals("", classMapping.getQName().getNamespace());
-
- //add another annotation so that the context model does not get blown away
- classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
- resourceType.removeAnnotation(JAXB.XML_TYPE);
-
- //set namespace again, this time starting with no XmlType annotation
- classMapping.getQName().setSpecifiedNamespace("foo");
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getNamespace());
- assertEquals("foo", classMapping.getQName().getSpecifiedNamespace());
- assertEquals("foo", classMapping.getQName().getNamespace());
- }
-
- public void testUpdateNamespace() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(classMapping.getQName().getSpecifiedNamespace());
- assertEquals("", classMapping.getQName().getDefaultNamespace());
- assertEquals("", classMapping.getQName().getNamespace());
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAMESPACE, "foo");
- }
- });
- assertEquals("foo", classMapping.getQName().getSpecifiedNamespace());
- assertEquals("foo", classMapping.getQName().getNamespace());
-
- //remove the namespace member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaClassMappingTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaClassMappingTests.this.values(xmlTypeAnnotation).remove(0);
- }
- });
- assertNull(classMapping.getQName().getSpecifiedNamespace());
- assertEquals("", classMapping.getQName().getNamespace());
- }
-
- public void testModifyAccessType() throws Exception {
- createXmlTypeWithAccessorType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertEquals(XmlAccessType.PROPERTY, classMapping.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PROPERTY, classMapping.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getDefaultAccessType());
-
- classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
- XmlAccessorTypeAnnotation accessorTypeAnnotation = (XmlAccessorTypeAnnotation) resourceType.getAnnotation(JAXB.XML_ACCESSOR_TYPE);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.FIELD, accessorTypeAnnotation.getValue());
- assertEquals(XmlAccessType.FIELD, classMapping.getAccessType());
-
- classMapping.setSpecifiedAccessType(XmlAccessType.PUBLIC_MEMBER);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.PUBLIC_MEMBER, accessorTypeAnnotation.getValue());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getAccessType());
-
- classMapping.setSpecifiedAccessType(XmlAccessType.NONE);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.NONE, accessorTypeAnnotation.getValue());
- assertEquals(XmlAccessType.NONE, classMapping.getAccessType());
-
- classMapping.setSpecifiedAccessType(null);
- accessorTypeAnnotation = (XmlAccessorTypeAnnotation) resourceType.getAnnotation(JAXB.XML_ACCESSOR_TYPE);
- assertNull(accessorTypeAnnotation.getValue());
- assertNull(classMapping.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getDefaultAccessType());
- }
-
- public void testUpdateAccessType() throws Exception {
- createXmlTypeWithAccessorType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertEquals(XmlAccessType.PROPERTY, classMapping.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PROPERTY, classMapping.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getDefaultAccessType());
-
- //set the accesser type value to FIELD
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__FIELD);
- }
- });
- assertEquals(XmlAccessType.FIELD, classMapping.getAccessType());
-
- //set the accesser type value to PUBLIC_MEMBER
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- }
- });
- assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getAccessType());
-
- //set the accesser type value to NONE
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__NONE);
- }
- });
- assertEquals(XmlAccessType.NONE, classMapping.getAccessType());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ACCESSOR_TYPE);
- }
- });
- assertNull(classMapping.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getDefaultAccessType());
- }
-
- /**
- * If there is a @XmlAccessorType on a class, then it is used.
- * Otherwise, if a @XmlAccessorType exists on one of its super classes, then it is inherited.
- * Otherwise, the @XmlAccessorType on a package is inherited.
- */
- public void testGetDefaultAccessType() throws Exception {
- createClassWithXmlType();
- createTestSubType();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbClass childJaxbClass = (JaxbClass) getContextRoot().getType("test.AnnotationTestTypeChild");
- JaxbClassMapping childClassMapping = childJaxbClass.getMapping();
-
- assertEquals(XmlAccessType.PUBLIC_MEMBER, childClassMapping.getDefaultAccessType());
-
- this.createPackageInfoWithAccessorType();
- assertEquals(XmlAccessType.PROPERTY, childClassMapping.getDefaultAccessType());
-
- classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
- assertEquals(XmlAccessType.FIELD, childClassMapping.getDefaultAccessType());
-
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- classMapping.setSpecifiedAccessType(null);
- assertEquals(XmlAccessType.PROPERTY, childClassMapping.getDefaultAccessType());
- contextPackageInfo.setSpecifiedAccessType(XmlAccessType.FIELD);
- assertEquals(XmlAccessType.FIELD, childClassMapping.getDefaultAccessType());
-
- contextPackageInfo.setSpecifiedAccessType(XmlAccessType.NONE);
- assertEquals(XmlAccessType.NONE, childClassMapping.getDefaultAccessType());
-
- contextPackageInfo.setSpecifiedAccessType(null);
- assertEquals(XmlAccessType.PUBLIC_MEMBER, childClassMapping.getDefaultAccessType());
- }
-
- public void testGetSuperPersistentClass() throws Exception {
- createClassWithXmlType();
- createTestSubType();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbClass childJaxbClass = (JaxbClass) getContextRoot().getType("test.AnnotationTestTypeChild");
- JaxbClassMapping childClassMapping = childJaxbClass.getMapping();
-
- assertEquals(classMapping, childClassMapping.getSuperclass());
-
- //test that the superClass is not null even when it is unannotated
- AnnotatedElement annotatedElement = this.annotatedElement(jaxbClass.getJavaResourceType());
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_TYPE);
- }
- });
- assertEquals(classMapping, childClassMapping.getSuperclass());
- }
-
- public void testModifyAccessOrder() throws Exception {
- createXmlTypeWithAccessorOrder();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertEquals(XmlAccessOrder.ALPHABETICAL, classMapping.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.ALPHABETICAL, classMapping.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getDefaultAccessOrder());
-
- classMapping.setSpecifiedAccessOrder(XmlAccessOrder.UNDEFINED);
- XmlAccessorOrderAnnotation accessorOrderAnnotation = (XmlAccessorOrderAnnotation) resourceType.getAnnotation(JAXB.XML_ACCESSOR_ORDER);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder.UNDEFINED, accessorOrderAnnotation.getValue());
- assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getAccessOrder());
-
- classMapping.setSpecifiedAccessOrder(null);
- accessorOrderAnnotation = (XmlAccessorOrderAnnotation) resourceType.getAnnotation(JAXB.XML_ACCESSOR_ORDER);
- assertNull(accessorOrderAnnotation.getValue());
- assertNull(classMapping.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getDefaultAccessOrder());
- }
-
- public void testUpdateAccessOrder() throws Exception {
- createXmlTypeWithAccessorOrder();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertEquals(XmlAccessOrder.ALPHABETICAL, classMapping.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.ALPHABETICAL, classMapping.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getDefaultAccessOrder());
-
- //set the access order value to UNDEFINED
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_ORDER, JAXB.XML_ACCESS_ORDER__UNDEFINED);
- }
- });
- assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getAccessOrder());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ACCESSOR_ORDER);
- }
- });
- assertNull(classMapping.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getDefaultAccessOrder());
- }
-
- public void testGetPropOrder() throws Exception {
- this.createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- ListIterator<String> props = classMapping.getPropOrder().iterator();
- assertFalse(props.hasNext());
-
- //add 2 prop orders
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addProp(declaration, 0, "bar");
- GenericJavaClassMappingTests.this.addProp(declaration, 1, "foo");
- }
- });
-
- props = classMapping.getPropOrder().iterator();
- assertEquals("bar", props.next());
- assertEquals("foo", props.next());
- assertFalse(props.hasNext());
- }
-
- protected void addProp(ModifiedDeclaration declaration, int index, String prop) {
- this.addArrayElement(declaration, JAXB.XML_TYPE, index, JAXB.XML_TYPE__PROP_ORDER, this.newStringLiteral(declaration.getAst(), prop));
- }
-
- public void testGetPropOrderSize() throws Exception {
- this.createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertEquals(0, classMapping.getPropOrderSize());
-
- //add 2 prop orders
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addProp(declaration, 0, "bar");
- GenericJavaClassMappingTests.this.addProp(declaration, 1, "foo");
- }
- });
- assertEquals(2, classMapping.getPropOrderSize());
- }
-
- public void testAddProp() throws Exception {
- this.createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- classMapping.addProp(0, "bar");
- classMapping.addProp(0, "foo");
- classMapping.addProp(0, "baz");
-
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- ListIterator<String> props = xmlTypeAnnotation.getPropOrder().iterator();
-
- assertEquals("baz", props.next());
- assertEquals("foo", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
- }
-
- public void testAddProp2() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- classMapping.addProp(0, "bar");
- classMapping.addProp(1, "foo");
- classMapping.addProp(0, "baz");
-
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- ListIterator<String> props = xmlTypeAnnotation.getPropOrder().iterator();
-
- assertEquals("baz", props.next());
- assertEquals("bar", props.next());
- assertEquals("foo", props.next());
- assertFalse(props.hasNext());
- }
-
- public void testRemoveProp() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- classMapping.addProp(0, "bar");
- classMapping.addProp(1, "foo");
- classMapping.addProp(2, "baz");
-
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
-
- classMapping.removeProp(1);
-
- ListIterator<String> resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
- assertEquals("bar", resourceProps.next());
- assertEquals("baz", resourceProps.next());
- assertFalse(resourceProps.hasNext());
-
- classMapping.removeProp(1);
- resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
- assertEquals("bar", resourceProps.next());
- assertFalse(resourceProps.hasNext());
-
- classMapping.removeProp(0);
- resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
- assertFalse(resourceProps.hasNext());
- }
-
- public void testMoveProp() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- classMapping.addProp(0, "bar");
- classMapping.addProp(1, "foo");
- classMapping.addProp(2, "baz");
-
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
-
- assertEquals(3, xmlTypeAnnotation.getPropOrderSize());
-
- classMapping.moveProp(2, 0);
- ListIterator<String> props = classMapping.getPropOrder().iterator();
- assertEquals("foo", props.next());
- assertEquals("baz", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
-
- ListIterator<String> resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
- assertEquals("foo", resourceProps.next());
- assertEquals("baz", resourceProps.next());
- assertEquals("bar", resourceProps.next());
-
- classMapping.moveProp(0, 1);
- props = classMapping.getPropOrder().iterator();
- assertEquals("baz", props.next());
- assertEquals("foo", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
-
- resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
- assertEquals("baz", resourceProps.next());
- assertEquals("foo", resourceProps.next());
- assertEquals("bar", resourceProps.next());
- }
-
- public void testSyncProps() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- ListIterator<String> props = classMapping.getPropOrder().iterator();
- assertFalse(props.hasNext());
-
- //add 3 prop orders
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addProp(declaration, 0, "bar");
- GenericJavaClassMappingTests.this.addProp(declaration, 1, "foo");
- GenericJavaClassMappingTests.this.addProp(declaration, 2, "baz");
- }
- });
-
- props = classMapping.getPropOrder().iterator();
- assertTrue(props.hasNext());
- assertEquals("bar", props.next());
- assertEquals("foo", props.next());
- assertEquals("baz", props.next());
- assertFalse(props.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.moveProp(declaration, 2, 0);
- }
- });
-
- props = classMapping.getPropOrder().iterator();
- assertTrue(props.hasNext());
- assertEquals("foo", props.next());
- assertEquals("baz", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.moveProp(declaration, 0, 1);
- }
- });
-
- props = classMapping.getPropOrder().iterator();
- assertTrue(props.hasNext());
- assertEquals("baz", props.next());
- assertEquals("foo", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeProp(declaration, 1);
- }
- });
-
- props = classMapping.getPropOrder().iterator();
- assertTrue(props.hasNext());
- assertEquals("baz", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeProp(declaration, 1);
- }
- });
-
- props = classMapping.getPropOrder().iterator();
- assertTrue(props.hasNext());
- assertEquals("baz", props.next());
- assertFalse(props.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeProp(declaration, 0);
- }
- });
-
- props = classMapping.getPropOrder().iterator();
- assertFalse(props.hasNext());
- }
-
- protected void addXmlTypeMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlTypeAnnotation(declaration), name, value);
- }
-
- protected void addXmlTypeTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlTypeAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected Annotation getXmlTypeAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_TYPE);
- }
-
- protected void moveProp(ModifiedDeclaration declaration, int targetIndex, int sourceIndex) {
- this.moveArrayElement((NormalAnnotation) getXmlTypeAnnotation(declaration), JAXB.XML_TYPE__PROP_ORDER, targetIndex, sourceIndex);
- }
-
- protected void removeProp(ModifiedDeclaration declaration, int index) {
- this.removeArrayElement((NormalAnnotation) getXmlTypeAnnotation(declaration), JAXB.XML_TYPE__PROP_ORDER, index);
- }
-
- public void testModifyXmlRootElement() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(classMapping.getXmlRootElement());
-
- classMapping.addXmlRootElement().getQName().setSpecifiedName("foo");
- XmlRootElementAnnotation xmlRootElementAnnotation = (XmlRootElementAnnotation) resourceType.getAnnotation(JAXB.XML_ROOT_ELEMENT);
- assertEquals("foo", xmlRootElementAnnotation.getName());
- assertEquals("foo", classMapping.getXmlRootElement().getQName().getName());
-
- classMapping.removeXmlRootElement();
- xmlRootElementAnnotation = (XmlRootElementAnnotation) resourceType.getAnnotation(JAXB.XML_ROOT_ELEMENT);
- assertNull(xmlRootElementAnnotation);
- assertNull(classMapping.getXmlRootElement());
- }
-
- public void testUpdateXmlRootElement() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(classMapping.getXmlRootElement());
-
- //add a XmlRootElement annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation annotation = GenericJavaClassMappingTests.this.addNormalAnnotation(declaration.getDeclaration(), JAXB.XML_ROOT_ELEMENT);
- GenericJavaClassMappingTests.this.addMemberValuePair(annotation, JAXB.XML_ROOT_ELEMENT__NAME, "foo");
- }
- });
- assertEquals("foo", classMapping.getXmlRootElement().getQName().getName());
-
- //remove the XmlRootElement annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ROOT_ELEMENT);
- }
- });
- assertNull(classMapping.getXmlRootElement());
- }
-
- public void testUpdateFieldAttributes() throws Exception {
- this.createTestXmlTypeWithFieldAndPublicMemberAccess();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
-
- //public int foo;
- publicFieldTest(classMapping);
-
- //public transient int foo;
- publicTransientFieldTest(classMapping);
-
- //public static int foo;
- publicStaticFieldTest(classMapping);
-
- //public final int foo;
- publicFinalFieldTest(classMapping);
-
- //public static final int foo;
- publicStaticFinalFieldTest(classMapping);
-
- //private int foo;
- privateFieldTest(classMapping);
-
- // private transient int foo;
- privateTransientFieldTest(classMapping);
-
- // @XmlAttribute
- // private static int foo; //persistent
- privateStaticFieldTest(classMapping);
-
- // @XmlAttribute
- // private static final int foo; //persistent
- privateStaticFinalFieldTest(classMapping);
- }
-
- protected void publicFieldTest(JaxbClassMapping classMapping) {
- //public int foo; PUBLIC_MEMBER access - persistent
- assertEquals(1, classMapping.getAttributesSize());
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //public int foo; //PROPERTY access - not persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public int foo; //FIELD access - persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //public int foo; //NONE access - not persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public int foo; PUBLIC_MEMBER access - persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //add @XmlTransient annotation and test each access type
- JavaResourceField resourceField = (JavaResourceField) classMapping.getAttributes().iterator().next().getJavaResourceAttribute();
- AnnotatedElement annotatedElement = this.annotatedElement(resourceField);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TRANSIENT);
- }
- });
- //@XmlTransient
- //public int foo; //PROPERTY access - not "persistent", but comes in to our context model because it is "mapped"
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlTransient
- //public int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlTransient
- //public int foo; //NONE access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlTransient
- //public int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_TRANSIENT);
- }
- });
- }
-
- protected void publicTransientFieldTest(JaxbClassMapping classMapping) {
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
-
- //public transient int foo; PUBLIC_MEMBER access - not persistent
- this.addModifiers(resourceField, ModifierKeyword.TRANSIENT_KEYWORD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public transient int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public transient int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public transient int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public transient int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, classMapping.getAttributesSize());
-
- this.removeModifiers(resourceField, ModifierKeyword.TRANSIENT_KEYWORD);
- }
-
- protected void publicStaticFieldTest(JaxbClassMapping classMapping) {
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
-
- //public static int foo; PUBLIC_MEMBER access - not persistent
- this.addModifiers(resourceField, ModifierKeyword.STATIC_KEYWORD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public static int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public static int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public static int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public static int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, classMapping.getAttributesSize());
-
- this.removeModifiers(resourceField, ModifierKeyword.STATIC_KEYWORD);
- }
-
- protected void publicFinalFieldTest(JaxbClassMapping classMapping) {
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
-
- //public final int foo; PUBLIC_MEMBER access - persistent
- this.addModifiers(resourceField, ModifierKeyword.FINAL_KEYWORD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //public final int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public final int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //public final int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public final int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- this.removeModifiers(resourceField, ModifierKeyword.FINAL_KEYWORD);
- }
-
- protected void publicStaticFinalFieldTest(JaxbClassMapping classMapping) {
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
-
- //public static final int foo; PUBLIC_MEMBER access - not persistent
- this.addModifiers(resourceField, ModifierKeyword.STATIC_KEYWORD, ModifierKeyword.FINAL_KEYWORD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public static final int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public static final int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public static final int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public static final int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, classMapping.getAttributesSize());
-
- this.removeModifiers(resourceField, ModifierKeyword.STATIC_KEYWORD, ModifierKeyword.FINAL_KEYWORD);
- }
-
- protected void privateFieldTest(JaxbClassMapping classMapping) {
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
- removeModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
- addModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD);
-
- //private int foo; PUBLIC_MEMBER access - not persistent
- assertEquals(0, classMapping.getAttributesSize());
-
- //private int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //private int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, classMapping.getAttributesSize());
-
-
- //add @XmlAttribute annotation and test each access type
- AnnotatedElement annotatedElement = this.annotatedElement(resourceField);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
- }
- });
- //@XmlAttribute
- //private int foo; //PROPERTY access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private int foo; //NONE access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
- }
- });
- removeModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD);
- addModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
- }
-
- protected void privateTransientFieldTest(JaxbClassMapping classMapping) {
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
- removeModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
- addModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD, ModifierKeyword.TRANSIENT_KEYWORD);
-
- //private transient int foo; PUBLIC_MEMBER access - not persistent
- assertEquals(0, classMapping.getAttributesSize());
-
- //private transient int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private transient int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private transient int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private transient int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, classMapping.getAttributesSize());
-
-
- //add @XmlAttribute annotation and test each access type
- AnnotatedElement annotatedElement = this.annotatedElement(resourceField);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
- }
- });
- //@XmlAttribute
- //private transient int foo; //PROPERTY access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private transient int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private transient int foo; //NONE access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private transient int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
- }
- });
- removeModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD, ModifierKeyword.TRANSIENT_KEYWORD);
- addModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
- }
-
- protected void privateStaticFieldTest(JaxbClassMapping classMapping) {
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
- removeModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
- addModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD, ModifierKeyword.STATIC_KEYWORD);
-
- //private static int foo; PUBLIC_MEMBER access - not persistent
- assertEquals(0, classMapping.getAttributesSize());
-
- //private static int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private static int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private static int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private static int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, classMapping.getAttributesSize());
-
-
- //add @XmlAttribute annotation and test each access type
- AnnotatedElement annotatedElement = this.annotatedElement(resourceField);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
- }
- });
- //@XmlAttribute
- //private static int foo; //PROPERTY access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private static int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private static int foo; //NONE access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private static int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
- }
- });
- removeModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD, ModifierKeyword.STATIC_KEYWORD);
- addModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
- }
-
- protected void privateStaticFinalFieldTest(JaxbClassMapping classMapping) {
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
- removeModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
- addModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD, ModifierKeyword.STATIC_KEYWORD, ModifierKeyword.FINAL_KEYWORD);
-
- //private static final int foo; PUBLIC_MEMBER access - not persistent
- assertEquals(0, classMapping.getAttributesSize());
-
- //private static final int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private static final int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private static final int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private static final int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, classMapping.getAttributesSize());
-
-
- //add @XmlAttribute annotation and test each access type
- AnnotatedElement annotatedElement = this.annotatedElement(resourceField);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
- }
- });
- //@XmlAttribute
- //private static final int foo; //PROPERTY access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private static final int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private static final int foo; //NONE access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private static final int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
- }
- });
- }
-
- public void testUpdatePropertyAttributes() throws Exception {
- createTestXmlTypeWithPropertyAndPublicMemberAccess();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
-
- //public int getFoo();, public void setFoo(int);
- publicGetterSetterTest(classMapping);
-
- //public static int getFoo();, public static void setFoo(int);
- publicStaticGetterSetterTest(classMapping);
-
- //private int getFoo();, private void setFoo(int);
- privateGetterSetterTest(classMapping);
- }
-
- public void testUpdateGetterPropertyAttributes() throws Exception {
- createTestXmlTypeWithPropertyGetterAndPublicMemberAccess();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
-
- //public int getFoo(); PUBLIC_MEMBER access - not persistent
- assertEquals(0, classMapping.getAttributesSize());
-
- //public int getFoo(); PROPERTY access - not persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public int getFoo(); FIELD access - not persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public int getFoo(); NONE access - not persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public int getFoo(); PUBLIC_MEMBER access - not persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, classMapping.getAttributesSize());
-
- //add @XmlAttribute annotation and test each access type
- JavaResourceMethod resourceMethod = classMapping.getJaxbType().getJavaResourceType().getMethods().iterator().next();
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
- }
- });
- //@XmlAttribute
- //public int getFoo(); PROPERTY access - persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- assertEquals(1, classMapping.getAttributesSize());
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public int getFoo(); FIELD access - persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public int getFoo(); NONE access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public int getFoo(); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
- }
- });
- }
-
- public void testUpdateSetterPropertyAttributes() throws Exception {
- createTestXmlTypeWithPropertySetterAndPublicMemberAccess();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
-
- //public void setFoo(int foo); PUBLIC_MEMBER access - not persistent
- assertEquals(0, classMapping.getAttributesSize());
-
- //public void setFoo(int foo); PROPERTY access - persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public void setFoo(int foo); FIELD access - not persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public void setFoo(int foo); NONE access - not persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public void setFoo(int foo); PUBLIC_MEMBER access - persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, classMapping.getAttributesSize());
-
- //add @XmlAttribute annotation and test each access type
- JavaResourceMethod resourceMethod = classMapping.getJaxbType().getJavaResourceType().getMethods().iterator().next();
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
- }
- });
- //@XmlAttribute
- //public void setFoo(int foo);; PROPERTY access - persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- assertEquals(1, classMapping.getAttributesSize());
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public void setFoo(int foo); FIELD access - persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public void setFoo(int foo); NONE access - persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public void setFoo(int foo); PUBLIC_MEMBER access - persistent
- setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
- }
- });
- }
-
- public void testUpdateGetterListPropertyAttributes() throws Exception {
- this.createTestXmlTypeWithPropertyGetterListAndPublicMemberAccess();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
-
- //public List<?> getFoo(); PUBLIC_MEMBER access - persistent
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- assertEquals(1, classMapping.getAttributesSize());
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //public List<?> getFoo(); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- attributes = classMapping.getAttributes().iterator();
- assertEquals(1, classMapping.getAttributesSize());
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //public List<?> getFoo(); FIELD access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public List<?> getFoo(); NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public List<?> getFoo(); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- attributes = classMapping.getAttributes().iterator();
- assertEquals(1, classMapping.getAttributesSize());
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //add @XmlAttribute annotation and test each access type
- JavaResourceMethod resourceMethod = classMapping.getJaxbType().getJavaResourceType().getMethods().iterator().next();
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
- }
- });
- //@XmlAttribute
- //public List<?> getFoo(); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- attributes = classMapping.getAttributes().iterator();
- assertEquals(1, classMapping.getAttributesSize());
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public List<?> getFoo(); FIELD access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public List<?> getFoo(); NONE access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public List<?> getFoo(); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
- }
- });
- }
-
- protected void publicGetterSetterTest(JaxbClassMapping classMapping) {
- //public int getFoo();, public void setFoo(int); PUBLIC_MEMBER access - persistent
- assertEquals(1, classMapping.getAttributesSize());
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //public int getFoo();, public void setFoo(int); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //public int getFoo();, public void setFoo(int); FIELD access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public int getFoo();, public void setFoo(int); NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public int getFoo();, public void setFoo(int); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
-
- //add @XmlAttribute annotation and test each access type
- JavaResourceMethod resourceMethod = (JavaResourceMethod) classMapping.getAttributes().iterator().next().getJavaResourceAttribute();
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
- }
- });
- //@XmlAttribute
- //public int getFoo();, public void setFoo(int); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public int getFoo();, public void setFoo(int); FIELD access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public int getFoo();, public void setFoo(int); NONE access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public int getFoo();, public void setFoo(int); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
- }
- });
- }
-
- protected void publicStaticGetterSetterTest(JaxbClassMapping classMapping) {
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- PropertyAccessor propertyAccessor = (PropertyAccessor) ReflectionTools.getFieldValue(attributes.next(), "accessor");
- JavaResourceMethod resourceGetter = propertyAccessor.getResourceGetterMethod();
- JavaResourceMethod resourceSetter = propertyAccessor.getResourceSetterMethod();
-
- //public static int getFoo();, public static void setFoo(int); PUBLIC_MEMBER access - not persistent
- this.addModifiers(resourceGetter, ModifierKeyword.STATIC_KEYWORD);
- this.addModifiers(resourceSetter, ModifierKeyword.STATIC_KEYWORD);
- assertEquals(0, classMapping.getAttributesSize());
-
-
- //public static int getFoo();, public static void setFoo(int); PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public static int getFoo();, public static void setFoo(int); FIELD access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public static int getFoo();, public static void setFoo(int); NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //public static int getFoo();, public static void setFoo(int); PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, classMapping.getAttributesSize());
-
-
- //add @XmlAttribute annotation and test each access type
- AnnotatedElement annotatedElement = this.annotatedElement(resourceGetter);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
- }
- });
- //@XmlAttribute
- //public static int getFoo();, public static void setFoo(int); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public static int getFoo();, public static void setFoo(int); FIELD access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public static int getFoo();, public static void setFoo(int); NONE access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //public static int getFoo();, public static void setFoo(int); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
- }
- });
- this.removeModifiers(resourceGetter, ModifierKeyword.STATIC_KEYWORD);
- this.removeModifiers(resourceSetter, ModifierKeyword.STATIC_KEYWORD);
- }
-
- protected void privateGetterSetterTest(JaxbClassMapping classMapping) {
- Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
- PropertyAccessor propertyAccessor = (PropertyAccessor) ReflectionTools.getFieldValue(attributes.next(), "accessor");
- JavaResourceMethod resourceGetter = propertyAccessor.getResourceGetterMethod();
- JavaResourceMethod resourceSetter = propertyAccessor.getResourceSetterMethod();
-
- //private int getFoo();, private void setFoo(int); PUBLIC_MEMBER access - not persistent
- this.removeModifiers(resourceGetter, ModifierKeyword.PUBLIC_KEYWORD);
- this.removeModifiers(resourceSetter, ModifierKeyword.PUBLIC_KEYWORD);
- this.addModifiers(resourceGetter, ModifierKeyword.PRIVATE_KEYWORD);
- this.addModifiers(resourceSetter, ModifierKeyword.PRIVATE_KEYWORD);
- assertEquals(0, classMapping.getAttributesSize());
-
-
- //private int getFoo();, private void setFoo(int); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //private int getFoo();, private void setFoo(int); FIELD access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private int getFoo();, private void setFoo(int); NONE access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, classMapping.getAttributesSize());
-
- //private int getFoo();, private void setFoo(int); PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, classMapping.getAttributesSize());
-
-
- //add @XmlAttribute annotation and test each access type
- AnnotatedElement annotatedElement = this.annotatedElement(resourceGetter);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
- }
- });
- //@XmlAttribute
- //private int getFoo();, private void setFoo(int); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private int getFoo();, private void setFoo(int); FIELD access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private int getFoo();, private void setFoo(int); NONE access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- //@XmlAttribute
- //private int getFoo();, private void setFoo(int); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, classMapping.getAttributesSize());
- attributes = classMapping.getAttributes().iterator();
- assertEquals("foo", attributes.next().getName());
- assertFalse(attributes.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
- }
- });
- this.removeModifiers(resourceGetter, ModifierKeyword.PRIVATE_KEYWORD);
- this.removeModifiers(resourceSetter, ModifierKeyword.PRIVATE_KEYWORD);
- this.addModifiers(resourceGetter, ModifierKeyword.PUBLIC_KEYWORD);
- this.addModifiers(resourceSetter, ModifierKeyword.PUBLIC_KEYWORD);
- }
-
- public void testModifyXmlSeeAlso() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- XmlSeeAlsoAnnotation annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNull(classMapping.getXmlSeeAlso());
- assertNull(annotation);
-
- classMapping.addXmlSeeAlso();
- annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNotNull(classMapping.getXmlSeeAlso());
- assertNotNull(annotation);
-
- classMapping.removeXmlSeeAlso();
- annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNull(classMapping.getXmlSeeAlso());
- assertNull(annotation);
- }
-
- public void testUpdateXmlSeeAlso() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- XmlSeeAlsoAnnotation annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNull(classMapping.getXmlSeeAlso());
- assertNull(annotation);
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_SEE_ALSO);
- }
- });
- annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNotNull(classMapping.getXmlSeeAlso());
- assertNotNull(annotation);
-
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(
- ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_SEE_ALSO);
- }
- });
- annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNull(classMapping.getXmlSeeAlso());
- assertNull(annotation);
- }
-
- protected void addModifiers(JavaResourceMember resourceMember, final ModifierKeyword... modifiers) {
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMember);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.addModifiers((BodyDeclaration) declaration.getDeclaration(), modifiers);
- }
- });
- }
-
- protected void removeModifiers(JavaResourceMember resourceMember, final ModifierKeyword... modifiers) {
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMember);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.removeModifiers((BodyDeclaration) declaration.getDeclaration(), modifiers);
- }
- });
- }
-
- protected void addModifiers(BodyDeclaration bodyDeclaration, ModifierKeyword... modifiers) {
- for (ModifierKeyword modifier : modifiers) {
- this.modifiers(bodyDeclaration).add(bodyDeclaration.getAST().newModifier(modifier));
- }
- }
-
- protected void removeModifiers(BodyDeclaration bodyDeclaration, ModifierKeyword... modifierKeywords) {
- for (ModifierKeyword modifierKeyWord : modifierKeywords) {
- for (Iterator<IExtendedModifier> stream = this.modifiers(bodyDeclaration).iterator(); stream.hasNext();) {
- IExtendedModifier modifier = stream.next();
- if (modifier.isModifier()) {
- if (((Modifier) modifier).getKeyword() == modifierKeyWord) {
- stream.remove();
- break;
- }
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- protected List<IExtendedModifier> modifiers(BodyDeclaration bodyDeclaration) {
- return bodyDeclaration.modifiers();
- }
-
- protected void setAccessTypeInJavaSource(JaxbClassMapping classMapping, final String accessType) {
- JavaResourceType resourceClass = classMapping.getJaxbType().getJavaResourceType();
- AnnotatedElement annotatedElement = this.annotatedElement(resourceClass);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaClassMappingTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, accessType);
- }
- });
- }
-
-} \ No newline at end of file
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaElementFactoryMethodTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaElementFactoryMethodTests.java
deleted file mode 100644
index e6e8f7640b..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaElementFactoryMethodTests.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
-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.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.core.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod;
-import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementDeclAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaElementFactoryMethodTests
- extends JaxbContextModelTestCase {
-
- public GenericJavaElementFactoryMethodTests(String name) {
- super(name);
- }
-
- protected ICompilationUnit createClassWithXmlRegistryAndCreateMethods() throws Exception {
- return this.createTestType(PACKAGE_NAME, "ObjectFactory.java", "ObjectFactory", new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_REGISTRY, JAXB.XML_ELEMENT_DECL, "javax.xml.bind.JAXBElement");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlRegistry");
- }
-
- @Override
- public void appendGetNameMethodAnnotationTo(StringBuilder sb) {
- sb.append("@XmlElementDecl").append(CR);
- sb.append(" JAXBElement<AnnotationTestType> createFoo(AnnotationTestType value) {return null}").append(CR);
- sb.append(CR);
- sb.append(" @XmlElementDecl(name=\"bar\")").append(CR);
- sb.append(" JAXBElement createBar(Object value) {return null}").append(CR);
- sb.append(CR);
- }
- });
- }
-
- public void testModifyElementName() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertNull(elementFactoryMethod.getQName().getName());
-
- elementFactoryMethod.getQName().setSpecifiedName("bar");
- XmlElementDeclAnnotation elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertEquals("bar", elementDeclAnnotation.getName());
- assertEquals("bar", elementFactoryMethod.getQName().getName());
-
- //verify the xml element decl annotation is not removed when the element name is set to null
- elementFactoryMethod.getQName().setSpecifiedName(null);
- elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertNull(elementDeclAnnotation.getName());
- assertNull(elementFactoryMethod.getQName().getName());
- }
-
- public void testUpdateElementName() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertNull(elementFactoryMethod.getQName().getName());
-
- //add a name member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.addXmlElementDeclMemberValuePair(declaration, JAXB.XML_ELEMENT_DECL__NAME, "foo");
- }
- });
- assertEquals("foo", elementFactoryMethod.getQName().getName());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
- }
- });
- assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
- }
-
- public void testModifyDefaultValue() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertNull(elementFactoryMethod.getDefaultValue());
-
- elementFactoryMethod.setDefaultValue("bar");
- XmlElementDeclAnnotation elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertEquals("bar", elementDeclAnnotation.getDefaultValue());
- assertEquals("bar", elementFactoryMethod.getDefaultValue());
-
- //verify the xml element decl annotation is not removed when the element name is set to null
- elementFactoryMethod.setDefaultValue(null);
- elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertNull(elementDeclAnnotation.getDefaultValue());
- assertNull(elementFactoryMethod.getDefaultValue());
- }
-
- public void testUpdateDefaultValue() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertNull(elementFactoryMethod.getDefaultValue());
-
- //add a name member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.addXmlElementDeclMemberValuePair(declaration, JAXB.XML_ELEMENT_DECL__DEFAULT_VALUE, "foo");
- }
- });
- assertEquals("foo", elementFactoryMethod.getDefaultValue());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
- }
- });
- assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
- }
-
- public void testModifyScope() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertNull(elementFactoryMethod.getScope());
- assertTrue(elementFactoryMethod.isGlobalScope());
-
- elementFactoryMethod.setScope("Bar");
- XmlElementDeclAnnotation elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertEquals("Bar", elementDeclAnnotation.getScope());
- assertEquals("Bar", elementFactoryMethod.getScope());
- assertFalse(elementFactoryMethod.isGlobalScope());
-
- elementFactoryMethod.setScope(JaxbElementFactoryMethod.DEFAULT_SCOPE_CLASS_NAME);
- elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertEquals(JaxbElementFactoryMethod.DEFAULT_SCOPE_CLASS_NAME, elementDeclAnnotation.getScope());
- assertEquals(JaxbElementFactoryMethod.DEFAULT_SCOPE_CLASS_NAME, elementFactoryMethod.getScope());
- assertTrue(elementFactoryMethod.isGlobalScope());
-
- //verify the xml element decl annotation is not removed when the element name is set to null
- elementFactoryMethod.setScope(null);
- elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertNull(elementDeclAnnotation.getScope());
- assertNull(elementFactoryMethod.getScope());
- }
-
- public void testUpdateScope() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertNull(elementFactoryMethod.getScope());
- assertTrue(elementFactoryMethod.isGlobalScope());
-
- //add a name member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.addXmlElementDeclTypeMemberValuePair(declaration, JAXB.XML_ELEMENT_DECL__SCOPE, "Foo");
- }
- });
- assertEquals("Foo", elementFactoryMethod.getScope());
- assertFalse(elementFactoryMethod.isGlobalScope());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
- }
- });
- assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
- }
-
- public void testModifySubstitutionHeadName() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertNull(elementFactoryMethod.getSubstitutionHeadQName().getName());
-
- elementFactoryMethod.getSubstitutionHeadQName().setSpecifiedName("bar");
- XmlElementDeclAnnotation elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertEquals("bar", elementDeclAnnotation.getSubstitutionHeadName());
- assertEquals("bar", elementFactoryMethod.getSubstitutionHeadQName().getName());
-
- //verify the xml element decl annotation is not removed when the element name is set to null
- elementFactoryMethod.getSubstitutionHeadQName().setSpecifiedName(null);
- elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertNull(elementDeclAnnotation.getSubstitutionHeadName());
- assertNull(elementFactoryMethod.getSubstitutionHeadQName().getName());
- }
-
- public void testUpdateSubstitutionHeadName() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertNull(elementFactoryMethod.getSubstitutionHeadQName().getName());
-
- //add a name member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.addXmlElementDeclMemberValuePair(declaration, JAXB.XML_ELEMENT_DECL__SUBSTITUTION_HEAD_NAME, "foo");
- }
- });
- assertEquals("foo", elementFactoryMethod.getSubstitutionHeadQName().getName());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
- }
- });
- assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
- }
-
- public void testModifySubstitutionHeadNamespace() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertEquals("", elementFactoryMethod.getSubstitutionHeadQName().getNamespace());
-
- elementFactoryMethod.getSubstitutionHeadQName().setSpecifiedNamespace("bar");
- XmlElementDeclAnnotation elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertEquals("bar", elementDeclAnnotation.getSubstitutionHeadNamespace());
- assertEquals("bar", elementFactoryMethod.getSubstitutionHeadQName().getNamespace());
-
- //verify the xml element decl annotation is not removed when the element name is set to null
- elementFactoryMethod.getSubstitutionHeadQName().setSpecifiedNamespace(null);
- elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertNull(elementDeclAnnotation.getSubstitutionHeadNamespace());
- assertEquals("", elementFactoryMethod.getSubstitutionHeadQName().getNamespace());
- }
-
- public void testUpdateSubstitutionHeadNamespace() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertEquals("", elementFactoryMethod.getSubstitutionHeadQName().getNamespace());
-
- //add a name member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.addXmlElementDeclMemberValuePair(declaration, JAXB.XML_ELEMENT_DECL__SUBSTITUTION_HEAD_NAMESPACE, "foo");
- }
- });
- assertEquals("foo", elementFactoryMethod.getSubstitutionHeadQName().getNamespace());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
- }
- });
- assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
- }
-
- public void testModifyNamespace() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertEquals("", elementFactoryMethod.getQName().getNamespace());
-
- elementFactoryMethod.getQName().setSpecifiedNamespace("bar");
- XmlElementDeclAnnotation elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertEquals("bar", elementDeclAnnotation.getNamespace());
- assertEquals("bar", elementFactoryMethod.getQName().getNamespace());
-
- //verify the xml element decl annotation is not removed when the element name is set to null
- elementFactoryMethod.getQName().setSpecifiedNamespace(null);
- elementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
- assertNull(elementDeclAnnotation.getNamespace());
- assertEquals("", elementFactoryMethod.getQName().getNamespace());
- }
-
- public void testUpdateNamespace() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
-
- assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
- assertEquals("", elementFactoryMethod.getQName().getNamespace());
-
- //add a name member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.addXmlElementDeclMemberValuePair(declaration, JAXB.XML_ELEMENT_DECL__NAMESPACE, "foo");
- }
- });
- assertEquals("foo", elementFactoryMethod.getQName().getNamespace());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
- }
- });
- assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
- }
-
- protected void addXmlElementDeclMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlElementDeclAnnotation(declaration), name, value);
- }
-
- protected Annotation getXmlElementDeclAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_ELEMENT_DECL);
- }
-
- protected void removeXmlElementDeclAnnotation(ModifiedDeclaration declaration) {
- this.removeAnnotation(declaration, JAXB.XML_ELEMENT_DECL);
- }
-
- protected void addXmlElementDeclTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlElementDeclAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
-} \ No newline at end of file
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumConstantTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumConstantTests.java
deleted file mode 100644
index 59b975eeec..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumConstantTests.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnumConstant;
-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.context.JaxbEnum;
-import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
-import org.eclipse.jpt.jaxb.core.context.JaxbEnumMapping;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumValueAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaEnumConstantTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaEnumConstantTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createEnumWithXmlEnum() throws Exception {
- return createTestEnum(new DefaultEnumAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE);
- }
- @Override
- public void appendEnumAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType").append(CR);
- }
- });
- }
-
- public void testUpdateName() throws Exception {
- createEnumWithXmlEnum();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JaxbEnumConstant contextEnumConstant = CollectionTools.get(enumMapping.getEnumConstants(), 1);
- JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
-
- assertEquals("MONDAY", contextEnumConstant.getName());
-
-
- //add a factoryClass member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaEnumConstantTests.this.changeEnumConstantName((EnumDeclaration) declaration.getDeclaration(), "MONDAY", "MONDAY2");
- }
- });
- contextEnumConstant = CollectionTools.get(enumMapping.getEnumConstants(), 1);
- assertEquals(2, enumMapping.getEnumConstantsSize());
- assertEquals("MONDAY2", contextEnumConstant.getName());
- }
-
- public void testModifyValue() throws Exception {
- createEnumWithXmlEnum();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JaxbEnumConstant contextEnumConstant = CollectionTools.get(enumMapping.getEnumConstants(), 1);
- JavaResourceEnumConstant resourceEnumConstant = contextEnumConstant.getResourceEnumConstant();
-
- assertEquals("MONDAY", contextEnumConstant.getDefaultValue());
- assertEquals("MONDAY", contextEnumConstant.getValue());
- assertNull(contextEnumConstant.getSpecifiedValue());
-
- contextEnumConstant.setSpecifiedValue("foo");
- XmlEnumValueAnnotation enumValueAnnotation = (XmlEnumValueAnnotation) resourceEnumConstant.getAnnotation(JAXB.XML_ENUM_VALUE);
- assertEquals("foo", enumValueAnnotation.getValue());
- assertEquals("MONDAY", contextEnumConstant.getDefaultValue());
- assertEquals("foo", contextEnumConstant.getValue());
- assertEquals("foo", contextEnumConstant.getSpecifiedValue());
-
- contextEnumConstant.setSpecifiedValue(null);
- enumValueAnnotation = (XmlEnumValueAnnotation) resourceEnumConstant.getAnnotation(JAXB.XML_ENUM_VALUE);
- assertNull(enumValueAnnotation.getValue());
- assertEquals("MONDAY", contextEnumConstant.getDefaultValue());
- assertEquals("MONDAY", contextEnumConstant.getValue());
- assertNull(contextEnumConstant.getSpecifiedValue());
- }
-
- public void testUpdateValue() throws Exception {
- createEnumWithXmlEnum();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JaxbEnumConstant contextEnumConstant = CollectionTools.get(enumMapping.getEnumConstants(), 1);
- JavaResourceEnumConstant resourceEnumConstant = contextEnumConstant.getResourceEnumConstant();
-
- assertEquals("MONDAY", contextEnumConstant.getDefaultValue());
- assertEquals("MONDAY", contextEnumConstant.getValue());
- assertNull(contextEnumConstant.getSpecifiedValue());
-
- //add an XmlEnumValue annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnumConstant);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation enumValueAnnotation = GenericJavaEnumConstantTests.this.addNormalAnnotation(declaration.getDeclaration(), JAXB.XML_ENUM_VALUE);
- GenericJavaEnumConstantTests.this.addMemberValuePair(enumValueAnnotation, JAXB.XML_ENUM_VALUE__VALUE, "foo");
- }
- });
-
- assertEquals("MONDAY", contextEnumConstant.getDefaultValue());
- assertEquals("foo", contextEnumConstant.getValue());
- assertEquals("foo", contextEnumConstant.getSpecifiedValue());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaEnumConstantTests.this.removeAnnotation(declaration, JAXB.XML_ENUM_VALUE);
- }
- });
- assertEquals("MONDAY", contextEnumConstant.getDefaultValue());
- assertEquals("MONDAY", contextEnumConstant.getValue());
- assertNull(contextEnumConstant.getSpecifiedValue());
- }
-
-} \ No newline at end of file
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumMappingTests.java
deleted file mode 100644
index 9b39ca4e72..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumMappingTests.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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.beans.Introspector;
-import java.util.Iterator;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
-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.jaxb.core.context.JaxbEnum;
-import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
-import org.eclipse.jpt.jaxb.core.context.JaxbEnumMapping;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaEnumMappingTests
- extends JaxbContextModelTestCase {
-
- public GenericJavaEnumMappingTests(String name) {
- super(name);
- }
-
-
- protected void addXmlTypeMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlTypeAnnotation(declaration), name, value);
- }
-
- protected void addXmlTypeTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlTypeAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected void addXmlEnumTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlEnumAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected Annotation getXmlTypeAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_TYPE);
- }
-
- protected Annotation getXmlEnumAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_ENUM);
- }
-
- public void testModifySchemaTypeName() throws Exception {
- createEnumWithXmlType();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
- String defaultXmlTypeName = Introspector.decapitalize(TYPE_NAME);
-
- assertNull(enumMapping.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, enumMapping.getQName().getDefaultName());
- assertEquals(defaultXmlTypeName, enumMapping.getQName().getName());
-
- enumMapping.getQName().setSpecifiedName("foo");
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getName());
- assertEquals("foo", enumMapping.getQName().getSpecifiedName());
- assertEquals("foo", enumMapping.getQName().getName());
-
- enumMapping.getQName().setSpecifiedName(null);
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertNull(xmlTypeAnnotation.getName());
- assertNull(enumMapping.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, enumMapping.getQName().getName());
-
- resourceEnum.removeAnnotation(JAXB.XML_TYPE);
-
- //set name again, this time starting with no XmlType annotation
- enumMapping.getQName().setSpecifiedName("foo");
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getName());
- assertEquals("foo", enumMapping.getQName().getSpecifiedName());
- assertEquals("foo", enumMapping.getQName().getName());
- }
-
- public void testUpdateSchemaTypeName() throws Exception {
- createEnumWithXmlType();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
- String defaultXmlTypeName = Introspector.decapitalize(TYPE_NAME);
-
- assertNull(enumMapping.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, enumMapping.getQName().getDefaultName());
- assertEquals(defaultXmlTypeName, enumMapping.getQName().getName());
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaEnumMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TYPE);
- GenericJavaEnumMappingTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAME, "foo");
- }
- });
- assertEquals("foo", enumMapping.getQName().getSpecifiedName());
- assertEquals("foo", enumMapping.getQName().getName());
-
- //remove the namespace member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaEnumMappingTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaEnumMappingTests.this.values(xmlTypeAnnotation).remove(0);
- }
- });
- assertNull(enumMapping.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, enumMapping.getQName().getName());
- }
-
- public void testModifyNamespace() throws Exception {
- createEnumWithXmlType();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
-
- assertNull(enumMapping.getQName().getSpecifiedNamespace());
- assertEquals("", enumMapping.getQName().getDefaultNamespace());
- assertEquals("", enumMapping.getQName().getNamespace());
-
- enumMapping.getQName().setSpecifiedNamespace("foo");
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getNamespace());
- assertEquals("foo", enumMapping.getQName().getSpecifiedNamespace());
- assertEquals("foo", enumMapping.getQName().getNamespace());
-
- enumMapping.getQName().setSpecifiedNamespace(null);
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertNull(xmlTypeAnnotation.getNamespace());
- assertNull(enumMapping.getQName().getSpecifiedNamespace());
- assertEquals("", enumMapping.getQName().getNamespace());
-
- resourceEnum.removeAnnotation(JAXB.XML_TYPE);
-
- //set namespace again, this time starting with no XmlType annotation
- enumMapping.getQName().setSpecifiedNamespace("foo");
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getNamespace());
- assertEquals("foo", enumMapping.getQName().getSpecifiedNamespace());
- assertEquals("foo", enumMapping.getQName().getNamespace());
- }
-
- public void testUpdateNamespace() throws Exception {
- createEnumWithXmlType();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
-
- assertNull(enumMapping.getQName().getSpecifiedNamespace());
- assertEquals("", enumMapping.getQName().getDefaultNamespace());
- assertEquals("", enumMapping.getQName().getNamespace());
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaEnumMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TYPE);
- GenericJavaEnumMappingTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAMESPACE, "foo");
- }
- });
- assertEquals("foo", enumMapping.getQName().getSpecifiedNamespace());
- assertEquals("foo", enumMapping.getQName().getNamespace());
-
- //remove the namespace member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaEnumMappingTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaEnumMappingTests.this.values(xmlTypeAnnotation).remove(0);
- }
- });
- assertNull(enumMapping.getQName().getSpecifiedNamespace());
- assertEquals("", enumMapping.getQName().getNamespace());
- }
-
- public void testModifyXmlRootElement() throws Exception {
- createEnumWithXmlType();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
-
- assertNull(enumMapping.getXmlRootElement());
-
- enumMapping.addXmlRootElement().getQName().setSpecifiedName("foo");
- XmlRootElementAnnotation xmlRootElementAnnotation = (XmlRootElementAnnotation) resourceEnum.getAnnotation(JAXB.XML_ROOT_ELEMENT);
- assertEquals("foo", xmlRootElementAnnotation.getName());
- assertEquals("foo", enumMapping.getXmlRootElement().getQName().getName());
-
- enumMapping.removeXmlRootElement();
- xmlRootElementAnnotation = (XmlRootElementAnnotation) resourceEnum.getAnnotation(JAXB.XML_ROOT_ELEMENT);
- assertNull(xmlRootElementAnnotation);
- assertNull(enumMapping.getXmlRootElement());
- }
-
- public void testUpdateXmlRootElement() throws Exception {
- createEnumWithXmlType();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
-
- assertNull(enumMapping.getXmlRootElement());
-
- //add a XmlRootElement annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation annotation = GenericJavaEnumMappingTests.this.addNormalAnnotation(declaration.getDeclaration(), JAXB.XML_ROOT_ELEMENT);
- GenericJavaEnumMappingTests.this.addMemberValuePair(annotation, JAXB.XML_ROOT_ELEMENT__NAME, "foo");
- }
- });
- assertEquals("foo", enumMapping.getXmlRootElement().getQName().getName());
-
- //remove the XmlRootElement annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaEnumMappingTests.this.removeAnnotation(declaration, JAXB.XML_ROOT_ELEMENT);
- }
- });
- assertNull(enumMapping.getXmlRootElement());
- }
-
- public void testModifyXmlEnumValue() throws Exception {
- createEnumWithXmlType();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
-
- assertNull(enumMapping.getSpecifiedXmlEnumValue());
- assertEquals(JaxbEnumMapping.DEFAULT_XML_ENUM_VALUE, enumMapping.getXmlEnumValue());
-
- enumMapping.setSpecifiedXmlEnumValue("Integer");
- XmlEnumAnnotation xmlEnumAnnotation = (XmlEnumAnnotation) resourceEnum.getAnnotation(JAXB.XML_ENUM);
- assertEquals("Integer", xmlEnumAnnotation.getValue());
- assertEquals("Integer", enumMapping.getSpecifiedXmlEnumValue());
- assertEquals("Integer", enumMapping.getXmlEnumValue());
-
- enumMapping.setSpecifiedXmlEnumValue(null);
- xmlEnumAnnotation = (XmlEnumAnnotation) resourceEnum.getAnnotation(JAXB.XML_ENUM);
- assertNull(enumMapping.getSpecifiedXmlEnumValue());
- assertEquals(JaxbEnumMapping.DEFAULT_XML_ENUM_VALUE, enumMapping.getXmlEnumValue());
-
- resourceEnum.addAnnotation(JAXB.XML_TYPE);
- resourceEnum.removeAnnotation(JAXB.XML_ENUM);
- enumMapping = ((JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0)).getMapping();
- assertNull(enumMapping.getSpecifiedXmlEnumValue());
- assertEquals(JaxbEnumMapping.DEFAULT_XML_ENUM_VALUE, enumMapping.getXmlEnumValue());
- }
-
- public void testUpdateXmlEnumValue() throws Exception {
- createEnumWithXmlType();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
-
- assertNull(enumMapping.getSpecifiedXmlEnumValue());
- assertEquals(JaxbEnumMapping.DEFAULT_XML_ENUM_VALUE, enumMapping.getXmlEnumValue());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaEnumMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ENUM);
- GenericJavaEnumMappingTests.this.addXmlEnumTypeMemberValuePair(declaration, JAXB.XML_ENUM__VALUE, "String");
- }
- });
- assertEquals("String", enumMapping.getSpecifiedXmlEnumValue());
- assertEquals("String", enumMapping.getXmlEnumValue());
-
- //remove the factoryClass member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlEnumAnnotation = (NormalAnnotation) GenericJavaEnumMappingTests.this.getXmlEnumAnnotation(declaration);
- GenericJavaEnumMappingTests.this.values(xmlEnumAnnotation).remove(0);
- }
- });
- assertNull(enumMapping.getSpecifiedXmlEnumValue());
- assertEquals(JaxbEnumMapping.DEFAULT_XML_ENUM_VALUE, enumMapping.getXmlEnumValue());
- }
-
- public void testUpdateEnumConstants() throws Exception {
- createEnumWithXmlType();
-
- JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
- JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
-
- assertEquals(2, enumMapping.getEnumConstantsSize());
- Iterator<JaxbEnumConstant> enumConstants = enumMapping.getEnumConstants().iterator();
- JaxbEnumConstant enumConstant = enumConstants.next();
- assertEquals("SUNDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("MONDAY", enumConstant.getName());
- assertFalse(enumConstants.hasNext());
-
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaEnumMappingTests.this.addEnumConstant((EnumDeclaration) declaration.getDeclaration(), "TUESDAY");
- GenericJavaEnumMappingTests.this.addEnumConstant((EnumDeclaration) declaration.getDeclaration(), "WEDNESDAY");
- }
- });
- assertEquals(4, enumMapping.getEnumConstantsSize());
- enumConstants = enumMapping.getEnumConstants().iterator();
- enumConstant = enumConstants.next();
- assertEquals("SUNDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("MONDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("TUESDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("WEDNESDAY", enumConstant.getName());
- assertFalse(enumConstants.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaEnumMappingTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "SUNDAY");
- }
- });
- assertEquals(3, enumMapping.getEnumConstantsSize());
- enumConstants = enumMapping.getEnumConstants().iterator();
- enumConstant = enumConstants.next();
- assertEquals("MONDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("TUESDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("WEDNESDAY", enumConstant.getName());
- assertFalse(enumConstants.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaEnumMappingTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "TUESDAY");
- GenericJavaEnumMappingTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "MONDAY");
- }
- });
- assertEquals(1, enumMapping.getEnumConstantsSize());
- enumConstants = enumMapping.getEnumConstants().iterator();
- enumConstant = enumConstants.next();
- assertEquals("WEDNESDAY", enumConstant.getName());
- assertFalse(enumConstants.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaEnumMappingTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "WEDNESDAY");
- }
- });
- assertEquals(0, enumMapping.getEnumConstantsSize());
- assertFalse(enumMapping.getEnumConstants().iterator().hasNext());
- }
-} \ No newline at end of file
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java
deleted file mode 100644
index 410125c98f..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java
+++ /dev/null
@@ -1,793 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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 java.util.ListIterator;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
-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.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SubListIterableWrapper;
-import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
-import org.eclipse.jpt.jaxb.core.context.XmlAccessOrder;
-import org.eclipse.jpt.jaxb.core.context.XmlAccessType;
-import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
-import org.eclipse.jpt.jaxb.core.context.XmlSchemaType;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorOrderAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaPackageInfoTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createPackageInfoWithAccessorType() throws CoreException {
- return createTestPackageInfo(
- "@XmlAccessorType(value = XmlAccessType.PROPERTY)",
- JAXB.XML_ACCESS_TYPE, JAXB.XML_ACCESSOR_TYPE);
- }
-
- private ICompilationUnit createPackageInfoWithAccessorOrder() throws CoreException {
- return createTestPackageInfo(
- "@XmlAccessorOrder(value = XmlAccessOrder.ALPHABETICAL)",
- JAXB.XML_ACCESS_ORDER, JAXB.XML_ACCESSOR_ORDER);
- }
-
- public void testModifyAccessType() throws Exception {
- createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertEquals(XmlAccessType.PROPERTY, contextPackageInfo.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PROPERTY, contextPackageInfo.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getDefaultAccessType());
-
- contextPackageInfo.setSpecifiedAccessType(XmlAccessType.FIELD);
- XmlAccessorTypeAnnotation accessorTypeAnnotation = (XmlAccessorTypeAnnotation) resourcePackage.getAnnotation(JAXB.XML_ACCESSOR_TYPE);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.FIELD, accessorTypeAnnotation.getValue());
- assertEquals(XmlAccessType.FIELD, contextPackageInfo.getAccessType());
-
- contextPackageInfo.setSpecifiedAccessType(XmlAccessType.PUBLIC_MEMBER);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.PUBLIC_MEMBER, accessorTypeAnnotation.getValue());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getAccessType());
-
- contextPackageInfo.setSpecifiedAccessType(XmlAccessType.NONE);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.NONE, accessorTypeAnnotation.getValue());
- assertEquals(XmlAccessType.NONE, contextPackageInfo.getAccessType());
-
- contextPackageInfo.setSpecifiedAccessType(null);
- accessorTypeAnnotation = (XmlAccessorTypeAnnotation) resourcePackage.getAnnotation(JAXB.XML_ACCESSOR_TYPE);
- assertNull(accessorTypeAnnotation.getValue());
- assertNull(contextPackageInfo.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getDefaultAccessType());
- }
-
- public void testUpdateAccessType() throws Exception {
- createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertEquals(XmlAccessType.PROPERTY, contextPackageInfo.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PROPERTY, contextPackageInfo.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getDefaultAccessType());
-
- //set the accesser type value to FIELD
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__FIELD);
- }
- });
- assertEquals(XmlAccessType.FIELD, contextPackageInfo.getAccessType());
-
- //set the accesser type value to PUBLIC_MEMBER
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- }
- });
- assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getAccessType());
-
- //set the accesser type value to NONE
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__NONE);
- }
- });
- assertEquals(XmlAccessType.NONE, contextPackageInfo.getAccessType());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.removeXmlAccessorTypeAnnotation(declaration);
- }
- });
- assertNull(contextPackageInfo.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getDefaultAccessType());
- }
-
- public void testModifyAccessOrder() throws Exception {
- createPackageInfoWithAccessorOrder();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertEquals(XmlAccessOrder.ALPHABETICAL, contextPackageInfo.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.ALPHABETICAL, contextPackageInfo.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getDefaultAccessOrder());
-
- contextPackageInfo.setSpecifiedAccessOrder(XmlAccessOrder.UNDEFINED);
- XmlAccessorOrderAnnotation accessorOrderAnnotation = (XmlAccessorOrderAnnotation) resourcePackage.getAnnotation(JAXB.XML_ACCESSOR_ORDER);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder.UNDEFINED, accessorOrderAnnotation.getValue());
- assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getAccessOrder());
-
- contextPackageInfo.setSpecifiedAccessOrder(null);
- accessorOrderAnnotation = (XmlAccessorOrderAnnotation) resourcePackage.getAnnotation(JAXB.XML_ACCESSOR_ORDER);
- assertNull(accessorOrderAnnotation.getValue());
- assertNull(contextPackageInfo.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getDefaultAccessOrder());
- }
-
- public void testUpdateAccessOrder() throws Exception {
- createPackageInfoWithAccessorOrder();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertEquals(XmlAccessOrder.ALPHABETICAL, contextPackageInfo.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.ALPHABETICAL, contextPackageInfo.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getDefaultAccessOrder());
-
- //set the access order value to UNDEFINED
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_ORDER, JAXB.XML_ACCESS_ORDER__UNDEFINED);
- }
- });
- assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getAccessOrder());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.removeXmlAccessorOrderAnnotation(declaration);
- }
- });
- assertNull(contextPackageInfo.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getDefaultAccessOrder());
- }
-
- //add another package annotation so that the context model object doesn't get removed when
- //removing the XmlAccessorType annotation. Only "annotated" packages are added to the context model
- protected void removeXmlAccessorTypeAnnotation(ModifiedDeclaration declaration) {
- this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_SCHEMA);
- this.removeAnnotation(declaration, JAXB.XML_ACCESSOR_TYPE);
- }
-
- //add another package annotation so that the context model object doesn't get removed when
- //removing the XmlAccessorOrder annotation. Only "annotated" packages are added to the context model
- protected void removeXmlAccessorOrderAnnotation(ModifiedDeclaration declaration) {
- this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_SCHEMA);
- this.removeAnnotation(declaration, JAXB.XML_ACCESSOR_ORDER);
- }
-
- public void testGetXmlSchemaTypes() throws Exception {
- this.createPackageInfoWithAccessorOrder();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- ListIterable<XmlSchemaType> xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes();
- assertFalse(xmlSchemaTypes.iterator().hasNext());
-
- //add 2 XmlSchemaTypes
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.addXmlSchemaType(declaration, 0, "bar");
- GenericJavaPackageInfoTests.this.addXmlSchemaType(declaration, 1, "foo");
- }
- });
-
- xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes();
- ListIterator<XmlSchemaType> xmlSchemaTypesIterator = xmlSchemaTypes.iterator();
- assertTrue(xmlSchemaTypesIterator.hasNext());
- assertEquals("bar", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("foo", xmlSchemaTypesIterator.next().getQName().getName());
- assertFalse(xmlSchemaTypesIterator.hasNext());
- }
-
- protected void addXmlSchemaType(ModifiedDeclaration declaration, int index, String name) {
- NormalAnnotation arrayElement = this.newXmlSchemaTypeAnnotation(declaration.getAst(), name);
- this.addArrayElement(declaration, JAXB.XML_SCHEMA_TYPES, index, JAXB.XML_SCHEMA_TYPES__VALUE, arrayElement);
- }
-
- protected NormalAnnotation newXmlSchemaTypeAnnotation(AST ast, String name) {
- NormalAnnotation annotation = this.newNormalAnnotation(ast, JAXB.XML_SCHEMA_TYPE);
- this.addMemberValuePair(annotation, JAXB.XML_SCHEMA_TYPE__NAME, name);
- return annotation;
- }
-
- public void testGetXmlSchemaTypesSize() throws Exception {
- this.createPackageInfoWithAccessorOrder();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertEquals(0, contextPackageInfo.getXmlSchemaTypesSize());
-
- //add 2 XmlSchemaTypes
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.addXmlSchemaType(declaration, 0, "bar");
- GenericJavaPackageInfoTests.this.addXmlSchemaType(declaration, 1, "foo");
- }
- });
- assertEquals(2, contextPackageInfo.getXmlSchemaTypesSize());
- }
-
- public void testAddXmlSchemaType() throws Exception {
- //create a package info with an annotation other than XmlSchema to test
- //adding things to the null schema annotation
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- contextPackageInfo.addXmlSchemaType(0).getQName().setSpecifiedName("bar");
- contextPackageInfo.addXmlSchemaType(0).getQName().setSpecifiedName("foo");
- contextPackageInfo.addXmlSchemaType(0).getQName().setSpecifiedName("baz");
-
- Iterator<XmlSchemaTypeAnnotation> xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage);
-
- assertEquals("baz", xmlSchemaTypes.next().getName());
- assertEquals("foo", xmlSchemaTypes.next().getName());
- assertEquals("bar", xmlSchemaTypes.next().getName());
- assertFalse(xmlSchemaTypes.hasNext());
- }
-
- protected Iterator<XmlSchemaTypeAnnotation> getSchemaTypeAnnotations(JavaResourcePackage resourcePackage) {
- return new SubListIterableWrapper<NestableAnnotation, XmlSchemaTypeAnnotation>(resourcePackage.getAnnotations(JAXB.XML_SCHEMA_TYPE)).iterator();
- }
-
- public void testAddXmlSchemaType2() throws Exception {
- //create a package info with an annotation other than XmlSchema to test
- //adding things to the null schema annotation
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- contextPackageInfo.addXmlSchemaType(0).getQName().setSpecifiedName("bar");
- contextPackageInfo.addXmlSchemaType(1).getQName().setSpecifiedName("foo");
- contextPackageInfo.addXmlSchemaType(0).getQName().setSpecifiedName("baz");
-
- Iterator<XmlSchemaTypeAnnotation> xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage);
-
- assertEquals("baz", xmlSchemaTypes.next().getName());
- assertEquals("bar", xmlSchemaTypes.next().getName());
- assertEquals("foo", xmlSchemaTypes.next().getName());
- assertFalse(xmlSchemaTypes.hasNext());
- }
-
- public void testRemoveXmlSchemaType() throws Exception {
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- contextPackageInfo.addXmlSchemaType(0).getQName().setSpecifiedName("bar");
- contextPackageInfo.addXmlSchemaType(1).getQName().setSpecifiedName("foo");
- contextPackageInfo.addXmlSchemaType(2).getQName().setSpecifiedName("baz");
-
- Iterator<XmlSchemaTypeAnnotation> xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage);
- assertEquals("bar", xmlSchemaTypes.next().getName());
- assertEquals("foo", xmlSchemaTypes.next().getName());
- assertEquals("baz", xmlSchemaTypes.next().getName());
- assertFalse(xmlSchemaTypes.hasNext());
-
- contextPackageInfo.removeXmlSchemaType(1);
-
- xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage);
- assertEquals("bar", xmlSchemaTypes.next().getName());
- assertEquals("baz", xmlSchemaTypes.next().getName());
- assertFalse(xmlSchemaTypes.hasNext());
-
- contextPackageInfo.removeXmlSchemaType(1);
- xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage);
- assertEquals("bar", xmlSchemaTypes.next().getName());
- assertFalse(xmlSchemaTypes.hasNext());
-
- contextPackageInfo.removeXmlSchemaType(0);
- xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage);
- assertFalse(xmlSchemaTypes.hasNext());
- }
-
- public void testMoveXmlSchemaType() throws Exception {
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- contextPackageInfo.addXmlSchemaType(0).getQName().setSpecifiedName("bar");
- contextPackageInfo.addXmlSchemaType(1).getQName().setSpecifiedName("foo");
- contextPackageInfo.addXmlSchemaType(2).getQName().setSpecifiedName("baz");
-
- Iterator<XmlSchemaTypeAnnotation> xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage);
- assertEquals("bar", xmlSchemaTypes.next().getName());
- assertEquals("foo", xmlSchemaTypes.next().getName());
- assertEquals("baz", xmlSchemaTypes.next().getName());
- assertFalse(xmlSchemaTypes.hasNext());
-
- contextPackageInfo.moveXmlSchemaType(2, 0);
- xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage);
- assertEquals("foo", xmlSchemaTypes.next().getName());
- assertEquals("baz", xmlSchemaTypes.next().getName());
- assertEquals("bar", xmlSchemaTypes.next().getName());
- assertFalse(xmlSchemaTypes.hasNext());
-
- contextPackageInfo.moveXmlSchemaType(0, 1);
- xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage);
- assertEquals("baz", xmlSchemaTypes.next().getName());
- assertEquals("foo", xmlSchemaTypes.next().getName());
- assertEquals("bar", xmlSchemaTypes.next().getName());
- assertFalse(xmlSchemaTypes.hasNext());
- }
-
- public void testSyncXmlSchemaTypes() throws Exception {
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- ListIterable<XmlSchemaType> xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes();
- assertFalse(xmlSchemaTypes.iterator().hasNext());
-
- //add 3 XmlSchemaTypes
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.addXmlSchemaType(declaration, 0, "bar");
- GenericJavaPackageInfoTests.this.addXmlSchemaType(declaration, 1, "foo");
- GenericJavaPackageInfoTests.this.addXmlSchemaType(declaration, 2, "baz");
- }
- });
-
- xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes();
- ListIterator<XmlSchemaType> xmlSchemaTypesIterator = xmlSchemaTypes.iterator();
- assertTrue(xmlSchemaTypesIterator.hasNext());
- assertEquals("bar", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("foo", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("baz", xmlSchemaTypesIterator.next().getQName().getName());
- assertFalse(xmlSchemaTypesIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.moveXmlSchemaType(declaration, 2, 0);
- }
- });
-
- xmlSchemaTypesIterator = xmlSchemaTypes.iterator();
- assertTrue(xmlSchemaTypesIterator.hasNext());
- assertEquals("foo", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("baz", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("bar", xmlSchemaTypesIterator.next().getQName().getName());
- assertFalse(xmlSchemaTypesIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.moveXmlSchemaType(declaration, 0, 1);
- }
- });
-
- xmlSchemaTypesIterator = xmlSchemaTypes.iterator();
- assertTrue(xmlSchemaTypesIterator.hasNext());
- assertEquals("baz", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("foo", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("bar", xmlSchemaTypesIterator.next().getQName().getName());
- assertFalse(xmlSchemaTypesIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.removeXmlSchemaType(declaration, 1);
- }
- });
-
- xmlSchemaTypesIterator = xmlSchemaTypes.iterator();
- assertTrue(xmlSchemaTypesIterator.hasNext());
- assertEquals("baz", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("bar", xmlSchemaTypesIterator.next().getQName().getName());
- assertFalse(xmlSchemaTypesIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.removeXmlSchemaType(declaration, 1);
- }
- });
-
- xmlSchemaTypesIterator = xmlSchemaTypes.iterator();
- assertTrue(xmlSchemaTypesIterator.hasNext());
- assertEquals("baz", xmlSchemaTypesIterator.next().getQName().getName());
- assertFalse(xmlSchemaTypesIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.removeXmlSchemaType(declaration, 0);
- }
- });
-
- xmlSchemaTypesIterator = xmlSchemaTypes.iterator();
- assertFalse(xmlSchemaTypesIterator.hasNext());
- }
-
- public void testSyncAddXmlSchemaTypes() throws Exception {
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- ListIterable<XmlSchemaType> xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes();
- assertFalse(xmlSchemaTypes.iterator().hasNext());
-
- //add 1 XmlSchemaType when none exist
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.addXmlSchemaType(declaration, 0, "bar");
- }
- });
-
- xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes();
- ListIterator<XmlSchemaType> xmlSchemaTypesIterator = xmlSchemaTypes.iterator();
- assertTrue(xmlSchemaTypesIterator.hasNext());
- assertEquals("bar", xmlSchemaTypesIterator.next().getQName().getName());
- assertFalse(xmlSchemaTypesIterator.hasNext());
-
-
- //add 1 XmlSchemaType when 1 standalone exists
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.addXmlSchemaType(declaration, 1, "foo");
- }
- });
-
- xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes();
- xmlSchemaTypesIterator = xmlSchemaTypes.iterator();
- assertTrue(xmlSchemaTypesIterator.hasNext());
- assertEquals("bar", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("foo", xmlSchemaTypesIterator.next().getQName().getName());
- assertFalse(xmlSchemaTypesIterator.hasNext());
-
- //add 1 XmlSchemaType when a container annotations exists
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.addXmlSchemaType(declaration, 2, "baz");
- }
- });
-
- xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes();
- xmlSchemaTypesIterator = xmlSchemaTypes.iterator();
- assertTrue(xmlSchemaTypesIterator.hasNext());
- assertEquals("bar", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("foo", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("baz", xmlSchemaTypesIterator.next().getQName().getName());
- assertFalse(xmlSchemaTypesIterator.hasNext());
-
- //add 1 XmlSchemaType to beginning of list when a container annotations exists
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.addXmlSchemaType(declaration, 0, "foobaz");
- }
- });
-
- xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes();
- xmlSchemaTypesIterator = xmlSchemaTypes.iterator();
- assertTrue(xmlSchemaTypesIterator.hasNext());
- assertEquals("foobaz", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("bar", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("foo", xmlSchemaTypesIterator.next().getQName().getName());
- assertEquals("baz", xmlSchemaTypesIterator.next().getQName().getName());
- assertFalse(xmlSchemaTypesIterator.hasNext());
- }
-
- protected void moveXmlSchemaType(ModifiedDeclaration declaration, int targetIndex, int sourceIndex) {
- this.moveArrayElement((NormalAnnotation) declaration.getAnnotationNamed(JAXB.XML_SCHEMA_TYPES), JAXB.XML_SCHEMA_TYPES__VALUE, targetIndex, sourceIndex);
- }
-
- protected void removeXmlSchemaType(ModifiedDeclaration declaration, int index) {
- this.removeArrayElement((NormalAnnotation) declaration.getAnnotationNamed(JAXB.XML_SCHEMA_TYPES), JAXB.XML_SCHEMA_TYPES__VALUE, index);
- }
-
-
- public void testGetXmlJavaTypeAdapters() throws Exception {
- this.createPackageInfoWithAccessorOrder();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- ListIterable<XmlJavaTypeAdapter> xmlJavaTypeAdapters = contextPackageInfo.getXmlJavaTypeAdapters();
- assertFalse(xmlJavaTypeAdapters.iterator().hasNext());
-
- //add 2 XmlJavaTypeAdapters
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.addXmlJavaTypeAdapter(declaration, 0, "String");
- GenericJavaPackageInfoTests.this.addXmlJavaTypeAdapter(declaration, 1, "Integer");
- }
- });
-
- xmlJavaTypeAdapters = contextPackageInfo.getXmlJavaTypeAdapters();
- ListIterator<XmlJavaTypeAdapter> xmlJavaTypeAdaptersIterator = xmlJavaTypeAdapters.iterator();
- assertTrue(xmlJavaTypeAdaptersIterator.hasNext());
- assertEquals("String", xmlJavaTypeAdaptersIterator.next().getValue());
- assertEquals("Integer", xmlJavaTypeAdaptersIterator.next().getValue());
- assertFalse(xmlJavaTypeAdaptersIterator.hasNext());
- }
-
- protected void addXmlJavaTypeAdapter(ModifiedDeclaration declaration, int index, String name) {
- NormalAnnotation arrayElement = this.newXmlJavaTypeAdapterAnnotation(declaration.getAst(), name);
- this.addArrayElement(declaration, JAXB.XML_JAVA_TYPE_ADAPTERS, index, JAXB.XML_JAVA_TYPE_ADAPTERS__VALUE, arrayElement);
- }
-
- protected NormalAnnotation newXmlJavaTypeAdapterAnnotation(AST ast, String valueTypeName) {
- NormalAnnotation annotation = this.newNormalAnnotation(ast, JAXB.XML_JAVA_TYPE_ADAPTER);
- this.addMemberValuePair(
- annotation,
- JAXB.XML_JAVA_TYPE_ADAPTER__VALUE,
- this.newTypeLiteral(ast, valueTypeName));
- return annotation;
- }
-
- public void testGetXmlJavaTypeAdaptersSize() throws Exception {
- this.createPackageInfoWithAccessorOrder();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertEquals(0, contextPackageInfo.getXmlJavaTypeAdaptersSize());
-
- //add 2 XmlJavaTypeAdapters
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.addXmlJavaTypeAdapter(declaration, 0, "String");
- GenericJavaPackageInfoTests.this.addXmlJavaTypeAdapter(declaration, 1, "Integer");
- }
- });
- assertEquals(2, contextPackageInfo.getXmlJavaTypeAdaptersSize());
- }
-
- public void testAddXmlJavaTypeAdapter() throws Exception {
- //create a package info with an annotation other than XmlSchema to test
- //adding things to the null schema annotation
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- contextPackageInfo.addXmlJavaTypeAdapter(0).setValue("bar");
- contextPackageInfo.addXmlJavaTypeAdapter(0).setValue("foo");
- contextPackageInfo.addXmlJavaTypeAdapter(0).setValue("baz");
-
- Iterator<XmlJavaTypeAdapterAnnotation> xmlJavaTypeAdapters = this.getXmlJavaTypeAdapterAnnotations(resourcePackage);
-
- assertEquals("baz", xmlJavaTypeAdapters.next().getValue());
- assertEquals("foo", xmlJavaTypeAdapters.next().getValue());
- assertEquals("bar", xmlJavaTypeAdapters.next().getValue());
- assertFalse(xmlJavaTypeAdapters.hasNext());
- }
-
- protected Iterator<XmlJavaTypeAdapterAnnotation> getXmlJavaTypeAdapterAnnotations(JavaResourcePackage resourcePackage) {
- return new SubListIterableWrapper<NestableAnnotation, XmlJavaTypeAdapterAnnotation>(resourcePackage.getAnnotations(JAXB.XML_JAVA_TYPE_ADAPTER)).iterator();
- }
-
- public void testAddXmlJavaTypeAdapter2() throws Exception {
- //create a package info with an annotation other than XmlSchema to test
- //adding things to the null schema annotation
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- contextPackageInfo.addXmlJavaTypeAdapter(0).setValue("bar");
- contextPackageInfo.addXmlJavaTypeAdapter(1).setValue("foo");
- contextPackageInfo.addXmlJavaTypeAdapter(0).setValue("baz");
-
- Iterator<XmlJavaTypeAdapterAnnotation> xmlJavaTypeAdapters = this.getXmlJavaTypeAdapterAnnotations(resourcePackage);
-
- assertEquals("baz", xmlJavaTypeAdapters.next().getValue());
- assertEquals("bar", xmlJavaTypeAdapters.next().getValue());
- assertEquals("foo", xmlJavaTypeAdapters.next().getValue());
- assertFalse(xmlJavaTypeAdapters.hasNext());
- }
-
- public void testRemoveXmlJavaTypeAdapter() throws Exception {
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- contextPackageInfo.addXmlJavaTypeAdapter(0).setValue("String");
- contextPackageInfo.addXmlJavaTypeAdapter(1).setValue("foo");
- contextPackageInfo.addXmlJavaTypeAdapter(2).setValue("baz");
-
- Iterator<XmlJavaTypeAdapterAnnotation> xmlJavaTypeAdapters = this.getXmlJavaTypeAdapterAnnotations(resourcePackage);
- XmlJavaTypeAdapterAnnotation adapterAnnotation = xmlJavaTypeAdapters.next();
- assertEquals("String", adapterAnnotation.getValue());
- assertEquals("java.lang.String", adapterAnnotation.getFullyQualifiedValue());
- assertEquals("foo", xmlJavaTypeAdapters.next().getValue());
- assertEquals("baz", xmlJavaTypeAdapters.next().getValue());
- assertFalse(xmlJavaTypeAdapters.hasNext());
-
- contextPackageInfo.removeXmlJavaTypeAdapter(1);
-
- xmlJavaTypeAdapters = this.getXmlJavaTypeAdapterAnnotations(resourcePackage);
- adapterAnnotation = xmlJavaTypeAdapters.next();
- assertEquals("String", adapterAnnotation.getValue());
- assertEquals("java.lang.String", adapterAnnotation.getFullyQualifiedValue());
- assertEquals("baz", xmlJavaTypeAdapters.next().getValue());
- assertFalse(xmlJavaTypeAdapters.hasNext());
-
- contextPackageInfo.removeXmlJavaTypeAdapter(1);
- xmlJavaTypeAdapters = this.getXmlJavaTypeAdapterAnnotations(resourcePackage);
- adapterAnnotation = xmlJavaTypeAdapters.next();
- assertEquals("String", adapterAnnotation.getValue());
- assertEquals("java.lang.String", adapterAnnotation.getFullyQualifiedValue());
- assertFalse(xmlJavaTypeAdapters.hasNext());
-
- contextPackageInfo.removeXmlJavaTypeAdapter(0);
- xmlJavaTypeAdapters = this.getXmlJavaTypeAdapterAnnotations(resourcePackage);
- assertFalse(xmlJavaTypeAdapters.hasNext());
- }
-
- public void testMoveXmlJavaTypeAdapter() throws Exception {
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- contextPackageInfo.addXmlJavaTypeAdapter(0).setValue("bar");
- contextPackageInfo.addXmlJavaTypeAdapter(1).setValue("foo");
- contextPackageInfo.addXmlJavaTypeAdapter(2).setValue("baz");
-
- Iterator<XmlJavaTypeAdapterAnnotation> xmlJavaTypeAdapters = this.getXmlJavaTypeAdapterAnnotations(resourcePackage);
- assertEquals("bar", xmlJavaTypeAdapters.next().getValue());
- assertEquals("foo", xmlJavaTypeAdapters.next().getValue());
- assertEquals("baz", xmlJavaTypeAdapters.next().getValue());
- assertFalse(xmlJavaTypeAdapters.hasNext());
-
- contextPackageInfo.moveXmlJavaTypeAdapter(2, 0);
- xmlJavaTypeAdapters = this.getXmlJavaTypeAdapterAnnotations(resourcePackage);
- assertEquals("foo", xmlJavaTypeAdapters.next().getValue());
- assertEquals("baz", xmlJavaTypeAdapters.next().getValue());
- assertEquals("bar", xmlJavaTypeAdapters.next().getValue());
- assertFalse(xmlJavaTypeAdapters.hasNext());
-
- contextPackageInfo.moveXmlJavaTypeAdapter(0, 1);
- xmlJavaTypeAdapters = this.getXmlJavaTypeAdapterAnnotations(resourcePackage);
- assertEquals("baz", xmlJavaTypeAdapters.next().getValue());
- assertEquals("foo", xmlJavaTypeAdapters.next().getValue());
- assertEquals("bar", xmlJavaTypeAdapters.next().getValue());
- assertFalse(xmlJavaTypeAdapters.hasNext());
- }
-
- public void testSyncXmlJavaTypeAdapters() throws Exception {
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- ListIterable<XmlJavaTypeAdapter> xmlJavaTypeAdapters = contextPackageInfo.getXmlJavaTypeAdapters();
- assertFalse(xmlJavaTypeAdapters.iterator().hasNext());
-
- //add 3 XmlJavaTypeAdapters
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.addXmlJavaTypeAdapter(declaration, 0, "bar");
- GenericJavaPackageInfoTests.this.addXmlJavaTypeAdapter(declaration, 1, "foo");
- GenericJavaPackageInfoTests.this.addXmlJavaTypeAdapter(declaration, 2, "baz");
- }
- });
-
- xmlJavaTypeAdapters = contextPackageInfo.getXmlJavaTypeAdapters();
- ListIterator<XmlJavaTypeAdapter> xmlJavaTypeAdaptersIterator = xmlJavaTypeAdapters.iterator();
- assertTrue(xmlJavaTypeAdaptersIterator.hasNext());
- assertEquals("bar", xmlJavaTypeAdaptersIterator.next().getValue());
- assertEquals("foo", xmlJavaTypeAdaptersIterator.next().getValue());
- assertEquals("baz", xmlJavaTypeAdaptersIterator.next().getValue());
- assertFalse(xmlJavaTypeAdaptersIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.moveXmlJavaTypeAdapter(declaration, 2, 0);
- }
- });
-
- xmlJavaTypeAdapters = contextPackageInfo.getXmlJavaTypeAdapters();
- xmlJavaTypeAdaptersIterator = xmlJavaTypeAdapters.iterator();
- assertTrue(xmlJavaTypeAdaptersIterator.hasNext());
- assertEquals("foo", xmlJavaTypeAdaptersIterator.next().getValue());
- assertEquals("baz", xmlJavaTypeAdaptersIterator.next().getValue());
- assertEquals("bar", xmlJavaTypeAdaptersIterator.next().getValue());
- assertFalse(xmlJavaTypeAdaptersIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.moveXmlJavaTypeAdapter(declaration, 0, 1);
- }
- });
-
- xmlJavaTypeAdapters = contextPackageInfo.getXmlJavaTypeAdapters();
- xmlJavaTypeAdaptersIterator = xmlJavaTypeAdapters.iterator();
- assertTrue(xmlJavaTypeAdaptersIterator.hasNext());
- assertEquals("baz", xmlJavaTypeAdaptersIterator.next().getValue());
- assertEquals("foo", xmlJavaTypeAdaptersIterator.next().getValue());
- assertEquals("bar", xmlJavaTypeAdaptersIterator.next().getValue());
- assertFalse(xmlJavaTypeAdaptersIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.removeXmlJavaTypeAdapter(declaration, 1);
- }
- });
-
- xmlJavaTypeAdapters = contextPackageInfo.getXmlJavaTypeAdapters();
- xmlJavaTypeAdaptersIterator = xmlJavaTypeAdapters.iterator();
- assertTrue(xmlJavaTypeAdaptersIterator.hasNext());
- assertEquals("baz", xmlJavaTypeAdaptersIterator.next().getValue());
- assertEquals("bar", xmlJavaTypeAdaptersIterator.next().getValue());
- assertFalse(xmlJavaTypeAdaptersIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.removeXmlJavaTypeAdapter(declaration, 1);
- }
- });
-
- xmlJavaTypeAdapters = contextPackageInfo.getXmlJavaTypeAdapters();
- xmlJavaTypeAdaptersIterator = xmlJavaTypeAdapters.iterator();
- assertTrue(xmlJavaTypeAdaptersIterator.hasNext());
- assertEquals("baz", xmlJavaTypeAdaptersIterator.next().getValue());
- assertFalse(xmlJavaTypeAdaptersIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageInfoTests.this.removeXmlJavaTypeAdapter(declaration, 0);
- }
- });
-
- xmlJavaTypeAdapters = contextPackageInfo.getXmlJavaTypeAdapters();
- xmlJavaTypeAdaptersIterator = xmlJavaTypeAdapters.iterator();
- assertFalse(xmlJavaTypeAdaptersIterator.hasNext());
- }
-
-
- protected void moveXmlJavaTypeAdapter(ModifiedDeclaration declaration, int targetIndex, int sourceIndex) {
- this.moveArrayElement((NormalAnnotation) declaration.getAnnotationNamed(JAXB.XML_JAVA_TYPE_ADAPTERS), JAXB.XML_JAVA_TYPE_ADAPTERS__VALUE, targetIndex, sourceIndex);
- }
-
- protected void removeXmlJavaTypeAdapter(ModifiedDeclaration declaration, int index) {
- this.removeArrayElement((NormalAnnotation) declaration.getAnnotationNamed(JAXB.XML_JAVA_TYPE_ADAPTERS), JAXB.XML_JAVA_TYPE_ADAPTERS__VALUE, index);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageXmlJavaTypeAdapterTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageXmlJavaTypeAdapterTests.java
deleted file mode 100644
index 0d45116955..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageXmlJavaTypeAdapterTests.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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 org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
-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.jaxb.core.context.JaxbPackageInfo;
-import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
-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 GenericJavaPackageXmlJavaTypeAdapterTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaPackageXmlJavaTypeAdapterTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createPackageInfoWithXmlJavaTypeAdapter() throws CoreException {
- return createTestPackageInfo(
- "@XmlJavaTypeAdapter",
- JAXB.XML_JAVA_TYPE_ADAPTER);
- }
-
-
- public void testModifyValue() throws Exception {
- this.createPackageInfoWithXmlJavaTypeAdapter();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextPackageInfo.getXmlJavaTypeAdapters().iterator().next();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlJavaTypeAdapter.getValue());
-
- contextXmlJavaTypeAdapter.setValue("foo");
- XmlJavaTypeAdapterAnnotation javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourcePackage.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertEquals("foo", javaTypeAdapterAnnotation.getValue());
- assertEquals("foo", contextXmlJavaTypeAdapter.getValue());
-
- //verify the xml schema type annotation is not removed when the value is set to null
- contextXmlJavaTypeAdapter.setValue(null);
- javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourcePackage.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(javaTypeAdapterAnnotation.getValue());
- assertNull(contextXmlJavaTypeAdapter.getValue());
- }
-
- public void testUpdateValue() throws Exception {
- this.createPackageInfoWithXmlJavaTypeAdapter();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextPackageInfo.getXmlJavaTypeAdapters().iterator().next();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlJavaTypeAdapter.getValue());
-
- //add a value member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageXmlJavaTypeAdapterTests.this.addXmlJavaTypeAdapterTypeMemberValuePair(declaration, JAXB.XML_JAVA_TYPE_ADAPTER__VALUE, "String");
- }
- });
- assertEquals("String", contextXmlJavaTypeAdapter.getValue());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageXmlJavaTypeAdapterTests.this.removeXmlJavaTypeAdapterAnnotation(declaration);
- }
- });
- assertFalse(contextPackageInfo.getXmlJavaTypeAdapters().iterator().hasNext());
- }
-
- public void testModifyType() throws Exception {
- this.createPackageInfoWithXmlJavaTypeAdapter();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextPackageInfo.getXmlJavaTypeAdapters().iterator().next();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlJavaTypeAdapter.getType());
- assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
- assertNull(contextXmlJavaTypeAdapter.getDefaultType());
-
- contextXmlJavaTypeAdapter.setSpecifiedType("foo");
- XmlJavaTypeAdapterAnnotation javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourcePackage.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertEquals("foo", javaTypeAdapterAnnotation.getType());
- assertEquals("foo", contextXmlJavaTypeAdapter.getType());
-
- //verify the xml schema type annotation is not removed when the type is set to null
- contextXmlJavaTypeAdapter.setSpecifiedType(null);
- javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourcePackage.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(javaTypeAdapterAnnotation.getType());
- assertNull(contextXmlJavaTypeAdapter.getType());
- assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
- assertNull(contextXmlJavaTypeAdapter.getDefaultType());
- }
-
- public void testUpdateType() throws Exception {
- this.createPackageInfoWithXmlJavaTypeAdapter();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextPackageInfo.getXmlJavaTypeAdapters().iterator().next();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlJavaTypeAdapter.getType());
- assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
- assertNull(contextXmlJavaTypeAdapter.getDefaultType());
-
- //add a type member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageXmlJavaTypeAdapterTests.this.addXmlJavaTypeAdapterTypeMemberValuePair(declaration, JAXB.XML_JAVA_TYPE_ADAPTER__TYPE, "String");
- }
- });
- assertEquals("String", contextXmlJavaTypeAdapter.getType());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPackageXmlJavaTypeAdapterTests.this.removeXmlJavaTypeAdapterAnnotation(declaration);
- }
- });
- assertFalse(contextPackageInfo.getXmlJavaTypeAdapters().iterator().hasNext());
- }
-
- protected void addXmlJavaTypeAdapterTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlJavaTypeAdapterAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected void addXmlJavaTypeAdapterMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlJavaTypeAdapterAnnotation(declaration), name, value);
- }
-
- //add another package annotation so that the context model object doesn't get removed when
- //removing the XmlJavaTypeAdapter annotation. Only "annotated" packages are added to the context model
- protected void removeXmlJavaTypeAdapterAnnotation(ModifiedDeclaration declaration) {
- this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ACCESSOR_ORDER);
- this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
-
- protected Annotation getXmlJavaTypeAdapterAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_JAVA_TYPE_ADAPTER);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentAttributeTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentAttributeTests.java
deleted file mode 100644
index 13bf4b00f7..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentAttributeTests.java
+++ /dev/null
@@ -1,112 +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 org.eclipse.core.runtime.CoreException;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-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.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-public class GenericJavaPersistentAttributeTests
- extends JaxbContextModelTestCase {
-
- private static String TEST_CLASS_NAME = "TestClass";
-
- public GenericJavaPersistentAttributeTests(String name) {
- super(name);
- }
-
-
- private void createXmlTypeWithVariousAttributes() throws CoreException {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ").append(JAXB.XML_TYPE).append(";").append(CR);
- sb.append("import java.util.List;").append(CR);
- sb.append(CR);
- sb.append("@XmlType").append(CR);
- sb.append("public class ").append(TEST_CLASS_NAME).append("<T extends Number> ").append("{").append(CR);
- sb.append(" public String string;").append(CR);
- sb.append(" public List<String> stringList;").append(CR);
- sb.append(" public String[] stringArray;").append(CR);
- sb.append(" public String[][] stringDoubleArray;").append(CR);
- sb.append(" public T generic;").append(CR);
- sb.append(" public List<T> genericList;").append(CR);
- sb.append(" public T[] genericArray;").append(CR);
- sb.append(" public List<?> wildcardList;").append(CR);
- sb.append(" public byte[] byteArray;").append(CR);
- sb.append(" public List list;").append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, TEST_CLASS_NAME + ".java", sourceWriter);
- }
-
-
- public void testJavaResourceType() throws Exception {
- createXmlTypeWithVariousAttributes();
- JaxbClassMapping classMapping = ((JaxbClass) getContextRoot().getType(PACKAGE_NAME_ + TEST_CLASS_NAME)).getMapping();
-
- // String string
- JaxbPersistentAttribute att = CollectionTools.get(classMapping.getAttributes(), 0);
- assertEquals("java.lang.String", att.getJavaResourceAttributeBaseTypeName());
- assertEquals(false, att.isJavaResourceAttributeCollectionType());
-
- // List<String> stringList
- att = CollectionTools.get(classMapping.getAttributes(), 1);
- assertEquals("java.lang.String", att.getJavaResourceAttributeBaseTypeName());
- assertEquals(true, att.isJavaResourceAttributeCollectionType());
-
- // String[] stringArray
- att = CollectionTools.get(classMapping.getAttributes(), 2);
- assertEquals("java.lang.String", att.getJavaResourceAttributeBaseTypeName());
- assertEquals(true, att.isJavaResourceAttributeCollectionType());
-
- // String[][] stringDoubleArray
- att = CollectionTools.get(classMapping.getAttributes(), 3);
- assertEquals("java.lang.String[][]", att.getJavaResourceAttributeBaseTypeName());
- assertEquals(false, att.isJavaResourceAttributeCollectionType());
-
- // T generic
- att = CollectionTools.get(classMapping.getAttributes(), 4);
- assertEquals("java.lang.Number", att.getJavaResourceAttributeBaseTypeName());
- assertEquals(false, att.isJavaResourceAttributeCollectionType());
-
- // List<T> genericList
- att = CollectionTools.get(classMapping.getAttributes(), 5);
- assertEquals("java.lang.Number", att.getJavaResourceAttributeBaseTypeName());
- assertEquals(true, att.isJavaResourceAttributeCollectionType());
-
- // T[] genericArray
- att = CollectionTools.get(classMapping.getAttributes(), 6);
- assertEquals("java.lang.Number", att.getJavaResourceAttributeBaseTypeName());
- assertEquals(true, att.isJavaResourceAttributeCollectionType());
-
- // List<?> wildcardList
- att = CollectionTools.get(classMapping.getAttributes(), 7);
- assertEquals("java.lang.Object", att.getJavaResourceAttributeBaseTypeName());
- assertEquals(true, att.isJavaResourceAttributeCollectionType());
-
- // byte[] byteArray
- att = CollectionTools.get(classMapping.getAttributes(), 8);
- assertEquals("byte[]", att.getJavaResourceAttributeBaseTypeName());
- assertEquals(false, att.isJavaResourceAttributeCollectionType());
-
- // List list
- att = CollectionTools.get(classMapping.getAttributes(), 9);
- assertEquals("java.lang.Object", att.getJavaResourceAttributeBaseTypeName());
- assertEquals(true, att.isJavaResourceAttributeCollectionType());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaRegistryTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaRegistryTests.java
deleted file mode 100644
index b01ba097ef..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaRegistryTests.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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 java.util.List;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.Block;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.IExtendedModifier;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-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.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.core.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod;
-import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaRegistryTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaRegistryTests(String name) {
- super(name);
- }
-
- protected ICompilationUnit createClassWithXmlRegistryAndCreateMethods() throws Exception {
- return this.createTestType(PACKAGE_NAME, "ObjectFactory.java", "ObjectFactory", new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_REGISTRY, JAXB.XML_ELEMENT_DECL, "javax.xml.bind.JAXBElement");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlRegistry");
- }
-
- @Override
- public void appendGetNameMethodAnnotationTo(StringBuilder sb) {
- sb.append("@XmlElementDecl(name=\"foo\")").append(CR);
- sb.append(" JAXBElement<AnnotationTestType> createFoo(AnnotationTestType value) {return null}").append(CR);
- sb.append(CR);
- sb.append(" @XmlElementDecl(name=\"bar\")").append(CR);
- sb.append(" JAXBElement createBar(Object value) {return null}").append(CR);
- sb.append(CR);
- }
- });
- }
-
-
- protected void addElementFactoryMethod(TypeDeclaration typeDeclaration, String methodName) {
- AST ast = typeDeclaration.getAST();
- MethodDeclaration methodDeclaration = this.newMethodDeclaration(ast, methodName);
- Block body = ast.newBlock();
- methodDeclaration.setBody(body);
- methodDeclaration.setReturnType2(ast.newSimpleType(ast.newName("JAXBElement")));
- SingleVariableDeclaration parameter = ast.newSingleVariableDeclaration();
- parameter.setName(ast.newSimpleName("value"));
- parameter.setType(ast.newSimpleType(ast.newName("Object")));
- parameters(methodDeclaration).add(parameter);
- NormalAnnotation elementDeclAnnotation = this.newNormalAnnotation(ast, "XmlElementDecl");
- modifiers(methodDeclaration).add(elementDeclAnnotation);
- this.bodyDeclarations(typeDeclaration).add(methodDeclaration);
- }
-
- protected MethodDeclaration newMethodDeclaration(AST ast, String methodName) {
- MethodDeclaration methodDeclaration = ast.newMethodDeclaration();
- methodDeclaration.setName(ast.newSimpleName(methodName));
- return methodDeclaration;
- }
-
- /**
- * minimize the scope of the suppressed warnings
- */
- @SuppressWarnings("unchecked")
- protected List<BodyDeclaration> bodyDeclarations(TypeDeclaration td) {
- return td.bodyDeclarations();
- }
-
- @SuppressWarnings("unchecked")
- protected List<SingleVariableDeclaration> parameters(MethodDeclaration md) {
- return md.parameters();
- }
-
- @SuppressWarnings("unchecked")
- protected List<IExtendedModifier> modifiers(MethodDeclaration md) {
- return md.modifiers();
- }
-
- protected void removeMethodDeclaration(TypeDeclaration typeDeclaration, String methodName) {
- for (MethodDeclaration md : typeDeclaration.getMethods()) {
- if (md.getName().getFullyQualifiedName().equals(methodName)) {
- this.bodyDeclarations(typeDeclaration).remove(md);
- break;
- }
- }
- }
-
- public void testUpdateElementFactoryMethods() throws Exception {
- createClassWithXmlType();
- createClassWithXmlRegistryAndCreateMethods();
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
- XmlRegistry contextRegistry = jaxbClass.getXmlRegistry();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- assertEquals(2, contextRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
- JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
- assertEquals("createFoo", elementFactoryMethod.getName());
- assertEquals("foo", elementFactoryMethod.getQName().getName());
- elementFactoryMethod = elementFactoryMethods.next();
- assertEquals("createBar", elementFactoryMethod.getName());
- assertEquals("bar", elementFactoryMethod.getQName().getName());
- assertFalse(elementFactoryMethods.hasNext());
-
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaRegistryTests.this.addElementFactoryMethod((TypeDeclaration) declaration.getDeclaration(), "createFoo2");
- GenericJavaRegistryTests.this.addElementFactoryMethod((TypeDeclaration) declaration.getDeclaration(), "createBar2");
- }
- });
- assertEquals(4, contextRegistry.getElementFactoryMethodsSize());
- elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
- elementFactoryMethod = elementFactoryMethods.next();
- assertEquals("createFoo", elementFactoryMethod.getName());
- assertEquals("foo", elementFactoryMethod.getQName().getName());
- elementFactoryMethod = elementFactoryMethods.next();
- assertEquals("createBar", elementFactoryMethod.getName());
- assertEquals("bar", elementFactoryMethod.getQName().getName());
- elementFactoryMethod = elementFactoryMethods.next();
- assertEquals("createFoo2", elementFactoryMethod.getName());
- assertEquals(null, elementFactoryMethod.getQName().getName());
- elementFactoryMethod = elementFactoryMethods.next();
- assertEquals("createBar2", elementFactoryMethod.getName());
- assertEquals(null, elementFactoryMethod.getQName().getName());
- assertFalse(elementFactoryMethods.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaRegistryTests.this.removeMethodDeclaration((TypeDeclaration) declaration.getDeclaration(), "createFoo");
- }
- });
- assertEquals(3, contextRegistry.getElementFactoryMethodsSize());
- elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
- elementFactoryMethod = elementFactoryMethods.next();
- assertEquals("createBar", elementFactoryMethod.getName());
- assertEquals("bar", elementFactoryMethod.getQName().getName());
- elementFactoryMethod = elementFactoryMethods.next();
- assertEquals("createFoo2", elementFactoryMethod.getName());
- assertEquals(null, elementFactoryMethod.getQName().getName());
- elementFactoryMethod = elementFactoryMethods.next();
- assertEquals("createBar2", elementFactoryMethod.getName());
- assertEquals(null, elementFactoryMethod.getQName().getName());
- assertFalse(elementFactoryMethods.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaRegistryTests.this.removeMethodDeclaration((TypeDeclaration) declaration.getDeclaration(), "createFoo2");
- GenericJavaRegistryTests.this.removeMethodDeclaration((TypeDeclaration) declaration.getDeclaration(), "createBar2");
- }
- });
- assertEquals(1, contextRegistry.getElementFactoryMethodsSize());
- elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
- elementFactoryMethod = elementFactoryMethods.next();
- assertEquals("createBar", elementFactoryMethod.getName());
- assertEquals("bar", elementFactoryMethod.getQName().getName());
- assertFalse(elementFactoryMethods.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaRegistryTests.this.removeMethodDeclaration((TypeDeclaration) declaration.getDeclaration(), "createBar");
- }
- });
- assertEquals(0, contextRegistry.getElementFactoryMethodsSize());
- assertFalse(contextRegistry.getElementFactoryMethods().iterator().hasNext());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaTypeXmlJavaTypeAdapterTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaTypeXmlJavaTypeAdapterTests.java
deleted file mode 100644
index 6df5f7d855..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaTypeXmlJavaTypeAdapterTests.java
+++ /dev/null
@@ -1,173 +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.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-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.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
-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 GenericJavaTypeXmlJavaTypeAdapterTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaTypeXmlJavaTypeAdapterTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTypeWithXmlJavaTypeAdapter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlJavaTypeAdapter");
- }
- });
- }
-
- public void testModifyValue() throws Exception {
- createTypeWithXmlJavaTypeAdapter();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = jaxbClass.getXmlJavaTypeAdapter();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(contextXmlJavaTypeAdapter.getValue());
-
- contextXmlJavaTypeAdapter.setValue("foo");
- XmlJavaTypeAdapterAnnotation javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceType.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertEquals("foo", javaTypeAdapterAnnotation.getValue());
- assertEquals("foo", contextXmlJavaTypeAdapter.getValue());
-
- //verify the xml schema type annotation is not removed when the value is set to null
- contextXmlJavaTypeAdapter.setValue(null);
- javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceType.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(javaTypeAdapterAnnotation.getValue());
- assertNull(contextXmlJavaTypeAdapter.getValue());
- }
-
- public void testUpdateValue() throws Exception {
- createTypeWithXmlJavaTypeAdapter();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = jaxbClass.getXmlJavaTypeAdapter();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(contextXmlJavaTypeAdapter.getValue());
-
- //add a value member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaTypeXmlJavaTypeAdapterTests.this.addXmlJavaTypeAdapterTypeMemberValuePair(declaration, JAXB.XML_JAVA_TYPE_ADAPTER__VALUE, "String");
- }
- });
- assertEquals("String", contextXmlJavaTypeAdapter.getValue());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaTypeXmlJavaTypeAdapterTests.this.removeXmlJavaTypeAdapterAnnotation(declaration);
- }
- });
- assertNull(jaxbClass.getXmlJavaTypeAdapter());
- }
-
- public void testModifyType() throws Exception {
- createTypeWithXmlJavaTypeAdapter();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = jaxbClass.getXmlJavaTypeAdapter();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, contextXmlJavaTypeAdapter.getType());
- assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, contextXmlJavaTypeAdapter.getDefaultType());
-
- contextXmlJavaTypeAdapter.setSpecifiedType("foo");
- XmlJavaTypeAdapterAnnotation javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceType.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertEquals("foo", javaTypeAdapterAnnotation.getType());
- assertEquals("foo", contextXmlJavaTypeAdapter.getSpecifiedType());
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, contextXmlJavaTypeAdapter.getDefaultType());
-
- contextXmlJavaTypeAdapter.setSpecifiedType(null);
- javaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceType.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(javaTypeAdapterAnnotation.getType());
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, contextXmlJavaTypeAdapter.getType());
- assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, contextXmlJavaTypeAdapter.getDefaultType());
- }
-
- public void testUpdateType() throws Exception {
- createTypeWithXmlJavaTypeAdapter();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = jaxbClass.getXmlJavaTypeAdapter();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, contextXmlJavaTypeAdapter.getType());
- assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, contextXmlJavaTypeAdapter.getDefaultType());
-
- //add a type member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaTypeXmlJavaTypeAdapterTests.this.addXmlJavaTypeAdapterTypeMemberValuePair(declaration, JAXB.XML_JAVA_TYPE_ADAPTER__TYPE, "String");
- }
- });
- assertEquals("String", contextXmlJavaTypeAdapter.getSpecifiedType());
- assertEquals("String", contextXmlJavaTypeAdapter.getType());
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, contextXmlJavaTypeAdapter.getDefaultType());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaTypeXmlJavaTypeAdapterTests.this.removeXmlJavaTypeAdapterAnnotation(declaration);
- }
- });
- assertNull(jaxbClass.getXmlJavaTypeAdapter());
- }
-
- protected void addXmlJavaTypeAdapterTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlJavaTypeAdapterAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected void addXmlJavaTypeAdapterMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlJavaTypeAdapterAnnotation(declaration), name, value);
- }
-
- //add another package annotation so that the context model object doesn't get removed when
- //removing the XmlJavaTypeAdapter annotation. Only "annotated" packages are added to the context model
- protected void removeXmlJavaTypeAdapterAnnotation(ModifiedDeclaration declaration) {
- this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ACCESSOR_ORDER);
- this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
-
- protected Annotation getXmlJavaTypeAdapterAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_JAVA_TYPE_ADAPTER);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAdapterTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAdapterTests.java
deleted file mode 100644
index 8e79e10763..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAdapterTests.java
+++ /dev/null
@@ -1,112 +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.core.runtime.CoreException;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-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.XmlAdapter;
-import org.eclipse.jpt.jaxb.core.context.XmlElementMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-public class GenericJavaXmlAdapterTests
- extends JaxbContextModelTestCase {
-
- public GenericJavaXmlAdapterTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createXmlType() throws Exception {
- return this.createTestType(
- new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
- });
- }
-
- private void createObjObjXmlAdapter() throws CoreException {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import " + JAXB.XML_ADAPTER + ";").append(CR);
- sb.append(CR);
- sb.append("public class ObjObjAdapter extends XmlAdapter<Object, Object> {").append(CR);
- sb.append(" public Object marshal(Object obj) { return null; }").append(CR);
- sb.append(" public Object unmarshal(Object obj) { return null; }").append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "ObjObjAdapter.java", sourceWriter);
- }
-
- private void createMapCalendarXmlAdapter() throws CoreException {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import " + JAXB.XML_ADAPTER + ";").append(CR);
- sb.append("import java.util.Map;").append(CR);
- sb.append("import java.util.GregorianCalendar;").append(CR);
- sb.append(CR);
- sb.append("public class MapCalendarAdapter extends XmlAdapter<GregorianCalendar, Map<String, String>> {").append(CR);
- sb.append(" public GregorianCalendar marshal(Map<String, String> obj) { return null; }").append(CR);
- sb.append(" public GregorianCalendar marshal(Object obj) { return null; }").append(CR);
- sb.append(" public Map<String, String> unmarshal(Gregorian Calendar obj) { return null; }").append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "MapCalendarAdapter.java", sourceWriter);
- }
-
-
- public void testBoundAndValueTypes() throws Exception {
- createXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping attributeMapping = (XmlElementMapping) persistentAttribute.getMapping();
-
- XmlJavaTypeAdapter xmlJavaTypeAdapter = attributeMapping.addXmlJavaTypeAdapter();
- xmlJavaTypeAdapter.setValue("test.ObjObjAdapter");
-
- assertEquals("test.ObjObjAdapter", xmlJavaTypeAdapter.getValue());
- assertEquals("test.ObjObjAdapter", xmlJavaTypeAdapter.getFullyQualifiedValue());
- assertNull(xmlJavaTypeAdapter.getXmlAdapter());
-
- createObjObjXmlAdapter();
- XmlAdapter xmlAdapter = xmlJavaTypeAdapter.getXmlAdapter();
- assertNotNull(xmlAdapter);
- assertEquals("java.lang.Object", xmlAdapter.getBoundType());
- assertEquals("java.lang.Object", xmlAdapter.getValueType());
-
- createMapCalendarXmlAdapter();
- xmlJavaTypeAdapter.setValue("test.MapCalendarAdapter");
- xmlAdapter = xmlJavaTypeAdapter.getXmlAdapter();
- assertNotNull(xmlAdapter);
- assertEquals("java.util.Map", xmlAdapter.getBoundType());
- assertEquals("java.util.GregorianCalendar", xmlAdapter.getValueType());
- }
-}
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
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyElementMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyElementMappingTests.java
deleted file mode 100644
index 392f95d821..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyElementMappingTests.java
+++ /dev/null
@@ -1,533 +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.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-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.XmlAnyElementMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlElementMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlElementRef;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAnyElementAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefsAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlMixedAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaXmlAnyElementMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTypeWithXmlAnyElement() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ANY_ELEMENT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlAnyElement");
- }
- });
- }
-
- public void testChangeMappingType() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNotNull(attributeMapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT));
-
- persistentAttribute.setMappingKey(MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- assertNotNull(xmlAttributeMapping);
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT));
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
-
- persistentAttribute.setMappingKey(MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY);
- attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- assertNotNull(attributeMapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT));
- 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_ELEMENT));
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
-
- persistentAttribute.setMappingKey(MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY);
- attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- assertNotNull(attributeMapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT));
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
- }
-
- public void testModifyXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) 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 {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) 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) {
- GenericJavaXmlAnyElementMappingTests.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) {
- GenericJavaXmlAnyElementMappingTests.this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(attributeMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
-
- public void testModifyLax() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(attributeMapping.getSpecifiedLax());
- assertEquals(false, attributeMapping.isDefaultLax());
- assertEquals(false, attributeMapping.isLax());
-
- attributeMapping.setSpecifiedLax(Boolean.TRUE);
- XmlAnyElementAnnotation xmlAnyElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
- assertEquals(Boolean.TRUE, xmlAnyElementAnnotation.getLax());
- assertEquals(Boolean.TRUE, attributeMapping.getSpecifiedLax());
- assertEquals(false, attributeMapping.isDefaultLax());
- assertEquals(true, attributeMapping.isLax());
-
- attributeMapping.setSpecifiedLax(null);
- xmlAnyElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
- assertNull(attributeMapping.getSpecifiedLax());
- assertEquals(false, attributeMapping.isDefaultLax());
- assertEquals(false, attributeMapping.isLax());
- }
-
- public void testUpdateLax() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(attributeMapping.getSpecifiedLax());
- assertEquals(false, attributeMapping.isDefaultLax());
- assertEquals(false, attributeMapping.isLax());
-
-
- //add a nillable member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAnyElementMappingTests.this.addXmlAnyElementMemberValuePair(declaration, JAXB.XML_ANY_ELEMENT__LAX, true);
- }
- });
- assertEquals(Boolean.TRUE, attributeMapping.getSpecifiedLax());
- assertEquals(false, attributeMapping.isDefaultLax());
- assertEquals(true, attributeMapping.isLax());
-
- //remove the lax member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementAnnotation = (NormalAnnotation) GenericJavaXmlAnyElementMappingTests.this.getXmlAnyElementAnnotation(declaration);
- GenericJavaXmlAnyElementMappingTests.this.values(xmlElementAnnotation).remove(0);
- }
- });
- assertNull(attributeMapping.getSpecifiedLax());
- assertEquals(false, attributeMapping.isDefaultLax());
- assertEquals(false, attributeMapping.isLax());
- }
-
- public void testModifyValue() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(attributeMapping.getSpecifiedValue());
-
- attributeMapping.setSpecifiedValue("Foo");
- XmlAnyElementAnnotation xmlElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
- assertEquals("Foo", attributeMapping.getSpecifiedValue());
- assertEquals("Foo", attributeMapping.getValue());
-
- attributeMapping.setSpecifiedValue(null);
- xmlElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
- assertNull(xmlElementAnnotation.getValue());
- assertNull(attributeMapping.getSpecifiedValue());
- }
-
- public void testUpdateValue() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(attributeMapping.getSpecifiedValue());
-
-
- //add a Value member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAnyElementMappingTests.this.addXmlAnyElementTypeMemberValuePair(declaration, JAXB.XML_ANY_ELEMENT__VALUE, "Foo");
- }
- });
- assertEquals("Foo", attributeMapping.getValue());
-
- //remove the Value member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementAnnotation = (NormalAnnotation) GenericJavaXmlAnyElementMappingTests.this.getXmlAnyElementAnnotation(declaration);
- GenericJavaXmlAnyElementMappingTests.this.values(xmlElementAnnotation).remove(0);
- }
- });
- assertNull(attributeMapping.getSpecifiedValue());
- }
-
- protected Annotation getXmlAnyElementAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_ANY_ELEMENT);
- }
-
- protected void addXmlAnyElementMemberValuePair(ModifiedDeclaration declaration, String name, boolean value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlAnyElementAnnotation(declaration), name, value);
- }
-
- protected void addXmlAnyElementTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlAnyElementAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
-
- // ***** XmlElementRefs *****
-
- public void testSyncXmlElementRefs() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- Iterable<XmlElementRef> xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
- assertTrue(CollectionTools.isEmpty(xmlElementRefs));
- assertEquals(0, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
-
- //add XmlElementRef annotation
- AnnotatedElement annotatedElement = annotatedElement(resourceAttribute);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAnyElementMappingTests.this.addMemberValuePair(
- GenericJavaXmlAnyElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ELEMENT_REF),
- JAXB.XML_ELEMENT_REF__NAME, "foo");
- }
- });
- xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
-
- assertFalse(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(1, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("foo", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
-
- // add XmlElementRefs annotation with nested annotation
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAnyElementMappingTests.this.addMarkerAnnotation(
- declaration.getDeclaration(), JAXB.XML_ELEMENT_REFS);
- NormalAnnotation annotation =
- GenericJavaXmlAnyElementMappingTests.this.newNormalAnnotation(declaration.getAst(), JAXB.XML_ELEMENT_REF);
- GenericJavaXmlAnyElementMappingTests.this.addMemberValuePair(
- annotation, JAXB.XML_ELEMENT_REF__NAME, "bar");
- GenericJavaXmlAnyElementMappingTests.this.addArrayElement(
- declaration, JAXB.XML_ELEMENT_REFS, 0, JAXB.XML_ELEMENT_REFS__VALUE, annotation);
- }
- });
- xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
-
- assertFalse(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(1, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("bar", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
-
- // add second nested XmlElementRef annotation
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation annotation =
- GenericJavaXmlAnyElementMappingTests.this.newNormalAnnotation(declaration.getAst(), JAXB.XML_ELEMENT_REF);
- GenericJavaXmlAnyElementMappingTests.this.addMemberValuePair(
- annotation, JAXB.XML_ELEMENT_REF__NAME, "baz");
- GenericJavaXmlAnyElementMappingTests.this.addArrayElement(
- declaration, JAXB.XML_ELEMENT_REFS, 1, JAXB.XML_ELEMENT_REFS__VALUE, annotation);
- }
- });
- xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
-
- assertFalse(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(2, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("bar", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
- assertEquals("baz", CollectionTools.get(xmlElementRefs, 1).getQName().getName());
-
- // switch nested XmlElementRef annotations
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAnyElementMappingTests.this.moveArrayElement(
- (NormalAnnotation) declaration.getAnnotationNamed(JAXB.XML_ELEMENT_REFS),
- JAXB.XML_ELEMENT_REFS__VALUE, 0, 1);
- }
- });
- xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
-
- assertFalse(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(2, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("baz", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
- assertEquals("bar", CollectionTools.get(xmlElementRefs, 1).getQName().getName());
-
- // remove XmlElementRefs annotation
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAnyElementMappingTests.this.removeArrayElement(
- (NormalAnnotation) declaration.getAnnotationNamed(JAXB.XML_ELEMENT_REFS),
- JAXB.XML_ELEMENT_REFS__VALUE, 1);
- GenericJavaXmlAnyElementMappingTests.this.removeArrayElement(
- (NormalAnnotation) declaration.getAnnotationNamed(JAXB.XML_ELEMENT_REFS),
- JAXB.XML_ELEMENT_REFS__VALUE, 0);
- GenericJavaXmlAnyElementMappingTests.this.removeAnnotation(
- declaration, JAXB.XML_ELEMENT_REFS);
- }
- });
- xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
-
- assertFalse(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(1, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("foo", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
-
- // remove XmlElementRef annotation
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAnyElementMappingTests.this.removeAnnotation(
- declaration, JAXB.XML_ELEMENT_REF);
- }
- });
- xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
-
- assertTrue(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(0, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
- }
-
- public void testModifyXmlElementRefs() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
- XmlElementRefsAnnotation xmlElementRefsAnnotation;
- XmlElementRefAnnotation xmlElementRefAnnotation;
-
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS));
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF));
- assertEquals(0, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
-
- attributeMapping.getXmlElementRefs().addXmlElementRef(0).getQName().setSpecifiedName("foo");
- xmlElementRefsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
- xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
-
- assertNull(xmlElementRefsAnnotation);
- assertNotNull(xmlElementRefAnnotation);
- assertEquals("foo", xmlElementRefAnnotation.getName());
-
- attributeMapping.getXmlElementRefs().addXmlElementRef(1).getQName().setSpecifiedName("bar");
- xmlElementRefsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
- xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
-
- assertNotNull(xmlElementRefsAnnotation);
- assertNull(xmlElementRefAnnotation);
- assertEquals(2, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("foo", CollectionTools.get(xmlElementRefsAnnotation.getXmlElementRefs(), 0).getName());
- assertEquals("bar", CollectionTools.get(xmlElementRefsAnnotation.getXmlElementRefs(), 1).getName());
-
- attributeMapping.getXmlElementRefs().moveXmlElementRef(0, 1);
- xmlElementRefsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
- xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
-
- assertNotNull(xmlElementRefsAnnotation);
- assertNull(xmlElementRefAnnotation);
- assertEquals(2, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("bar", CollectionTools.get(xmlElementRefsAnnotation.getXmlElementRefs(), 0).getName());
- assertEquals("foo", CollectionTools.get(xmlElementRefsAnnotation.getXmlElementRefs(), 1).getName());
-
- attributeMapping.getXmlElementRefs().removeXmlElementRef(0);
- xmlElementRefsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
- xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
-
- assertNull(xmlElementRefsAnnotation);
- assertNotNull(xmlElementRefAnnotation);
- assertEquals(1, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("foo", xmlElementRefAnnotation.getName());
-
- attributeMapping.getXmlElementRefs().removeXmlElementRef(0);
- xmlElementRefsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
- xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
-
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS));
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF));
- assertEquals(0, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
- }
-
- public void testModifyXmlMixed() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlMixedAnnotation xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(attributeMapping.getXmlMixed());
- assertNull(xmlListAnnotation);
-
- attributeMapping.addXmlMixed();
- xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNotNull(attributeMapping.getXmlMixed());
- assertNotNull(xmlListAnnotation);
-
- attributeMapping.removeXmlMixed();
- xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- }
-
- public void testUpdateXmlMixed() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlMixedAnnotation xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(attributeMapping.getXmlMixed());
- assertNull(xmlListAnnotation);
-
-
- //add an XmlMixed annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAnyElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_MIXED);
- }
- });
- xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNotNull(attributeMapping.getXmlMixed());
- assertNotNull(xmlListAnnotation);
-
- //remove the XmlMixed annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAnyElementMappingTests.this.removeAnnotation(declaration, JAXB.XML_MIXED);
- }
- });
- xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(attributeMapping.getXmlMixed());
- assertNull(xmlListAnnotation);
- }
-
-} \ No newline at end of file
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAttributeMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAttributeMappingTests.java
deleted file mode 100644
index aed0072858..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAttributeMappingTests.java
+++ /dev/null
@@ -1,731 +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.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-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.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.XmlAttachmentRefAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAttributeAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlIDAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlIDREFAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaXmlAttributeMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTypeWithXmlAttribute() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ATTRIBUTE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlAttribute");
- }
- });
- }
-
- private ICompilationUnit createTypeWithCollectionXmlAttribute() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import java.util.List;").append(CR);
- sb.append("import javax.xml.bind.annotation.XmlAttribute;").append(CR);
- sb.append("import javax.xml.bind.annotation.XmlType;").append(CR);
- sb.append(CR);
- sb.append("@XmlType").append(CR);
- sb.append("public class ").append(TYPE_NAME).append(" {").append(CR);
- sb.append(" @XmlAttribute").append(CR);
- sb.append(" public List<String> list;").append(CR);
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createCompilationUnit(PACKAGE_NAME, TYPE_NAME + ".java", sourceWriter);
- }
-
-
- public void testModifyName() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlAttributeMapping.getQName().getSpecifiedName());
- assertEquals("id", xmlAttributeMapping.getQName().getDefaultName());
- assertEquals("id", xmlAttributeMapping.getQName().getName());
-
- xmlAttributeMapping.getQName().setSpecifiedName("foo");
- XmlAttributeAnnotation xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
- assertEquals("foo", xmlAttributeAnnotation.getName());
- assertEquals("foo", xmlAttributeMapping.getQName().getSpecifiedName());
- assertEquals("id", xmlAttributeMapping.getQName().getDefaultName());
- assertEquals("foo", xmlAttributeMapping.getQName().getName());
-
- xmlAttributeMapping.getQName().setSpecifiedName(null);
- xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
- assertNull(xmlAttributeAnnotation.getName());
- assertNull(xmlAttributeMapping.getQName().getSpecifiedName());
- }
-
- public void testUpdateName() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlAttributeMapping.getQName().getSpecifiedName());
-
-
- //add a Name member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.addXmlAttributeMemberValuePair(declaration, JAXB.XML_ATTRIBUTE__NAME, "foo");
- }
- });
- assertEquals("foo", xmlAttributeMapping.getQName().getName());
-
- //remove the Name member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlAttributeAnnotation = (NormalAnnotation) GenericJavaXmlAttributeMappingTests.this.getXmlAttributeAnnotation(declaration);
- GenericJavaXmlAttributeMappingTests.this.values(xmlAttributeAnnotation).remove(0);
- }
- });
- assertNull(xmlAttributeMapping.getQName().getSpecifiedName());
- }
-
- public void testModifyNamespace() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlAttributeMapping.getQName().getSpecifiedNamespace());
-
- xmlAttributeMapping.getQName().setSpecifiedNamespace("foo");
- XmlAttributeAnnotation xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
- assertEquals("foo", xmlAttributeAnnotation.getNamespace());
- assertEquals("foo", xmlAttributeMapping.getQName().getNamespace());
-
- xmlAttributeMapping.getQName().setSpecifiedNamespace(null);
- xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
- assertNull(xmlAttributeAnnotation.getNamespace());
- assertNull(xmlAttributeMapping.getQName().getSpecifiedNamespace());
- }
-
- public void testUpdateNamespace() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlAttributeMapping.getQName().getSpecifiedNamespace());
-
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.addXmlAttributeMemberValuePair(declaration, JAXB.XML_ATTRIBUTE__NAMESPACE, "foo");
- }
- });
- assertEquals("foo", xmlAttributeMapping.getQName().getNamespace());
-
- //remove the namespace member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlAttributeAnnotation = (NormalAnnotation) GenericJavaXmlAttributeMappingTests.this.getXmlAttributeAnnotation(declaration);
- GenericJavaXmlAttributeMappingTests.this.values(xmlAttributeAnnotation).remove(0);
- }
- });
- assertNull(xmlAttributeMapping.getQName().getSpecifiedNamespace());
- }
-
- public void testModifyRequired() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlAttributeMapping.getSpecifiedRequired());
- assertEquals(false, xmlAttributeMapping.isDefaultRequired());
- assertEquals(false, xmlAttributeMapping.isRequired());
-
- xmlAttributeMapping.setSpecifiedRequired(Boolean.TRUE);
- XmlAttributeAnnotation xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
- assertEquals(Boolean.TRUE, xmlAttributeAnnotation.getRequired());
- assertEquals(Boolean.TRUE, xmlAttributeMapping.getSpecifiedRequired());
- assertEquals(false, xmlAttributeMapping.isDefaultRequired());
- assertEquals(true, xmlAttributeMapping.isRequired());
-
- xmlAttributeMapping.setSpecifiedRequired(null);
- xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
- assertNull(xmlAttributeAnnotation.getName());
- assertNull(xmlAttributeMapping.getSpecifiedRequired());
- assertEquals(false, xmlAttributeMapping.isDefaultRequired());
- assertEquals(false, xmlAttributeMapping.isRequired());
- }
-
- public void testUpdateRequired() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlAttributeMapping.getSpecifiedRequired());
- assertEquals(false, xmlAttributeMapping.isDefaultRequired());
- assertEquals(false, xmlAttributeMapping.isRequired());
-
-
- //add a required member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.addXmlAttributeMemberValuePair(declaration, JAXB.XML_ATTRIBUTE__REQUIRED, true);
- }
- });
- assertEquals(Boolean.TRUE, xmlAttributeMapping.getSpecifiedRequired());
- assertEquals(false, xmlAttributeMapping.isDefaultRequired());
- assertEquals(true, xmlAttributeMapping.isRequired());
-
- //remove the required member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlAttributeAnnotation = (NormalAnnotation) GenericJavaXmlAttributeMappingTests.this.getXmlAttributeAnnotation(declaration);
- GenericJavaXmlAttributeMappingTests.this.values(xmlAttributeAnnotation).remove(0);
- }
- });
- assertNull(xmlAttributeMapping.getSpecifiedRequired());
- assertEquals(false, xmlAttributeMapping.isDefaultRequired());
- assertEquals(false, xmlAttributeMapping.isRequired());
- }
-
- public void testChangeMappingType() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNotNull(xmlAttributeMapping);
- assertNotNull(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_ATTRIBUTE));
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
-
-
- persistentAttribute.setMappingKey(MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
- xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- assertNotNull(xmlAttributeMapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
- }
-
- public void testModifyXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlAttributeMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
- xmlAttributeMapping.addXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlAttributeMapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- xmlAttributeMapping.removeXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
-
- public void testUpdateXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlAttributeMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
-
- //add an XmlJavaTypeAdapter annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlAttributeMapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- //remove the XmlJavaTypeAdapter annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlAttributeMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
-
- public void testModifyXmlSchemaType() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlSchemaTypeAnnotation xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNull(xmlAttributeMapping.getXmlSchemaType());
- assertNull(xmlSchemaTypeAnnotation);
-
- xmlAttributeMapping.addXmlSchemaType();
- xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNotNull(xmlAttributeMapping.getXmlSchemaType());
- assertNotNull(xmlSchemaTypeAnnotation);
-
- xmlAttributeMapping.removeXmlSchemaType();
- xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- }
-
- public void testUpdateXmlSchemaType() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlSchemaTypeAnnotation xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNull(xmlAttributeMapping.getXmlSchemaType());
- assertNull(xmlSchemaTypeAnnotation);
-
-
- //add an XmlSchemaType annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_SCHEMA_TYPE);
- }
- });
- xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNotNull(xmlAttributeMapping.getXmlSchemaType());
- assertNotNull(xmlSchemaTypeAnnotation);
-
- //remove the XmlSchemaType annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.removeAnnotation(declaration, JAXB.XML_SCHEMA_TYPE);
- }
- });
- xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNull(xmlAttributeMapping.getXmlSchemaType());
- assertNull(xmlSchemaTypeAnnotation);
- }
-
- protected void addXmlAttributeMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlAttributeAnnotation(declaration), name, value);
- }
-
- protected void addXmlAttributeMemberValuePair(ModifiedDeclaration declaration, String name, boolean value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlAttributeAnnotation(declaration), name, value);
- }
-
- protected void addXmlAttributeTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlAttributeAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected Annotation getXmlAttributeAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_ATTRIBUTE);
- }
-
- public void testModifyXmlList1() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertFalse(xmlAttributeMapping.isXmlList());
- assertFalse(xmlAttributeMapping.isDefaultXmlList());
- assertFalse(xmlAttributeMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlAttributeMapping.setSpecifiedXmlList(true);
-
- assertTrue(xmlAttributeMapping.isXmlList());
- assertFalse(xmlAttributeMapping.isDefaultXmlList());
- assertTrue(xmlAttributeMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlAttributeMapping.setSpecifiedXmlList(false);
-
- assertFalse(xmlAttributeMapping.isXmlList());
- assertFalse(xmlAttributeMapping.isDefaultXmlList());
- assertFalse(xmlAttributeMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-
- public void testModifyXmlList2() throws Exception {
- createTypeWithCollectionXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertTrue(xmlAttributeMapping.isXmlList());
- assertTrue(xmlAttributeMapping.isDefaultXmlList());
- assertFalse(xmlAttributeMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlAttributeMapping.setSpecifiedXmlList(true);
-
- assertTrue(xmlAttributeMapping.isXmlList());
- assertTrue(xmlAttributeMapping.isDefaultXmlList());
- assertTrue(xmlAttributeMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlAttributeMapping.setSpecifiedXmlList(false);
-
- assertTrue(xmlAttributeMapping.isXmlList());
- assertTrue(xmlAttributeMapping.isDefaultXmlList());
- assertFalse(xmlAttributeMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-
- public void testUpdateXmlList1() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertFalse(xmlAttributeMapping.isXmlList());
- assertFalse(xmlAttributeMapping.isDefaultXmlList());
- assertFalse(xmlAttributeMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //add an XmlList annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_LIST);
- }
- });
-
- assertTrue(xmlAttributeMapping.isXmlList());
- assertFalse(xmlAttributeMapping.isDefaultXmlList());
- assertTrue(xmlAttributeMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //remove the XmlList annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.removeAnnotation(declaration, JAXB.XML_LIST);
- }
- });
-
- assertFalse(xmlAttributeMapping.isXmlList());
- assertFalse(xmlAttributeMapping.isDefaultXmlList());
- assertFalse(xmlAttributeMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-
- public void testUpdateXmlList2() throws Exception {
- createTypeWithCollectionXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertTrue(xmlAttributeMapping.isXmlList());
- assertTrue(xmlAttributeMapping.isDefaultXmlList());
- assertFalse(xmlAttributeMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //add an XmlList annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_LIST);
- }
- });
-
- assertTrue(xmlAttributeMapping.isXmlList());
- assertTrue(xmlAttributeMapping.isDefaultXmlList());
- assertTrue(xmlAttributeMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //remove the XmlList annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.removeAnnotation(declaration, JAXB.XML_LIST);
- }
- });
-
- assertTrue(xmlAttributeMapping.isXmlList());
- assertTrue(xmlAttributeMapping.isDefaultXmlList());
- assertFalse(xmlAttributeMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-
- public void testModifyXmlID() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlIDAnnotation xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- assertNull(xmlAttributeMapping.getXmlID());
- assertNull(xmlIDAnnotation);
-
- xmlAttributeMapping.addXmlID();
- xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- assertNotNull(xmlAttributeMapping.getXmlID());
- assertNotNull(xmlIDAnnotation);
-
- xmlAttributeMapping.removeXmlID();
- xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- }
-
- public void testUpdateXmlID() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlIDAnnotation xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- assertNull(xmlAttributeMapping.getXmlID());
- assertNull(xmlIDAnnotation);
-
-
- //add an XmlID annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ID);
- }
- });
- xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- assertNotNull(xmlAttributeMapping.getXmlID());
- assertNotNull(xmlIDAnnotation);
-
- //remove the XmlID annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.removeAnnotation(declaration, JAXB.XML_ID);
- }
- });
- xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- assertNull(xmlAttributeMapping.getXmlID());
- assertNull(xmlIDAnnotation);
- }
-
- public void testModifyXmlIDREF() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlIDREFAnnotation xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- assertNull(xmlAttributeMapping.getXmlIDREF());
- assertNull(xmlIDREFAnnotation);
-
- xmlAttributeMapping.addXmlIDREF();
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- assertNotNull(xmlAttributeMapping.getXmlIDREF());
- assertNotNull(xmlIDREFAnnotation);
-
- xmlAttributeMapping.removeXmlIDREF();
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- }
-
- public void testUpdateXmlIDREF() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlIDREFAnnotation xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- assertNull(xmlAttributeMapping.getXmlIDREF());
- assertNull(xmlIDREFAnnotation);
-
-
- //add an XmlIDREF annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_IDREF);
- }
- });
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- assertNotNull(xmlAttributeMapping.getXmlIDREF());
- assertNotNull(xmlIDREFAnnotation);
-
- //remove the XmlIDREF annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.removeAnnotation(declaration, JAXB.XML_IDREF);
- }
- });
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- assertNull(xmlAttributeMapping.getXmlIDREF());
- assertNull(xmlIDREFAnnotation);
- }
-
- public void testModifyXmlAttachmentRef() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlAttachmentRefAnnotation xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- assertNull(xmlAttributeMapping.getXmlAttachmentRef());
- assertNull(xmlAttachmentRefAnnotation);
-
- xmlAttributeMapping.addXmlAttachmentRef();
- xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- assertNotNull(xmlAttributeMapping.getXmlAttachmentRef());
- assertNotNull(xmlAttachmentRefAnnotation);
-
- xmlAttributeMapping.removeXmlAttachmentRef();
- xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- }
-
- public void testUpdateXmlAttachmentRef() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlAttachmentRefAnnotation xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- assertNull(xmlAttributeMapping.getXmlAttachmentRef());
- assertNull(xmlAttachmentRefAnnotation);
-
-
- //add an XmlAttachmentRef annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTACHMENT_REF);
- }
- });
- xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- assertNotNull(xmlAttributeMapping.getXmlAttachmentRef());
- assertNotNull(xmlAttachmentRefAnnotation);
-
- //remove the XmlAttachmentRef annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlAttributeMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTACHMENT_REF);
- }
- });
- xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- assertNull(xmlAttributeMapping.getXmlAttachmentRef());
- assertNull(xmlAttachmentRefAnnotation);
- }
-} \ No newline at end of file
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementMappingTests.java
deleted file mode 100644
index 64ad796fcf..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementMappingTests.java
+++ /dev/null
@@ -1,1055 +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.core.runtime.CoreException;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-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.XmlAttributeMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlElement;
-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.XmlAttachmentRefAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementWrapperAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlIDAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlIDREFAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaXmlElementMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTypeWithXmlElement() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ELEMENT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlElement");
- }
- });
- }
-
- private ICompilationUnit createTypeWithCollectionXmlElement() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import java.util.List;").append(CR);
- sb.append("import javax.xml.bind.annotation.XmlElement;").append(CR);
- sb.append("import javax.xml.bind.annotation.XmlType;").append(CR);
- sb.append(CR);
- sb.append("@XmlType").append(CR);
- sb.append("public class ").append(TYPE_NAME).append(" {").append(CR);
- sb.append(" @XmlElement").append(CR);
- sb.append(" public List<String> list;").append(CR);
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createCompilationUnit(PACKAGE_NAME, TYPE_NAME + ".java", sourceWriter);
- }
-
- private void createXmlTypeWithVariousAttributes() throws CoreException {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ").append(JAXB.XML_TYPE).append(";").append(CR);
- sb.append("import java.util.List;").append(CR);
- sb.append(CR);
- sb.append("@XmlType").append(CR);
- sb.append("public class ").append(TYPE_NAME).append("{").append(CR);
- sb.append(" public String string;").append(CR);
- sb.append(" public List<String> stringList;").append(CR);
- sb.append(" public String[] stringArray;").append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, TYPE_NAME + ".java", sourceWriter);
- }
-
- public void testModifyName() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElement.getQName().getSpecifiedName());
- assertEquals("id", xmlElement.getQName().getDefaultName());
- assertEquals("id", xmlElement.getQName().getName());
-
- xmlElement.getQName().setSpecifiedName("foo");
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
- assertEquals("foo", xmlElementAnnotation.getName());
- assertEquals("foo", xmlElement.getQName().getSpecifiedName());
- assertEquals("id", xmlElement.getQName().getDefaultName());
- assertEquals("foo", xmlElement.getQName().getName());
-
- xmlElement.getQName().setSpecifiedName(null);
- xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
- assertNull(xmlElementAnnotation.getName());
- assertNull(xmlElement.getQName().getSpecifiedName());
- }
-
- public void testUpdateName() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElement.getQName().getSpecifiedName());
-
-
- //add a Name member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addXmlElementMemberValuePair(declaration, JAXB.XML_ELEMENT__NAME, "foo");
- }
- });
- assertEquals("foo", xmlElement.getQName().getName());
-
- //remove the Name member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementAnnotation = (NormalAnnotation) GenericJavaXmlElementMappingTests.this.getXmlElementAnnotation(declaration);
- GenericJavaXmlElementMappingTests.this.values(xmlElementAnnotation).remove(0);
- }
- });
- assertNull(xmlElement.getQName().getSpecifiedName());
- }
-
- public void testModifyNamespace() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElement.getQName().getSpecifiedNamespace());
-
- xmlElement.getQName().setSpecifiedNamespace("foo");
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
- assertEquals("foo", xmlElementAnnotation.getNamespace());
- assertEquals("foo", xmlElement.getQName().getNamespace());
-
- xmlElement.getQName().setSpecifiedNamespace(null);
- xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
- assertNull(xmlElementAnnotation.getNamespace());
- assertNull(xmlElement.getQName().getSpecifiedNamespace());
- }
-
- public void testUpdateNamespace() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElement.getQName().getSpecifiedNamespace());
-
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addXmlElementMemberValuePair(declaration, JAXB.XML_ELEMENT__NAMESPACE, "foo");
- }
- });
- assertEquals("foo", xmlElement.getQName().getNamespace());
-
- //remove the namespace member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementAnnotation = (NormalAnnotation) GenericJavaXmlElementMappingTests.this.getXmlElementAnnotation(declaration);
- GenericJavaXmlElementMappingTests.this.values(xmlElementAnnotation).remove(0);
- }
- });
- assertNull(xmlElement.getQName().getSpecifiedNamespace());
- }
-
- public void testModifyRequired() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElement.getSpecifiedRequired());
- assertEquals(false, xmlElement.isDefaultRequired());
- assertEquals(false, xmlElement.isRequired());
-
- xmlElement.setSpecifiedRequired(Boolean.TRUE);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
- assertEquals(Boolean.TRUE, xmlElementAnnotation.getRequired());
- assertEquals(Boolean.TRUE, xmlElement.getSpecifiedRequired());
- assertEquals(false, xmlElement.isDefaultRequired());
- assertEquals(true, xmlElement.isRequired());
-
- xmlElement.setSpecifiedRequired(null);
- xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
- assertNull(xmlElementAnnotation.getName());
- assertNull(xmlElement.getSpecifiedRequired());
- assertEquals(false, xmlElement.isDefaultRequired());
- assertEquals(false, xmlElement.isRequired());
- }
-
- public void testUpdateRequired() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElement.getSpecifiedRequired());
- assertEquals(false, xmlElement.isDefaultRequired());
- assertEquals(false, xmlElement.isRequired());
-
-
- //add a required member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addXmlElementMemberValuePair(declaration, JAXB.XML_ELEMENT__REQUIRED, true);
- }
- });
- assertEquals(Boolean.TRUE, xmlElement.getSpecifiedRequired());
- assertEquals(false, xmlElement.isDefaultRequired());
- assertEquals(true, xmlElement.isRequired());
-
- //remove the required member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementAnnotation = (NormalAnnotation) GenericJavaXmlElementMappingTests.this.getXmlElementAnnotation(declaration);
- GenericJavaXmlElementMappingTests.this.values(xmlElementAnnotation).remove(0);
- }
- });
- assertNull(xmlElement.getSpecifiedRequired());
- assertEquals(false, xmlElement.isDefaultRequired());
- assertEquals(false, xmlElement.isRequired());
- }
-
- public void testModifyNillable() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElement.getSpecifiedNillable());
- assertEquals(false, xmlElement.isDefaultNillable());
- assertEquals(false, xmlElement.isNillable());
-
- xmlElement.setSpecifiedNillable(Boolean.TRUE);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
- assertEquals(Boolean.TRUE, xmlElementAnnotation.getNillable());
- assertEquals(Boolean.TRUE, xmlElement.getSpecifiedNillable());
- assertEquals(false, xmlElement.isDefaultNillable());
- assertEquals(true, xmlElement.isNillable());
-
- xmlElement.setSpecifiedNillable(null);
- xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
- assertNull(xmlElementAnnotation.getName());
- assertNull(xmlElement.getSpecifiedNillable());
- assertEquals(false, xmlElement.isDefaultNillable());
- assertEquals(false, xmlElement.isNillable());
- }
-
- public void testUpdateNillable() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElement.getSpecifiedNillable());
- assertEquals(false, xmlElement.isDefaultNillable());
- assertEquals(false, xmlElement.isNillable());
-
-
- //add a nillable member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addXmlElementMemberValuePair(declaration, JAXB.XML_ELEMENT__NILLABLE, true);
- }
- });
- assertEquals(Boolean.TRUE, xmlElement.getSpecifiedNillable());
- assertEquals(false, xmlElement.isDefaultNillable());
- assertEquals(true, xmlElement.isNillable());
-
- //remove the nillable member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementAnnotation = (NormalAnnotation) GenericJavaXmlElementMappingTests.this.getXmlElementAnnotation(declaration);
- GenericJavaXmlElementMappingTests.this.values(xmlElementAnnotation).remove(0);
- }
- });
- assertNull(xmlElement.getSpecifiedNillable());
- assertEquals(false, xmlElement.isDefaultNillable());
- assertEquals(false, xmlElement.isNillable());
- }
-
- public void testDefaultNillable() throws Exception {
- createXmlTypeWithVariousAttributes();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
-
- // string
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = persistentAttribute.getJavaResourceAttribute();
-
- assertEquals(false, xmlElement.isDefaultNillable());
-
- annotatedElement(resourceAttribute).edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ELEMENT);
- }
- });
-
- assertEquals(false, xmlElement.isDefaultNillable());
-
- // string list
- persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 1);
- xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- xmlElement = xmlElementMapping.getXmlElement();
- resourceAttribute = persistentAttribute.getJavaResourceAttribute();
-
- assertEquals(true, xmlElement.isDefaultNillable());
-
- annotatedElement(resourceAttribute).edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ELEMENT);
- }
- });
-
- assertEquals(false, xmlElement.isDefaultNillable());
-
- // string array
- persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 2);
- xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- xmlElement = xmlElementMapping.getXmlElement();
- resourceAttribute = persistentAttribute.getJavaResourceAttribute();
-
- assertEquals(true, xmlElement.isDefaultNillable());
-
- annotatedElement(resourceAttribute).edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ELEMENT);
- }
- });
-
- assertEquals(false, xmlElement.isDefaultNillable());
- }
-
- public void testModifyDefaultValue() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElement.getDefaultValue());
-
- xmlElement.setDefaultValue("foo");
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
- assertEquals("foo", xmlElementAnnotation.getDefaultValue());
- assertEquals("foo", xmlElement.getDefaultValue());
-
- xmlElement.setDefaultValue(null);
- xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
- assertNull(xmlElementAnnotation.getDefaultValue());
- assertNull(xmlElement.getDefaultValue());
- }
-
- public void testUpdateDefaultValue() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElement.getDefaultValue());
-
-
- //add a DefaultValue member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addXmlElementMemberValuePair(declaration, JAXB.XML_ELEMENT__DEFAULT_VALUE, "foo");
- }
- });
- assertEquals("foo", xmlElement.getDefaultValue());
-
- //remove the DefaultValue member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementAnnotation = (NormalAnnotation) GenericJavaXmlElementMappingTests.this.getXmlElementAnnotation(declaration);
- GenericJavaXmlElementMappingTests.this.values(xmlElementAnnotation).remove(0);
- }
- });
- assertNull(xmlElement.getDefaultValue());
- }
-
- public void testModifyType() throws Exception {
- createTypeWithXmlElement();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
-
- assertNull(xmlElement.getSpecifiedType());
- assertEquals("int", xmlElement.getType());
- assertEquals("int", xmlElement.getDefaultType());
-
- xmlElement.setSpecifiedType("Foo");
- assertEquals("Foo", xmlElement.getSpecifiedType());
- assertEquals("Foo", xmlElement.getType());
-
- xmlElement.setSpecifiedType(null);
- assertNull(xmlElement.getSpecifiedType());
- assertEquals("int", xmlElement.getType());
- }
-
- public void testUpdateType() throws Exception {
- createTypeWithXmlElement();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- XmlElement xmlElement = xmlElementMapping.getXmlElement();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElement.getSpecifiedType());
- assertEquals("int", xmlElement.getDefaultType());
- assertEquals("int", xmlElement.getType());
-
- //add a Type member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addXmlElementTypeMemberValuePair(declaration, JAXB.XML_ELEMENT__TYPE, "Foo");
- }
- });
- assertEquals("Foo", xmlElement.getSpecifiedType());
- assertEquals("Foo", xmlElement.getType());
-
- //remove the Type member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementAnnotation = (NormalAnnotation) GenericJavaXmlElementMappingTests.this.getXmlElementAnnotation(declaration);
- GenericJavaXmlElementMappingTests.this.values(xmlElementAnnotation).remove(0);
- }
- });
- assertNull(xmlElement.getSpecifiedType());
- assertEquals("int", xmlElement.getType());
- }
-
- public void testChangeMappingType() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNotNull(xmlElementMapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
-
- persistentAttribute.setMappingKey(MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- assertNotNull(xmlAttributeMapping);
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
-
-
- persistentAttribute.setMappingKey(MappingKeys.XML_ELEMENT_ATTRIBUTE_MAPPING_KEY);
- xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- assertNotNull(xmlElementMapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
- }
-
- public void testModifyXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlElementMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
- xmlElementMapping.addXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlElementMapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- xmlElementMapping.removeXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlElementMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
-
- public void testUpdateXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlElementMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
-
- //add an XmlJavaTypeAdapter annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlElementMapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- //remove the XmlJavaTypeAdapter annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlElementMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
-
- public void testModifyXmlSchemaType() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlSchemaTypeAnnotation xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNull(xmlElementMapping.getXmlSchemaType());
- assertNull(xmlSchemaTypeAnnotation);
-
- xmlElementMapping.addXmlSchemaType();
- xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNotNull(xmlElementMapping.getXmlSchemaType());
- assertNotNull(xmlSchemaTypeAnnotation);
-
- xmlElementMapping.removeXmlSchemaType();
- xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- }
-
- public void testUpdateXmlSchemaType() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlSchemaTypeAnnotation xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNull(xmlElementMapping.getXmlSchemaType());
- assertNull(xmlSchemaTypeAnnotation);
-
-
- //add an XmlSchemaType annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_SCHEMA_TYPE);
- }
- });
- xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNotNull(xmlElementMapping.getXmlSchemaType());
- assertNotNull(xmlSchemaTypeAnnotation);
-
- //remove the XmlSchemaType annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.removeAnnotation(declaration, JAXB.XML_SCHEMA_TYPE);
- }
- });
- xmlSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNull(xmlElementMapping.getXmlSchemaType());
- assertNull(xmlSchemaTypeAnnotation);
- }
-
- protected void addXmlElementMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlElementAnnotation(declaration), name, value);
- }
-
- protected void addXmlElementMemberValuePair(ModifiedDeclaration declaration, String name, boolean value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlElementAnnotation(declaration), name, value);
- }
-
- protected void addXmlElementTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlElementAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected Annotation getXmlElementAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_ELEMENT);
- }
-
-
- public void testModifyXmlElementWrapper() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNull(xmlElementMapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
-
- xmlElementMapping.addXmlElementWrapper();
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNotNull(xmlElementMapping.getXmlElementWrapper());
- assertNotNull(xmlElementWrapperAnnotation);
-
- xmlElementMapping.removeXmlElementWrapper();
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- }
-
- public void testUpdateXmlElementWrapper() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNull(xmlElementMapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
-
-
- //add an XmlElementWrapper annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ELEMENT_WRAPPER);
- }
- });
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNotNull(xmlElementMapping.getXmlElementWrapper());
- assertNotNull(xmlElementWrapperAnnotation);
-
- //remove the XmlElementWrapper annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.removeAnnotation(declaration, JAXB.XML_ELEMENT_WRAPPER);
- }
- });
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNull(xmlElementMapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
- }
-
- public void testModifyXmlList1() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertFalse(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertFalse(xmlElementMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlElementMapping.setSpecifiedXmlList(true);
-
- assertTrue(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertTrue(xmlElementMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlElementMapping.setSpecifiedXmlList(false);
-
- assertFalse(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertFalse(xmlElementMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-
- public void testModifyXmlList2() throws Exception {
- createTypeWithCollectionXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertFalse(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertFalse(xmlElementMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlElementMapping.setSpecifiedXmlList(true);
-
- assertTrue(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertTrue(xmlElementMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlElementMapping.setSpecifiedXmlList(false);
-
- assertFalse(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertFalse(xmlElementMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-
- public void testUpdateXmlList1() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertFalse(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertFalse(xmlElementMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //add an XmlList annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_LIST);
- }
- });
-
- assertTrue(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertTrue(xmlElementMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //remove the XmlList annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.removeAnnotation(declaration, JAXB.XML_LIST);
- }
- });
-
- assertFalse(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertFalse(xmlElementMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-
- public void testUpdateXmlList2() throws Exception {
- createTypeWithCollectionXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertFalse(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertFalse(xmlElementMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //add an XmlList annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_LIST);
- }
- });
-
- assertTrue(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertTrue(xmlElementMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //remove the XmlList annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.removeAnnotation(declaration, JAXB.XML_LIST);
- }
- });
-
- assertFalse(xmlElementMapping.isXmlList());
- assertFalse(xmlElementMapping.isDefaultXmlList());
- assertFalse(xmlElementMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-
- public void testModifyXmlID() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlIDAnnotation xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- assertNull(xmlElementMapping.getXmlID());
- assertNull(xmlIDAnnotation);
-
- xmlElementMapping.addXmlID();
- xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- assertNotNull(xmlElementMapping.getXmlID());
- assertNotNull(xmlIDAnnotation);
-
- xmlElementMapping.removeXmlID();
- xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- }
-
- public void testUpdateXmlID() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlIDAnnotation xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- assertNull(xmlElementMapping.getXmlID());
- assertNull(xmlIDAnnotation);
-
-
- //add an XmlID annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ID);
- }
- });
- xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- assertNotNull(xmlElementMapping.getXmlID());
- assertNotNull(xmlIDAnnotation);
-
- //remove the XmlID annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.removeAnnotation(declaration, JAXB.XML_ID);
- }
- });
- xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
- assertNull(xmlElementMapping.getXmlID());
- assertNull(xmlIDAnnotation);
- }
-
- public void testModifyXmlIDREF() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlIDREFAnnotation xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- assertNull(xmlElementMapping.getXmlIDREF());
- assertNull(xmlIDREFAnnotation);
-
- xmlElementMapping.addXmlIDREF();
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- assertNotNull(xmlElementMapping.getXmlIDREF());
- assertNotNull(xmlIDREFAnnotation);
-
- xmlElementMapping.removeXmlIDREF();
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- assertNull(xmlElementMapping.getXmlIDREF());
- assertNull(xmlIDREFAnnotation);
- }
-
- public void testUpdateXmlIDREF() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlIDREFAnnotation xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- assertNull(xmlElementMapping.getXmlIDREF());
- assertNull(xmlIDREFAnnotation);
-
-
- //add an XmlIDREF annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_IDREF);
- }
- });
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- assertNotNull(xmlElementMapping.getXmlIDREF());
- assertNotNull(xmlIDREFAnnotation);
-
- //remove the XmlIDREF annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.removeAnnotation(declaration, JAXB.XML_IDREF);
- }
- });
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
- assertNull(xmlElementMapping.getXmlIDREF());
- assertNull(xmlIDREFAnnotation);
- }
-
- public void testModifyXmlAttachmentRef() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlAttachmentRefAnnotation xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- assertNull(xmlElementMapping.getXmlAttachmentRef());
- assertNull(xmlAttachmentRefAnnotation);
-
- xmlElementMapping.addXmlAttachmentRef();
- xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- assertNotNull(xmlElementMapping.getXmlAttachmentRef());
- assertNotNull(xmlAttachmentRefAnnotation);
-
- xmlElementMapping.removeXmlAttachmentRef();
- xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- }
-
- public void testUpdateXmlAttachmentRef() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlAttachmentRefAnnotation xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- assertNull(xmlElementMapping.getXmlAttachmentRef());
- assertNull(xmlAttachmentRefAnnotation);
-
-
- //add an XmlAttachmentRef annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTACHMENT_REF);
- }
- });
- xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- assertNotNull(xmlElementMapping.getXmlAttachmentRef());
- assertNotNull(xmlAttachmentRefAnnotation);
-
- //remove the XmlAttachmentRef annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTACHMENT_REF);
- }
- });
- xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
- assertNull(xmlElementMapping.getXmlAttachmentRef());
- assertNull(xmlAttachmentRefAnnotation);
- }
-
-} \ No newline at end of file
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefMappingTests.java
deleted file mode 100644
index 96a910d5de..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefMappingTests.java
+++ /dev/null
@@ -1,594 +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.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-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.XmlAttributeMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlElementRef;
-import org.eclipse.jpt.jaxb.core.context.XmlElementRefMapping;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementWrapperAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlMixedAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-public class GenericJavaXmlElementRefMappingTests
- extends JaxbContextModelTestCase {
-
- public GenericJavaXmlElementRefMappingTests(String name) {
- super(name);
- }
-
-
- private ICompilationUnit createTypeWithXmlElementRef() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ELEMENT_REF);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlElementRef");
- }
- });
- }
-
- private ICompilationUnit createTypeWithJAXBElementXmlElementRef() throws Exception {
- return this.createTestType(TYPE_NAME + "2", new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ELEMENT_REF, JAXB.JAXB_ELEMENT);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlElementRef").append(CR);
- sb.append("private JAXBElement foo;").append(CR).append(CR);
- }
- });
- }
-
- private ICompilationUnit createTypeWithRootElementXmlElementRef() throws Exception {
- return this.createTestType(TYPE_NAME + "3", new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ELEMENT_REF, JAXB.XML_ROOT_ELEMENT);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType").append(CR);
- sb.append("@XmlRootElement(name=\"foo\")");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlElementRef").append(CR);
- sb.append("private " + TYPE_NAME + "3 foo;").append(CR).append(CR);
- }
- });
- }
-
-
- public void testDefaultName() throws Exception {
- createTypeWithXmlElementRef();
- createTypeWithJAXBElementXmlElementRef(); // FULLY_QUALIFIED_TYPE_NAME + "2"
- createTypeWithRootElementXmlElementRef(); // FULLY_QUALIFIED_TYPE_NAME + "3"
-
- JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
- XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
-
- // XmlElementRef type is java.lang.String -> no default name or namespace
- assertEquals("", xmlElementRef.getQName().getName());
- assertEquals("", xmlElementRef.getQName().getNamespace());
-
- classMapping = ((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME + "2")).getMapping();
- xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- xmlElementRef = xmlElementRefMapping.getXmlElementRef();
-
- // XmlElementRef type is JAXBElement -> default name is name of attribute
- assertEquals("foo", xmlElementRef.getQName().getName());
- assertEquals("", xmlElementRef.getQName().getNamespace());
-
- classMapping = ((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME + "3")).getMapping();
- xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- xmlElementRef = xmlElementRefMapping.getXmlElementRef();
-
- // XmlElementRef type is type with root element -> default name is root element name
- assertEquals("foo", xmlElementRef.getQName().getName());
- assertEquals("", xmlElementRef.getQName().getNamespace());
- }
-
- public void testModifyName() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElementRef.getQName().getSpecifiedName());
- assertEquals("", xmlElementRef.getQName().getDefaultName());
- assertEquals("", xmlElementRef.getQName().getName());
-
- xmlElementRef.getQName().setSpecifiedName("foo");
- XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
- assertEquals("foo", xmlElementRefAnnotation.getName());
- assertEquals("foo", xmlElementRef.getQName().getSpecifiedName());
- assertEquals("foo", xmlElementRef.getQName().getName());
-
- xmlElementRef.getQName().setSpecifiedName(null);
- xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
- assertNull(xmlElementRefAnnotation.getName());
- assertNull(xmlElementRef.getQName().getSpecifiedName());
- }
-
- public void testUpdateName() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElementRef.getQName().getSpecifiedName());
-
-
- //add a Name member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefMappingTests.this.addXmlElementRefMemberValuePair(declaration, JAXB.XML_ELEMENT_REF__NAME, "foo");
- }
- });
- assertEquals("foo", xmlElementRef.getQName().getName());
-
- //remove the Name member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementRefAnnotation = (NormalAnnotation) GenericJavaXmlElementRefMappingTests.this.getXmlElementRefAnnotation(declaration);
- GenericJavaXmlElementRefMappingTests.this.values(xmlElementRefAnnotation).remove(0);
- }
- });
- assertNull(xmlElementRef.getQName().getSpecifiedName());
- }
-
- public void testModifyNamespace() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElementRef.getQName().getSpecifiedNamespace());
-
- xmlElementRef.getQName().setSpecifiedNamespace("foo");
- XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
- assertEquals("foo", xmlElementRefAnnotation.getNamespace());
- assertEquals("foo", xmlElementRef.getQName().getNamespace());
-
- xmlElementRef.getQName().setSpecifiedNamespace(null);
- xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
- assertNull(xmlElementRefAnnotation.getNamespace());
- assertNull(xmlElementRef.getQName().getSpecifiedNamespace());
- }
-
- public void testUpdateNamespace() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElementRef.getQName().getSpecifiedNamespace());
-
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefMappingTests.this.addXmlElementRefMemberValuePair(declaration, JAXB.XML_ELEMENT_REF__NAMESPACE, "foo");
- }
- });
- assertEquals("foo", xmlElementRef.getQName().getNamespace());
-
- //remove the namespace member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementRefAnnotation = (NormalAnnotation) GenericJavaXmlElementRefMappingTests.this.getXmlElementRefAnnotation(declaration);
- GenericJavaXmlElementRefMappingTests.this.values(xmlElementRefAnnotation).remove(0);
- }
- });
- assertNull(xmlElementRef.getQName().getSpecifiedNamespace());
- }
-
- public void testModifyRequired() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElementRef.getSpecifiedRequired());
- assertEquals(false, xmlElementRef.isDefaultRequired());
- assertEquals(false, xmlElementRef.isRequired());
-
- xmlElementRef.setSpecifiedRequired(Boolean.TRUE);
- XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
- assertEquals(Boolean.TRUE, xmlElementRefAnnotation.getRequired());
- assertEquals(Boolean.TRUE, xmlElementRef.getSpecifiedRequired());
- assertEquals(false, xmlElementRef.isDefaultRequired());
- assertEquals(true, xmlElementRef.isRequired());
-
- xmlElementRef.setSpecifiedRequired(null);
- xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
- assertNull(xmlElementRefAnnotation.getName());
- assertNull(xmlElementRef.getSpecifiedRequired());
- assertEquals(false, xmlElementRef.isDefaultRequired());
- assertEquals(false, xmlElementRef.isRequired());
- }
-
- public void testUpdateRequired() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElementRef.getSpecifiedRequired());
- assertEquals(false, xmlElementRef.isDefaultRequired());
- assertEquals(false, xmlElementRef.isRequired());
-
-
- //add a required member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefMappingTests.this.addXmlElementRefMemberValuePair(declaration, JAXB.XML_ELEMENT_REF__REQUIRED, true);
- }
- });
- assertEquals(Boolean.TRUE, xmlElementRef.getSpecifiedRequired());
- assertEquals(false, xmlElementRef.isDefaultRequired());
- assertEquals(true, xmlElementRef.isRequired());
-
- //remove the required member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementRefAnnotation = (NormalAnnotation) GenericJavaXmlElementRefMappingTests.this.getXmlElementRefAnnotation(declaration);
- GenericJavaXmlElementRefMappingTests.this.values(xmlElementRefAnnotation).remove(0);
- }
- });
- assertNull(xmlElementRef.getSpecifiedRequired());
- assertEquals(false, xmlElementRef.isDefaultRequired());
- assertEquals(false, xmlElementRef.isRequired());
- }
-
- public void testModifyType() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
-
- assertNull(xmlElementRef.getSpecifiedType());
- assertEquals("int", xmlElementRef.getType());
- assertEquals("int", xmlElementRef.getDefaultType());
-
- xmlElementRef.setSpecifiedType("Foo");
- assertEquals("Foo", xmlElementRef.getSpecifiedType());
- assertEquals("Foo", xmlElementRef.getType());
-
- xmlElementRef.setSpecifiedType(null);
- assertNull(xmlElementRef.getSpecifiedType());
- assertEquals("int", xmlElementRef.getType());
- }
-
- public void testUpdateType() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlElementRef.getSpecifiedType());
- assertEquals("int", xmlElementRef.getDefaultType());
- assertEquals("int", xmlElementRef.getType());
-
- //add a Type member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefMappingTests.this.addXmlElementRefTypeMemberValuePair(declaration, JAXB.XML_ELEMENT_REF__TYPE, "Foo");
- }
- });
- assertEquals("Foo", xmlElementRef.getSpecifiedType());
- assertEquals("Foo", xmlElementRef.getType());
-
- //remove the Type member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlElementRefAnnotation = (NormalAnnotation) GenericJavaXmlElementRefMappingTests.this.getXmlElementRefAnnotation(declaration);
- GenericJavaXmlElementRefMappingTests.this.values(xmlElementRefAnnotation).remove(0);
- }
- });
- assertNull(xmlElementRef.getSpecifiedType());
- assertEquals("int", xmlElementRef.getType());
- }
-
- public void testChangeMappingType() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNotNull(xmlElementRefMapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF));
-
- persistentAttribute.setMappingKey(MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- assertNotNull(xmlAttributeMapping);
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF));
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
-
-
- persistentAttribute.setMappingKey(MappingKeys.XML_ELEMENT_REF_ATTRIBUTE_MAPPING_KEY);
- xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
- assertNotNull(xmlElementRefMapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF));
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
- }
-
- public void testModifyXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlElementRefMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
- xmlElementRefMapping.addXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlElementRefMapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- xmlElementRefMapping.removeXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlElementRefMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
-
- public void testUpdateXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlElementRefMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
-
- //add an XmlJavaTypeAdapter annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlElementRefMapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- //remove the XmlJavaTypeAdapter annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefMappingTests.this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlElementRefMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
-
- protected void addXmlElementRefMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlElementRefAnnotation(declaration), name, value);
- }
-
- protected void addXmlElementRefMemberValuePair(ModifiedDeclaration declaration, String name, boolean value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlElementRefAnnotation(declaration), name, value);
- }
-
- protected void addXmlElementRefTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlElementRefAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected Annotation getXmlElementRefAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_ELEMENT_REF);
- }
-
-
- public void testModifyXmlElementWrapper() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNull(xmlElementRefMapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
-
- xmlElementRefMapping.addXmlElementWrapper();
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNotNull(xmlElementRefMapping.getXmlElementWrapper());
- assertNotNull(xmlElementWrapperAnnotation);
-
- xmlElementRefMapping.removeXmlElementWrapper();
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- }
-
- public void testUpdateXmlElementRefWrapper() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNull(xmlElementRefMapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
-
- //add an XmlElementWrapper annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ELEMENT_WRAPPER);
- }
- });
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNotNull(xmlElementRefMapping.getXmlElementWrapper());
- assertNotNull(xmlElementWrapperAnnotation);
-
- //remove the XmlElementWrapper annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefMappingTests.this.removeAnnotation(declaration, JAXB.XML_ELEMENT_WRAPPER);
- }
- });
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNull(xmlElementRefMapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
- }
-
- public void testModifyXmlMixed() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefMapping attributeMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlMixedAnnotation annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(attributeMapping.getXmlMixed());
- assertNull(annotation);
-
- attributeMapping.addXmlMixed();
- annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNotNull(attributeMapping.getXmlMixed());
- assertNotNull(annotation);
-
- attributeMapping.removeXmlMixed();
- annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(attributeMapping.getXmlMixed());
- assertNull(annotation);
- }
-
- public void testUpdateXmlMixed() throws Exception {
- createTypeWithXmlElementRef();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefMapping attributeMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlMixedAnnotation annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(attributeMapping.getXmlMixed());
- assertNull(annotation);
-
- //add an XmlMixed annotation
- AnnotatedElement annotatedElement = annotatedElement(resourceAttribute);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_MIXED);
- }
- });
- annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNotNull(attributeMapping.getXmlMixed());
- assertNotNull(annotation);
-
- //remove the XmlMixed annotation
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefMappingTests.this.removeAnnotation(declaration, JAXB.XML_MIXED);
- }
- });
- annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(attributeMapping.getXmlMixed());
- assertNull(annotation);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefsMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefsMappingTests.java
deleted file mode 100644
index 2d74ff09a3..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefsMappingTests.java
+++ /dev/null
@@ -1,415 +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.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-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.XmlAttributeMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlElementRef;
-import org.eclipse.jpt.jaxb.core.context.XmlElementRefsMapping;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefsAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementWrapperAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlMixedAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-public class GenericJavaXmlElementRefsMappingTests
- extends JaxbContextModelTestCase {
-
- public GenericJavaXmlElementRefsMappingTests(String name) {
- super(name);
- }
-
-
- private ICompilationUnit createTypeWithXmlElementRefs() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ELEMENT_REFS);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlElementRefs");
- }
- });
- }
-
- protected Annotation getXmlElementRefsAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_ELEMENT_REFS);
- }
-
- protected void addXmlElementRefsMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- addMemberValuePair((MarkerAnnotation) this.getXmlElementRefsAnnotation(declaration), name, value);
- }
-
- protected void addXmlElementRefsMemberValuePair(ModifiedDeclaration declaration, String name, boolean value) {
- addMemberValuePair((MarkerAnnotation) getXmlElementRefsAnnotation(declaration), name, value);
- }
-
- protected void addXmlElementRefsTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- addMemberValuePair(
- (MarkerAnnotation) getXmlElementRefsAnnotation(declaration),
- name,
- newTypeLiteral(declaration.getAst(), typeName));
- }
-
-
- // ***** XmlElementRefs *****
-
- protected NormalAnnotation newXmlElementRefAnnotation(AST ast, String name) {
- NormalAnnotation annotation = newNormalAnnotation(ast, JAXB.XML_ELEMENT_REF);
- addMemberValuePair(annotation, JAXB.XML_ELEMENT_REF__NAME, name);
- return annotation;
- }
-
- protected void addXmlElementRef(ModifiedDeclaration declaration, int index, String name) {
- NormalAnnotation arrayElement = newXmlElementRefAnnotation(declaration.getAst(), name);
- addArrayElement(declaration, JAXB.XML_ELEMENT_REFS, index, JAXB.XML_ELEMENT_REFS__VALUE, arrayElement);
- }
-
- protected void moveXmlElementRef(ModifiedDeclaration declaration, int targetIndex, int sourceIndex) {
- moveArrayElement((NormalAnnotation) declaration.getAnnotationNamed(JAXB.XML_ELEMENT_REFS), JAXB.XML_ELEMENT_REFS__VALUE, targetIndex, sourceIndex);
- }
-
- protected void removeXmlElementRef(ModifiedDeclaration declaration, int index) {
- removeArrayElement((NormalAnnotation) declaration.getAnnotationNamed(JAXB.XML_ELEMENT_REFS), JAXB.XML_ELEMENT_REFS__VALUE, index);
- }
-
- public void testSyncXmlElementRefs() throws Exception {
- createTypeWithXmlElementRefs();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementRefsMapping mapping = (XmlElementRefsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- Iterable<XmlElementRef> xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
- assertTrue(CollectionTools.isEmpty(xmlElementRefs));
- assertEquals(0, mapping.getXmlElementRefs().getXmlElementRefsSize());
-
- //add 2 XmlElementRef annotations
- AnnotatedElement annotatedElement = annotatedElement(resourceAttribute);
- annotatedElement.edit(
- new Member.Editor() {
-
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefsMappingTests.this.addXmlElementRef(declaration, 0, "foo");
- GenericJavaXmlElementRefsMappingTests.this.addXmlElementRef(declaration, 1, "bar");
- }
- });
-
- xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
-
- assertFalse(CollectionTools.isEmpty(mapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(2, mapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("foo", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
- assertEquals("bar", CollectionTools.get(xmlElementRefs, 1).getQName().getName());
-
- // switch XmlElementRef annotations
- annotatedElement.edit(
- new Member.Editor() {
-
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefsMappingTests.this.moveXmlElementRef(declaration, 0, 1);
- }
- });
-
- xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
-
- assertFalse(CollectionTools.isEmpty(mapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(2, mapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("bar", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
- assertEquals("foo", CollectionTools.get(xmlElementRefs, 1).getQName().getName());
-
- // remove XmlElementRef annotations
- annotatedElement.edit(
- new Member.Editor() {
-
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefsMappingTests.this.removeXmlElementRef(declaration, 1);
- GenericJavaXmlElementRefsMappingTests.this.removeXmlElementRef(declaration, 0);
- }
- });
-
- xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
-
- assertTrue(CollectionTools.isEmpty(xmlElementRefs));
- assertEquals(0, mapping.getXmlElementRefs().getXmlElementRefsSize());
- }
-
- public void testModifyXmlElementRefs() throws Exception {
- createTypeWithXmlElementRefs();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementRefsMapping mapping = (XmlElementRefsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
- XmlElementRefsAnnotation annotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
-
- Iterable<XmlElementRefAnnotation> annotations = annotation.getXmlElementRefs();
-
- assertEquals(0, annotation.getXmlElementRefsSize());
- assertEquals(0, mapping.getXmlElementRefs().getXmlElementRefsSize());
-
- mapping.getXmlElementRefs().addXmlElementRef(0).getQName().setSpecifiedName("foo");
- mapping.getXmlElementRefs().addXmlElementRef(1).getQName().setSpecifiedName("baz");
- mapping.getXmlElementRefs().addXmlElementRef(1).getQName().setSpecifiedName("bar");
-
- annotations = annotation.getXmlElementRefs();
-
- assertEquals(3, annotation.getXmlElementRefsSize());
- assertEquals(3, mapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("foo", CollectionTools.get(annotations, 0).getName());
- assertEquals("bar", CollectionTools.get(annotations, 1).getName());
- assertEquals("baz", CollectionTools.get(annotations, 2).getName());
-
- mapping.getXmlElementRefs().moveXmlElementRef(1, 2);
-
- annotations = annotation.getXmlElementRefs();
-
- assertEquals(3, annotation.getXmlElementRefsSize());
- assertEquals(3, mapping.getXmlElementRefs().getXmlElementRefsSize());
- assertEquals("foo", CollectionTools.get(annotations, 0).getName());
- assertEquals("baz", CollectionTools.get(annotations, 1).getName());
- assertEquals("bar", CollectionTools.get(annotations, 2).getName());
-
- mapping.getXmlElementRefs().removeXmlElementRef(2);
- mapping.getXmlElementRefs().removeXmlElementRef(0);
- mapping.getXmlElementRefs().removeXmlElementRef(0);
-
- assertEquals(0, annotation.getXmlElementRefsSize());
- assertEquals(0, mapping.getXmlElementRefs().getXmlElementRefsSize());
- }
-
- public void testChangeMappingType() throws Exception {
- createTypeWithXmlElementRefs();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNotNull(mapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS));
-
- persistentAttribute.setMappingKey(MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- assertNotNull(xmlAttributeMapping);
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS));
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
-
- persistentAttribute.setMappingKey(MappingKeys.XML_ELEMENT_REFS_ATTRIBUTE_MAPPING_KEY);
- mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
- assertNotNull(mapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS));
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
- }
-
- public void testModifyXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlElementRefs();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(mapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
- mapping.addXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(mapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- mapping.removeXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(mapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
-
- public void testUpdateXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlElementRefs();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(mapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
-
- //add an XmlJavaTypeAdapter annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefsMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(mapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- //remove the XmlJavaTypeAdapter annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefsMappingTests.this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(mapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
-
- public void testModifyXmlElementWrapper() throws Exception {
- createTypeWithXmlElementRefs();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNull(mapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
-
- mapping.addXmlElementWrapper();
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNotNull(mapping.getXmlElementWrapper());
- assertNotNull(xmlElementWrapperAnnotation);
-
- mapping.removeXmlElementWrapper();
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- }
-
- public void testUpdateXmlElementWrapper() throws Exception {
- createTypeWithXmlElementRefs();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNull(mapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
-
- //add an XmlElementWrapper annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefsMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ELEMENT_WRAPPER);
- }
- });
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNotNull(mapping.getXmlElementWrapper());
- assertNotNull(xmlElementWrapperAnnotation);
-
- //remove the XmlElementWrapper annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefsMappingTests.this.removeAnnotation(declaration, JAXB.XML_ELEMENT_WRAPPER);
- }
- });
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- assertNull(mapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
- }
-
- public void testModifyXmlMixed() throws Exception {
- createTypeWithXmlElementRefs();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlMixedAnnotation annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(mapping.getXmlMixed());
- assertNull(annotation);
-
- mapping.addXmlMixed();
- annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNotNull(mapping.getXmlMixed());
- assertNotNull(annotation);
-
- mapping.removeXmlMixed();
- annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(mapping.getXmlMixed());
- assertNull(annotation);
- }
-
- public void testUpdateXmlMixed() throws Exception {
- createTypeWithXmlElementRefs();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlMixedAnnotation annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(mapping.getXmlMixed());
- assertNull(annotation);
-
- //add an XmlMixed annotation
- AnnotatedElement annotatedElement = annotatedElement(resourceAttribute);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefsMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_MIXED);
- }
- });
- annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNotNull(mapping.getXmlMixed());
- assertNotNull(annotation);
-
- //remove the XmlMixed annotation
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementRefsMappingTests.this.removeAnnotation(declaration, JAXB.XML_MIXED);
- }
- });
- annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(mapping.getXmlMixed());
- assertNull(annotation);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementsMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementsMappingTests.java
deleted file mode 100644
index 8b5d73cb67..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementsMappingTests.java
+++ /dev/null
@@ -1,371 +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.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-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.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlElement;
-import org.eclipse.jpt.jaxb.core.context.XmlElementsMapping;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementWrapperAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementsAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlIDREFAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-public class GenericJavaXmlElementsMappingTests
- extends JaxbContextModelTestCase {
-
- public GenericJavaXmlElementsMappingTests(String name) {
- super(name);
- }
-
-
- private ICompilationUnit createTypeWithXmlElements() throws Exception {
- return this.createTestType(
- new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ELEMENTS);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlElements");
- }
- });
- }
-
-
- // ***** XmlElements *****
-
- protected NormalAnnotation newXmlElementAnnotation(AST ast, String name) {
- NormalAnnotation annotation = newNormalAnnotation(ast, JAXB.XML_ELEMENT);
- addMemberValuePair(annotation, JAXB.XML_ELEMENT__NAME, name);
- return annotation;
- }
-
- protected void addXmlElement(ModifiedDeclaration declaration, int index, String name) {
- NormalAnnotation arrayElement = newXmlElementAnnotation(declaration.getAst(), name);
- addArrayElement(declaration, JAXB.XML_ELEMENTS, index, JAXB.XML_ELEMENTS__VALUE, arrayElement);
- }
-
- protected void moveXmlElement(ModifiedDeclaration declaration, int targetIndex, int sourceIndex) {
- moveArrayElement((NormalAnnotation) declaration.getAnnotationNamed(JAXB.XML_ELEMENTS), JAXB.XML_ELEMENTS__VALUE, targetIndex, sourceIndex);
- }
-
- protected void removeXmlElement(ModifiedDeclaration declaration, int index) {
- removeArrayElement((NormalAnnotation) declaration.getAnnotationNamed(JAXB.XML_ELEMENTS), JAXB.XML_ELEMENTS__VALUE, index);
- }
-
- public void testSyncXmlElements() throws Exception {
- createTypeWithXmlElements();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- Iterable<XmlElement> xmlElements = mapping.getXmlElements();
- assertTrue(CollectionTools.isEmpty(xmlElements));
- assertEquals(0, mapping.getXmlElementsSize());
-
- //add 2 XmlElement annotations
- AnnotatedElement annotatedElement = annotatedElement(resourceAttribute);
- annotatedElement.edit(
- new Member.Editor() {
-
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementsMappingTests.this.addXmlElement(declaration, 0, "foo");
- GenericJavaXmlElementsMappingTests.this.addXmlElement(declaration, 1, "bar");
- }
- });
-
- xmlElements = mapping.getXmlElements();
-
- assertFalse(CollectionTools.isEmpty(mapping.getXmlElements()));
- assertEquals(2, mapping.getXmlElementsSize());
- assertEquals("foo", CollectionTools.get(xmlElements, 0).getQName().getName());
- assertEquals("bar", CollectionTools.get(xmlElements, 1).getQName().getName());
-
- // switch XmlElement annotations
- annotatedElement.edit(
- new Member.Editor() {
-
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementsMappingTests.this.moveXmlElement(declaration, 0, 1);
- }
- });
-
- xmlElements = mapping.getXmlElements();
-
- assertFalse(CollectionTools.isEmpty(mapping.getXmlElements()));
- assertEquals(2, mapping.getXmlElementsSize());
- assertEquals("bar", CollectionTools.get(xmlElements, 0).getQName().getName());
- assertEquals("foo", CollectionTools.get(xmlElements, 1).getQName().getName());
-
- // remove XmlElement annotations
- annotatedElement.edit(
- new Member.Editor() {
-
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementsMappingTests.this.removeXmlElement(declaration, 1);
- GenericJavaXmlElementsMappingTests.this.removeXmlElement(declaration, 0);
- }
- });
-
- xmlElements = mapping.getXmlElements();
-
- assertTrue(CollectionTools.isEmpty(xmlElements));
- assertEquals(0, mapping.getXmlElementsSize());
- }
-
- public void testModifyXmlElements() throws Exception {
- createTypeWithXmlElements();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
- XmlElementsAnnotation xmlElementsAnnotation = (XmlElementsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENTS);
-
- Iterable<XmlElementAnnotation> xmlElementAnnotations = xmlElementsAnnotation.getXmlElements();
-
- assertEquals(0, xmlElementsAnnotation.getXmlElementsSize());
- assertEquals(0, mapping.getXmlElementsSize());
-
- mapping.addXmlElement(0).getQName().setSpecifiedName("foo");
- mapping.addXmlElement(1).getQName().setSpecifiedName("baz");
- mapping.addXmlElement(1).getQName().setSpecifiedName("bar");
-
- xmlElementAnnotations = xmlElementsAnnotation.getXmlElements();
-
- assertEquals(3, xmlElementsAnnotation.getXmlElementsSize());
- assertEquals(3, mapping.getXmlElementsSize());
- assertEquals("foo", CollectionTools.get(xmlElementAnnotations, 0).getName());
- assertEquals("bar", CollectionTools.get(xmlElementAnnotations, 1).getName());
- assertEquals("baz", CollectionTools.get(xmlElementAnnotations, 2).getName());
-
- mapping.moveXmlElement(1, 2);
-
- xmlElementAnnotations = xmlElementsAnnotation.getXmlElements();
-
- assertEquals(3, xmlElementsAnnotation.getXmlElementsSize());
- assertEquals(3, mapping.getXmlElementsSize());
- assertEquals("foo", CollectionTools.get(xmlElementAnnotations, 0).getName());
- assertEquals("baz", CollectionTools.get(xmlElementAnnotations, 1).getName());
- assertEquals("bar", CollectionTools.get(xmlElementAnnotations, 2).getName());
-
- mapping.removeXmlElement(2);
- mapping.removeXmlElement(0);
- mapping.removeXmlElement(0);
-
- assertEquals(0, xmlElementsAnnotation.getXmlElementsSize());
- assertEquals(0, mapping.getXmlElementsSize());
- }
-
- public void testModifyXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlElements();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
-
- assertNull(mapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
- mapping.addXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(mapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- mapping.removeXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
-
- assertNull(mapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
-
- public void testUpdateXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlElements();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
-
- assertNull(mapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
- AnnotatedElement annotatedElement = annotatedElement(resourceAttribute);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementsMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
-
- assertNotNull(mapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementsMappingTests.this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
-
- assertNull(mapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
-
- public void testModifyXmlElementWrapper() throws Exception {
- createTypeWithXmlElements();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
-
- assertNull(mapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
-
- mapping.addXmlElementWrapper();
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
-
- assertNotNull(mapping.getXmlElementWrapper());
- assertNotNull(xmlElementWrapperAnnotation);
-
- mapping.removeXmlElementWrapper();
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
-
- assertNull(mapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
- }
-
- public void testUpdateXmlElementWrapper() throws Exception {
- createTypeWithXmlElements();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
-
- assertNull(mapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
-
- AnnotatedElement annotatedElement = annotatedElement(resourceAttribute);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementsMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ELEMENT_WRAPPER);
- }
- });
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
-
- assertNotNull(mapping.getXmlElementWrapper());
- assertNotNull(xmlElementWrapperAnnotation);
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(
- ModifiedDeclaration declaration) {
- GenericJavaXmlElementsMappingTests.this.removeAnnotation(declaration, JAXB.XML_ELEMENT_WRAPPER);
- }
- });
- xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
-
- assertNull(mapping.getXmlElementWrapper());
- assertNull(xmlElementWrapperAnnotation);
- }
-
- public void testModifyXmlIDREF() throws Exception {
- createTypeWithXmlElements();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlIDREFAnnotation xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
-
- assertNull(mapping.getXmlIDREF());
- assertNull(xmlIDREFAnnotation);
-
- mapping.addXmlIDREF();
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
-
- assertNotNull(mapping.getXmlIDREF());
- assertNotNull(xmlIDREFAnnotation);
-
- mapping.removeXmlIDREF();
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
-
- assertNull(mapping.getXmlIDREF());
- assertNull(xmlIDREFAnnotation);
- }
-
- public void testUpdateXmlIDREF() throws Exception {
- createTypeWithXmlElements();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlIDREFAnnotation xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
-
- assertNull(mapping.getXmlIDREF());
- assertNull(xmlIDREFAnnotation);
-
- AnnotatedElement annotatedElement = annotatedElement(resourceAttribute);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementsMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_IDREF);
- }
- });
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
-
- assertNotNull(mapping.getXmlIDREF());
- assertNotNull(xmlIDREFAnnotation);
-
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlElementsMappingTests.this.removeAnnotation(declaration, JAXB.XML_IDREF);
- }
- });
- xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
-
- assertNull(mapping.getXmlIDREF());
- assertNull(xmlIDREFAnnotation);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java
deleted file mode 100644
index c4382408a0..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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.beans.Introspector;
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-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.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlRootElement;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaXmlRootElementTests
- extends JaxbContextModelTestCase {
-
- public GenericJavaXmlRootElementTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTypeWithXmlTypeWithXmlRootElement() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ROOT_ELEMENT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType").append(CR);
- sb.append("@XmlRootElement").append(CR);
- }
- });
- }
-
-
- public void testModifyNamespace() throws Exception {
- createTypeWithXmlTypeWithXmlRootElement();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlRootElement contextRootElement = classMapping.getXmlRootElement();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(contextRootElement.getQName().getSpecifiedNamespace());
- assertEquals("", contextRootElement.getQName().getDefaultNamespace());
- assertEquals("", contextRootElement.getQName().getNamespace());
-
- contextRootElement.getQName().setSpecifiedNamespace("foo");
- XmlRootElementAnnotation rootElementAnnotation = (XmlRootElementAnnotation) resourceType.getAnnotation(JAXB.XML_ROOT_ELEMENT);
- assertEquals("foo", rootElementAnnotation.getNamespace());
- assertEquals("foo", contextRootElement.getQName().getSpecifiedNamespace());
- assertEquals("foo", contextRootElement.getQName().getNamespace());
-
- contextRootElement.getQName().setSpecifiedNamespace(null);
- rootElementAnnotation = (XmlRootElementAnnotation) resourceType.getAnnotation(JAXB.XML_ROOT_ELEMENT);
- assertNull(rootElementAnnotation.getNamespace());
- assertNull(contextRootElement.getQName().getSpecifiedNamespace());
- assertEquals("", contextRootElement.getQName().getNamespace());
- }
-
- public void testUpdateNamespace() throws Exception {
- createTypeWithXmlTypeWithXmlRootElement();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlRootElement contextRootElement = classMapping.getXmlRootElement();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
-
- assertNull(contextRootElement.getQName().getSpecifiedNamespace());
- assertEquals("", contextRootElement.getQName().getDefaultNamespace());
- assertEquals("", contextRootElement.getQName().getNamespace());
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlRootElementTests.this.addXmlRootElementMemberValuePair(declaration, JAXB.XML_ROOT_ELEMENT__NAMESPACE, "foo");
- }
- });
- assertEquals("foo", contextRootElement.getQName().getSpecifiedNamespace());
- assertEquals("foo", contextRootElement.getQName().getNamespace());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlRootElementTests.this.removeAnnotation(declaration, JAXB.XML_ROOT_ELEMENT);
- }
- });
- assertNull(classMapping.getXmlRootElement());
- }
-
- public void testModifyName() throws Exception {
- createTypeWithXmlTypeWithXmlRootElement();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlRootElement contextRootElement = classMapping.getXmlRootElement();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
- String defaultName = Introspector.decapitalize(TYPE_NAME);
-
- assertNull(contextRootElement.getQName().getSpecifiedName());
- assertEquals(defaultName, contextRootElement.getQName().getDefaultName());
- assertEquals(defaultName, contextRootElement.getQName().getName());
-
- contextRootElement.getQName().setSpecifiedName("foo");
- XmlRootElementAnnotation rootElementAnnotation = (XmlRootElementAnnotation) resourceType.getAnnotation(JAXB.XML_ROOT_ELEMENT);
- assertEquals("foo", rootElementAnnotation.getName());
- assertEquals("foo", contextRootElement.getQName().getSpecifiedName());
- assertEquals("foo", contextRootElement.getQName().getName());
-
- contextRootElement.getQName().setSpecifiedName(null);
- rootElementAnnotation = (XmlRootElementAnnotation) resourceType.getAnnotation(JAXB.XML_ROOT_ELEMENT);
- assertNull(rootElementAnnotation.getName());
- assertNull(contextRootElement.getQName().getSpecifiedName());
- assertEquals(defaultName, contextRootElement.getQName().getName());
- }
-
- public void testUpdateName() throws Exception {
- createTypeWithXmlTypeWithXmlRootElement();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlRootElement contextRootElement = classMapping.getXmlRootElement();
- JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
- String defaultName = Introspector.decapitalize(TYPE_NAME);
-
- assertNull(contextRootElement.getQName().getSpecifiedName());
- assertEquals(defaultName, contextRootElement.getQName().getDefaultName());
- assertEquals(defaultName, contextRootElement.getQName().getName());
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlRootElementTests.this.addXmlRootElementMemberValuePair(declaration, JAXB.XML_ROOT_ELEMENT__NAME, "foo");
- }
- });
- assertEquals("foo", contextRootElement.getQName().getSpecifiedName());
- assertEquals("foo", contextRootElement.getQName().getName());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlRootElementTests.this.removeAnnotation(declaration, JAXB.XML_ROOT_ELEMENT);
- }
- });
- assertNull(classMapping.getXmlRootElement());
- }
-
- protected void addXmlRootElementMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlRootElementAnnotation(declaration), name, value);
- }
-
- protected Annotation getXmlRootElementAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_ROOT_ELEMENT);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTests.java
deleted file mode 100644
index 05f0a4c3a3..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTests.java
+++ /dev/null
@@ -1,669 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.ListIterator;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
-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.iterables.ListIterable;
-import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
-import org.eclipse.jpt.jaxb.core.context.XmlAccessType;
-import org.eclipse.jpt.jaxb.core.context.XmlNs;
-import org.eclipse.jpt.jaxb.core.context.XmlNsForm;
-import org.eclipse.jpt.jaxb.core.context.XmlSchema;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlNsAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaXmlSchemaTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaXmlSchemaTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createPackageInfoWithXmlSchema() throws CoreException {
- return createTestPackageInfo(
- "@XmlSchema",
- JAXB.XML_SCHEMA);
- }
-
- private ICompilationUnit createPackageInfoWithAccessorType() throws CoreException {
- return createTestPackageInfo(
- "@XmlAccessorType(value = XmlAccessType.PROPERTY)",
- JAXB.XML_ACCESS_TYPE, JAXB.XML_ACCESSOR_TYPE);
- }
-
- public void testModifyNamespace() throws Exception {
- createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertEquals("", contextXmlSchema.getNamespace());
- assertNull(contextXmlSchema.getSpecifiedNamespace());
-
- contextXmlSchema.setSpecifiedNamespace("foo");
- XmlSchemaAnnotation schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertEquals("foo", schemaAnnotation.getNamespace());
- assertEquals("foo", contextXmlSchema.getNamespace());
- assertEquals("foo", contextXmlSchema.getSpecifiedNamespace());
-
- //set another annotation so the context model is not blown away by removing the XmlSchema annotation
- contextPackageInfo.setSpecifiedAccessType(XmlAccessType.FIELD);
- contextXmlSchema.setSpecifiedNamespace(null);
- schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertNull(schemaAnnotation.getNamespace());
- assertEquals("", contextXmlSchema.getNamespace());
- assertNull(contextXmlSchema.getSpecifiedNamespace());
-
- //set namespace again, this time starting with no XmlSchema annotation
- contextXmlSchema.setSpecifiedNamespace("foo");
- schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertEquals("foo", schemaAnnotation.getNamespace());
- assertEquals("foo", contextXmlSchema.getSpecifiedNamespace());
- assertEquals("foo", contextXmlSchema.getNamespace());
- }
-
- public void testUpdateNamespace() throws Exception {
- this.createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertEquals("", contextXmlSchema.getNamespace());
- assertNull(contextXmlSchema.getSpecifiedNamespace());
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.addXmlSchemaMemberValuePair(declaration, JAXB.XML_SCHEMA__NAMESPACE, "foo");
- }
- });
- assertEquals("foo", contextXmlSchema.getNamespace());
- assertEquals("foo", contextXmlSchema.getSpecifiedNamespace());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.removeXmlSchemaAnnotation(declaration);
- }
- });
- contextXmlSchema = contextPackageInfo.getXmlSchema();
- assertEquals("", contextXmlSchema.getNamespace());
- assertNull(contextXmlSchema.getSpecifiedNamespace());
- }
-
- public void testModifyLocation() throws Exception {
- createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchema.getLocation());
-
- contextXmlSchema.setLocation("foo");
- XmlSchemaAnnotation schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertEquals("foo", schemaAnnotation.getLocation());
- assertEquals("foo", contextXmlSchema.getLocation());
-
- //set another annotation so the context model is not blown away by removing the XmlSchema annotation
- contextPackageInfo.setSpecifiedAccessType(XmlAccessType.FIELD);
- contextXmlSchema.setLocation(null);
- schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertNull(schemaAnnotation.getLocation());
- assertNull(contextXmlSchema.getLocation());
-
- //set location again, this time starting with no XmlSchema annotation
- contextXmlSchema.setLocation("foo");
- schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertEquals("foo", schemaAnnotation.getLocation());
- assertEquals("foo", contextXmlSchema.getLocation());
- }
-
- public void testUpdateLocation() throws Exception {
- this.createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchema.getLocation());
-
- //add a location member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.addXmlSchemaMemberValuePair(declaration, JAXB.XML_SCHEMA__LOCATION, "foo");
- }
- });
-
- assertEquals("foo", contextXmlSchema.getLocation());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.removeXmlSchemaAnnotation(declaration);
- }
- });
- contextXmlSchema = contextPackageInfo.getXmlSchema();
- assertNull(contextXmlSchema.getLocation());
- }
-
- public void testModifyAttributeFormDefault() throws Exception {
- createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchema.getSpecifiedAttributeFormDefault());
- assertEquals(XmlNsForm.UNSET, contextXmlSchema.getAttributeFormDefault());
-
- contextXmlSchema.setSpecifiedAttributeFormDefault(XmlNsForm.QUALIFIED);
- XmlSchemaAnnotation schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlNsForm.QUALIFIED, schemaAnnotation.getAttributeFormDefault());
- assertEquals(XmlNsForm.QUALIFIED, contextXmlSchema.getAttributeFormDefault());
-
- contextXmlSchema.setSpecifiedAttributeFormDefault(XmlNsForm.UNQUALIFIED);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlNsForm.UNQUALIFIED, schemaAnnotation.getAttributeFormDefault());
- assertEquals(XmlNsForm.UNQUALIFIED, contextXmlSchema.getAttributeFormDefault());
-
- //set another annotation so the context model is not blown away by removing the XmlSchema annotation
- contextPackageInfo.setSpecifiedAccessType(XmlAccessType.FIELD);
- contextXmlSchema.setSpecifiedAttributeFormDefault(null);
- schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertNull(schemaAnnotation.getAttributeFormDefault());
- assertNull(contextXmlSchema.getSpecifiedAttributeFormDefault());
-
- //set attribute form default again, this time starting with no XmlSchema annotation
- contextXmlSchema.setSpecifiedAttributeFormDefault(XmlNsForm.QUALIFIED);
- schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlNsForm.QUALIFIED, schemaAnnotation.getAttributeFormDefault());
- assertEquals(XmlNsForm.QUALIFIED, contextXmlSchema.getAttributeFormDefault());
- }
-
- public void testUpdateAttributeFormDefault() throws Exception {
- this.createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchema.getSpecifiedAttributeFormDefault());
- assertEquals(XmlNsForm.UNSET, contextXmlSchema.getAttributeFormDefault());
-
- //set the attribute form default value to QUALIFIED
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.addXmlSchemaEnumMemberValuePair(
- declaration,
- JAXB.XML_SCHEMA__ATTRIBUTE_FORM_DEFAULT,
- JAXB.XML_NS_FORM__QUALIFIED);
- }
- });
-
- assertEquals(XmlNsForm.QUALIFIED, contextXmlSchema.getSpecifiedAttributeFormDefault());
- assertEquals(XmlNsForm.QUALIFIED, contextXmlSchema.getAttributeFormDefault());
-
- //set the attribute form default value to UNQUALIFIED
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.setXmlSchemaEnumMemberValuePair(
- declaration,
- JAXB.XML_SCHEMA__ATTRIBUTE_FORM_DEFAULT,
- JAXB.XML_NS_FORM__UNQUALIFIED);
- }
- });
-
- assertEquals(XmlNsForm.UNQUALIFIED, contextXmlSchema.getSpecifiedAttributeFormDefault());
- assertEquals(XmlNsForm.UNQUALIFIED, contextXmlSchema.getAttributeFormDefault());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.removeXmlSchemaAnnotation(declaration);
- }
- });
-
- contextXmlSchema = contextPackageInfo.getXmlSchema();
- assertNull(contextXmlSchema.getSpecifiedAttributeFormDefault());
- assertEquals(XmlNsForm.UNSET, contextXmlSchema.getAttributeFormDefault());
- }
-
- public void testModifyElementFormDefault() throws Exception {
- createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchema.getSpecifiedElementFormDefault());
- assertEquals(XmlNsForm.UNSET, contextXmlSchema.getElementFormDefault());
-
- contextXmlSchema.setSpecifiedElementFormDefault(XmlNsForm.QUALIFIED);
- XmlSchemaAnnotation schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlNsForm.QUALIFIED, schemaAnnotation.getElementFormDefault());
- assertEquals(XmlNsForm.QUALIFIED, contextXmlSchema.getElementFormDefault());
-
- contextXmlSchema.setSpecifiedElementFormDefault(XmlNsForm.UNQUALIFIED);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlNsForm.UNQUALIFIED, schemaAnnotation.getElementFormDefault());
- assertEquals(XmlNsForm.UNQUALIFIED, contextXmlSchema.getElementFormDefault());
-
- //set another annotation so the context model is not blown away by removing the XmlSchema annotation
- contextPackageInfo.setSpecifiedAccessType(XmlAccessType.FIELD);
- contextXmlSchema.setSpecifiedElementFormDefault(null);
- schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertNull(schemaAnnotation.getElementFormDefault());
- assertNull(contextXmlSchema.getSpecifiedElementFormDefault());
-
- //set element form default again, this time starting with no XmlSchema annotation
- contextXmlSchema.setSpecifiedElementFormDefault(XmlNsForm.QUALIFIED);
- schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlNsForm.QUALIFIED, schemaAnnotation.getElementFormDefault());
- assertEquals(XmlNsForm.QUALIFIED, contextXmlSchema.getElementFormDefault());
- }
-
- public void testUpdateElementFormDefault() throws Exception {
- this.createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchema.getSpecifiedElementFormDefault());
- assertEquals(XmlNsForm.UNSET, contextXmlSchema.getElementFormDefault());
-
- //set the element form default value to QUALIFIED
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.addXmlSchemaEnumMemberValuePair(
- declaration,
- JAXB.XML_SCHEMA__ELEMENT_FORM_DEFAULT,
- JAXB.XML_NS_FORM__QUALIFIED);
- }
- });
-
- assertEquals(XmlNsForm.QUALIFIED, contextXmlSchema.getSpecifiedElementFormDefault());
- assertEquals(XmlNsForm.QUALIFIED, contextXmlSchema.getElementFormDefault());
-
- //set the element form default value to UNQUALIFIED
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.setXmlSchemaEnumMemberValuePair(
- declaration,
- JAXB.XML_SCHEMA__ELEMENT_FORM_DEFAULT,
- JAXB.XML_NS_FORM__UNQUALIFIED);
- }
- });
-
- assertEquals(XmlNsForm.UNQUALIFIED, contextXmlSchema.getSpecifiedElementFormDefault());
- assertEquals(XmlNsForm.UNQUALIFIED, contextXmlSchema.getElementFormDefault());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.removeXmlSchemaAnnotation(declaration);
- }
- });
-
- contextXmlSchema = contextPackageInfo.getXmlSchema();
- assertNull(contextXmlSchema.getSpecifiedElementFormDefault());
- assertEquals(XmlNsForm.UNSET, contextXmlSchema.getElementFormDefault());
- }
-
- public void testGetXmlNsPrefixes() throws Exception {
- this.createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- ListIterable<XmlNs> xmlNsPrefixes = contextXmlSchema.getXmlNsPrefixes();
- assertFalse(xmlNsPrefixes.iterator().hasNext());
-
- //add 2 XmlNs prefixes
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.addXmlNs(declaration, 0, "bar", "barPrefix");
- GenericJavaXmlSchemaTests.this.addXmlNs(declaration, 1, "foo", "fooPrefix");
- }
- });
-
- xmlNsPrefixes = contextXmlSchema.getXmlNsPrefixes();
- ListIterator<XmlNs> xmlNsPrefixesIterator = xmlNsPrefixes.iterator();
- assertTrue(xmlNsPrefixesIterator.hasNext());
- XmlNs xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("bar", xmlNsPref.getNamespaceURI());
- assertEquals("barPrefix", xmlNsPref.getPrefix());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("foo", xmlNsPref.getNamespaceURI());
- assertEquals("fooPrefix", xmlNsPref.getPrefix());
- assertFalse(xmlNsPrefixesIterator.hasNext());
- }
-
- protected void addXmlNs(ModifiedDeclaration declaration, int index, String namespaceURI, String prefix) {
- NormalAnnotation arrayElement = this.newXmlNsAnnotation(declaration.getAst(), namespaceURI, prefix);
- this.addArrayElement(declaration, JAXB.XML_SCHEMA, index, JAXB.XML_SCHEMA__XMLNS, arrayElement);
- }
-
- protected NormalAnnotation newXmlNsAnnotation(AST ast, String namespaceURI, String prefix) {
- NormalAnnotation annotation = this.newNormalAnnotation(ast, JAXB.XML_NS);
- this.addMemberValuePair(annotation, JAXB.XML_NS__NAMESPACE_URI, namespaceURI);
- this.addMemberValuePair(annotation, JAXB.XML_NS__PREFIX, prefix);
- return annotation;
- }
-
- public void testGetXmlNsPrexiesSize() throws Exception {
- this.createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertEquals(0, contextXmlSchema.getXmlNsPrefixesSize());
-
- //add 2 XmlNs prefixes
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.addXmlNs(declaration, 0, "bar", "barPrefix");
- GenericJavaXmlSchemaTests.this.addXmlNs(declaration, 1, "foo", "fooPrefix");
- }
- });
- assertEquals(2, contextXmlSchema.getXmlNsPrefixesSize());
- }
-
- public void testAddXmlNsPrefix() throws Exception {
- //create a package info with an annotation other than XmlSchema to test
- //adding things to the null schema annotation
- this.createPackageInfoWithAccessorType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- XmlNs xmlNsPrefix = contextXmlSchema.addXmlNsPrefix(0);
- xmlNsPrefix.setNamespaceURI("bar");
- xmlNsPrefix.setPrefix("barPrefix");
- xmlNsPrefix = contextXmlSchema.addXmlNsPrefix(0);
- xmlNsPrefix.setNamespaceURI("foo");
- xmlNsPrefix.setPrefix("fooPrefix");
- xmlNsPrefix = contextXmlSchema.addXmlNsPrefix(0);
- xmlNsPrefix.setNamespaceURI("baz");
- xmlNsPrefix.setPrefix("bazPrefix");
-
- XmlSchemaAnnotation schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- ListIterator<XmlNsAnnotation> xmlNsPrefixes = schemaAnnotation.getXmlns().iterator();
-
- XmlNsAnnotation xmlNsAnnotation = xmlNsPrefixes.next();
- assertEquals("baz", xmlNsAnnotation.getNamespaceURI());
- assertEquals("bazPrefix", xmlNsAnnotation.getPrefix());
- xmlNsAnnotation = xmlNsPrefixes.next();
- assertEquals("foo", xmlNsAnnotation.getNamespaceURI());
- assertEquals("fooPrefix", xmlNsAnnotation.getPrefix());
- xmlNsAnnotation = xmlNsPrefixes.next();
- assertEquals("bar", xmlNsAnnotation.getNamespaceURI());
- assertEquals("barPrefix", xmlNsAnnotation.getPrefix());
- assertFalse(xmlNsPrefixes.hasNext());
- }
-
- public void testAddXmlNsPrefix2() throws Exception {
- this.createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- XmlNs xmlNsPrefix = contextXmlSchema.addXmlNsPrefix(0);
- xmlNsPrefix.setNamespaceURI("bar");
- xmlNsPrefix.setPrefix("barPrefix");
- xmlNsPrefix = contextXmlSchema.addXmlNsPrefix(1);
- xmlNsPrefix.setNamespaceURI("foo");
- xmlNsPrefix.setPrefix("fooPrefix");
- xmlNsPrefix = contextXmlSchema.addXmlNsPrefix(0);
- xmlNsPrefix.setNamespaceURI("baz");
- xmlNsPrefix.setPrefix("bazPrefix");
-
- XmlSchemaAnnotation schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- ListIterator<XmlNsAnnotation> xmlNsPrefixes = schemaAnnotation.getXmlns().iterator();
-
- XmlNsAnnotation xmlNsAnnotation = xmlNsPrefixes.next();
- assertEquals("baz", xmlNsAnnotation.getNamespaceURI());
- assertEquals("bazPrefix", xmlNsAnnotation.getPrefix());
- xmlNsAnnotation = xmlNsPrefixes.next();
- assertEquals("bar", xmlNsAnnotation.getNamespaceURI());
- assertEquals("barPrefix", xmlNsAnnotation.getPrefix());
- xmlNsAnnotation = xmlNsPrefixes.next();
- assertEquals("foo", xmlNsAnnotation.getNamespaceURI());
- assertEquals("fooPrefix", xmlNsAnnotation.getPrefix());
- assertFalse(xmlNsPrefixes.hasNext());
- }
-
- public void testRemoveXmlNsPrefix() throws Exception {
- this.createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- contextXmlSchema.addXmlNsPrefix(0).setNamespaceURI("bar");
- contextXmlSchema.addXmlNsPrefix(1).setNamespaceURI("foo");
- contextXmlSchema.addXmlNsPrefix(2).setNamespaceURI("baz");
-
- XmlSchemaAnnotation schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
- assertEquals(3, schemaAnnotation.getXmlnsSize());
-
- contextXmlSchema.removeXmlNsPrefix(1);
-
- ListIterator<XmlNsAnnotation> xmlNsPrefixes = schemaAnnotation.getXmlns().iterator();
- assertEquals("bar", xmlNsPrefixes.next().getNamespaceURI());
- assertEquals("baz", xmlNsPrefixes.next().getNamespaceURI());
- assertFalse(xmlNsPrefixes.hasNext());
-
- contextXmlSchema.removeXmlNsPrefix(1);
- xmlNsPrefixes = schemaAnnotation.getXmlns().iterator();
- assertEquals("bar", xmlNsPrefixes.next().getNamespaceURI());
- assertFalse(xmlNsPrefixes.hasNext());
-
- contextXmlSchema.removeXmlNsPrefix(0);
- xmlNsPrefixes = schemaAnnotation.getXmlns().iterator();
- assertFalse(xmlNsPrefixes.hasNext());
- }
-
- public void testMoveXmlNsPrefix() throws Exception {
- this.createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- contextXmlSchema.addXmlNsPrefix(0).setNamespaceURI("bar");
- contextXmlSchema.addXmlNsPrefix(1).setNamespaceURI("foo");
- contextXmlSchema.addXmlNsPrefix(2).setNamespaceURI("baz");
-
-
- XmlSchemaAnnotation schemaAnnotation = (XmlSchemaAnnotation) resourcePackage.getAnnotation(JAXB.XML_SCHEMA);
-
- assertEquals(3, schemaAnnotation.getXmlnsSize());
-
- contextXmlSchema.moveXmlNsPrefix(2, 0);
- ListIterator<XmlNs> xmlNsPrefixes = contextXmlSchema.getXmlNsPrefixes().iterator();
- assertEquals("foo", xmlNsPrefixes.next().getNamespaceURI());
- assertEquals("baz", xmlNsPrefixes.next().getNamespaceURI());
- assertEquals("bar", xmlNsPrefixes.next().getNamespaceURI());
- assertFalse(xmlNsPrefixes.hasNext());
-
- ListIterator<XmlNsAnnotation> xmlNsAnnotations = schemaAnnotation.getXmlns().iterator();
- assertEquals("foo", xmlNsAnnotations.next().getNamespaceURI());
- assertEquals("baz", xmlNsAnnotations.next().getNamespaceURI());
- assertEquals("bar", xmlNsAnnotations.next().getNamespaceURI());
-
-
- contextXmlSchema.moveXmlNsPrefix(0, 1);
- xmlNsPrefixes = contextXmlSchema.getXmlNsPrefixes().iterator();
- assertEquals("baz", xmlNsPrefixes.next().getNamespaceURI());
- assertEquals("foo", xmlNsPrefixes.next().getNamespaceURI());
- assertEquals("bar", xmlNsPrefixes.next().getNamespaceURI());
- assertFalse(xmlNsPrefixes.hasNext());
-
- xmlNsAnnotations = schemaAnnotation.getXmlns().iterator();
- assertEquals("baz", xmlNsAnnotations.next().getNamespaceURI());
- assertEquals("foo", xmlNsAnnotations.next().getNamespaceURI());
- assertEquals("bar", xmlNsAnnotations.next().getNamespaceURI());
- }
-
- public void testSyncXmlNsPrefixes() throws Exception {
- this.createPackageInfoWithXmlSchema();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchema contextXmlSchema = contextPackageInfo.getXmlSchema();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- ListIterable<XmlNs> xmlNsPrefixes = contextXmlSchema.getXmlNsPrefixes();
- assertFalse(xmlNsPrefixes.iterator().hasNext());
-
- //add 3 XmlNs prefixes
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.addXmlNs(declaration, 0, "bar", "barPrefix");
- GenericJavaXmlSchemaTests.this.addXmlNs(declaration, 1, "foo", "fooPrefix");
- GenericJavaXmlSchemaTests.this.addXmlNs(declaration, 2, "baz", "bazPrefix");
- }
- });
-
- xmlNsPrefixes = contextXmlSchema.getXmlNsPrefixes();
- ListIterator<XmlNs> xmlNsPrefixesIterator = xmlNsPrefixes.iterator();
- assertTrue(xmlNsPrefixesIterator.hasNext());
- XmlNs xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("bar", xmlNsPref.getNamespaceURI());
- assertEquals("barPrefix", xmlNsPref.getPrefix());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("foo", xmlNsPref.getNamespaceURI());
- assertEquals("fooPrefix", xmlNsPref.getPrefix());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("baz", xmlNsPref.getNamespaceURI());
- assertEquals("bazPrefix", xmlNsPref.getPrefix());
- assertFalse(xmlNsPrefixesIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.moveXmlNsPrefix(declaration, 2, 0);
- }
- });
-
- xmlNsPrefixesIterator = xmlNsPrefixes.iterator();
- assertTrue(xmlNsPrefixesIterator.hasNext());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("foo", xmlNsPref.getNamespaceURI());
- assertEquals("fooPrefix", xmlNsPref.getPrefix());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("baz", xmlNsPref.getNamespaceURI());
- assertEquals("bazPrefix", xmlNsPref.getPrefix());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("bar", xmlNsPref.getNamespaceURI());
- assertEquals("barPrefix", xmlNsPref.getPrefix());
- assertFalse(xmlNsPrefixesIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.moveXmlNsPrefix(declaration, 0, 1);
- }
- });
-
- xmlNsPrefixesIterator = xmlNsPrefixes.iterator();
- assertTrue(xmlNsPrefixesIterator.hasNext());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("baz", xmlNsPref.getNamespaceURI());
- assertEquals("bazPrefix", xmlNsPref.getPrefix());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("foo", xmlNsPref.getNamespaceURI());
- assertEquals("fooPrefix", xmlNsPref.getPrefix());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("bar", xmlNsPref.getNamespaceURI());
- assertEquals("barPrefix", xmlNsPref.getPrefix());
- assertFalse(xmlNsPrefixesIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.removeXmlNsPrefix(declaration, 1);
- }
- });
-
- xmlNsPrefixesIterator = xmlNsPrefixes.iterator();
- assertTrue(xmlNsPrefixesIterator.hasNext());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("baz", xmlNsPref.getNamespaceURI());
- assertEquals("bazPrefix", xmlNsPref.getPrefix());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("bar", xmlNsPref.getNamespaceURI());
- assertEquals("barPrefix", xmlNsPref.getPrefix());
- assertFalse(xmlNsPrefixesIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.removeXmlNsPrefix(declaration, 1);
- }
- });
-
- xmlNsPrefixesIterator = xmlNsPrefixes.iterator();
- assertTrue(xmlNsPrefixesIterator.hasNext());
- xmlNsPref = xmlNsPrefixesIterator.next();
- assertEquals("baz", xmlNsPref.getNamespaceURI());
- assertEquals("bazPrefix", xmlNsPref.getPrefix());
- assertFalse(xmlNsPrefixesIterator.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTests.this.removeXmlNsPrefix(declaration, 0);
- }
- });
-
- xmlNsPrefixesIterator = xmlNsPrefixes.iterator();
- assertFalse(xmlNsPrefixesIterator.hasNext());
- }
-
- protected void addXmlSchemaEnumMemberValuePair(ModifiedDeclaration declaration, String elementName, String value) {
- this.addEnumMemberValuePair((MarkerAnnotation) this.getXmlSchemaAnnotation(declaration), elementName, value);
- }
-
- protected void setXmlSchemaEnumMemberValuePair(ModifiedDeclaration declaration, String elementName, String enumValue) {
- this.setEnumMemberValuePair((NormalAnnotation) this.getXmlSchemaAnnotation(declaration), elementName, enumValue);
- }
-
- protected void addXmlSchemaMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlSchemaAnnotation(declaration), name, value);
- }
-
- //add another package annotation so that the context model object doesn't get removed when
- //removing the XmlSchema annotation. Only "annotated" packages are added to the context model
- protected void removeXmlSchemaAnnotation(ModifiedDeclaration declaration) {
- this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ACCESSOR_ORDER);
- this.removeAnnotation(declaration, JAXB.XML_SCHEMA);
- }
-
- protected Annotation getXmlSchemaAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_SCHEMA);
- }
-
- protected void moveXmlNsPrefix(ModifiedDeclaration declaration, int targetIndex, int sourceIndex) {
- this.moveArrayElement((NormalAnnotation) getXmlSchemaAnnotation(declaration), JAXB.XML_SCHEMA__XMLNS, targetIndex, sourceIndex);
- }
-
- protected void removeXmlNsPrefix(ModifiedDeclaration declaration, int index) {
- this.removeArrayElement((NormalAnnotation) getXmlSchemaAnnotation(declaration), JAXB.XML_SCHEMA__XMLNS, index);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTypeTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTypeTests.java
deleted file mode 100644
index 412482cabb..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTypeTests.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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 org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
-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.jaxb.core.context.JaxbPackageInfo;
-import org.eclipse.jpt.jaxb.core.context.XmlSchemaType;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-import org.eclipse.xsd.util.XSDUtil;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaXmlSchemaTypeTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaXmlSchemaTypeTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createPackageInfoWithXmlSchemaType() throws CoreException {
- return createTestPackageInfo(
- "@XmlSchemaType",
- JAXB.XML_SCHEMA_TYPE);
- }
-
- public void testModifyName() throws Exception {
- this.createPackageInfoWithXmlSchemaType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchemaType contextXmlSchemaType = contextPackageInfo.getXmlSchemaTypes().iterator().next();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchemaType.getQName().getName());
-
- contextXmlSchemaType.getQName().setSpecifiedName("foo");
- XmlSchemaTypeAnnotation schemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertEquals("foo", schemaTypeAnnotation.getName());
- assertEquals("foo", contextXmlSchemaType.getQName().getName());
-
- //verify the xml schema type annotation is not removed when the name is set to null
- contextXmlSchemaType.getQName().setSpecifiedName(null);
- schemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNull(schemaTypeAnnotation.getName());
- assertNull(contextXmlSchemaType.getQName().getName());
- }
-
- public void testUpdateName() throws Exception {
- this.createPackageInfoWithXmlSchemaType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchemaType contextXmlSchemaType = contextPackageInfo.getXmlSchemaTypes().iterator().next();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchemaType.getQName().getName());
-
- //add a name member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTypeTests.this.addXmlSchemaTypeMemberValuePair(declaration, JAXB.XML_SCHEMA_TYPE__NAME, "foo");
- }
- });
- assertEquals("foo", contextXmlSchemaType.getQName().getName());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTypeTests.this.removeXmlSchemaTypeAnnotation(declaration);
- }
- });
- assertFalse(contextPackageInfo.getXmlSchemaTypes().iterator().hasNext());
- }
-
- public void testModifyNamespace() throws Exception {
- this.createPackageInfoWithXmlSchemaType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchemaType contextXmlSchemaType = contextPackageInfo.getXmlSchemaTypes().iterator().next();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchemaType.getQName().getSpecifiedNamespace());
- assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getQName().getDefaultNamespace());
- assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getQName().getNamespace());
-
- contextXmlSchemaType.getQName().setSpecifiedNamespace("foo");
- XmlSchemaTypeAnnotation schemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertEquals("foo", schemaTypeAnnotation.getNamespace());
- assertEquals("foo", contextXmlSchemaType.getQName().getSpecifiedNamespace());
- assertEquals("foo", contextXmlSchemaType.getQName().getNamespace());
-
- //verify the xml schema type annotation is not removed when the namespace is set to null
- contextXmlSchemaType.getQName().setSpecifiedNamespace(null);
- schemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNull(schemaTypeAnnotation.getNamespace());
- assertNull(contextXmlSchemaType.getQName().getSpecifiedNamespace());
- assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getQName().getNamespace());
- }
-
- public void testUpdateNamespace() throws Exception {
- this.createPackageInfoWithXmlSchemaType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchemaType contextXmlSchemaType = contextPackageInfo.getXmlSchemaTypes().iterator().next();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchemaType.getQName().getSpecifiedNamespace());
- assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getQName().getDefaultNamespace());
- assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getQName().getNamespace());
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTypeTests.this.addXmlSchemaTypeMemberValuePair(declaration, JAXB.XML_SCHEMA_TYPE__NAMESPACE, "foo");
- }
- });
- assertEquals("foo", contextXmlSchemaType.getQName().getSpecifiedNamespace());
- assertEquals("foo", contextXmlSchemaType.getQName().getNamespace());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTypeTests.this.removeXmlSchemaTypeAnnotation(declaration);
- }
- });
- assertFalse(contextPackageInfo.getXmlSchemaTypes().iterator().hasNext());
- }
-
- public void testModifyType() throws Exception {
- this.createPackageInfoWithXmlSchemaType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchemaType contextXmlSchemaType = contextPackageInfo.getXmlSchemaTypes().iterator().next();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchemaType.getType());
-
- contextXmlSchemaType.setType("foo");
- XmlSchemaTypeAnnotation schemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertEquals("foo", schemaTypeAnnotation.getType());
- assertEquals("foo", contextXmlSchemaType.getType());
-
- //verify the xml schema type annotation is not removed when the type is set to null
- contextXmlSchemaType.setType(null);
- schemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
- assertNull(schemaTypeAnnotation.getType());
- assertNull(contextXmlSchemaType.getType());
- }
-
- public void testUpdateType() throws Exception {
- this.createPackageInfoWithXmlSchemaType();
- JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- XmlSchemaType contextXmlSchemaType = contextPackageInfo.getXmlSchemaTypes().iterator().next();
- JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
-
- assertNull(contextXmlSchemaType.getType());
-
- //add a type member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTypeTests.this.addXmlSchemaTypeTypeMemberValuePair(declaration, JAXB.XML_SCHEMA_TYPE__TYPE, "String");
- }
- });
- assertEquals("String", contextXmlSchemaType.getType());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSchemaTypeTests.this.removeXmlSchemaTypeAnnotation(declaration);
- }
- });
- assertFalse(contextPackageInfo.getXmlSchemaTypes().iterator().hasNext());
- }
-
- protected void addXmlSchemaTypeTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlSchemaTypeAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected void addXmlSchemaTypeMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlSchemaTypeAnnotation(declaration), name, value);
- }
-
- //add another package annotation so that the context model object doesn't get removed when
- //removing the XmlSchemaType annotation. Only "annotated" packages are added to the context model
- protected void removeXmlSchemaTypeAnnotation(ModifiedDeclaration declaration) {
- this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ACCESSOR_ORDER);
- this.removeAnnotation(declaration, JAXB.XML_SCHEMA_TYPE);
- }
-
- protected Annotation getXmlSchemaTypeAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_SCHEMA_TYPE);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSeeAlsoTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSeeAlsoTests.java
deleted file mode 100644
index 0ede8a964d..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSeeAlsoTests.java
+++ /dev/null
@@ -1,152 +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.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-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.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlSeeAlso;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlSeeAlsoAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-public class GenericJavaXmlSeeAlsoTests
- extends JaxbContextModelTestCase {
-
- public GenericJavaXmlSeeAlsoTests(String name) {
- super(name);
- }
-
-
- private ICompilationUnit createAnnotatedPersistentClassWithXmlSeeAlso() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_SEE_ALSO);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType" + CR);
- sb.append("@XmlSeeAlso");
- }
- });
- }
-
- public void testModifyClasses() throws Exception {
- createAnnotatedPersistentClassWithXmlSeeAlso();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlSeeAlso contextXmlSeeAlso = classMapping.getXmlSeeAlso();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- assertEquals(0, contextXmlSeeAlso.getClassesSize());
-
- // add a class
- contextXmlSeeAlso.addClass(0, "foo");
- XmlSeeAlsoAnnotation annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertEquals(1, annotation.getClassesSize());
- assertTrue(CollectionTools.contains(annotation.getClasses(), "foo"));
- assertFalse(CollectionTools.contains(annotation.getClasses(), "bar"));
-
- // add another
- contextXmlSeeAlso.addClass(0, "bar");
- annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertEquals(2, annotation.getClassesSize());
- assertTrue(CollectionTools.contains(annotation.getClasses(), "foo"));
- assertTrue(CollectionTools.contains(annotation.getClasses(), "bar"));
-
- // remove one
- contextXmlSeeAlso.removeClass(1);
- annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertEquals(1, annotation.getClassesSize());
- assertFalse(CollectionTools.contains(annotation.getClasses(), "foo"));
- assertTrue(CollectionTools.contains(annotation.getClasses(), "bar"));
-
- // remove the other
- contextXmlSeeAlso.removeClass(0);
- annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertEquals(0, annotation.getClassesSize());
- assertFalse(CollectionTools.contains(annotation.getClasses(), "bar"));
- assertFalse(CollectionTools.contains(annotation.getClasses(), "foo"));
- }
-
- public void testUpdateClasses() throws Exception {
- createAnnotatedPersistentClassWithXmlSeeAlso();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- XmlSeeAlso contextXmlSeeAlso = classMapping.getXmlSeeAlso();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
- AnnotatedElement annotatedElement = annotatedElement(resourceType);
-
- assertEquals(0, contextXmlSeeAlso.getClassesSize());
-
- // add a class
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSeeAlsoTests.this.addClass(declaration, 0, "foo");
- }
- });
- assertEquals(1, contextXmlSeeAlso.getClassesSize());
- assertTrue(CollectionTools.contains(contextXmlSeeAlso.getClasses(), "foo"));
- assertFalse(CollectionTools.contains(contextXmlSeeAlso.getClasses(), "bar"));
-
- // add another
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSeeAlsoTests.this.addClass(declaration, 0, "bar");
- }
- });
- assertEquals(2, contextXmlSeeAlso.getClassesSize());
- assertTrue(CollectionTools.contains(contextXmlSeeAlso.getClasses(), "foo"));
- assertTrue(CollectionTools.contains(contextXmlSeeAlso.getClasses(), "bar"));
-
- // remove one
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSeeAlsoTests.this.removeClass(declaration, 1);
- }
- });
- assertEquals(1, contextXmlSeeAlso.getClassesSize());
- assertFalse(CollectionTools.contains(contextXmlSeeAlso.getClasses(), "foo"));
- assertTrue(CollectionTools.contains(contextXmlSeeAlso.getClasses(), "bar"));
-
- // remove the other
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlSeeAlsoTests.this.removeClass(declaration, 0);
- }
- });
- assertEquals(0, contextXmlSeeAlso.getClassesSize());
- assertFalse(CollectionTools.contains(contextXmlSeeAlso.getClasses(), "bar"));
- assertFalse(CollectionTools.contains(contextXmlSeeAlso.getClasses(), "foo"));
- }
-
- protected void addClass(ModifiedDeclaration declaration, int index, String clazz) {
- addArrayElement(declaration, JAXB.XML_SEE_ALSO, index, JAXB.XML_SEE_ALSO__VALUE, newTypeLiteral(declaration.getAst(), clazz));
- }
-
- protected void removeClass(ModifiedDeclaration declaration, int index) {
- removeArrayElement((NormalAnnotation) getXmlSeeAlsoAnnotation(declaration), JAXB.XML_SEE_ALSO__VALUE, index);
- }
-
- protected Annotation getXmlSeeAlsoAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_SEE_ALSO);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlValueMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlValueMappingTests.java
deleted file mode 100644
index d5d0d01dad..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlValueMappingTests.java
+++ /dev/null
@@ -1,306 +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.tests.internal.projects.TestJavaProject.SourceWriter;
-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.XmlAttributeMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlElementMapping;
-import org.eclipse.jpt.jaxb.core.context.XmlValueMapping;
-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 GenericJavaXmlValueMappingTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaXmlValueMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTypeWithXmlValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_VALUE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlValue");
- }
- });
- }
-
- private ICompilationUnit createTypeWithCollectionXmlValue() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import java.util.List;").append(CR);
- sb.append("import javax.xml.bind.annotation.XmlValue;").append(CR);
- sb.append("import javax.xml.bind.annotation.XmlType;").append(CR);
- sb.append(CR);
- sb.append("@XmlType").append(CR);
- sb.append("public class ").append(TYPE_NAME).append(" {").append(CR);
- sb.append(" @XmlValue").append(CR);
- sb.append(" public List<String> list;").append(CR);
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createCompilationUnit(PACKAGE_NAME, TYPE_NAME + ".java", sourceWriter);
- }
-
- public void testChangeMappingType() throws Exception {
- createTypeWithXmlValue();
-
- JaxbClassMapping classMapping = ((JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0)).getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlValueMapping xmlValueMapping = (XmlValueMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlValueMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNotNull(xmlValueMapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_VALUE));
-
- persistentAttribute.setMappingKey(MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
- assertNotNull(xmlAttributeMapping);
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_VALUE));
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
-
- persistentAttribute.setMappingKey(MappingKeys.XML_VALUE_ATTRIBUTE_MAPPING_KEY);
- xmlValueMapping = (XmlValueMapping) persistentAttribute.getMapping();
- assertNotNull(xmlValueMapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_VALUE));
- 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_VALUE));
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
-
- persistentAttribute.setMappingKey(MappingKeys.XML_VALUE_ATTRIBUTE_MAPPING_KEY);
- xmlValueMapping = (XmlValueMapping) persistentAttribute.getMapping();
- assertNotNull(xmlValueMapping);
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_VALUE));
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
- }
-
- public void testModifyXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlValue();
-
- JaxbClassMapping classMapping = ((JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0)).getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlValueMapping xmlValueMapping = (XmlValueMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlValueMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlValueMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
- xmlValueMapping.addXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlValueMapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- xmlValueMapping.removeXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
-
- public void testUpdateXmlJavaTypeAdapter() throws Exception {
- createTypeWithXmlValue();
-
- JaxbClassMapping classMapping = ((JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0)).getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlValueMapping xmlValueMapping = (XmlValueMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlValueMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlValueMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
-
- //add an XmlJavaTypeAdapter annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlValueMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlValueMapping.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- //remove the XmlJavaTypeAdapter annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlValueMappingTests.this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlValueMapping.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
-
- public void testModifyXmlList1() throws Exception {
- createTypeWithXmlValue();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlValueMapping xmlMapping = (XmlValueMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertFalse(xmlMapping.isXmlList());
- assertFalse(xmlMapping.isDefaultXmlList());
- assertFalse(xmlMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlMapping.setSpecifiedXmlList(true);
-
- assertTrue(xmlMapping.isXmlList());
- assertFalse(xmlMapping.isDefaultXmlList());
- assertTrue(xmlMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlMapping.setSpecifiedXmlList(false);
-
- assertFalse(xmlMapping.isXmlList());
- assertFalse(xmlMapping.isDefaultXmlList());
- assertFalse(xmlMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-
- public void testModifyXmlList2() throws Exception {
- createTypeWithCollectionXmlValue();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlValueMapping xmlMapping = (XmlValueMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertTrue(xmlMapping.isXmlList());
- assertTrue(xmlMapping.isDefaultXmlList());
- assertFalse(xmlMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlMapping.setSpecifiedXmlList(true);
-
- assertTrue(xmlMapping.isXmlList());
- assertTrue(xmlMapping.isDefaultXmlList());
- assertTrue(xmlMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- xmlMapping.setSpecifiedXmlList(false);
-
- assertTrue(xmlMapping.isXmlList());
- assertTrue(xmlMapping.isDefaultXmlList());
- assertFalse(xmlMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-
- public void testUpdateXmlList1() throws Exception {
- createTypeWithXmlValue();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlValueMapping xmlMapping = (XmlValueMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertFalse(xmlMapping.isXmlList());
- assertFalse(xmlMapping.isDefaultXmlList());
- assertFalse(xmlMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //add an XmlList annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlValueMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_LIST);
- }
- });
-
- assertTrue(xmlMapping.isXmlList());
- assertFalse(xmlMapping.isDefaultXmlList());
- assertTrue(xmlMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //remove the XmlList annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlValueMappingTests.this.removeAnnotation(declaration, JAXB.XML_LIST);
- }
- });
-
- assertFalse(xmlMapping.isXmlList());
- assertFalse(xmlMapping.isDefaultXmlList());
- assertFalse(xmlMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-
- public void testUpdateXmlList2() throws Exception {
- createTypeWithCollectionXmlValue();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- XmlValueMapping xmlMapping = (XmlValueMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertTrue(xmlMapping.isXmlList());
- assertTrue(xmlMapping.isDefaultXmlList());
- assertFalse(xmlMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //add an XmlList annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlValueMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_LIST);
- }
- });
-
- assertTrue(xmlMapping.isXmlList());
- assertTrue(xmlMapping.isDefaultXmlList());
- assertTrue(xmlMapping.isSpecifiedXmlList());
- assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
-
- //remove the XmlList annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaXmlValueMappingTests.this.removeAnnotation(declaration, JAXB.XML_LIST);
- }
- });
-
- assertTrue(xmlMapping.isXmlList());
- assertTrue(xmlMapping.isDefaultXmlList());
- assertFalse(xmlMapping.isSpecifiedXmlList());
- assertNull(resourceAttribute.getAnnotation(JAXB.XML_LIST));
- }
-} \ No newline at end of file
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java
deleted file mode 100644
index 5ff192e9f1..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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 junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JaxbCoreJavaContextModelTests
- extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JaxbCoreJavaContextModelTests.class.getName());
- suite.addTestSuite(GenericJavaElementFactoryMethodTests.class);
- suite.addTestSuite(GenericJavaEnumConstantTests.class);
- suite.addTestSuite(GenericJavaPackageInfoTests.class);
- suite.addTestSuite(GenericJavaPersistentAttributeTests.class);
- suite.addTestSuite(GenericJavaClassMappingTests.class);
- suite.addTestSuite(GenericJavaEnumMappingTests.class);
- suite.addTestSuite(GenericJavaRegistryTests.class);
- suite.addTestSuite(GenericJavaXmlAdapterTests.class);
- suite.addTestSuite(GenericJavaXmlAnyAttributeMappingTests.class);
- suite.addTestSuite(GenericJavaXmlAnyElementMappingTests.class);
- suite.addTestSuite(GenericJavaXmlAttributeMappingTests.class);
- suite.addTestSuite(GenericJavaXmlElementMappingTests.class);
- suite.addTestSuite(GenericJavaXmlElementRefMappingTests.class);
- suite.addTestSuite(GenericJavaXmlElementRefsMappingTests.class);
- suite.addTestSuite(GenericJavaXmlElementsMappingTests.class);
- suite.addTestSuite(GenericJavaPackageXmlJavaTypeAdapterTests.class);
- suite.addTestSuite(GenericJavaTypeXmlJavaTypeAdapterTests.class);
- suite.addTestSuite(GenericJavaAttributeXmlJavaTypeAdapterTests.class);
- suite.addTestSuite(GenericJavaXmlRootElementTests.class);
- suite.addTestSuite(GenericJavaXmlSchemaTests.class);
- suite.addTestSuite(GenericJavaXmlSchemaTypeTests.class);
- suite.addTestSuite(GenericJavaXmlSeeAlsoTests.class);
- suite.addTestSuite(GenericJavaXmlValueMappingTests.class);
- return suite;
- }
-
-
- private JaxbCoreJavaContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}

Back to the top