Uploaded image for project: 'CDI TCK'
  1. CDI TCK
  2. CDITCK-160

NewEnterpriseBeanICTest.testNewBeanHasSameConstructor() assumes new instance creation

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 1.0.1.Final
    • Fix Version/s: 1.0.2.CR1
    • Component/s: Tests
    • Labels:
      None
    • Environment:

      run against GlassFish v3.0.1 intermediate build

    • Steps to Reproduce:
      Hide

      Run against v3.0.1. Note that this issue was discovered during development testing of the fix for EJB constructor injection so that fix has not been checked in yet. GlassFish issue 11180 https://glassfish.dev.java.net/issues/show_bug.cgi?id=11180 can be used to check the status of that fix. Otherwise, the WELD TCK test will fail before reaching the assertion in question.

      Show
      Run against v3.0.1. Note that this issue was discovered during development testing of the fix for EJB constructor injection so that fix has not been checked in yet. GlassFish issue 11180 https://glassfish.dev.java.net/issues/show_bug.cgi?id=11180 can be used to check the status of that fix. Otherwise, the WELD TCK test will fail before reaching the assertion in question.

      Description

      I'm working on supporting EJB constructor injection for GlassFish v3.0.1(https://glassfish.dev.java.net/issues/show_bug.cgi?id=11180) but I'm seeing a failure in NewEnterpriseBeanICTest.testNewBeanHasSameConstructor(NewEnterpriseBeanICTest, line 49. I can confirm that the Stateless Session bean class one-arg constructor is being invoked as a result of the InjectionTarget.produce() operation, but I don't understand the assumption the test client is making.

      The test client accesses the bean through a reference, then calls a bean method that resets a static field counting the number of constructor calls for that bean class. It then calls getInstanceByType() and assumes that the constructor count has been incremented as a result of a new bean instance creation. The pooling strategy of the container might mean an existing bean instance is reused. In that case, the constructor will not be called a second time and the test assertion will fail.

      34 @Artifact
      35 @Packaging(PackagingType.EAR)
      36 @IntegrationTest
      37 @SpecVersion(spec="cdi", version="20091101")
      38 public class NewEnterpriseBeanICTest extends AbstractJSR299Test
      39 {
      40
      41 @Test(groups =

      { "new" }

      )
      42 @SpecAssertion(section = "3.12", id = "l")
      43 public void testNewBeanHasSameConstructor()
      44

      { 45 ExplicitConstructor bean = getInstanceByType(ExplicitConstructor.class); 46 bean.setConstructorCalls(0); 47 ExplicitConstructor newBean = getInstanceByType(ExplicitConstructor.class, ExplicitConstructorSessionBean.NEW); 48 assert bean != newBean; 49 assert bean.getConstructorCalls() == 1; 50 assert bean.getInjectedSimpleBean() != null; 51 }

      [testng] java.lang.AssertionError
      [testng] at org.jboss.jsr299.tck.tests.implementation.enterprise.newBean.NewEnterpriseBeanICTest.testNewBeanHasSameConstructor(NewEnterpriseBeanICTest.java:49)
      [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [testng] at java.lang.reflect.Method.invoke(Method.java:597)
      [testng] at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:609)
      [testng] at org.testng.internal.MethodHelper$1.runTestMethod(MethodHelper.java:727)
      [testng] at org.jboss.testharness.AbstractTest.run(AbstractTest.java:244)
      [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [testng] at java.lang.reflect.Method.invoke(Method.java:597)
      [testng] at org.testng.internal.MethodHelper.invokeHookable(MethodHelper.java:735)
      [testng] at org.testng.internal.Invoker.invokeMethod(Invoker.java:525)
      [testng] at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:686)
      [testng] at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1018)
      [testng] at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:128)
      [testng] at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
      [testng] at org.testng.TestRunner.runWorkers(TestRunner.java:759)
      [testng] at org.testng.TestRunner.privateRun(TestRunner.java:592)
      [testng] at org.testng.TestRunner.run(TestRunner.java:486)
      [testng] at org.testng.SuiteRunner.runTest(SuiteRunner.java:332)
      [testng] at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:327)
      [testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:299)
      [testng] at org.testng.SuiteRunner.run(SuiteRunner.java:204)
      [testng] at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:912)
      [testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:876)
      [testng] at org.testng.TestNG.run(TestNG.java:784)
      [testng] at org.jboss.testharness.impl.runner.TestRunner.run(TestRunner.java:61)
      [testng] at org.jboss.testharness.impl.runner.servlet.ServletTestRunner.doGet(ServletTestRunner.java:120)
      [testng] at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
      [testng] at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      [testng] at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
      [testng] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
      [testng] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
      [testng] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
      [testng] at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
      [testng] at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
      [testng] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
      [testng] at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
      [testng] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
      [testng] at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
      [testng] at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
      [testng] at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
      [testng] at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
      [testng] at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
      [testng] at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
      [testng] at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
      [testng] at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
      [testng] at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
      [testng] at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
      [testng] at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
      [testng] at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
      [testng] at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
      [testng] at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
      [testng] at java.lang.Thread.run(Thread.java:637)

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                pmuir Pete Muir
                Reporter:
                ken_saks Ken Saks
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: