Author: scabanovich
Date: 2011-04-04 17:53:50 -0400 (Mon, 04 Apr 2011)
New Revision: 30293
Added:
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/CDISolderCoreAllTests.java
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/VetoTest.java
Removed:
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/CDISolderCoreAllTests.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/META-INF/MANIFEST.MF
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/BeanNamingTest.java
Log:
JBIDE-8198
https://issues.jboss.org/browse/JBIDE-8198
Modified: trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/META-INF/MANIFEST.MF 2011-04-04
21:53:42 UTC (rev 30292)
+++ trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/META-INF/MANIFEST.MF 2011-04-04
21:53:50 UTC (rev 30293)
@@ -20,5 +20,5 @@
org.jboss.tools.jst.web.kb,
org.jboss.tools.cdi.xml,
org.eclipse.jst.standard.schemas
-Export-Package: org.jboss.tools.cdi.solder.core.test
+Export-Package: org.jboss.tools.seam.solder.core.test
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/BeanNamingTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/cdi/solder/core/test/BeanNamingTest.java 2011-03-31
00:52:51 UTC (rev 30171)
+++
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/BeanNamingTest.java 2011-04-04
21:53:50 UTC (rev 30293)
@@ -1,4 +1,4 @@
-package org.jboss.tools.cdi.solder.core.test;
+package org.jboss.tools.seam.solder.core.test;
import java.io.IOException;
import java.util.Set;
Deleted:
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/CDISolderCoreAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/cdi/solder/core/test/CDISolderCoreAllTests.java 2011-03-31
00:52:51 UTC (rev 30171)
+++
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/CDISolderCoreAllTests.java 2011-04-04
21:53:50 UTC (rev 30293)
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.solder.core.test;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.jdt.internal.core.JavaModelManager;
-/**
- * @author Viacheslav Kabanovich
- */
-public class CDISolderCoreAllTests {
-
- public static Test suite() {
- // it could be done here because it is not needed to be enabled back
- JavaModelManager.getIndexManager().disable();
-
- TestSuite suiteAll = new TestSuite("CDI Solder Core Tests");
-
- suiteAll.addTestSuite(BeanNamingTest.class);
-
- return suiteAll;
- }
-}
Copied:
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/CDISolderCoreAllTests.java
(from rev 30242,
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/cdi/solder/core/test/CDISolderCoreAllTests.java)
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/CDISolderCoreAllTests.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/CDISolderCoreAllTests.java 2011-04-04
21:53:50 UTC (rev 30293)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.solder.core.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.internal.core.JavaModelManager;
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class CDISolderCoreAllTests {
+
+ public static Test suite() {
+ // it could be done here because it is not needed to be enabled back
+ JavaModelManager.getIndexManager().disable();
+
+ TestSuite suiteAll = new TestSuite("CDI Solder Core Tests");
+
+ suiteAll.addTestSuite(BeanNamingTest.class);
+ suiteAll.addTestSuite(VetoTest.class);
+
+ return suiteAll;
+ }
+}
Copied:
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/VetoTest.java
(from rev 30287,
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/cdi/solder/core/test/VetoTest.java)
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/VetoTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.solder.core.test/src/org/jboss/tools/seam/solder/core/test/VetoTest.java 2011-04-04
21:53:50 UTC (rev 30293)
@@ -0,0 +1,114 @@
+package org.jboss.tools.seam.solder.core.test;
+
+
+import java.io.IOException;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.IAnnotationDeclaration;
+import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class VetoTest extends TestCase {
+ protected static String PLUGIN_ID = "org.jboss.tools.cdi.solder.core.test";
+ IProject project = null;
+
+ public VetoTest() {}
+
+ public void setUp() throws Exception {
+ project = ResourcesUtils.importProject(PLUGIN_ID,
"/projects/CDISolderTest");
+ JobUtils.waitForIdle();
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ JobUtils.waitForIdle();
+ }
+
+ public void testVeto() throws CoreException, IOException {
+ ICDIProject cdi = CDICorePlugin.getCDIProject(project, true);
+
+ //1. package annotated @Veto; class is not annotated with it
+ TypeDefinition d =
cdi.getNature().getDefinitions().getTypeDefinition("org.jboss.vetoed.Tiger");
+ assertNotNull(d); //Though there exists Java type Tiger
+ IAnnotationDeclaration a = d.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ assertNotNull(a);
+ Object name = a.getMemberValue(null);
+ assertEquals("tiger", name); //...and it is annotated with
@Named("tiger")
+ Set<IBean> bs = cdi.getBeans("tiger", false);
+ assertTrue(bs.isEmpty()); //...CDI model does not have a bean named
"tiger"
+ bs = cdi.getBeans(d.getResource().getFullPath());
+ assertTrue(bs.isEmpty()); //...and does not loaded any beans form its resource
+
+ //2. class annotated @Veto
+ d =
cdi.getNature().getDefinitions().getTypeDefinition("org.jboss.somevetoed.Lion");
+ assertNotNull(d); //Though there exists Java type Lion
+ a = d.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ assertNotNull(a);
+ name = a.getMemberValue(null);
+ assertEquals("lion", name); //...and it is annotated with
@Named("lion")
+ bs = cdi.getBeans("lion", false);
+ assertTrue(bs.isEmpty()); //...CDI model does not have a bean named
"lion"
+ bs = cdi.getBeans(d.getResource().getFullPath());
+ assertTrue(bs.isEmpty()); //...and does not loaded any beans form its resource
+ }
+
+ public void testRequires() throws CoreException, IOException {
+ ICDIProject cdi = CDICorePlugin.getCDIProject(project, true);
+
+ //1. class annotated @Requires that references single non-available class
+ TypeDefinition d =
cdi.getNature().getDefinitions().getTypeDefinition("org.jboss.requires.Bear");
+ assertNotNull(d); //Though there exists Java type Bear
+ IAnnotationDeclaration a = d.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ assertNotNull(a);
+ Object name = a.getMemberValue(null);
+ assertEquals("bear", name); //...and it is annotated with
@Named("bear")
+ Set<IBean> bs = cdi.getBeans("bear", false);
+ assertTrue(bs.isEmpty()); //...CDI model does not have a bean named
"bear"
+ bs = cdi.getBeans(d.getResource().getFullPath());
+ assertTrue(bs.isEmpty()); //...and does not loaded any beans form its resource
+
+ //2. class annotated @Requires that references array of classes some of which are not
available
+ d =
cdi.getNature().getDefinitions().getTypeDefinition("org.jboss.requires.Bee");
+ assertNotNull(d); //Though there exists Java type Bee
+ a = d.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ assertNotNull(a);
+ name = a.getMemberValue(null);
+ assertEquals("bee", name); //...and it is annotated with
@Named("bee")
+ bs = cdi.getBeans("bee", false);
+ assertTrue(bs.isEmpty()); //...CDI model does not have a bean named "bee"
+ bs = cdi.getBeans(d.getResource().getFullPath());
+ assertTrue(bs.isEmpty()); //...and does not loaded any beans form its resource
+
+ //3. class annotated @Requires that references single available class
+ bs = cdi.getBeans("fly", false);
+ assertEquals(1, bs.size()); //...CDI model has a bean named "fly"
+
+ //4. class annotated @Requires that references array of available classes
+ bs = cdi.getBeans("dragonfly", false);
+ assertEquals(1, bs.size()); //...CDI model has a bean named "dragonfly"
+
+ }
+
+ public void tearDown() throws Exception {
+ boolean saveAutoBuild = ResourcesUtils.setBuildAutomatically(false);
+ JobUtils.waitForIdle();
+ project.delete(true, true, null);
+ JobUtils.waitForIdle();
+ ResourcesUtils.setBuildAutomatically(saveAutoBuild);
+ JobUtils.waitForIdle();
+ }
+}