Loading ...
Sorry, an error occurred while loading the content.

[XP] Re: EJB and junit

Expand Messages
  • Mike Morris
    ... The same problem crops up in writing Jini services and clients -- how do you test the remote stuff in short times (which is probably where stuff is most
    Message 1 of 13 , Feb 28, 2000
    • 0 Attachment
      Gerd Boerrigter wrote:
      >
      > Hi,
      >
      > we are using WebLogic server to build Enterprise JavaBeans. I want to
      > use junit to do unit tests of the beans. I am new to EJB and can not
      > think about an easy way to test the beans in the container.
      >
      > It looks like I need to write a Remote-Interface for the tests to be
      > able to run them on the server. This looks like too much work to do.
      > Is there an easy way to run junit on the server? How do other people
      > do it?

      The same problem crops up in writing Jini services and clients -- how do
      you test the remote stuff in short times (which is probably where stuff
      is most likely to break).

      I am presently experimenting with testing the server locally first,
      which ensure that at least it sets itself up properly (Jini being
      somewhat finicky about setup issues), and I'll take figure out the next
      step when I get to it.

      Has anyone else more experience with unit-testing distributed apps?
      Tips, traps, tricks?
      --
      Mike Morris cOcO Technologies cc

      Java & OO training, consulting and software.

      mike.morris@...
      Ph: Intl +27-44-388-4635 Local (044)388-4635
      P O Box 34, Rheenendal, 6576, South Africa

      -- A day without chillies is a day wasted --
    • Tim Mackinnon
      ... Yes - write your code so that you can Mock Up the distributed bits locally. As pointed out - distributed stuff is very finicky, so make sure you unit
      Message 2 of 13 , Feb 29, 2000
      • 0 Attachment
        > Has anyone else more experience with unit-testing distributed apps?
        > Tips, traps, tricks?

        Yes - write your code so that you can "Mock Up" the distributed bits
        locally. As pointed out - distributed stuff is very finicky, so make sure
        you unit test all of your code with mock distribution that you can rely on,
        or can force known errors in. Proving the stability of this code at the unit
        level then gives you lots more confidence to test the harder distributed
        bits (we do it as a system test, which is sort of like a technical
        functional test and is allowed to fail for a small amount of time while we
        sort out distribution/comms issues).

        This changes how you write your code, but IMHO you write better code this
        way. Its annoying that the vendors that supply this stuff don't ship with
        the test infrastructure they use (or should be using) so that you can plug
        into it and run your tests. I haven't used EJB's yet - but I can imagine
        that you get very little shipped as a test infrastructure to use.

        I had the same issue writing a tool for VisualAge - you end up having to
        bite the bullet and write Mock objects that you can test with. It decreases
        your velocity intially but in the end you do win.

        Tim
      • Ron Lusk
        I ve just started this with some RMI work (expecting to move to EJB in the future). I needed the tests to start the rmiregistry program. First pass, I had the
        Message 3 of 13 , Feb 29, 2000
        • 0 Attachment
          I've just started this with some RMI work (expecting to move to EJB in the
          future). I needed the tests to start the rmiregistry program.

          First pass, I had the setUp() method using Runtime to create a Process
          running rmiregistry; tearDown() would kill the Process with the destroy()
          method. If I understand correctly, however, for each testXxxx method in my
          test class, setUp()/tearDown() get called. This could get expensive.

          Second pass, I had a Singleton creating the rmiregistry process. This
          doesn't get finalized, so the registry process (and Console window) hang
          around staring at me.

          Third try, now under construction, is a RegistrySetup derived from
          junit.extensions.TestSetup, which (again, if I understand correctly) does a
          one-time setUp/tearDown for a suite or test. I'll use this to wrap tests
          that need rmiregistry support in the future.

          > -----Original Message-----
          > From: Mike Morris [mailto:mike.morris@...]
          > Sent: Monday, February 28, 2000 9:24 am
          > To: extremeprogramming@egroups.com
          > Subject: [XP] Re: EJB and junit
          >
          >
          > Gerd Boerrigter wrote:
          > >
          > > Hi,
          > >
          > > we are using WebLogic server to build Enterprise JavaBeans. I want to
          > > use junit to do unit tests of the beans. I am new to EJB and can not
          > > think about an easy way to test the beans in the container.
          > >
          > > It looks like I need to write a Remote-Interface for the tests to be
          > > able to run them on the server. This looks like too much work to do.
          > > Is there an easy way to run junit on the server? How do other people
          > > do it?
          >
          > The same problem crops up in writing Jini services and clients -- how do
          > you test the remote stuff in short times (which is probably where stuff
          > is most likely to break).
          >
          > I am presently experimenting with testing the server locally first,
          > which ensure that at least it sets itself up properly (Jini being
          > somewhat finicky about setup issues), and I'll take figure out the next
          > step when I get to it.
          >
          > Has anyone else more experience with unit-testing distributed apps?
          > Tips, traps, tricks?
          > --
          > Mike Morris cOcO Technologies cc
          >
          > Java & OO training, consulting and software.
          >
          > mike.morris@...
          > Ph: Intl +27-44-388-4635 Local (044)388-4635
          > P O Box 34, Rheenendal, 6576, South Africa
          >
          > -- A day without chillies is a day wasted --
          >
          >
          > ------------------------------------------------------------------------
          > To Post a message, send it to: extremeprogramming@...
          > To Unsubscribe, send a blank message to:
          > extremeprogramming-unsubscribe@...
          > Ad-free courtesy of objectmentor.com
          >
          > ------------------------------------------------------------------------
          > -- Easily schedule meetings and events using the group calendar!
          > -- http://www.egroups.com/cal?listname=extremeprogramming&m=1
          >
          >
        • Paul Hodgetts
          ... For EJB testing, where I want to do the home lookup once per set of tests, I do this: public class TSPServicesTest extends TestCase { // constructor,
          Message 4 of 13 , Feb 29, 2000
          • 0 Attachment
            Ron Lusk wrote:

            > I've just started this with some RMI work (expecting to move to EJB in the
            > future). I needed the tests to start the rmiregistry program.
            >
            > First pass, I had the setUp() method using Runtime to create a Process
            > running rmiregistry; tearDown() would kill the Process with the destroy()
            > method. If I understand correctly, however, for each testXxxx method in my
            > test class, setUp()/tearDown() get called. This could get expensive.
            >
            > Second pass, I had a Singleton creating the rmiregistry process. This
            > doesn't get finalized, so the registry process (and Console window) hang
            > around staring at me.
            >
            > Third try, now under construction, is a RegistrySetup derived from
            > junit.extensions.TestSetup, which (again, if I understand correctly) does a
            > one-time setUp/tearDown for a suite or test. I'll use this to wrap tests
            > that need rmiregistry support in the future.

            For EJB testing, where I want to do the home lookup once per set
            of tests, I do this:

            public class TSPServicesTest
            extends TestCase {

            // constructor, suite, and test methods...

            protected void setUp() {
            // Get the TSP Services home reference.
            if (servicesHome == null) {
            // Actual EJB code to get the context, do the JNDI lookup...
            }
            }

            private TSPServicesHome servicesHome;
            }

            What this seems to do (unless I'm spacing on something) is to get
            the home reference on the first setUp call, and skips it on the
            rest of them. Since EJB home lookups are expensive, this makes
            the set of tests run much faster. Of course this doesn't work so
            well across multiple TestCases, but it does across multiple tests
            within one TestCase. Across multiple TestCases, I think I'd try
            the TestSetup approach that you mentioned.

            I don't need to tear down the EJB home reference, but in your case,
            if you need to kill the process, you could have a tearDown:

            protect void tearDown() {
            if (processCreated) {
            // Kill the process.
            }
            }

            I guess this is a kind of "non-external singleton." ;-) Does that
            help, or am I missing something?

            -Paul Hodgetts
          • Ron Lusk
            RegistrySetup does perform as expected: does a single setup and then runs the test suite. Eventually this should load some config settings (such as the port
            Message 5 of 13 , Feb 29, 2000
            • 0 Attachment
              RegistrySetup does perform as expected: does a single setup and
              then runs the test suite. Eventually this should load some config
              settings (such as the port for the registry) so I won't conflict
              with the non-test registry.

              > Third try, now under construction, is a RegistrySetup
              > derived from junit.extensions.TestSetup, which
              > does a one-time setUp/tearDown for a suite or test.
              > I'll use this to wrap tests that need rmiregistry
              > support in the future.
            • Michael T. Nygard
              I ve written a test runner that is a servlet. It can invoke EJBs in-place on the server. Coupled with a quick deployment and a local server, unit testing
              Message 6 of 13 , Mar 1 10:21 AM
              • 0 Attachment
                I've written a test runner that is a servlet. It can invoke EJBs "in-place"
                on the server. Coupled with a quick deployment and a local server, unit
                testing them becomes easy.

                If there is interest, I will post the code.

                --Michael T. Nygard


                ----- Original Message -----
                From: "Mike Morris" <mike.morris@...>
                To: <extremeprogramming@egroups.com>
                Sent: Monday, February 28, 2000 8:23 AM
                Subject: [XP] Re: EJB and junit


                > Gerd Boerrigter wrote:
                > >
                > > Hi,
                > >
                > > we are using WebLogic server to build Enterprise JavaBeans. I want to
                > > use junit to do unit tests of the beans. I am new to EJB and can not
                > > think about an easy way to test the beans in the container.
                > >
                > > It looks like I need to write a Remote-Interface for the tests to be
                > > able to run them on the server. This looks like too much work to do.
                > > Is there an easy way to run junit on the server? How do other people
                > > do it?
                >
                > The same problem crops up in writing Jini services and clients -- how do
                > you test the remote stuff in short times (which is probably where stuff
                > is most likely to break).
                >
                > I am presently experimenting with testing the server locally first,
                > which ensure that at least it sets itself up properly (Jini being
                > somewhat finicky about setup issues), and I'll take figure out the next
                > step when I get to it.
                >
                > Has anyone else more experience with unit-testing distributed apps?
                > Tips, traps, tricks?
                > --
                > Mike Morris cOcO Technologies cc
                >
                > Java & OO training, consulting and software.
                >
                > mike.morris@...
                > Ph: Intl +27-44-388-4635 Local (044)388-4635
                > P O Box 34, Rheenendal, 6576, South Africa
                >
                > -- A day without chillies is a day wasted --
              • Gareth Reeves
                Is this really Unit testing or is it Functional testing? ... From: Michael T. Nygard [mailto:michaeln@javelintech.com] Sent: Wednesday, March 01, 2000 12:21 PM
                Message 7 of 13 , Mar 1 10:51 AM
                • 0 Attachment
                  Is this really Unit testing or is it Functional testing?

                  -----Original Message-----
                  From: Michael T. Nygard [mailto:michaeln@...]
                  Sent: Wednesday, March 01, 2000 12:21 PM
                  To: extremeprogramming@egroups.com
                  Subject: [XP] Re: EJB and junit


                  I've written a test runner that is a servlet. It can invoke EJBs "in-place"
                  on the server. Coupled with a quick deployment and a local server, unit
                  testing them becomes easy.

                  If there is interest, I will post the code.

                  --Michael T. Nygard


                  ----- Original Message -----
                  From: "Mike Morris" <mike.morris@...>
                  To: <extremeprogramming@egroups.com>
                  Sent: Monday, February 28, 2000 8:23 AM
                  Subject: [XP] Re: EJB and junit


                  > Gerd Boerrigter wrote:
                  > >
                  > > Hi,
                  > >
                  > > we are using WebLogic server to build Enterprise JavaBeans. I want to
                  > > use junit to do unit tests of the beans. I am new to EJB and can not
                  > > think about an easy way to test the beans in the container.
                  > >
                  > > It looks like I need to write a Remote-Interface for the tests to be
                  > > able to run them on the server. This looks like too much work to do.
                  > > Is there an easy way to run junit on the server? How do other people
                  > > do it?
                  >
                  > The same problem crops up in writing Jini services and clients -- how do
                  > you test the remote stuff in short times (which is probably where stuff
                  > is most likely to break).
                  >
                  > I am presently experimenting with testing the server locally first,
                  > which ensure that at least it sets itself up properly (Jini being
                  > somewhat finicky about setup issues), and I'll take figure out the next
                  > step when I get to it.
                  >
                  > Has anyone else more experience with unit-testing distributed apps?
                  > Tips, traps, tricks?
                  > --
                  > Mike Morris cOcO Technologies cc
                  >
                  > Java & OO training, consulting and software.
                  >
                  > mike.morris@...
                  > Ph: Intl +27-44-388-4635 Local (044)388-4635
                  > P O Box 34, Rheenendal, 6576, South Africa
                  >
                  > -- A day without chillies is a day wasted --



                  ------------------------------------------------------------------------
                  To Post a message, send it to: extremeprogramming@...
                  To Unsubscribe, send a blank message to:
                  extremeprogramming-unsubscribe@...
                  Ad-free courtesy of objectmentor.com

                  ------------------------------------------------------------------------
                  -- Check out your group's private Chat room
                  -- http://www.egroups.com/ChatPage?listName=extremeprogramming&m=1
                • Eric Rizzo
                  ... Yes, please do! -- Eric Nicholas Rizzo eric.rizzo@trcinc.com The Technical Resource Connection, Inc. Perot Systems ... I embrace my personality
                  Message 8 of 13 , Mar 1 11:04 AM
                  • 0 Attachment
                    "Michael T. Nygard" wrote:
                    >
                    > I've written a test runner that is a servlet. It can invoke EJBs "in-place"
                    > on the server. Coupled with a quick deployment and a local server, unit
                    > testing them becomes easy.
                    >
                    > If there is interest, I will post the code.

                    Yes, please do!

                    --
                    Eric Nicholas Rizzo
                    eric.rizzo@...
                    The Technical Resource Connection, Inc. Perot Systems
                    ---------------------------------------------------------------
                    I embrace my personality flaws, for without them I might not
                    have any personality at all.
                  • Michael T. Nygard
                    Here s the code for the servlet itself. I have additional resources for deploying this as a web component in the Sun J2EE reference implementation, which are
                    Message 9 of 13 , Mar 1 11:10 AM
                    • 0 Attachment
                      Here's the code for the servlet itself. I have additional resources for
                      deploying this as a web component in the Sun J2EE reference implementation,
                      which are not attached, but are easy to recreate.

                      This is part of an article for which I am seeking a publisher.

                      Feedback would be wonderful. I wrote this at home, with no pair [/me hangs
                      head in shame].

                      Cheers,
                      --Michael T. Nygard
                    • Michael T. Nygard
                      I believe it is really unit testing, for two reasons: 1. It s running JUnit test cases. 2. I write the same tests to be invoked this way as with any
                      Message 10 of 13 , Mar 1 2:15 PM
                      • 0 Attachment
                        I believe it is really unit testing, for two reasons:

                        1. It's running JUnit test cases. <grin>

                        2. I write the same tests to be invoked this way as with any other unit
                        tests. The only difference is the "test harness".

                        I've seen proposals to create a test harness that accurately duplicates the
                        behavior of a servlet engine, or an EJB container. First of all, that is
                        exceedingly difficult. Second, any test harness sufficiently accurate will
                        be equivalent to the application server itself. (And, of course, that means
                        the test harness is complex enough to have its own set of defects.)

                        (If one truly wants to employ a "test harness" that accurates duplicates the
                        application server's environment, one could turn to the Apache-Sun
                        collaboration, Tomcat.)

                        Cheers,
                        --Michael T. Nygard

                        ----- Original Message -----
                        From: "Gareth Reeves" <reevesy@...>
                        To: <extremeprogramming@egroups.com>
                        Sent: Wednesday, March 01, 2000 12:51 PM
                        Subject: [XP] Re: EJB and junit


                        > Is this really Unit testing or is it Functional testing?
                        >
                        > -----Original Message-----
                        > From: Michael T. Nygard [mailto:michaeln@...]
                        > Sent: Wednesday, March 01, 2000 12:21 PM
                        > To: extremeprogramming@egroups.com
                        > Subject: [XP] Re: EJB and junit
                        >
                        >
                        > I've written a test runner that is a servlet. It can invoke EJBs
                        "in-place"
                        > on the server. Coupled with a quick deployment and a local server, unit
                        > testing them becomes easy.
                        >
                        > If there is interest, I will post the code.
                        >
                        > --Michael T. Nygard
                        >
                        >
                        > ----- Original Message -----
                        > From: "Mike Morris" <mike.morris@...>
                        > To: <extremeprogramming@egroups.com>
                        > Sent: Monday, February 28, 2000 8:23 AM
                        > Subject: [XP] Re: EJB and junit
                        >
                        >
                        > > Gerd Boerrigter wrote:
                        > > >
                        > > > Hi,
                        > > >
                        > > > we are using WebLogic server to build Enterprise JavaBeans. I want to
                        > > > use junit to do unit tests of the beans. I am new to EJB and can not
                        > > > think about an easy way to test the beans in the container.
                        > > >
                        > > > It looks like I need to write a Remote-Interface for the tests to be
                        > > > able to run them on the server. This looks like too much work to do.
                        > > > Is there an easy way to run junit on the server? How do other people
                        > > > do it?
                        > >
                        > > The same problem crops up in writing Jini services and clients -- how do
                        > > you test the remote stuff in short times (which is probably where stuff
                        > > is most likely to break).
                        > >
                        > > I am presently experimenting with testing the server locally first,
                        > > which ensure that at least it sets itself up properly (Jini being
                        > > somewhat finicky about setup issues), and I'll take figure out the next
                        > > step when I get to it.
                        > >
                        > > Has anyone else more experience with unit-testing distributed apps?
                        > > Tips, traps, tricks?
                        > > --
                        > > Mike Morris cOcO Technologies cc
                        > >
                        > > Java & OO training, consulting and software.
                        > >
                        > > mike.morris@...
                        > > Ph: Intl +27-44-388-4635 Local (044)388-4635
                        > > P O Box 34, Rheenendal, 6576, South Africa
                        > >
                        > > -- A day without chillies is a day wasted --
                        >
                        >
                        >
                        > ------------------------------------------------------------------------
                        > To Post a message, send it to: extremeprogramming@...
                        > To Unsubscribe, send a blank message to:
                        > extremeprogramming-unsubscribe@...
                        > Ad-free courtesy of objectmentor.com
                        >
                        > ------------------------------------------------------------------------
                        > -- Check out your group's private Chat room
                        > -- http://www.egroups.com/ChatPage?listName=extremeprogramming&m=1
                        >
                        >
                        >
                        > ------------------------------------------------------------------------
                        > To Post a message, send it to: extremeprogramming@...
                        > To Unsubscribe, send a blank message to:
                        extremeprogramming-unsubscribe@...
                        > Ad-free courtesy of objectmentor.com
                        >
                        > ------------------------------------------------------------------------
                        > -- Create a poll/survey for your group!
                        > -- http://www.egroups.com/vote?listname=extremeprogramming&m=1
                        >
                        >
                      • James W Grenning
                        ... First get confidence in local execution, then move toward distributed execution. The client side of an interface can be tested using a server stub that
                        Message 11 of 13 , Mar 2 9:25 PM
                        • 0 Attachment
                          > Has anyone else more experience with unit-testing distributed apps?
                          > Tips, traps, tricks?

                          First get confidence in local execution, then move toward distributed
                          execution. The client side of an interface can be tested using a server
                          stub that has the same interface and asynchronous behavior as the real
                          server, but produces consistent/canned/repeatable results. Once the local
                          asynchronous tests are running, move your server stub to a distributed
                          machine. Run those same tests comparing the consistent/canned/repeatable
                          results as before. Adding the asynchronous behavior makes the tests more
                          complicated.

                          The strategy can be reversed for testing the server to client interactions.

                          We're using this strategy in a c++ environment using CppUnit. I had to
                          extend CppUnit to have overall Initialize and Finalize functions for system
                          setup and tear down that is used over all the tests run.

                          James
                          -------------------------------------------------------------
                          James Grenning High Point Software Technology Company
                          Design Consulting 10 High Point Drive (847) 438-9942
                          Project Management Hawthorn Woods, IL
                          OO Training 60047
                          jgrenning@... www.HighPointSoftware.com
                          --------------------------------------------------------------
                        • Greg Kapfhammer
                          ... If you are doing distributed computing development with Jini, JavaSpaces and Java, then you should look to reading some of the short articles that Ken
                          Message 12 of 13 , Mar 3 1:16 PM
                          • 0 Attachment
                            On Thu, 2 Mar 2000, James W Grenning wrote:

                            > > Has anyone else more experience with unit-testing distributed apps?
                            > > Tips, traps, tricks?
                            >
                            > First get confidence in local execution, then move toward distributed
                            > execution. The client side of an interface can be tested using a server

                            If you are doing distributed computing development with Jini, JavaSpaces
                            and Java, then you should look to reading some of the short articles that
                            Ken Edwards wrote about designing and testing distributed applications.
                            He makes some good practical reccomendations about the best way to to set
                            up your Jini environment so that you do not make common mistakes when you
                            are testing in a "local execution" framework.

                            Check out the article at:

                            http://www.kedwards.com/jini/develop.html

                            Other helpful hints can be found at:

                            http://www.kedwards.com/jini/

                            Anyone out there using Jini to do distributing computing development in a
                            commercial application?

                            greg

                            +----------------------------+----------------------------+
                            | Gregory M. Kapfhammer | RST Corporation |
                            | Research Associate | 21351 Ridgetop Circle |
                            | gkapfham@... | Dulles, VA 20166 |
                            | http://www.rstcorp.com | (703) 404-9293 |
                          • Brian Wilson
                            I m interested!
                            Message 13 of 13 , Apr 3, 2000
                            • 0 Attachment
                              I'm interested!
                            Your message has been successfully submitted and would be delivered to recipients shortly.