Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core')
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/JptJaxbEclipseLinkCoreTestsPlugin.java59
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/ELJaxbCoreTests.java85
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/ELJaxbContextModelTestCase.java29
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/ELJaxbCoreContextModelTests.java38
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaClassMappingTests.java155
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAnyAttributeMappingTests.java112
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAnyElementMappingTests.java112
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAttributeMappingTests.java240
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlDiscriminatorNodeTests.java134
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlDiscriminatorValueTests.java125
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlElementMappingTests.java296
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlElementsMappingTests.java173
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlInverseReferenceMappingTests.java116
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlJoinNodeTests.java209
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlJoinNodesMappingTests.java197
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlPathTests.java126
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlValueMappingTests.java109
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJaxbCoreJavaContextModelTests.java43
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/ELJaxbCoreResourceModelTests.java40
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/ELJaxbJavaResourceModelTestCase.java48
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/ELJaxbJavaResourceModelTests.java39
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlCDATAAnnotationTests.java74
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlDiscriminatorNodeAnnotationTests.java89
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlDiscriminatorValueAnnotationTests.java89
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlInverseReferenceAnnotationTests.java112
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlJoinNodeAnnotationTests.java251
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlKeyAnnotationTests.java74
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlPathAnnotationTests.java162
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlTransformationAnnotationTests.java121
29 files changed, 0 insertions, 3457 deletions
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/JptJaxbEclipseLinkCoreTestsPlugin.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/JptJaxbEclipseLinkCoreTestsPlugin.java
deleted file mode 100644
index b4b6735882..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/JptJaxbEclipseLinkCoreTestsPlugin.java
+++ /dev/null
@@ -1,59 +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.eclipselink.core.tests;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.jaxb.core.JaxbProjectManager;
-import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
-import org.eclipse.jpt.jaxb.core.internal.prefs.JaxbPreferencesManager;
-import org.osgi.framework.BundleContext;
-
-/**
- * configure the core to handle events synchronously when we are
- * running tests
- */
-@SuppressWarnings("nls")
-public class JptJaxbEclipseLinkCoreTestsPlugin
- extends Plugin {
-
- private static JptJaxbEclipseLinkCoreTestsPlugin INSTANCE;
-
-
- public static JptJaxbEclipseLinkCoreTestsPlugin instance() {
- return INSTANCE;
- }
-
-
- // ********** plug-in implementation **********
-
- public JptJaxbEclipseLinkCoreTestsPlugin() {
- super();
- if (INSTANCE != null) {
- throw new IllegalStateException();
- }
- // this convention is *wack*... ~bjv
- INSTANCE = this;
- }
-
-
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- JaxbProjectManager jaxbProjectManager = JptJaxbCorePlugin.getProjectManager();
- ReflectionTools.executeMethod(jaxbProjectManager, "handleEventsSynchronously");
- ReflectionTools.executeStaticMethod(JaxbPreferencesManager.class, "doNotFlushPreferences");
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/ELJaxbCoreTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/ELJaxbCoreTests.java
deleted file mode 100644
index 233d80ca4e..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/ELJaxbCoreTests.java
+++ /dev/null
@@ -1,85 +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.eclipselink.core.tests.internal;
-
-import java.io.File;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.jpt.jaxb.core.tests.internal.projects.TestJaxbProject;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbCoreContextModelTests;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.resource.ELJaxbCoreResourceModelTests;
-
-
-public class ELJaxbCoreTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ELJaxbCoreTests.class.getPackage().getName());
- suite.addTest(ELJaxbCoreResourceModelTests.suite());
- suite.addTest(ELJaxbCoreContextModelTests.suite());
- return suite;
- }
-
- public static boolean requiredJarsExists() {
- return jaxbJarPropertyExists()
- && jaxbJarFileExists()
- && eclipselinkJarPropertyExists()
- && eclipselinkJarFileExists();
- }
-
- public static boolean jaxbJarPropertyExists() {
- return getSystemProperty(TestJaxbProject.JAXB_JAR_NAME_SYSTEM_PROPERTY) != null;
- }
-
- public static boolean jaxbJarFileExists() {
- return (new File(getSystemProperty(TestJaxbProject.JAXB_JAR_NAME_SYSTEM_PROPERTY))).exists();
- }
-
- public static boolean eclipselinkJarPropertyExists() {
- return getSystemProperty(TestJaxbProject.ECLIPSELINK_JAR_NAME_SYSTEM_PROPERTY) != null;
- }
-
- public static boolean eclipselinkJarFileExists() {
- return (new File(getSystemProperty(TestJaxbProject.ECLIPSELINK_JAR_NAME_SYSTEM_PROPERTY))).exists();
- }
-
- public static String buildMissingJarErrorMessage() {
- if( ! jaxbJarPropertyExists()) {
- return errorMissingProperty(TestJaxbProject.JAXB_JAR_NAME_SYSTEM_PROPERTY);
- }
- else if( ! jaxbJarFileExists()) {
- return errorJarFileDoesNotExist(getSystemProperty(TestJaxbProject.JAXB_JAR_NAME_SYSTEM_PROPERTY));
- }
- else if( ! eclipselinkJarPropertyExists()) {
- return errorMissingProperty(TestJaxbProject.ECLIPSELINK_JAR_NAME_SYSTEM_PROPERTY);
- }
- return errorJarFileDoesNotExist(getSystemProperty(TestJaxbProject.ECLIPSELINK_JAR_NAME_SYSTEM_PROPERTY));
- }
-
- /*********** private **********/
- private static String errorMissingProperty(String propertyName) {
- return "missing Java system property: \"" + propertyName + "\"";
- }
-
- private static String errorJarFileDoesNotExist(String propertyValue) {
- return "JAR file doesn't exist: \"" + propertyValue + "\"";
- }
-
- private static String getSystemProperty(String propertyName) {
- return System.getProperty(propertyName);
- }
-
-
- private ELJaxbCoreTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/ELJaxbContextModelTestCase.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/ELJaxbContextModelTestCase.java
deleted file mode 100644
index 4bb947c77f..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/ELJaxbContextModelTestCase.java
+++ /dev/null
@@ -1,29 +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.eclipselink.core.tests.internal.context;
-
-import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
-
-
-public abstract class ELJaxbContextModelTestCase
- extends JaxbContextModelTestCase {
-
- public ELJaxbContextModelTestCase(String name) {
- super(name);
- }
-
-
- @Override
- protected JaxbPlatformDescription getPlatform() {
- return ELJaxbPlatform.getDefaultPlatform(getProjectFacetVersion());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/ELJaxbCoreContextModelTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/ELJaxbCoreContextModelTests.java
deleted file mode 100644
index 1eacaf9eb8..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/ELJaxbCoreContextModelTests.java
+++ /dev/null
@@ -1,38 +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.eclipselink.core.tests.internal.context;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.ELJaxbCoreTests;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.java.ELJaxbCoreJavaContextModelTests;
-
-
-public class ELJaxbCoreContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(ELJaxbCoreContextModelTests.class.getName());
-
- if (ELJaxbCoreTests.requiredJarsExists()) {
-// suite.addTestSuite(GenericContextRootTests.class);
- suite.addTest(ELJaxbCoreJavaContextModelTests.suite());
- }
- else {
- suite.addTest(TestSuite.warning(ELJaxbCoreTests.buildMissingJarErrorMessage()));
- }
- return suite;
- }
-
- private ELJaxbCoreContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaClassMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaClassMappingTests.java
deleted file mode 100644
index 071df8fcc5..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaClassMappingTests.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.eclipselink.core.tests.internal.context.java;
-
-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.jaxb.core.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
-import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELClassMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlDiscriminatorNodeAnnotation;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlDiscriminatorValueAnnotation;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaClassMappingTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaClassMappingTests(String name) {
- super(name);
- }
-
-
- @Override
- protected JaxbPlatformDescription getPlatform() {
- return ELJaxbPlatform.VERSION_2_2;
- }
-
- public void testModifyXmlDiscriminatorNode() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- ELClassMapping classMapping = (ELClassMapping) jaxbClass.getMapping();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- XmlDiscriminatorNodeAnnotation annotation =
- (XmlDiscriminatorNodeAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_NODE);
- assertNull(classMapping.getXmlDiscriminatorNode());
- assertNull(annotation);
-
- classMapping.addXmlDiscriminatorNode();
- annotation = (XmlDiscriminatorNodeAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_NODE);
- assertNotNull(classMapping.getXmlDiscriminatorNode());
- assertNotNull(annotation);
-
- classMapping.removeXmlDiscriminatorNode();
- annotation = (XmlDiscriminatorNodeAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_NODE);
- assertNull(classMapping.getXmlDiscriminatorNode());
- assertNull(annotation);
- }
-
- public void testUpdateXmlDiscriminatorNode() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- ELClassMapping classMapping = (ELClassMapping) jaxbClass.getMapping();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- XmlDiscriminatorNodeAnnotation annotation =
- (XmlDiscriminatorNodeAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_NODE);
- assertNull(classMapping.getXmlDiscriminatorNode());
- assertNull(annotation);
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), ELJaxb.XML_DISCRIMINATOR_NODE);
- }
- });
- annotation = (XmlDiscriminatorNodeAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_NODE);
- assertNotNull(classMapping.getXmlDiscriminatorNode());
- assertNotNull(annotation);
-
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(
- ModifiedDeclaration declaration) {
- ELJavaClassMappingTests.this.removeAnnotation(declaration, ELJaxb.XML_DISCRIMINATOR_NODE);
- }
- });
- annotation = (XmlDiscriminatorNodeAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_NODE);
- assertNull(classMapping.getXmlDiscriminatorNode());
- assertNull(annotation);
- }
-
- public void testModifyXmlDiscriminatorValue() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- ELClassMapping classMapping = (ELClassMapping) jaxbClass.getMapping();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- XmlDiscriminatorValueAnnotation annotation =
- (XmlDiscriminatorValueAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_VALUE);
- assertNull(classMapping.getXmlDiscriminatorValue());
- assertNull(annotation);
-
- classMapping.addXmlDiscriminatorValue();
- annotation = (XmlDiscriminatorValueAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_VALUE);
- assertNotNull(classMapping.getXmlDiscriminatorValue());
- assertNotNull(annotation);
-
- classMapping.removeXmlDiscriminatorValue();
- annotation = (XmlDiscriminatorValueAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_VALUE);
- assertNull(classMapping.getXmlDiscriminatorValue());
- assertNull(annotation);
- }
-
- public void testUpdateXmlDiscriminatorValue() throws Exception {
- createClassWithXmlType();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- ELClassMapping classMapping = (ELClassMapping) jaxbClass.getMapping();
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
-
- XmlDiscriminatorValueAnnotation annotation =
- (XmlDiscriminatorValueAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_VALUE);
- assertNull(classMapping.getXmlDiscriminatorValue());
- assertNull(annotation);
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), ELJaxb.XML_DISCRIMINATOR_VALUE);
- }
- });
- annotation = (XmlDiscriminatorValueAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_VALUE);
- assertNotNull(classMapping.getXmlDiscriminatorValue());
- assertNotNull(annotation);
-
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(
- ModifiedDeclaration declaration) {
- ELJavaClassMappingTests.this.removeAnnotation(declaration, ELJaxb.XML_DISCRIMINATOR_VALUE);
- }
- });
- annotation = (XmlDiscriminatorValueAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_VALUE);
- assertNull(classMapping.getXmlDiscriminatorValue());
- assertNull(annotation);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAnyAttributeMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAnyAttributeMappingTests.java
deleted file mode 100644
index 3e98fb4ba6..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAnyAttributeMappingTests.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.eclipselink.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.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.eclipselink.core.internal.context.java.ELJavaXmlAnyAttributeMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlAnyAttributeMappingTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlAnyAttributeMappingTests(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 testModifyXmlPath() throws Exception {
- createTypeWithXmlAnyAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlAnyAttributeMapping mapping = (ELJavaXmlAnyAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
-
- mapping.addXmlPath();
-
- assertEquals(1, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNotNull(mapping.getXmlPath());
-
- mapping.removeXmlPath();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
- }
-
- public void testUpdateXmlPath() throws Exception {
- createTypeWithXmlAnyAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlAnyAttributeMapping mapping = (ELJavaXmlAnyAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlAnyAttributeMappingTests.this.addMarkerAnnotation(
- declaration.getDeclaration(), ELJaxb.XML_PATH);
- }
- });
-
- assertEquals(1, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNotNull(mapping.getXmlPath());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlAnyAttributeMappingTests.this.removeAnnotation(declaration, ELJaxb.XML_PATH);
- }
- });
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAnyElementMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAnyElementMappingTests.java
deleted file mode 100644
index c1105b1d0b..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAnyElementMappingTests.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.eclipselink.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.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.eclipselink.core.internal.context.java.ELJavaXmlAnyElementMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlAnyElementMappingTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlAnyElementMappingTests(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 testModifyXmlPath() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlAnyElementMapping mapping = (ELJavaXmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
-
- mapping.addXmlPath();
-
- assertEquals(1, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNotNull(mapping.getXmlPath());
-
- mapping.removeXmlPath();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
- }
-
- public void testUpdateXmlPath() throws Exception {
- createTypeWithXmlAnyElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlAnyElementMapping mapping = (ELJavaXmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlAnyElementMappingTests.this.addMarkerAnnotation(
- declaration.getDeclaration(), ELJaxb.XML_PATH);
- }
- });
-
- assertEquals(1, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNotNull(mapping.getXmlPath());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlAnyElementMappingTests.this.removeAnnotation(declaration, ELJaxb.XML_PATH);
- }
- });
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAttributeMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAttributeMappingTests.java
deleted file mode 100644
index 5bd7097c79..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlAttributeMappingTests.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.eclipselink.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.platform.JaxbPlatformDescription;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlAttributeMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlPathAnnotation;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlAttributeMappingTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlAttributeMappingTests(String name) {
- super(name);
- }
-
-
- @Override
- protected JaxbPlatformDescription getPlatform() {
- return ELJaxbPlatform.VERSION_2_2;
- }
-
- 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 createTypeWithXmlPath() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, ELJaxb.XML_PATH);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlPath");
- }
- });
- }
-
-
- public void testModifyXmlPath() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlAttributeMapping mapping = (ELJavaXmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
-
- mapping.addXmlPath();
-
- assertEquals(1, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNotNull(mapping.getXmlPath());
-
- mapping.removeXmlPath();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
- }
-
- public void testUpdateXmlPath() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlAttributeMapping mapping = (ELJavaXmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlAttributeMappingTests.this.addMarkerAnnotation(
- declaration.getDeclaration(), ELJaxb.XML_PATH);
- }
- });
-
- assertEquals(1, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNotNull(mapping.getXmlPath());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlAttributeMappingTests.this.removeAnnotation(declaration, ELJaxb.XML_PATH);
- }
- });
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
- }
-
- public void testDefault() throws Exception {
- createTypeWithXmlPath();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- JavaResourceAttribute resourceAttribute = persistentAttribute.getJavaResourceAttribute();
- XmlPathAnnotation xmlPathAnnotation = (XmlPathAnnotation) resourceAttribute.getAnnotation(0, ELJaxb.XML_PATH);
-
- assertNotNull(xmlPathAnnotation);
- assertFalse(persistentAttribute.getMapping().getKey() == MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlAttributeMappingTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_PATH, "./element[@name=\"foo\"]/element[1]/text()");
- }
- });
-
- assertNotNull(xmlPathAnnotation.getValue());
- assertFalse(persistentAttribute.getMapping().getKey() == MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlAttributeMappingTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_PATH, "element/@attribute");
- }
- });
-
- assertNotNull(xmlPathAnnotation.getValue());
- assertTrue(persistentAttribute.getMapping().getKey() == MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlAttributeMappingTests.this.removeMemberValuePair(
- declaration, ELJaxb.XML_PATH);
- }
- });
-
- assertNull(xmlPathAnnotation.getValue());
- assertFalse(persistentAttribute.getMapping().getKey() == MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
- }
-
- public void testModifyXmlKey() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlAttributeMapping mapping = (ELJavaXmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNull(mapping.getXmlKey());
-
- mapping.addXmlKey();
-
- assertNotNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNotNull(mapping.getXmlKey());
-
- mapping.removeXmlKey();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNull(mapping.getXmlKey());
- }
-
- public void testUpdateXmlKey() throws Exception {
- createTypeWithXmlAttribute();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlAttributeMapping mapping = (ELJavaXmlAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNull(mapping.getXmlKey());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlAttributeMappingTests.this.addMarkerAnnotation(
- declaration.getDeclaration(), ELJaxb.XML_KEY);
- }
- });
-
- assertNotNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNotNull(mapping.getXmlKey());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlAttributeMappingTests.this.removeAnnotation(declaration, ELJaxb.XML_KEY);
- }
- });
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNull(mapping.getXmlKey());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlDiscriminatorNodeTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlDiscriminatorNodeTests.java
deleted file mode 100644
index a8c111f83a..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlDiscriminatorNodeTests.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-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.platform.JaxbPlatformDescription;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELClassMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlDiscriminatorNode;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlDiscriminatorNodeAnnotation;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlDiscriminatorNodeTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlDiscriminatorNodeTests(String name) {
- super(name);
- }
-
-
- @Override
- protected JaxbPlatformDescription getPlatform() {
- return ELJaxbPlatform.VERSION_2_2;
- }
-
-
- private ICompilationUnit createTypeWithXmlDiscriminatorNode() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, ELJaxb.XML_DISCRIMINATOR_NODE);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType").append(CR);
- sb.append("@XmlDiscriminatorNode").append(CR);
- }
- });
- }
-
-
- public void testModifyValue() throws Exception {
- createTypeWithXmlDiscriminatorNode();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
- ELClassMapping classMapping = (ELClassMapping) jaxbClass.getMapping();
- ELXmlDiscriminatorNode discNode = classMapping.getXmlDiscriminatorNode();
- XmlDiscriminatorNodeAnnotation annotation =
- (XmlDiscriminatorNodeAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_NODE);
-
- assertNull(annotation.getValue());
- assertNull(discNode.getValue());
-
- discNode.setValue("foo");
-
- assertEquals("foo", annotation.getValue());
- assertEquals("foo", discNode.getValue());
-
- discNode.setValue("");
-
- assertEquals("", annotation.getValue());
- assertEquals("", discNode.getValue());
-
- discNode.setValue(null);
-
- assertNull(annotation.getValue());
- assertNull(discNode.getValue());
- }
-
- public void testUpdateValue() throws Exception {
- createTypeWithXmlDiscriminatorNode();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
- ELClassMapping classMapping = (ELClassMapping) jaxbClass.getMapping();
- ELXmlDiscriminatorNode discNode = classMapping.getXmlDiscriminatorNode();
- XmlDiscriminatorNodeAnnotation annotation =
- (XmlDiscriminatorNodeAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_NODE);
-
- assertNull(annotation.getValue());
- assertNull(discNode.getValue());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlDiscriminatorNodeTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_DISCRIMINATOR_NODE, "foo");
- }
- });
-
- assertEquals("foo", annotation.getValue());
- assertEquals("foo", discNode.getValue());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlDiscriminatorNodeTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_DISCRIMINATOR_NODE, "");
- }
- });
-
- assertEquals("", annotation.getValue());
- assertEquals("", discNode.getValue());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlDiscriminatorNodeTests.this.removeMemberValuePair(
- declaration, ELJaxb.XML_DISCRIMINATOR_NODE);
- }
- });
-
- assertNull(annotation.getValue());
- assertNull(discNode.getValue());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlDiscriminatorValueTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlDiscriminatorValueTests.java
deleted file mode 100644
index efc79fa8e0..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlDiscriminatorValueTests.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-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.platform.JaxbPlatformDescription;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELClassMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlDiscriminatorValue;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlDiscriminatorValueAnnotation;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlDiscriminatorValueTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlDiscriminatorValueTests(String name) {
- super(name);
- }
-
-
- @Override
- protected JaxbPlatformDescription getPlatform() {
- return ELJaxbPlatform.VERSION_2_2;
- }
-
-
- private ICompilationUnit createTypeWithXmlDiscriminatorValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, ELJaxb.XML_DISCRIMINATOR_VALUE);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType").append(CR);
- sb.append("@XmlDiscriminatorValue").append(CR);
- }
- });
- }
-
-
- public void testModifyValue() throws Exception {
- createTypeWithXmlDiscriminatorValue();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
- ELClassMapping classMapping = (ELClassMapping) jaxbClass.getMapping();
- ELXmlDiscriminatorValue discValue = classMapping.getXmlDiscriminatorValue();
- XmlDiscriminatorValueAnnotation annotation =
- (XmlDiscriminatorValueAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_VALUE);
-
- assertNull(annotation.getValue());
- assertNull(discValue.getValue());
-
- discValue.setValue("foo");
-
- assertEquals("foo", annotation.getValue());
- assertEquals("foo", discValue.getValue());
-
- discValue.setValue("");
-
- assertEquals("", annotation.getValue());
- assertEquals("", discValue.getValue());
-
- discValue.setValue(null);
-
- assertNull(annotation.getValue());
- assertNull(discValue.getValue());
- }
-
- public void testUpdateValue() throws Exception {
- createTypeWithXmlDiscriminatorValue();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JavaResourceType resourceType = jaxbClass.getJavaResourceType();
- ELClassMapping classMapping = (ELClassMapping) jaxbClass.getMapping();
- ELXmlDiscriminatorValue discValue = classMapping.getXmlDiscriminatorValue();
- XmlDiscriminatorValueAnnotation annotation =
- (XmlDiscriminatorValueAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_VALUE);
-
- assertNull(annotation.getValue());
- assertNull(discValue.getValue());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlDiscriminatorValueTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_DISCRIMINATOR_VALUE, "foo");
- }
- });
-
- assertEquals("foo", annotation.getValue());
- assertEquals("foo", discValue.getValue());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlDiscriminatorValueTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_DISCRIMINATOR_VALUE, "");
- }
- });
-
- assertEquals("", annotation.getValue());
- assertEquals("", discValue.getValue());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlDiscriminatorValueTests.this.removeMemberValuePair(
- declaration, ELJaxb.XML_DISCRIMINATOR_VALUE);
- }
- });
-
- assertNull(annotation.getValue());
- assertNull(discValue.getValue());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlElementMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlElementMappingTests.java
deleted file mode 100644
index c44f46f873..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlElementMappingTests.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.eclipselink.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.platform.JaxbPlatformDescription;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlElementMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlPathAnnotation;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlElementMappingTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlElementMappingTests(String name) {
- super(name);
- }
-
-
- @Override
- protected JaxbPlatformDescription getPlatform() {
- return ELJaxbPlatform.VERSION_2_2;
- }
-
- 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 createTypeWithXmlPath() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, ELJaxb.XML_PATH);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlPath");
- }
- });
- }
-
-
- public void testModifyXmlPath() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlElementMapping mapping = (ELJavaXmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
-
- mapping.addXmlPath();
-
- assertEquals(1, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNotNull(mapping.getXmlPath());
-
- mapping.removeXmlPath();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
- }
-
- public void testUpdateXmlPath() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlElementMapping mapping = (ELJavaXmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementMappingTests.this.addMarkerAnnotation(
- declaration.getDeclaration(), ELJaxb.XML_PATH);
- }
- });
-
- assertEquals(1, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNotNull(mapping.getXmlPath());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementMappingTests.this.removeAnnotation(declaration, ELJaxb.XML_PATH);
- }
- });
-
- assertEquals(0, CollectionTools.size(resourceAttribute.getAnnotations(ELJaxb.XML_PATH)));
- assertNull(mapping.getXmlPath());
- }
-
- public void testDefault() throws Exception {
- createTypeWithXmlPath();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- JavaResourceAttribute resourceAttribute = persistentAttribute.getJavaResourceAttribute();
- XmlPathAnnotation xmlPathAnnotation = (XmlPathAnnotation) resourceAttribute.getAnnotation(0, ELJaxb.XML_PATH);
-
- assertNotNull(xmlPathAnnotation);
- assertTrue(persistentAttribute.getMapping().getKey() == MappingKeys.XML_ELEMENT_ATTRIBUTE_MAPPING_KEY);
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementMappingTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_PATH, "element/@attribute");
- }
- });
-
- assertNotNull(xmlPathAnnotation.getValue());
- assertFalse(persistentAttribute.getMapping().getKey() == MappingKeys.XML_ELEMENT_ATTRIBUTE_MAPPING_KEY);
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementMappingTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_PATH, "./element[@name=\"foo\"]/element[1]/text()");
- }
- });
-
- assertNotNull(xmlPathAnnotation.getValue());
- assertTrue(persistentAttribute.getMapping().getKey() == MappingKeys.XML_ELEMENT_ATTRIBUTE_MAPPING_KEY);
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementMappingTests.this.removeMemberValuePair(
- declaration, ELJaxb.XML_PATH);
- }
- });
-
- assertNull(xmlPathAnnotation.getValue());
- assertTrue(persistentAttribute.getMapping().getKey() == MappingKeys.XML_ELEMENT_ATTRIBUTE_MAPPING_KEY);
- }
-
- public void testModifyXmlKey() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlElementMapping mapping = (ELJavaXmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNull(mapping.getXmlKey());
-
- mapping.addXmlKey();
-
- assertNotNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNotNull(mapping.getXmlKey());
-
- mapping.removeXmlKey();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNull(mapping.getXmlKey());
- }
-
- public void testUpdateXmlKey() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlElementMapping mapping = (ELJavaXmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNull(mapping.getXmlKey());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementMappingTests.this.addMarkerAnnotation(
- declaration.getDeclaration(), ELJaxb.XML_KEY);
- }
- });
-
- assertNotNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNotNull(mapping.getXmlKey());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementMappingTests.this.removeAnnotation(declaration, ELJaxb.XML_KEY);
- }
- });
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_KEY));
- assertNull(mapping.getXmlKey());
- }
-
- public void testModifyXmlCDATA() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlElementMapping mapping = (ELJavaXmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNull(mapping.getXmlCDATA());
-
- mapping.addXmlCDATA();
-
- assertNotNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNotNull(mapping.getXmlCDATA());
-
- mapping.removeXmlCDATA();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNull(mapping.getXmlCDATA());
- }
-
- public void testUpdateXmlCDATA() throws Exception {
- createTypeWithXmlElement();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlElementMapping mapping = (ELJavaXmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNull(mapping.getXmlCDATA());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementMappingTests.this.addMarkerAnnotation(
- declaration.getDeclaration(), ELJaxb.XML_CDATA);
- }
- });
-
- assertNotNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNotNull(mapping.getXmlCDATA());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementMappingTests.this.removeAnnotation(declaration, ELJaxb.XML_CDATA);
- }
- });
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNull(mapping.getXmlCDATA());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlElementsMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlElementsMappingTests.java
deleted file mode 100644
index 8f81a35897..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlElementsMappingTests.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package org.eclipse.jpt.jaxb.eclipselink.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.iterables.SubIterableWrapper;
-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.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlElementsMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlPath;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlPathAnnotation;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlElementsMappingTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlElementsMappingTests(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");
- }
- });
- }
-
- protected NormalAnnotation newXmlPathAnnotation(AST ast, String value) {
- NormalAnnotation annotation = newNormalAnnotation(ast, ELJaxb.XML_PATH);
- addMemberValuePair(annotation, ELJaxb.XML_PATH__VALUE, value);
- return annotation;
- }
-
- protected void addXmlPath(ModifiedDeclaration declaration, int index, String value) {
- NormalAnnotation annotation = newXmlPathAnnotation(declaration.getAst(), value);
- addArrayElement(declaration, ELJaxb.XML_PATHS, index, "value", annotation);
- }
-
- protected void moveXmlPath(ModifiedDeclaration declaration, int targetIndex, int sourceIndex) {
- moveArrayElement((NormalAnnotation) declaration.getAnnotationNamed(ELJaxb.XML_PATHS), "value", targetIndex, sourceIndex);
- }
-
- protected void removeXmlPath(ModifiedDeclaration declaration, int index) {
- removeArrayElement((NormalAnnotation) declaration.getAnnotationNamed(ELJaxb.XML_PATHS), "value", index);
- }
-
-
- public void testUpdateXmlElements() throws Exception {
- createTypeWithXmlElements();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- ELXmlElementsMapping mapping = (ELXmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- Iterable<ELXmlPath> xmlPaths = mapping.getXmlPaths();
- assertTrue(CollectionTools.isEmpty(xmlPaths));
- assertEquals(0, mapping.getXmlPathsSize());
-
- //add 2 XmlPath annotations
- AnnotatedElement annotatedElement = annotatedElement(resourceAttribute);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementsMappingTests.this.addXmlPath(declaration, 0, "foo");
- ELJavaXmlElementsMappingTests.this.addXmlPath(declaration, 1, "bar");
- }
- });
-
- xmlPaths = mapping.getXmlPaths();
-
- assertFalse(CollectionTools.isEmpty(xmlPaths));
- assertEquals(2, mapping.getXmlPathsSize());
- assertEquals("foo", CollectionTools.get(xmlPaths, 0).getValue());
- assertEquals("bar", CollectionTools.get(xmlPaths, 1).getValue());
-
- // switch XmlPath annotations
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementsMappingTests.this.moveXmlPath(declaration, 0, 1);
- }
- });
-
- xmlPaths = mapping.getXmlPaths();
-
- assertFalse(CollectionTools.isEmpty(xmlPaths));
- assertEquals(2, mapping.getXmlPathsSize());
- assertEquals("bar", CollectionTools.get(xmlPaths, 0).getValue());
- assertEquals("foo", CollectionTools.get(xmlPaths, 1).getValue());
-
- // remove XmlPath annotations
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlElementsMappingTests.this.removeXmlPath(declaration, 1);
- ELJavaXmlElementsMappingTests.this.removeXmlPath(declaration, 0);
- }
- });
-
- xmlPaths = mapping.getXmlPaths();
-
- assertTrue(CollectionTools.isEmpty(xmlPaths));
- assertEquals(0, mapping.getXmlPathsSize());
- }
-
- public void testModifyXmlPaths() throws Exception {
- createTypeWithXmlElements();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- ELXmlElementsMapping mapping = (ELXmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertEquals(0, resourceAttribute.getAnnotationsSize(ELJaxb.XML_PATH));
- assertEquals(0, mapping.getXmlPathsSize());
-
- mapping.addXmlPath(0).setValue("foo");
- mapping.addXmlPath(1).setValue("baz");
- mapping.addXmlPath(1).setValue("bar");
-
- Iterable<XmlPathAnnotation> xmlPathAnnotations =
- new SubIterableWrapper(resourceAttribute.getAnnotations(ELJaxb.XML_PATH));
-
- assertEquals(3, CollectionTools.size(xmlPathAnnotations));
- assertEquals(3, mapping.getXmlPathsSize());
- assertEquals("foo", CollectionTools.get(xmlPathAnnotations, 0).getValue());
- assertEquals("bar", CollectionTools.get(xmlPathAnnotations, 1).getValue());
- assertEquals("baz", CollectionTools.get(xmlPathAnnotations, 2).getValue());
-
- mapping.moveXmlPath(1, 2);
-
- xmlPathAnnotations =
- new SubIterableWrapper(resourceAttribute.getAnnotations(ELJaxb.XML_PATH));
-
- assertEquals(3, CollectionTools.size(xmlPathAnnotations));
- assertEquals(3, mapping.getXmlPathsSize());
- assertEquals("foo", CollectionTools.get(xmlPathAnnotations, 0).getValue());
- assertEquals("baz", CollectionTools.get(xmlPathAnnotations, 1).getValue());
- assertEquals("bar", CollectionTools.get(xmlPathAnnotations, 2).getValue());
-
- mapping.removeXmlPath(2);
- mapping.removeXmlPath(0);
- mapping.removeXmlPath(0);
-
- xmlPathAnnotations =
- new SubIterableWrapper(resourceAttribute.getAnnotations(ELJaxb.XML_PATH));
-
- assertEquals(0, CollectionTools.size(xmlPathAnnotations));
- assertEquals(0, mapping.getXmlPathsSize());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlInverseReferenceMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlInverseReferenceMappingTests.java
deleted file mode 100644
index ba7710b517..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlInverseReferenceMappingTests.java
+++ /dev/null
@@ -1,116 +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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-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.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.eclipselink.core.internal.context.java.ELJavaXmlInverseReferenceMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlInverseReferenceAnnotation;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlInverseReferenceMappingTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlInverseReferenceMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTypeWithXmlInverseReference() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, ELJaxb.XML_INVERSE_REFERENCE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlInverseReference");
- }
- });
- }
-
-
- public void testModifyMappedBy() throws Exception {
- createTypeWithXmlInverseReference();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlInverseReferenceMapping mapping = (ELJavaXmlInverseReferenceMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
- XmlInverseReferenceAnnotation annotation = (XmlInverseReferenceAnnotation) resourceAttribute.getAnnotation(ELJaxb.XML_INVERSE_REFERENCE);
-
- assertNull(annotation.getMappedBy());
- assertNull(mapping.getMappedBy());
-
- mapping.setMappedBy("foo");
-
- assertEquals("foo", annotation.getMappedBy());
- assertEquals("foo", mapping.getMappedBy());
-
- mapping.setMappedBy(null);
-
- assertNull(annotation.getMappedBy());
- assertNull(mapping.getMappedBy());
- }
-
- public void testUpdateMappedBy() throws Exception {
- createTypeWithXmlInverseReference();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlInverseReferenceMapping mapping = (ELJavaXmlInverseReferenceMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
- XmlInverseReferenceAnnotation annotation = (XmlInverseReferenceAnnotation) resourceAttribute.getAnnotation(ELJaxb.XML_INVERSE_REFERENCE);
-
- assertNull(annotation.getMappedBy());
- assertNull(mapping.getMappedBy());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlInverseReferenceMappingTests.this.addMemberValuePair(
- (MarkerAnnotation) declaration.getAnnotationNamed(ELJaxb.XML_INVERSE_REFERENCE),
- ELJaxb.XML_INVERSE_REFERENCE__MAPPED_BY, "foo");
- }
- });
-
- assertEquals("foo", annotation.getMappedBy());
- assertEquals("foo", mapping.getMappedBy());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation annotation = (NormalAnnotation) declaration.getAnnotationNamed(ELJaxb.XML_INVERSE_REFERENCE);
- ELJavaXmlInverseReferenceMappingTests.this.values(annotation).remove(0);
- }
- });
-
- assertNull(annotation.getMappedBy());
- assertNull(mapping.getMappedBy());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlJoinNodeTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlJoinNodeTests.java
deleted file mode 100644
index 0cbe7d3f3e..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlJoinNodeTests.java
+++ /dev/null
@@ -1,209 +0,0 @@
-package org.eclipse.jpt.jaxb.eclipselink.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.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlJoinNode;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlJoinNodesMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlJoinNodesMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlJoinNodeAnnotation;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlJoinNodeTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlJoinNodeTests(String name) {
- super(name);
- }
-
-
- @Override
- protected JaxbPlatformDescription getPlatform() {
- return ELJaxbPlatform.VERSION_2_2;
- }
-
- private ICompilationUnit createTypeWithXmlJoinNode() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, ELJaxb.XML_JOIN_NODE);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlJoinNode");
- }
- });
- }
-
-
- public void testModifyXmlPath() throws Exception {
- createTypeWithXmlJoinNode();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELXmlJoinNodesMapping mapping = (ELXmlJoinNodesMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
- ELXmlJoinNode xmlJoinNode = CollectionTools.get(mapping.getXmlJoinNodes(), 0);
- XmlJoinNodeAnnotation annotation = (XmlJoinNodeAnnotation) resourceAttribute.getAnnotation(0, ELJaxb.XML_JOIN_NODE);
-
- assertNull(annotation.getXmlPath());
- assertNull(xmlJoinNode.getXmlPath());
-
- xmlJoinNode.setXmlPath("foo");
-
- assertEquals("foo", annotation.getXmlPath());
- assertEquals("foo", xmlJoinNode.getXmlPath());
-
- xmlJoinNode.setXmlPath("");
-
- assertEquals("", annotation.getXmlPath());
- assertEquals("", xmlJoinNode.getXmlPath());
-
- xmlJoinNode.setXmlPath(null);
-
- assertNull(annotation.getXmlPath());
- assertNull(xmlJoinNode.getXmlPath());
- }
-
- public void testUpdateXmlPath() throws Exception {
- createTypeWithXmlJoinNode();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlJoinNodesMapping mapping = (ELJavaXmlJoinNodesMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
- ELXmlJoinNode xmlJoinNode = CollectionTools.get(mapping.getXmlJoinNodes(), 0);
- XmlJoinNodeAnnotation annotation = (XmlJoinNodeAnnotation) resourceAttribute.getAnnotation(0, ELJaxb.XML_JOIN_NODE);
-
- assertNull(annotation.getXmlPath());
- assertNull(xmlJoinNode.getXmlPath());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlJoinNodeTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_JOIN_NODE, ELJaxb.XML_JOIN_NODE__XML_PATH, "foo");
- }
- });
-
- assertEquals("foo", annotation.getXmlPath());
- assertEquals("foo", xmlJoinNode.getXmlPath());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlJoinNodeTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_JOIN_NODE, ELJaxb.XML_JOIN_NODE__XML_PATH, "");
- }
- });
-
- assertEquals("", annotation.getXmlPath());
- assertEquals("", xmlJoinNode.getXmlPath());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlJoinNodeTests.this.removeMemberValuePair(
- declaration, ELJaxb.XML_JOIN_NODE, ELJaxb.XML_JOIN_NODE__XML_PATH);
- }
- });
-
- assertNull(annotation.getXmlPath());
- assertNull(xmlJoinNode.getXmlPath());
- }
-
- public void testModifyReferencedXmlPath() throws Exception {
- createTypeWithXmlJoinNode();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELXmlJoinNodesMapping mapping = (ELXmlJoinNodesMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
- ELXmlJoinNode xmlJoinNode = CollectionTools.get(mapping.getXmlJoinNodes(), 0);
- XmlJoinNodeAnnotation annotation = (XmlJoinNodeAnnotation) resourceAttribute.getAnnotation(0, ELJaxb.XML_JOIN_NODE);
-
- assertNull(annotation.getReferencedXmlPath());
- assertNull(xmlJoinNode.getReferencedXmlPath());
-
- xmlJoinNode.setReferencedXmlPath("foo");
-
- assertEquals("foo", annotation.getReferencedXmlPath());
- assertEquals("foo", xmlJoinNode.getReferencedXmlPath());
-
- xmlJoinNode.setReferencedXmlPath("");
-
- assertEquals("", annotation.getReferencedXmlPath());
- assertEquals("", xmlJoinNode.getReferencedXmlPath());
-
- xmlJoinNode.setReferencedXmlPath(null);
-
- assertNull(annotation.getReferencedXmlPath());
- assertNull(xmlJoinNode.getReferencedXmlPath());
- }
-
- public void testUpdateReferencedXmlPath() throws Exception {
- createTypeWithXmlJoinNode();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlJoinNodesMapping mapping = (ELJavaXmlJoinNodesMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
- ELXmlJoinNode xmlJoinNode = CollectionTools.get(mapping.getXmlJoinNodes(), 0);
- XmlJoinNodeAnnotation annotation = (XmlJoinNodeAnnotation) resourceAttribute.getAnnotation(0, ELJaxb.XML_JOIN_NODE);
-
- assertNull(annotation.getReferencedXmlPath());
- assertNull(xmlJoinNode.getReferencedXmlPath());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlJoinNodeTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_JOIN_NODE, ELJaxb.XML_JOIN_NODE__REFERENCED_XML_PATH, "foo");
- }
- });
-
- assertEquals("foo", annotation.getReferencedXmlPath());
- assertEquals("foo", xmlJoinNode.getReferencedXmlPath());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlJoinNodeTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_JOIN_NODE, ELJaxb.XML_JOIN_NODE__REFERENCED_XML_PATH, "");
- }
- });
-
- assertEquals("", annotation.getReferencedXmlPath());
- assertEquals("", xmlJoinNode.getReferencedXmlPath());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlJoinNodeTests.this.removeMemberValuePair(
- declaration, ELJaxb.XML_JOIN_NODE, ELJaxb.XML_JOIN_NODE__REFERENCED_XML_PATH);
- }
- });
-
- assertNull(annotation.getReferencedXmlPath());
- assertNull(xmlJoinNode.getReferencedXmlPath());
- }
-} \ No newline at end of file
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlJoinNodesMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlJoinNodesMappingTests.java
deleted file mode 100644
index ce0559ae6a..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlJoinNodesMappingTests.java
+++ /dev/null
@@ -1,197 +0,0 @@
-package org.eclipse.jpt.jaxb.eclipselink.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.iterables.SubIterableWrapper;
-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.platform.JaxbPlatformDescription;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlJoinNode;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlJoinNodesMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlJoinNodeAnnotation;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlJoinNodesMappingTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlJoinNodesMappingTests(String name) {
- super(name);
- }
-
-
- @Override
- protected JaxbPlatformDescription getPlatform() {
- return ELJaxbPlatform.VERSION_2_2;
- }
-
- private ICompilationUnit createTypeWithXmlJoinNodes() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, ELJaxb.XML_JOIN_NODES);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlJoinNodes");
- }
- });
- }
-
- protected NormalAnnotation newXmlJoinNodeAnnotation(AST ast, String xmlPath, String referencedXmlPath) {
- NormalAnnotation annotation = newNormalAnnotation(ast, ELJaxb.XML_JOIN_NODE);
- addMemberValuePair(annotation, ELJaxb.XML_JOIN_NODE__XML_PATH, xmlPath);
- addMemberValuePair(annotation, ELJaxb.XML_JOIN_NODE__REFERENCED_XML_PATH, referencedXmlPath);
- return annotation;
- }
-
- protected void addXmlJoinNode(ModifiedDeclaration declaration, int index, String xmlPath, String referencedXmlPath) {
- NormalAnnotation annotation = newXmlJoinNodeAnnotation(declaration.getAst(), xmlPath, referencedXmlPath);
- addArrayElement(declaration, ELJaxb.XML_JOIN_NODES, index, "value", annotation);
- }
-
- protected void moveXmlJoinNode(ModifiedDeclaration declaration, int targetIndex, int sourceIndex) {
- moveArrayElement((NormalAnnotation) declaration.getAnnotationNamed(ELJaxb.XML_JOIN_NODES), "value", targetIndex, sourceIndex);
- }
-
- protected void removeXmlJoinNode(ModifiedDeclaration declaration, int index) {
- removeArrayElement((NormalAnnotation) declaration.getAnnotationNamed(ELJaxb.XML_JOIN_NODES), "value", index);
- }
-
-
- public void testUpdateXmlJoinNodes() throws Exception {
- createTypeWithXmlJoinNodes();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- ELXmlJoinNodesMapping mapping = (ELXmlJoinNodesMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- Iterable<ELXmlJoinNode> xmlJoinNodes = mapping.getXmlJoinNodes();
- assertTrue(CollectionTools.isEmpty(xmlJoinNodes));
- assertEquals(0, mapping.getXmlJoinNodesSize());
-
- //add 2 XmlJoinNode annotations
- AnnotatedElement annotatedElement = annotatedElement(resourceAttribute);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlJoinNodesMappingTests.this.addXmlJoinNode(declaration, 0, "foo", "@foo");
- ELJavaXmlJoinNodesMappingTests.this.addXmlJoinNode(declaration, 1, "bar", "@bar");
- }
- });
-
- xmlJoinNodes = mapping.getXmlJoinNodes();
-
- assertFalse(CollectionTools.isEmpty(xmlJoinNodes));
- assertEquals(2, mapping.getXmlJoinNodesSize());
- assertEquals("foo", CollectionTools.get(xmlJoinNodes, 0).getXmlPath());
- assertEquals("@foo", CollectionTools.get(xmlJoinNodes, 0).getReferencedXmlPath());
- assertEquals("bar", CollectionTools.get(xmlJoinNodes, 1).getXmlPath());
- assertEquals("@bar", CollectionTools.get(xmlJoinNodes, 1).getReferencedXmlPath());
-
- // switch XmlJoinNode annotations
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlJoinNodesMappingTests.this.moveXmlJoinNode(declaration, 0, 1);
- }
- });
-
- xmlJoinNodes = mapping.getXmlJoinNodes();
-
- assertFalse(CollectionTools.isEmpty(xmlJoinNodes));
- assertEquals(2, mapping.getXmlJoinNodesSize());
- assertEquals("bar", CollectionTools.get(xmlJoinNodes, 0).getXmlPath());
- assertEquals("@bar", CollectionTools.get(xmlJoinNodes, 0).getReferencedXmlPath());
- assertEquals("foo", CollectionTools.get(xmlJoinNodes, 1).getXmlPath());
- assertEquals("@foo", CollectionTools.get(xmlJoinNodes, 1).getReferencedXmlPath());
-
- // remove XmlJoinNode annotations
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlJoinNodesMappingTests.this.removeXmlJoinNode(declaration, 1);
- ELJavaXmlJoinNodesMappingTests.this.removeXmlJoinNode(declaration, 0);
- }
- });
-
- xmlJoinNodes = mapping.getXmlJoinNodes();
-
- assertTrue(CollectionTools.isEmpty(xmlJoinNodes));
- assertEquals(0, mapping.getXmlJoinNodesSize());
- }
-
- public void testModifyXmlJoinNodes() throws Exception {
- createTypeWithXmlJoinNodes();
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- ELXmlJoinNodesMapping mapping = (ELXmlJoinNodesMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertEquals(0, resourceAttribute.getAnnotationsSize(ELJaxb.XML_JOIN_NODE));
- assertEquals(0, mapping.getXmlJoinNodesSize());
-
- ELXmlJoinNode joinNode = mapping.addXmlJoinNode(0);
- joinNode.setXmlPath("foo");
- joinNode.setReferencedXmlPath("@foo");
- joinNode = mapping.addXmlJoinNode(1);
- joinNode.setXmlPath("baz");
- joinNode.setReferencedXmlPath("@baz");
- joinNode = mapping.addXmlJoinNode(1);
- joinNode.setXmlPath("bar");
- joinNode.setReferencedXmlPath("@bar");
-
- Iterable<XmlJoinNodeAnnotation> xmlJoinNodeAnnotations =
- new SubIterableWrapper(resourceAttribute.getAnnotations(ELJaxb.XML_JOIN_NODE));
-
- assertEquals(3, CollectionTools.size(xmlJoinNodeAnnotations));
- assertEquals(3, mapping.getXmlJoinNodesSize());
- assertEquals("foo", CollectionTools.get(xmlJoinNodeAnnotations, 0).getXmlPath());
- assertEquals("@foo", CollectionTools.get(xmlJoinNodeAnnotations, 0).getReferencedXmlPath());
- assertEquals("bar", CollectionTools.get(xmlJoinNodeAnnotations, 1).getXmlPath());
- assertEquals("@bar", CollectionTools.get(xmlJoinNodeAnnotations, 1).getReferencedXmlPath());
- assertEquals("baz", CollectionTools.get(xmlJoinNodeAnnotations, 2).getXmlPath());
- assertEquals("@baz", CollectionTools.get(xmlJoinNodeAnnotations, 2).getReferencedXmlPath());
-
- mapping.moveXmlJoinNode(1, 2);
-
- xmlJoinNodeAnnotations =
- new SubIterableWrapper(resourceAttribute.getAnnotations(ELJaxb.XML_JOIN_NODE));
-
- assertEquals(3, CollectionTools.size(xmlJoinNodeAnnotations));
- assertEquals(3, mapping.getXmlJoinNodesSize());
- assertEquals("foo", CollectionTools.get(xmlJoinNodeAnnotations, 0).getXmlPath());
- assertEquals("@foo", CollectionTools.get(xmlJoinNodeAnnotations, 0).getReferencedXmlPath());
- assertEquals("baz", CollectionTools.get(xmlJoinNodeAnnotations, 1).getXmlPath());
- assertEquals("@baz", CollectionTools.get(xmlJoinNodeAnnotations, 1).getReferencedXmlPath());
- assertEquals("bar", CollectionTools.get(xmlJoinNodeAnnotations, 2).getXmlPath());
- assertEquals("@bar", CollectionTools.get(xmlJoinNodeAnnotations, 2).getReferencedXmlPath());
-
- mapping.removeXmlJoinNode(2);
- mapping.removeXmlJoinNode(0);
- mapping.removeXmlJoinNode(0);
-
- xmlJoinNodeAnnotations =
- new SubIterableWrapper(resourceAttribute.getAnnotations(ELJaxb.XML_JOIN_NODE));
-
- assertEquals(0, CollectionTools.size(xmlJoinNodeAnnotations));
- assertEquals(0, mapping.getXmlJoinNodesSize());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlPathTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlPathTests.java
deleted file mode 100644
index 2f58cb937e..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlPathTests.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package org.eclipse.jpt.jaxb.eclipselink.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.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.eclipselink.core.context.java.ELXmlElementMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlPath;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlElementMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlPathAnnotation;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlPathTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlPathTests(String name) {
- super(name);
- }
-
-
- private ICompilationUnit createTypeWithXmlPath() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, ELJaxb.XML_PATH);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlPath");
- }
- });
- }
-
-
- public void testModifyValue() throws Exception {
- createTypeWithXmlPath();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELXmlElementMapping mapping = (ELXmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
- ELXmlPath xpath = mapping.getXmlPath();
- XmlPathAnnotation annotation = (XmlPathAnnotation) resourceAttribute.getAnnotation(0, ELJaxb.XML_PATH);
-
- assertNull(annotation.getValue());
- assertNull(xpath.getValue());
-
- xpath.setValue("foo");
-
- assertEquals("foo", annotation.getValue());
- assertEquals("foo", xpath.getValue());
-
- xpath.setValue("");
-
- assertEquals("", annotation.getValue());
- assertEquals("", xpath.getValue());
-
- xpath.setValue(null);
-
- assertNull(annotation.getValue());
- assertNull(xpath.getValue());
- }
-
- public void testUpdateValue() throws Exception {
- createTypeWithXmlPath();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlElementMapping mapping = (ELJavaXmlElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
- ELXmlPath xpath = mapping.getXmlPath();
- XmlPathAnnotation annotation = (XmlPathAnnotation) resourceAttribute.getAnnotation(0, ELJaxb.XML_PATH);
-
- assertNull(annotation.getValue());
- assertNull(xpath.getValue());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlPathTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_PATH, "foo");
- }
- });
-
- assertEquals("foo", annotation.getValue());
- assertEquals("foo", xpath.getValue());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlPathTests.this.setMemberValuePair(
- declaration, ELJaxb.XML_PATH, "");
- }
- });
-
- assertEquals("", annotation.getValue());
- assertEquals("", xpath.getValue());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlPathTests.this.removeMemberValuePair(
- declaration, ELJaxb.XML_PATH);
- }
- });
-
- assertNull(annotation.getValue());
- assertNull(xpath.getValue());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlValueMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlValueMappingTests.java
deleted file mode 100644
index b1e44a2b14..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlValueMappingTests.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.eclipse.jpt.jaxb.eclipselink.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.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlValueMapping;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
-
-
-public class ELJavaXmlValueMappingTests
- extends ELJaxbContextModelTestCase {
-
- public ELJavaXmlValueMappingTests(String name) {
- super(name);
- }
-
-
- @Override
- protected JaxbPlatformDescription getPlatform() {
- return ELJaxbPlatform.VERSION_2_2;
- }
-
- 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");
- }
- });
- }
-
- public void testModifyXmlCDATA() throws Exception {
- createTypeWithXmlValue();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlValueMapping mapping = (ELJavaXmlValueMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNull(mapping.getXmlCDATA());
-
- mapping.addXmlCDATA();
-
- assertNotNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNotNull(mapping.getXmlCDATA());
-
- mapping.removeXmlCDATA();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNull(mapping.getXmlCDATA());
- }
-
- public void testUpdateXmlCDATA() throws Exception {
- createTypeWithXmlValue();
-
- JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
- JaxbClassMapping classMapping = jaxbClass.getMapping();
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
- ELJavaXmlValueMapping mapping = (ELJavaXmlValueMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNull(mapping.getXmlCDATA());
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlValueMappingTests.this.addMarkerAnnotation(
- declaration.getDeclaration(), ELJaxb.XML_CDATA);
- }
- });
-
- assertNotNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNotNull(mapping.getXmlCDATA());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- ELJavaXmlValueMappingTests.this.removeAnnotation(declaration, ELJaxb.XML_CDATA);
- }
- });
-
- assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
- assertNull(mapping.getXmlCDATA());
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJaxbCoreJavaContextModelTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJaxbCoreJavaContextModelTests.java
deleted file mode 100644
index 29bc7f62f8..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJaxbCoreJavaContextModelTests.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 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.eclipselink.core.tests.internal.context.java;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-public class ELJaxbCoreJavaContextModelTests
- extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ELJaxbCoreJavaContextModelTests.class.getName());
- suite.addTestSuite(ELJavaClassMappingTests.class);
- suite.addTestSuite(ELJavaXmlAnyAttributeMappingTests.class);
- suite.addTestSuite(ELJavaXmlAnyElementMappingTests.class);
- suite.addTestSuite(ELJavaXmlAttributeMappingTests.class);
- suite.addTestSuite(ELJavaXmlDiscriminatorNodeTests.class);
- suite.addTestSuite(ELJavaXmlDiscriminatorValueTests.class);
- suite.addTestSuite(ELJavaXmlElementMappingTests.class);
- suite.addTestSuite(ELJavaXmlElementsMappingTests.class);
- suite.addTestSuite(ELJavaXmlInverseReferenceMappingTests.class);
- suite.addTestSuite(ELJavaXmlJoinNodesMappingTests.class);
- suite.addTestSuite(ELJavaXmlJoinNodeTests.class);
- suite.addTestSuite(ELJavaXmlPathTests.class);
- suite.addTestSuite(ELJavaXmlValueMappingTests.class);
- return suite;
- }
-
-
- private ELJaxbCoreJavaContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/ELJaxbCoreResourceModelTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/ELJaxbCoreResourceModelTests.java
deleted file mode 100644
index 12a00c2ed6..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/ELJaxbCoreResourceModelTests.java
+++ /dev/null
@@ -1,40 +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.eclipselink.core.tests.internal.resource;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.ELJaxbCoreTests;
-import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.resource.java.ELJaxbJavaResourceModelTests;
-
-
-public class ELJaxbCoreResourceModelTests
- extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ELJaxbCoreResourceModelTests.class.getName());
-
- if (ELJaxbCoreTests.requiredJarsExists()) {
- suite.addTest(ELJaxbJavaResourceModelTests.suite());
- }
- else {
- suite.addTest(TestSuite.warning(ELJaxbCoreTests.buildMissingJarErrorMessage()));
- }
- return suite;
- }
-
-
- private ELJaxbCoreResourceModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/ELJaxbJavaResourceModelTestCase.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/ELJaxbJavaResourceModelTestCase.java
deleted file mode 100644
index 479010c881..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/ELJaxbJavaResourceModelTestCase.java
+++ /dev/null
@@ -1,48 +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.eclipselink.core.tests.internal.resource.java;
-
-import org.eclipse.jpt.common.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotationDefinition;
-import org.eclipse.jpt.common.core.tests.internal.resource.java.JavaResourceModelTestCase;
-import org.eclipse.jpt.jaxb.core.tests.internal.projects.TestJaxbProject;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_1.ELJaxb_2_1_PlatformDefinition;
-
-
-public class ELJaxbJavaResourceModelTestCase
- extends JavaResourceModelTestCase {
-
- public ELJaxbJavaResourceModelTestCase(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.javaProject.addJar(TestJaxbProject.eclipselinkJarName());
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- // nothing as of yet
- }
-
- @Override
- protected AnnotationDefinition[] annotationDefinitions() {
- return ELJaxb_2_1_PlatformDefinition.instance().getAnnotationDefinitions();
- }
-
- @Override
- protected NestableAnnotationDefinition[] nestableAnnotationDefinitions() {
- return ELJaxb_2_1_PlatformDefinition.instance().getNestableAnnotationDefinitions();
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/ELJaxbJavaResourceModelTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/ELJaxbJavaResourceModelTests.java
deleted file mode 100644
index 27c4a89886..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/ELJaxbJavaResourceModelTests.java
+++ /dev/null
@@ -1,39 +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.eclipselink.core.tests.internal.resource.java;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-public class ELJaxbJavaResourceModelTests
- extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ELJaxbJavaResourceModelTests.class.getName());
- suite.addTestSuite(XmlCDATAAnnotationTests.class);
- suite.addTestSuite(XmlDiscriminatorNodeAnnotationTests.class);
- suite.addTestSuite(XmlDiscriminatorValueAnnotationTests.class);
- suite.addTestSuite(XmlInverseReferenceAnnotationTests.class);
- suite.addTestSuite(XmlJoinNodeAnnotationTests.class);
- suite.addTestSuite(XmlKeyAnnotationTests.class);
- suite.addTestSuite(XmlPathAnnotationTests.class);
- suite.addTestSuite(XmlTransformationAnnotationTests.class);
-
- return suite;
- }
-
-
- private ELJaxbJavaResourceModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlCDATAAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlCDATAAnnotationTests.java
deleted file mode 100644
index 04882213f2..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlCDATAAnnotationTests.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotationDefinition;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2.ELJaxb_2_2_PlatformDefinition;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlCDATAAnnotation;
-
-
-public class XmlCDATAAnnotationTests
- extends ELJaxbJavaResourceModelTestCase {
-
- public XmlCDATAAnnotationTests(String name) {
- super(name);
- }
-
-
- @Override
- protected AnnotationDefinition[] annotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getAnnotationDefinitions();
- }
-
- @Override
- protected NestableAnnotationDefinition[] nestableAnnotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getNestableAnnotationDefinitions();
- }
-
-
- private ICompilationUnit createTestXmlCDATA()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_CDATA);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlCDATA");
- }
- });
- }
-
- private XmlCDATAAnnotation getXmlCDATAAnnotation(JavaResourceAttribute resourceAttribute) {
- return (XmlCDATAAnnotation) resourceAttribute.getAnnotation(ELJaxb.XML_CDATA);
- }
-
-
- public void testGetNull() throws Exception {
- ICompilationUnit cu = createTestXmlCDATA();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlCDATAAnnotation annotation = getXmlCDATAAnnotation(resourceAttribute);
-
- assertTrue(annotation != null);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlDiscriminatorNodeAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlDiscriminatorNodeAnnotationTests.java
deleted file mode 100644
index cfd2f6e26e..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlDiscriminatorNodeAnnotationTests.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotationDefinition;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2.ELJaxb_2_2_PlatformDefinition;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlDiscriminatorNodeAnnotation;
-
-
-public class XmlDiscriminatorNodeAnnotationTests
- extends ELJaxbJavaResourceModelTestCase {
-
- public XmlDiscriminatorNodeAnnotationTests(String name) {
- super(name);
- }
-
-
- @Override
- protected AnnotationDefinition[] annotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getAnnotationDefinitions();
- }
-
- @Override
- protected NestableAnnotationDefinition[] nestableAnnotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getNestableAnnotationDefinitions();
- }
-
-
- private ICompilationUnit createTestXmlDiscriminatorNodeWithValue()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_DISCRIMINATOR_NODE);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlDiscriminatorNode(\"foo\")");
- }
- });
- }
-
-
- private XmlDiscriminatorNodeAnnotation getXmlDiscriminatorNodeAnnotation(JavaResourceType resourceType) {
- return (XmlDiscriminatorNodeAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_NODE);
- }
-
-
- public void testValue() throws Exception {
- ICompilationUnit cu = createTestXmlDiscriminatorNodeWithValue();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- XmlDiscriminatorNodeAnnotation annotation = getXmlDiscriminatorNodeAnnotation(resourceType);
-
- assertEquals("foo", annotation.getValue());
- assertSourceContains("@XmlDiscriminatorNode(\"foo\")", cu);
-
- annotation.setValue("bar");
-
- assertEquals("bar", annotation.getValue());
- assertSourceContains("@XmlDiscriminatorNode(\"bar\")", cu);
-
- annotation.setValue("");
-
- assertEquals("", annotation.getValue());
- assertSourceContains("@XmlDiscriminatorNode(\"\")", cu);
-
- annotation.setValue(null);
-
- assertNull(annotation.getValue());
- assertSourceContains("@XmlDiscriminatorNode", cu);
- assertSourceDoesNotContain("@XmlDiscriminatorNode(", cu);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlDiscriminatorValueAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlDiscriminatorValueAnnotationTests.java
deleted file mode 100644
index f7743fd91d..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlDiscriminatorValueAnnotationTests.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotationDefinition;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2.ELJaxb_2_2_PlatformDefinition;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlDiscriminatorValueAnnotation;
-
-
-public class XmlDiscriminatorValueAnnotationTests
- extends ELJaxbJavaResourceModelTestCase {
-
- public XmlDiscriminatorValueAnnotationTests(String name) {
- super(name);
- }
-
-
- @Override
- protected AnnotationDefinition[] annotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getAnnotationDefinitions();
- }
-
- @Override
- protected NestableAnnotationDefinition[] nestableAnnotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getNestableAnnotationDefinitions();
- }
-
-
- private ICompilationUnit createTestXmlDiscriminatorValueWithValue()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_DISCRIMINATOR_VALUE);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlDiscriminatorValue(\"foo\")");
- }
- });
- }
-
-
- private XmlDiscriminatorValueAnnotation getXmlDiscriminatorValueAnnotation(JavaResourceType resourceType) {
- return (XmlDiscriminatorValueAnnotation) resourceType.getAnnotation(ELJaxb.XML_DISCRIMINATOR_VALUE);
- }
-
-
- public void testValue() throws Exception {
- ICompilationUnit cu = createTestXmlDiscriminatorValueWithValue();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- XmlDiscriminatorValueAnnotation annotation = getXmlDiscriminatorValueAnnotation(resourceType);
-
- assertEquals("foo", annotation.getValue());
- assertSourceContains("@XmlDiscriminatorValue(\"foo\")", cu);
-
- annotation.setValue("bar");
-
- assertEquals("bar", annotation.getValue());
- assertSourceContains("@XmlDiscriminatorValue(\"bar\")", cu);
-
- annotation.setValue("");
-
- assertEquals("", annotation.getValue());
- assertSourceContains("@XmlDiscriminatorValue(\"\")", cu);
-
- annotation.setValue(null);
-
- assertNull(annotation.getValue());
- assertSourceContains("@XmlDiscriminatorValue", cu);
- assertSourceDoesNotContain("@XmlDiscriminatorValue(", cu);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlInverseReferenceAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlInverseReferenceAnnotationTests.java
deleted file mode 100644
index 1a404f911c..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlInverseReferenceAnnotationTests.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.eclipselink.core.tests.internal.resource.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.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlInverseReferenceAnnotation;
-
-
-public class XmlInverseReferenceAnnotationTests
- extends ELJaxbJavaResourceModelTestCase {
-
- public XmlInverseReferenceAnnotationTests(String name) {
- super(name);
- }
-
-
- private ICompilationUnit createTestXmlInverseReference()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_INVERSE_REFERENCE);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlInverseReference");
- }
- });
- }
-
- private ICompilationUnit createTestXmlInverseReferenceWithMappedBy()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_INVERSE_REFERENCE);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlInverseReference(mappedBy = \"foo\")");
- }
- });
- }
-
- private XmlInverseReferenceAnnotation getXmlInverseReferenceAnnotation(JavaResourceAttribute resourceAttribute) {
- return (XmlInverseReferenceAnnotation) resourceAttribute.getAnnotation(ELJaxb.XML_INVERSE_REFERENCE);
- }
-
-
- public void testGetNull() throws Exception {
- ICompilationUnit cu = createTestXmlInverseReference();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlInverseReferenceAnnotation annotation = getXmlInverseReferenceAnnotation(resourceAttribute);
-
- assertTrue(annotation != null);
- assertNull(annotation.getMappedBy());
- }
-
- public void testGetMappedBy() throws Exception {
- ICompilationUnit cu = createTestXmlInverseReferenceWithMappedBy();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlInverseReferenceAnnotation annotation = getXmlInverseReferenceAnnotation(resourceAttribute);
-
- assertEquals("foo", annotation.getMappedBy());
- }
-
- public void testSetMappedBy() throws Exception {
- ICompilationUnit cu = createTestXmlInverseReference();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlInverseReferenceAnnotation annotation = getXmlInverseReferenceAnnotation(resourceAttribute);
-
- assertNull(annotation.getMappedBy());
-
- annotation.setMappedBy("bar");
-
- assertEquals("bar", annotation.getMappedBy());
- assertSourceContains("@XmlInverseReference(mappedBy = \"bar\")", cu);
-
- annotation.setMappedBy("");
-
- assertEquals("", annotation.getMappedBy());
- assertSourceContains("@XmlInverseReference(mappedBy = \"\")", cu);
-
- annotation.setMappedBy(null);
-
- assertNull(annotation.getMappedBy());
- assertSourceContains("@XmlInverseReference", cu);
- assertSourceDoesNotContain("mappedBy", cu);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlJoinNodeAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlJoinNodeAnnotationTests.java
deleted file mode 100644
index b4b815ef8d..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlJoinNodeAnnotationTests.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotationDefinition;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2.ELJaxb_2_2_PlatformDefinition;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlJoinNodeAnnotation;
-
-
-public class XmlJoinNodeAnnotationTests
- extends ELJaxbJavaResourceModelTestCase {
-
- public XmlJoinNodeAnnotationTests(String name) {
- super(name);
- }
-
-
- @Override
- protected AnnotationDefinition[] annotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getAnnotationDefinitions();
- }
-
- @Override
- protected NestableAnnotationDefinition[] nestableAnnotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getNestableAnnotationDefinitions();
- }
-
-
- private ICompilationUnit createTestXmlJoinNode()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_JOIN_NODE);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlJoinNode");
- }
- });
- }
-
- private ICompilationUnit createTestXmlJoinNodeWithXmlPath()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_JOIN_NODE);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlJoinNode(xmlPath=\"foo\")");
- }
- });
- }
-
- private ICompilationUnit createTestXmlJoinNodeWithReferencedXmlPath()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_JOIN_NODE);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlJoinNode(referencedXmlPath=\"foo\")");
- }
- });
- }
-
- private ICompilationUnit createTestXmlJoinNodes()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_JOIN_NODES, ELJaxb.XML_JOIN_NODE);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlJoinNodes({@XmlJoinNode,@XmlJoinNode})");
- }
- });
- }
-
- private XmlJoinNodeAnnotation getXmlJoinNodeAnnotation(JavaResourceAttribute resourceAttribute) {
- return getXmlJoinNodeAnnotation(resourceAttribute, 0);
- }
-
- private XmlJoinNodeAnnotation getXmlJoinNodeAnnotation(JavaResourceAttribute resourceAttribute, int index) {
- return (XmlJoinNodeAnnotation) resourceAttribute.getAnnotation(index, ELJaxb.XML_JOIN_NODE);
- }
-
-
- public void testXmlPath() throws Exception {
- ICompilationUnit cu = createTestXmlJoinNodeWithXmlPath();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlJoinNodeAnnotation annotation = getXmlJoinNodeAnnotation(resourceAttribute);
-
- assertEquals("foo", annotation.getXmlPath());
- assertSourceContains("@XmlJoinNode(xmlPath=\"foo\")", cu);
-
- annotation.setXmlPath("bar");
-
- assertEquals("bar", annotation.getXmlPath());
- assertSourceContains("@XmlJoinNode(xmlPath=\"bar\")", cu);
-
- annotation.setXmlPath("");
-
- assertEquals("", annotation.getXmlPath());
- assertSourceContains("@XmlJoinNode(xmlPath=\"\")", cu);
-
- annotation.setXmlPath(null);
-
- assertNull(annotation.getXmlPath());
- assertSourceContains("@XmlJoinNode", cu);
- assertSourceDoesNotContain("@XmlJoinNode(", cu);
- }
-
- public void testReferencedXmlPath() throws Exception {
- ICompilationUnit cu = createTestXmlJoinNodeWithReferencedXmlPath();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlJoinNodeAnnotation annotation = getXmlJoinNodeAnnotation(resourceAttribute);
-
- assertEquals("foo", annotation.getReferencedXmlPath());
- assertSourceContains("@XmlJoinNode(referencedXmlPath=\"foo\")", cu);
-
- annotation.setReferencedXmlPath("bar");
-
- assertEquals("bar", annotation.getReferencedXmlPath());
- assertSourceContains("@XmlJoinNode(referencedXmlPath=\"bar\")", cu);
-
- annotation.setReferencedXmlPath("");
-
- assertEquals("", annotation.getReferencedXmlPath());
- assertSourceContains("@XmlJoinNode(referencedXmlPath=\"\")", cu);
-
- annotation.setReferencedXmlPath(null);
-
- assertNull(annotation.getReferencedXmlPath());
- assertSourceContains("@XmlJoinNode", cu);
- assertSourceDoesNotContain("@XmlJoinNode(", cu);
- }
-
- public void testContainedXmlPath() throws Exception {
- // test contained annotation xmlPath setting/updating
-
- ICompilationUnit cu = createTestXmlJoinNodes();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlJoinNodeAnnotation annotation = getXmlJoinNodeAnnotation(resourceAttribute);
-
- assertNull(annotation.getXmlPath());
- assertSourceContains(
- "@XmlJoinNodes({@XmlJoinNode,@XmlJoinNode})", cu);
-
- annotation.setXmlPath("foo");
- assertEquals("foo", annotation.getXmlPath());
- assertSourceContains(
- "@XmlJoinNodes({@XmlJoinNode(xmlPath = \"foo\"),@XmlJoinNode})", cu);
-
- annotation.setXmlPath(null);
- assertNull(annotation.getXmlPath());
- assertSourceContains(
- "@XmlJoinNodes({@XmlJoinNode,@XmlJoinNode})", cu);
- }
-
- public void testContainedReferencedXmlPath() throws Exception {
- // test contained annotation referencedXmlPath setting/updating
-
- ICompilationUnit cu = createTestXmlJoinNodes();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlJoinNodeAnnotation annotation = getXmlJoinNodeAnnotation(resourceAttribute);
-
- assertNull(annotation.getReferencedXmlPath());
- assertSourceContains(
- "@XmlJoinNodes({@XmlJoinNode,@XmlJoinNode})", cu);
-
- annotation.setReferencedXmlPath("foo");
- assertEquals("foo", annotation.getReferencedXmlPath());
- assertSourceContains(
- "@XmlJoinNodes({@XmlJoinNode(referencedXmlPath = \"foo\"),@XmlJoinNode})", cu);
-
- annotation.setReferencedXmlPath(null);
- assertNull(annotation.getReferencedXmlPath());
- assertSourceContains(
- "@XmlJoinNodes({@XmlJoinNode,@XmlJoinNode})", cu);
- }
-
- public void testContained()
- throws Exception {
- // test adding/removing/moving
-
- ICompilationUnit cu = createTestXmlJoinNode();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- assertEquals(1, resourceAttribute.getAnnotationsSize(ELJaxb.XML_JOIN_NODE));
-
- resourceAttribute.addAnnotation(1, ELJaxb.XML_JOIN_NODE);
-
- assertEquals(2, resourceAttribute.getAnnotationsSize(ELJaxb.XML_JOIN_NODE));
- assertSourceContains("@XmlJoinNodes({ @XmlJoinNode, @XmlJoinNode })", cu);
-
- XmlJoinNodeAnnotation annotation1 = getXmlJoinNodeAnnotation(resourceAttribute, 0);
- annotation1.setXmlPath("foo");
- XmlJoinNodeAnnotation annotation2 = getXmlJoinNodeAnnotation(resourceAttribute, 1);
- annotation2.setXmlPath("bar");
- assertSourceContains(
- "@XmlJoinNodes({ @XmlJoinNode(xmlPath = \"foo\"), @XmlJoinNode(xmlPath = \"bar\") })", cu);
-
- resourceAttribute.moveAnnotation(0, 1, ELJaxb.XML_JOIN_NODE);
- assertSourceContains(
- "@XmlJoinNodes({ @XmlJoinNode(xmlPath = \"bar\"), @XmlJoinNode(xmlPath = \"foo\") })", cu);
-
- resourceAttribute.removeAnnotation(0, ELJaxb.XML_JOIN_NODE);
- assertEquals(1, resourceAttribute.getAnnotationsSize(ELJaxb.XML_JOIN_NODE));
- assertSourceContains(
- "@XmlJoinNode(xmlPath = \"foo\")", cu);
- assertSourceDoesNotContain("@XmlJoinNodes", cu);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlKeyAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlKeyAnnotationTests.java
deleted file mode 100644
index bbd0a16f4d..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlKeyAnnotationTests.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotationDefinition;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2.ELJaxb_2_2_PlatformDefinition;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlKeyAnnotation;
-
-
-public class XmlKeyAnnotationTests
- extends ELJaxbJavaResourceModelTestCase {
-
- public XmlKeyAnnotationTests(String name) {
- super(name);
- }
-
-
- @Override
- protected AnnotationDefinition[] annotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getAnnotationDefinitions();
- }
-
- @Override
- protected NestableAnnotationDefinition[] nestableAnnotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getNestableAnnotationDefinitions();
- }
-
-
- private ICompilationUnit createTestXmlKey()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_KEY);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlKey");
- }
- });
- }
-
- private XmlKeyAnnotation getXmlKeyAnnotation(JavaResourceAttribute resourceAttribute) {
- return (XmlKeyAnnotation) resourceAttribute.getAnnotation(ELJaxb.XML_KEY);
- }
-
-
- public void testGetNull() throws Exception {
- ICompilationUnit cu = createTestXmlKey();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlKeyAnnotation annotation = getXmlKeyAnnotation(resourceAttribute);
-
- assertTrue(annotation != null);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlPathAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlPathAnnotationTests.java
deleted file mode 100644
index f427394ab1..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlPathAnnotationTests.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.resource.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.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlPathAnnotation;
-
-
-public class XmlPathAnnotationTests
- extends ELJaxbJavaResourceModelTestCase {
-
- public XmlPathAnnotationTests(String name) {
- super(name);
- }
-
-
- private ICompilationUnit createTestXmlPath()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_PATH);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlPath");
- }
- });
- }
-
- private ICompilationUnit createTestXmlPathWithValue()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_PATH);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlPath(\"foo\")");
- }
- });
- }
-
- private ICompilationUnit createTestXmlPaths()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_PATHS, ELJaxb.XML_PATH);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlPaths({@XmlPath,@XmlPath})");
- }
- });
- }
-
- private XmlPathAnnotation getXmlPathAnnotation(JavaResourceAttribute resourceAttribute) {
- return getXmlPathAnnotation(resourceAttribute, 0);
- }
-
- private XmlPathAnnotation getXmlPathAnnotation(JavaResourceAttribute resourceAttribute, int index) {
- return (XmlPathAnnotation) resourceAttribute.getAnnotation(index, ELJaxb.XML_PATH);
- }
-
-
- public void testValue() throws Exception {
- ICompilationUnit cu = createTestXmlPathWithValue();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlPathAnnotation annotation = getXmlPathAnnotation(resourceAttribute);
-
- assertEquals("foo", annotation.getValue());
- assertSourceContains("@XmlPath(\"foo\")", cu);
-
- annotation.setValue("bar");
-
- assertEquals("bar", annotation.getValue());
- assertSourceContains("@XmlPath(\"bar\")", cu);
-
- annotation.setValue("");
-
- assertEquals("", annotation.getValue());
- assertSourceContains("@XmlPath(\"\")", cu);
-
- annotation.setValue(null);
-
- assertNull(annotation.getValue());
- assertSourceContains("@XmlPath", cu);
- assertSourceDoesNotContain("@XmlPath(", cu);
- }
-
- public void testContainedValue() throws Exception {
- // test contained annotation value setting/updating
-
- ICompilationUnit cu = createTestXmlPaths();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlPathAnnotation annotation = getXmlPathAnnotation(resourceAttribute);
-
- assertNull(annotation.getValue());
- assertSourceContains(
- "@XmlPaths({@XmlPath,@XmlPath})", cu);
-
- annotation.setValue("foo");
- assertEquals("foo", annotation.getValue());
- assertSourceContains(
- "@XmlPaths({@XmlPath(\"foo\"),@XmlPath})", cu);
-
- annotation.setValue(null);
- assertNull(annotation.getValue());
- assertSourceContains(
- "@XmlPaths({@XmlPath,@XmlPath})", cu);
- }
-
- public void testContained()
- throws Exception {
- // test adding/removing/moving
-
- ICompilationUnit cu = createTestXmlPath();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- assertEquals(1, resourceAttribute.getAnnotationsSize(ELJaxb.XML_PATH));
-
- resourceAttribute.addAnnotation(1, ELJaxb.XML_PATH);
-
- assertEquals(2, resourceAttribute.getAnnotationsSize(ELJaxb.XML_PATH));
- assertSourceContains("@XmlPaths({ @XmlPath, @XmlPath })", cu);
-
- XmlPathAnnotation annotation1 = getXmlPathAnnotation(resourceAttribute, 0);
- annotation1.setValue("foo");
- XmlPathAnnotation annotation2 = getXmlPathAnnotation(resourceAttribute, 1);
- annotation2.setValue("bar");
- assertSourceContains(
- "@XmlPaths({ @XmlPath(\"foo\"), @XmlPath(\"bar\") })", cu);
-
- resourceAttribute.moveAnnotation(0, 1, ELJaxb.XML_PATH);
- assertSourceContains(
- "@XmlPaths({ @XmlPath(\"bar\"), @XmlPath(\"foo\") })", cu);
-
- resourceAttribute.removeAnnotation(0, ELJaxb.XML_PATH);
- assertEquals(1, resourceAttribute.getAnnotationsSize(ELJaxb.XML_PATH));
- assertSourceContains(
- "@XmlPath(\"foo\")", cu);
- assertSourceDoesNotContain("@XmlPaths", cu);
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlTransformationAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlTransformationAnnotationTests.java
deleted file mode 100644
index 2fd4039364..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/resource/java/XmlTransformationAnnotationTests.java
+++ /dev/null
@@ -1,121 +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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotationDefinition;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2.ELJaxb_2_2_PlatformDefinition;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlTransformationAnnotation;
-
-
-public class XmlTransformationAnnotationTests
- extends ELJaxbJavaResourceModelTestCase {
-
- public XmlTransformationAnnotationTests(String name) {
- super(name);
- }
-
-
- @Override
- protected AnnotationDefinition[] annotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getAnnotationDefinitions();
- }
-
- @Override
- protected NestableAnnotationDefinition[] nestableAnnotationDefinitions() {
- return ELJaxb_2_2_PlatformDefinition.instance().getNestableAnnotationDefinitions();
- }
-
-
- private ICompilationUnit createTestXmlTransformation()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_TRANSFORMATION);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlTransformation");
- }
- });
- }
-
- private ICompilationUnit createTestXmlTransformationWithOptional()
- throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
-
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(ELJaxb.XML_TRANSFORMATION);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@XmlTransformation(optional = true)");
- }
- });
- }
-
- private XmlTransformationAnnotation getXmlTransformationAnnotation(JavaResourceAttribute resourceAttribute) {
- return (XmlTransformationAnnotation) resourceAttribute.getAnnotation(ELJaxb.XML_TRANSFORMATION);
- }
-
-
- public void testGetNull() throws Exception {
- ICompilationUnit cu = createTestXmlTransformation();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlTransformationAnnotation annotation = getXmlTransformationAnnotation(resourceAttribute);
-
- assertTrue(annotation != null);
- assertNull(annotation.getOptional());
- }
-
- public void testGetOptional() throws Exception {
- ICompilationUnit cu = createTestXmlTransformationWithOptional();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlTransformationAnnotation annotation = getXmlTransformationAnnotation(resourceAttribute);
-
- assertEquals(Boolean.TRUE, annotation.getOptional());
- }
-
- public void testSetOptional() throws Exception {
- ICompilationUnit cu = createTestXmlTransformation();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlTransformationAnnotation annotation = getXmlTransformationAnnotation(resourceAttribute);
-
- assertNull(annotation.getOptional());
-
- annotation.setOptional(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, annotation.getOptional());
- assertSourceContains("@XmlTransformation(optional = false)", cu);
-
- annotation.setOptional(null);
-
- assertNull(annotation.getOptional());
- assertSourceContains("@XmlTransformation", cu);
- assertSourceDoesNotContain("optional", cu);
- }
-}

Back to the top