Author: scabanovich
Date: 2011-07-29 12:00:35 -0400 (Fri, 29 Jul 2011)
New Revision: 33355
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.changed
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.original
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/RemoveJarFromClasspathTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BuiltInBeanInjectionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
Log:
JBIDE-9401
https://issues.jboss.org/browse/JBIDE-9401
Test for built-in bean injection in cases of presence/absence of its custom
implementation.
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.changed
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.changed
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.changed 2011-07-29
16:00:35 UTC (rev 33355)
@@ -0,0 +1,51 @@
+package org.jboss.jsr299.tck.tests.jbt.builtin;
+
+import javax.enterprise.context.Conversation;
+import javax.inject.Named;
+
+(a)Named("javax.enterprise.context.conversation")
+public class ConversationImpl implements Conversation {
+
+ @Override
+ public void begin() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void begin(String arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void end() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getTimeout() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean isTransient() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setTimeout(long arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.java 2011-07-29
16:00:35 UTC (rev 33355)
@@ -0,0 +1,53 @@
+package org.jboss.jsr299.tck.tests.jbt.builtin;
+
+import javax.enterprise.context.Conversation;
+import javax.inject.Named;
+
+(a)Named("javax.enterprise.context.conversation")
+public class ConversationImpl implements Conversation {
+
+ public ConversationImpl(String s) {}
+
+ @Override
+ public void begin() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void begin(String arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void end() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getTimeout() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean isTransient() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setTimeout(long arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.original
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.original
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/builtin/ConversationImpl.original 2011-07-29
16:00:35 UTC (rev 33355)
@@ -0,0 +1,53 @@
+package org.jboss.jsr299.tck.tests.jbt.builtin;
+
+import javax.enterprise.context.Conversation;
+import javax.inject.Named;
+
+(a)Named("javax.enterprise.context.conversation")
+public class ConversationImpl implements Conversation {
+
+ public ConversationImpl(String s) {}
+
+ @Override
+ public void begin() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void begin(String arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void end() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getTimeout() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean isTransient() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setTimeout(long arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/RemoveJarFromClasspathTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/RemoveJarFromClasspathTest.java 2011-07-29
15:06:38 UTC (rev 33354)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/RemoveJarFromClasspathTest.java 2011-07-29
16:00:35 UTC (rev 33355)
@@ -19,6 +19,8 @@
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.filesystems.impl.Libs;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.jsp.test.TestUtil;
+import org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager;
import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.test.util.ResourcesUtils;
@@ -98,6 +100,7 @@
IFile target = project.getFile(new Path(targetPath));
IFile source = project.getFile(new Path(sourcePath));
assertTrue(source.exists());
+ ValidatorManager.setStatus(ValidatorManager.RUNNING);
if(!target.exists()) {
target.create(source.getContents(), true, new NullProgressMonitor());
} else {
@@ -106,6 +109,7 @@
JobUtils.waitForIdle();
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new
NullProgressMonitor());
JobUtils.waitForIdle();
+ TestUtil.waitForValidation();
} finally {
ResourcesUtils.setBuildAutomatically(saveAutoBuild);
JobUtils.waitForIdle();
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BuiltInBeanInjectionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BuiltInBeanInjectionTest.java 2011-07-29
15:06:38 UTC (rev 33354)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BuiltInBeanInjectionTest.java 2011-07-29
16:00:35 UTC (rev 33355)
@@ -12,12 +12,15 @@
import java.util.Set;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IType;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IBuiltInBean;
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IInjectionPointField;
+import org.jboss.tools.cdi.core.test.RemoveJarFromClasspathTest;
/**
* @author Viacheslav Kabanovich
@@ -116,6 +119,7 @@
IBean b = beans.iterator().next();
assertTrue(b instanceof IClassBean);
+ assertTrue(b instanceof IBuiltInBean);
IType t = b.getBeanClass();
assertEquals(CDIConstants.CONVERSATION_TYPE_NAME, t.getFullyQualifiedName());
assertEquals(CDIConstants.CONVERSATION_BEAN_NAME, b.getName());
@@ -123,4 +127,36 @@
assertTrue(beans.contains(b));
}
+ /**
+ * Test that when custom project provides implementation of
javax.enterprise.context.Conversation
+ * that is visible to our model, our built-in bean is replaced by it.
+ */
+ public void testBuiltInConversationBeanCustomImplementation() throws CoreException {
+ String c =
"JavaSource/org/jboss/jsr299/tck/tests/jbt/builtin/ConversationImpl.java";
+ String c_active =
"JavaSource/org/jboss/jsr299/tck/tests/jbt/builtin/ConversationImpl.changed";
+ String c_original =
"JavaSource/org/jboss/jsr299/tck/tests/jbt/builtin/ConversationImpl.original";
+
+ Set<IBean> beans = cdiProject.getBeans(CDIConstants.CONVERSATION_BEAN_NAME,
false);
+ assertEquals(1, beans.size());
+ IBean b = beans.iterator().next();
+ assertTrue(b instanceof IClassBean);
+ assertTrue(b instanceof IBuiltInBean);
+
+ RemoveJarFromClasspathTest.replaceFile(tckProject, c_active, c);
+
+ beans = cdiProject.getBeans(CDIConstants.CONVERSATION_BEAN_NAME, false);
+ assertEquals(1, beans.size());
+ b = beans.iterator().next();
+ assertTrue(b instanceof IClassBean);
+ assertFalse(b instanceof IBuiltInBean);
+ assertEquals("org.jboss.jsr299.tck.tests.jbt.builtin.ConversationImpl",
b.getBeanClass().getFullyQualifiedName());
+
+ RemoveJarFromClasspathTest.replaceFile(tckProject, c_original, c);
+ beans = cdiProject.getBeans(CDIConstants.CONVERSATION_BEAN_NAME, false);
+ b = beans.iterator().next();
+ assertEquals(1, beans.size());
+ assertTrue(b instanceof IClassBean);
+ assertTrue(b instanceof IBuiltInBean);
+ }
+
}
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2011-07-29
15:06:38 UTC (rev 33354)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2011-07-29
16:00:35 UTC (rev 33355)
@@ -207,7 +207,14 @@
static class JavaFileFilter implements FileFilter {
public boolean accept(File pathname) {
String name = pathname.getName();
- return (pathname.isDirectory() && !name.endsWith(".svn")) ||
((name.endsWith(".java") || name.endsWith(".qfxresult") ||
name.endsWith(".validation") || name.equals("beans.xml")) &&
!name.endsWith("Test.java"));
+ return (pathname.isDirectory() && !name.endsWith(".svn"))
+ || ((name.endsWith(".java")
+ || name.endsWith(".qfxresult")
+ || name.endsWith(".validation")
+ || name.endsWith(".changed") //used to replace content of java file
+ || name.endsWith(".original") //used to restore content of java file
+ || name.equals("beans.xml"))
+ && !name.endsWith("Test.java"));
}
}