Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jaxb
diff options
context:
space:
mode:
authorpfullbright2011-03-14 17:35:45 +0000
committerpfullbright2011-03-14 17:35:45 +0000
commit20b90a1910e6f8cbc66b01d2d097583584e6fabe (patch)
tree1d95384b459ef1998f6519bf3ba476832b985901 /jaxb
parentbbdff9cb935f6ac7cd71a44533594633e4f862c2 (diff)
downloadwebtools.dali-20b90a1910e6f8cbc66b01d2d097583584e6fabe.tar.gz
webtools.dali-20b90a1910e6f8cbc66b01d2d097583584e6fabe.tar.xz
webtools.dali-20b90a1910e6f8cbc66b01d2d097583584e6fabe.zip
added jaxb.index context tests
Diffstat (limited to 'jaxb')
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/GenericContextRootTests.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/GenericContextRootTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/GenericContextRootTests.java
index ebbd71d09c..2e3784cb86 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/GenericContextRootTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/GenericContextRootTests.java
@@ -9,9 +9,12 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.core.tests.internal.context;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
import java.util.Iterator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.Expression;
@@ -555,4 +558,47 @@ public class GenericContextRootTests
assertEquals(1, CollectionTools.size(getContextRoot().getPersistentClasses()));
assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
}
+
+ public void testJaxbIndex() throws Exception {
+ final String otherClassName = "Other" + TYPE_NAME;
+ final String fqOtherClassName = PACKAGE_NAME_ + otherClassName;
+ final String otherClassName2 = "Other" + TYPE_NAME + "2";
+ final String fqOtherClassName2 = PACKAGE_NAME_ + otherClassName2;
+ createUnannotatedClassNamed(otherClassName);
+ createUnannotatedClassNamed(otherClassName2);
+
+ // make sure unannotated other classes are not in context
+ assertTrue(CollectionTools.isEmpty(getContextRoot().getPersistentClasses()));
+
+ createAnnotatedPersistentClass();
+ JavaResourceType thisType = (JavaResourceType) getJaxbProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME);
+ AnnotatedElement annotatedType = annotatedElement(thisType);
+
+ // make sure unannotated other classes are not in context
+ assertEquals(1, CollectionTools.size(getContextRoot().getPersistentClasses()));
+ assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
+
+ // add a jaxb.index with one class
+ IFile jaxbIndex = getJavaProject().getProject().getFile(new Path("src/test/jaxb.index"));
+ InputStream stream = new ByteArrayInputStream(otherClassName.getBytes());
+ jaxbIndex.create(stream, true, null);
+
+ assertEquals(2, CollectionTools.size(getContextRoot().getPersistentClasses()));
+ assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
+ assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName));
+
+ // change to jaxb.index with two classes
+ jaxbIndex.setContents(new ByteArrayInputStream((otherClassName + CR + otherClassName2).getBytes()), true, false, null);
+
+ assertEquals(3, CollectionTools.size(getContextRoot().getPersistentClasses()));
+ assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
+ assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName));
+ assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName2));
+
+ // clear the jaxb.index
+ jaxbIndex.setContents(new ByteArrayInputStream(new byte[0]), true, false, null);
+
+ assertEquals(1, CollectionTools.size(getContextRoot().getPersistentClasses()));
+ assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
+ }
}

Back to the top