9 Replies Latest reply on Jun 9, 2008 4:29 AM by jaikiran

    Instructions for SerializableMethod Unit Tests

    alrubinger

      Jaikiran:

      Within the EJB3 Proxy Component is a currently untested class, "org.jboss.ejb3.proxy.lang.SerializableMethod". We need tests to ensure that:

      * .equals() returns true if the name, className, returnType, and each of the argumentTypes are equal by value.
      * .hashCode() follows the contract of .hashCode(), ie: if two objects are equal by value, they must have the same hashCode
      * java.lang.reflect.Method > SerializableMethod > Method roundtrip returns with input equal by value to output given the same ClassLoader

      The project itself follows the standard Maven2 layout, and you should be able to follow the template (naming conventions, etc) of the other tests. I'll send the JBoss Eclipse formatting and code templates for you to import.

      To Download and Build:

      svn co https://svn.jboss.org/repos/jbossas/projects/ejb3/trunk
      cd trunk
      mvn clean install


      From there, you can easily "cd" into the "proxy" component and issue "mvn clean install" to run the tests, see the Maven Surefire Plugin documentation for information on attaching a debugger, running only one test, etc.

      Once you've completed, if you attach a patch ("svn diff > filename.patch") to the JIRA below; I'll review and commit it.

      http://jira.jboss.com/jira/browse/EJBTHREE-1400

      Thanks for your interest; let's use this Thread for any questions so we keep development concerns truly open to the community. :)

      S,
      ALR

        • 1. Re: Instructions for SerializableMethod Unit Tests
          alrubinger

          Forgot to mention:

          Many of the dependencies for the project are in the JBoss Maven Repositories, which you'll need to configure:

          http://wiki.jboss.org/wiki/MavenSettings
          http://wiki.jboss.org/wiki/MavenSettingsExample

          S,
          ALR

          • 2. Re: Instructions for SerializableMethod Unit Tests
            alrubinger

            Oh, and use Maven 2.0.9; 2.0.8 will give you unpredictable results.

            S,
            ALR

            • 3. Re: Instructions for SerializableMethod Unit Tests
              jaikiran

              Andrew,

              Thanks for your efforts in guiding me :)

              I have checked out EJB3 project and installed Maven 2.0.9. I am new to Maven (have been using Ant) and it's going to take some time to start understanding how it works. But so far, based on the wiki that you pointed me to, the maven configuration has been smooth.

              Right now, i am just going through the code/tests to see how they are structured. I have some basic questions regarding this:

              1) There's a "testsuite" containing the testcases. Based on what i see, the test cases are written in package named org.jboss.ejb3.test.[XXX].unit. Then there is also a package named org.jboss.ejb3.test.[XXX] which probably contains the required resources for the corresponding test cases (ex: If an testcase depends on a bean, then the bean implementation goes in this package). Is this correct?

              2) I also see test cases under each component, example: the proxy component has the src/test/java/org.jboss.ejb3.test.proxy.remoteaccess.unit.RemoteAccessTestCase testcase. How are these test cases different from the ones in the "testsuite"?

              3) Some of the testcases extend the JUnit TestCase class where as some of them use annotations @Test. Is there any convention to be followed while writing new testcases?

              • 4. Re: Instructions for SerializableMethod Unit Tests
                alrubinger

                 

                "jaikiran" wrote:
                1) There's a "testsuite" containing the testcases. Based on what i see, the test cases are written in package named org.jboss.ejb3.test.[XXX].unit. Then there is also a package named org.jboss.ejb3.test.[XXX] which probably contains the required resources for the corresponding test cases (ex: If an testcase depends on a bean, then the bean implementation goes in this package). Is this correct?


                Correct.

                "jaikiran" wrote:
                2) I also see test cases under each component, example: the proxy component has the src/test/java/org.jboss.ejb3.test.proxy.remoteaccess.unit.RemoteAccessTestCase testcase. How are these test cases different from the ones in the "testsuite"?


                Here's some definitions until I can update the EJB3 Development Wiki:

                "testsuite" Module = The EJB3 Integration TestSuite; deployable units intended to be installed into a running AS. Let's leave this alone for the time being. :)

                "test" Module = Backing libraries for EJB3 Unit Tests

                "src/test/java" and "src/test/resources" in each Module = Unit Tests specific to that module. These run standalone (executed by Maven as part of the "test" phase, which is in turn part of the "install" phase. These are intended to run quickly and test fine-grained parts of a component, and this is where we need coverage for SerializableMethod.

                "jaikiran" wrote:
                3) Some of the testcases extend the JUnit TestCase class where as some of them use annotations @Test. Is there any convention to be followed while writing new testcases?


                Newer tests are built using JUnit 4.4, which supports POJO-based testing. So as a convention for new tests I prefer to follow the form exhibited by TestCases in EJB3 Proxy, for example.

                S,
                ALR

                • 5. Re: Instructions for SerializableMethod Unit Tests
                  jaikiran

                  Thanks Andrew. This should be enough to get started with the testcase.

                  • 6. Re: Instructions for SerializableMethod Unit Tests
                    jaikiran

                    Andrew,

                    I have updated the JIRA with the test cases and other details. Any review comments/suggestions are most welcome :)

                    Btw, is there a way/goal/target through which i can generate html reports of these test?

                    • 7. Re: Instructions for SerializableMethod Unit Tests
                      alrubinger

                      Jaikiran:

                      I've reviewed and committed your tests, and have opened http://jira.jboss.com/jira/browse/EJBTHREE-1407 to address the failures you've exposed. Next step is to resolve this. :)

                      "jaikiran" wrote:
                      Btw, is there a way/goal/target through which i can generate html reports of these test?


                      http://maven.apache.org/plugins/maven-surefire-report-plugin/

                      Also note that the text containing the output and client-side errors are in target/surefire-reports.

                      S,
                      ALR

                      • 8. Re: Instructions for SerializableMethod Unit Tests
                        alrubinger

                        I've fixed EJBTHREE-1407; thanks to Jaikiran for finding these and providing tests with great coverage.

                        Apologies for not leaving these for you to fix; any failing testsuite has to be resolved before we can successfully complete a build. Hard and fast rule here in EJB3 looking forward. We have a (unit) TestSuite now at 100%, and we will be building onto it without allowing any regression to seep in.

                        S,
                        ALR

                        • 9. Re: Instructions for SerializableMethod Unit Tests
                          jaikiran

                           

                          "ALRubinger" wrote:


                          "jaikiran" wrote:
                          Btw, is there a way/goal/target through which i can generate html reports of these test?


                          http://maven.apache.org/plugins/maven-surefire-report-plugin/

                          Also note that the text containing the output and client-side errors are in target/surefire-reports.

                          S,
                          ALR


                          Thanks!