Unit test for J2EE application

I am writting a Unit test for One J2EE application. The Application is built in such a way that makes unit testing extremely difficult.
There are 2 things that contribute to the mess.
1. Sping integration means all the config files are specified in web.xml independently, even though their beans rely on each other across files. End result is in a unit, I cannot try to load a bean because some of its dependencies are missing (ie. they are in a config file that the first file does not include). For this I tried to use AbstractDependencyInjectionSpringContextTests class to set the Spring Application Context when you are not in the flow but didn't success ed.If any one has use this please post the example.
2. The application is using Errors interface of package org.springframework.validation. To write a test for any validator class you have to pass the object of Error in the validate method with the command object. Now my question is how you can set this Error object when you are not in the flow. For this I tried to use Mock object e.g Errors error;
Mockery context = new Mockery();
final Errors errorMock =context.mock(Errors.class);
//call the validate object with mock object
classObject.doValidate(cmdObject, errorMock)
This thing doesn't work. It gives me below error message.
unexpected invocation: errors.pushNestedPath("")
no expectations specified: did you...
- forget to start an expectation with a cardinality clause?
- call a mocked method to specify the parameter of an expectation?
Is there any way to get around these hiccups programmatically in unit tests?
thanks...

If you are doing unit testing, try to use straight JUnit4 without involving the Spring framework. Given that you do unit testing, you might not need Spring configuration in your unit test at all. You can programmatically instantiate the instance of the class under testing and either programmatically instantiate collaborating objects, or create mock objects for that purpose. If you are doing functional testing, you might need a Spring context after all. Understand that your tests are running in the different context than the complete application, so you would have to create separate application context for your test(s). You might have to go through the existing Spring configuration modules that you created for your application and re-jiggle them a bit so that they can be included both in your application context and your unit test context.
Hope this helps.

Similar Messages

  • How can I unit test my Swing application?

    Hi All,
    In my application I came across a situation where I have to automate the unit testing of my application.
    Using my application user can able to draw polylines and rectangles on a BufferedImage added to a JFrame.
    Can any one please help/suggest me, how to automate the drawing process (this process consists of drawing the polylines with mouse and few action/mouse events)?
    your help will be highly helpful to me.
    Satya

    What exactly will that unit test prove? That you can mock the drawing of lines?
    Unit test are supposed to test certain parts of your application code - I'd concentrate on unit tests that are actually useful and for example in the future can help to catch regressions.
    If anywhere you can get help creating unit tests of this magnitude, I'd look in the unit testing support for Swing applications. Google for "java swing unit test" to see what you can come up with. Probably you'll need to create some plumbing yourself to make custom painting unit-testable; perhaps you could do something with painting to a BufferedImage in stead of to a Swing component for example.

  • Unit test of FPM applications?

    Is there any way to implement/execute some kind of unit tests for floorplan manager applications? I would like to write some automatically reproducible tests but cannot find any solution/framework for it.
    Thomas

    Dear Thomas,
    Nguyen is right. Either you mock the behavior directly in the UI (then no ABAP Unit is needed). Or you are using GUIBBs with feeder classes and use ABAP Unit which requires you to call methods like FLUSH or PROCESS_EVENT in the ABAP unit test manually.
    I tried it myself and it works pretty straight forward. All you would have to to is to
    resolve all dependencies like the instance of IF_FPM in the INITIALIZE method.
    A new feeder's subclass will be subject to the unit test.
    Override INITIALIZE there and replace all dependencies by mocked instances
    call the UIBB's methods like the FPM would do it: INITIALIZE, FLUSH, PROCESS_EVENT etc.
    when needed, also mock parameter input like events (CL_FPM_EVENT)
    carry out verifications against the mocked dependencies (e.g. if various methods like RAISE_EVENT or OPEN_DIALOG_BOX in IF_FPM have been called or not, or of certain wire objects have been passed)
    Regards,
    Uwe

  • [svn:osmf:] 13916: Added DynamicDRMTrait, Composite Unit tests for parallel and serial compositions.

    Revision: 13916
    Revision: 13916
    Author:   [email protected]
    Date:     2010-02-01 16:42:09 -0800 (Mon, 01 Feb 2010)
    Log Message:
    Added DynamicDRMTrait, Composite Unit tests for parallel and serial compositions.  Bug fixes in CompositeDRMTrait.
    Modified Paths:
        osmf/trunk/framework/OSMF/org/osmf/composition/CompositeDRMTrait.as
        osmf/trunk/framework/OSMFTest/org/osmf/OSMFTests.as
        osmf/trunk/framework/OSMFTest/org/osmf/utils/DynamicMediaElement.as
    Added Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/composition/TestParallelElementDRMTrait.as
        osmf/trunk/framework/OSMFTest/org/osmf/composition/TestSerialElementDRMTrait.as
        osmf/trunk/framework/OSMFTest/org/osmf/utils/DynamicDRMTrait.as

  • Unit test for object types

    In the current version (2.1.0.63) I can perform only unit test for packages, function and procedures. But we use a lot of object types in the database and would like to test them. Is there any support for object types scheduled?

    You can also use the original UT PLSQL package from sourceforge.
    I have used this in the past for testing with file comparisons, table object output from procedures, etc.
    We've also used the same setup for Oracle Forms code testing.
    Dennis

  • [svn:osmf:] 10437: Add support and unit tests for parsing VAST documents ( inline or wrapper).

    Revision: 10437
    Author:   [email protected]
    Date:     2009-09-20 13:31:16 -0700 (Sun, 20 Sep 2009)
    Log Message:
    Add support and unit tests for parsing VAST documents (inline or wrapper).   All elements are covered with the exception of Video.
    Modified Paths:
        osmf/trunk/libs/VAST/.flexLibProperties
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTAdPackageBase.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTDocument.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTInlineAd.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTWrapperAd.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/parser/VASTParser.as
        osmf/trunk/libs/VASTTest/org/openvideoplayer/vast/parser/TestVASTParser.as
    Added Paths:
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTAdBase.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTCompanionAd.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTNonLinearAd.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTTrackingEvent.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTTrackingEventType.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTUrl.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTVideoClick.as

    Your problem sounds similar to this one, except that they're using software raid rather than just pure LVM. If you're using an initrd, you may not have the appropriate modules installed. If you're not using an initrd, then the kernel probably needs LVM support compiled in (not as a module) and could be solved by fixing that. I have never used the ck-patchset, but this should give you an additional data point.
    Also comment=systemd.automount will be deprecated soon as I understand it; if you have a need for automounting, x-systemd.automount should be used instead.

  • Unit Tests for Beckend Beans?

    Does anybody has any idea how to write Unit Tests for JSF Beckend Beans? Especially if they are using session and request objects. How can I simulate Session for example?

    Walter Laan wrote:
    SwingX has a nice helper class TreeModelReport but the actual test is not that complete.what do you mean by "not complete" - SwingX has no special TreeModel, so nothing much to test :-) should have some TreeTableModel related tests, though. Not sure how complete they are ...
    CU
    Jeanette

  • [svn:osmf:] 13640: First checkin of unit tests for FLV tags and their parser

    Revision: 13640
    Revision: 13640
    Author:   [email protected]
    Date:     2010-01-19 15:07:11 -0800 (Tue, 19 Jan 2010)
    Log Message:
    First checkin of unit tests for FLV tags and their parser
    Modified Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/OSMFTests.as
    Added Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/flv/
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/flv/FLVTestHelper.as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/flv/TestFLVHeader.as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/flv/TestFLVTagAudio.as
    Property Changed:
        osmf/trunk/framework/OSMFTest/org/osmf/

    Thanks for posting this!
    I would only mention that your definition is incomplete for this -
    Contextual selector A type of Style Sheet Selector that
    and that it's most often referred to now as a Descendent selector, not a contextual selector.  It's basically the same as the Compound selector that you have already defined....

  • [svn:bz-trunk] 22381: Add some unit tests for the flex.messaging.client. FlexClientManager, including one for the new getFlexClient(String id, boolean createNewIfNotExist) method signature.

    Revision: 22381
    Revision: 22381
    Author:   [email protected]
    Date:     2011-09-02 05:10:41 -0700 (Fri, 02 Sep 2011)
    Log Message:
    Add some unit tests for the flex.messaging.client.FlexClientManager, including one for the new getFlexClient(String id, boolean createNewIfNotExist) method signature.
    Added Paths:
        blazeds/trunk/modules/core/test/src/flex/messaging/client/
        blazeds/trunk/modules/core/test/src/flex/messaging/client/FlexClientManagerTest.java

  • [svn:osmf:] 11233: Add downloadable related unit tests for MediaPlayer

    Revision: 11233
    Author:   [email protected]
    Date:     2009-10-28 11:29:23 -0700 (Wed, 28 Oct 2009)
    Log Message:
    Add downloadable related unit tests for MediaPlayer
    Modified Paths:
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/media/TestMediaPlayer.as
    Added Paths:
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/utils/MockMediaElementWithDownloadab leTrait.as

    Revision: 11233
    Author:   [email protected]
    Date:     2009-10-28 11:29:23 -0700 (Wed, 28 Oct 2009)
    Log Message:
    Add downloadable related unit tests for MediaPlayer
    Modified Paths:
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/media/TestMediaPlayer.as
    Added Paths:
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/utils/MockMediaElementWithDownloadab leTrait.as

  • [svn:osmf:] 10517: Last set of unit tests for ListenerProxyElement.

    Revision: 10517
    Author:   [email protected]
    Date:     2009-09-22 15:47:18 -0700 (Tue, 22 Sep 2009)
    Log Message:
    Last set of unit tests for ListenerProxyElement.
    Modified Paths:
        osmf/trunk/framework/MediaFramework/org/openvideoplayer/proxies/ListenerProxyElement.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/openvideoplayer/proxies/TestListenerProxy ElementAsSubclass.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/openvideoplayer/utils/DynamicListenerProx yElement.as

    Revision: 10517
    Author:   [email protected]
    Date:     2009-09-22 15:47:18 -0700 (Tue, 22 Sep 2009)
    Log Message:
    Last set of unit tests for ListenerProxyElement.
    Modified Paths:
        osmf/trunk/framework/MediaFramework/org/openvideoplayer/proxies/ListenerProxyElement.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/openvideoplayer/proxies/TestListenerProxy ElementAsSubclass.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/openvideoplayer/utils/DynamicListenerProx yElement.as

  • [svn:osmf:] 17080: Add basic unit tests for MulticastNetLoader

    Revision: 17080
    Revision: 17080
    Author:   [email protected]
    Date:     2010-07-27 16:03:01 -0700 (Tue, 27 Jul 2010)
    Log Message:
    Add basic unit tests for MulticastNetLoader
    Modified Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/OSMFTests.as
    Added Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/net/multicast/
        osmf/trunk/framework/OSMFTest/org/osmf/net/multicast/TestMulticastNetLoader.as

  • [svn:osmf:] 11282: updated the unit tests for the DRM subsystem.

    Revision: 11282
    Author:   [email protected]
    Date:     2009-10-29 16:44:46 -0700 (Thu, 29 Oct 2009)
    Log Message:
    updated the unit tests for the DRM subsystem.  Still lacking tests for Authentication Token.
    Modified Paths:
        osmf/trunk/framework/MediaFramework/.actionScriptProperties
        osmf/trunk/framework/MediaFramework/org/osmf/drm/DRMServices.as
        osmf/trunk/framework/MediaFramework/org/osmf/net/NetStreamContentProtectableTrait.as
        osmf/trunk/framework/MediaFramework/org/osmf/video/VideoElement.as
        osmf/trunk/framework/MediaFrameworkAirTest/.actionScriptProperties
        osmf/trunk/framework/MediaFrameworkFlexTest/.actionScriptProperties
        osmf/trunk/framework/MediaFrameworkFlexTest/.flexProperties
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/traits/TestIContentProtectable.as
        osmf/trunk/framework/MediaFrameworkIntegrationTest/.actionScriptProperties
        osmf/trunk/framework/MediaFrameworkIntegrationTest/org/osmf/MediaFrameworkIntegrationTest s.as
        osmf/trunk/framework/MediaFrameworkIntegrationTest/org/osmf/net/TestNetContentProtectable .as
    Added Paths:
        osmf/trunk/framework/MediaFrameworkIntegrationTest/org/osmf/video/
        osmf/trunk/framework/MediaFrameworkIntegrationTest/org/osmf/video/TestVideoElement.as
    Property Changed:
        osmf/trunk/framework/MediaFrameworkFlexTest/
        osmf/trunk/framework/MediaFrameworkIntegrationTest/

    Hello Alex,
    I don't have an answer for you.
    But, can you try to use http://drmtest2.adobe.com:8080/Content/anonymous.f4v with locally hosted OSMF player? This content doens't require user/pass info.
    I'm wondering that Google TV's flash player doesn't support prompt dialog.
    http://drmtest2.adobe.com/AccessPlayer/player.html requires flash player 11. That's why it won't be loaded with flash player 10.x.
    Thanks,
    -- Hiroshi

  • [svn:osmf:] 10425: Add initial unit tests for VASTParser.

    Revision: 10425
    Author:   [email protected]
    Date:     2009-09-18 17:35:58 -0700 (Fri, 18 Sep 2009)
    Log Message:
    Add initial unit tests for VASTParser.  Minor changes to parsing code.
    Modified Paths:
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTAd.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTAdPackageBase.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/parser/VASTParser.as
        osmf/trunk/libs/VASTTest/org/openvideoplayer/vast/VASTTests.as
    Added Paths:
        osmf/trunk/libs/VASTTest/org/openvideoplayer/vast/parser/
        osmf/trunk/libs/VASTTest/org/openvideoplayer/vast/parser/TestVASTParser.as

  • [svn:osmf:] 10447: Add more unit tests for VAST validation.

    Revision: 10447
    Author:   [email protected]
    Date:     2009-09-20 19:59:57 -0700 (Sun, 20 Sep 2009)
    Log Message:
    Add more unit tests for VAST validation.
    Modified Paths:
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/parser/VASTParser.as
        osmf/trunk/libs/VASTTest/org/openvideoplayer/vast/parser/TestVASTParser.as

    Abuse reported.

Maybe you are looking for

  • Broken links on Oracle By Example pages

    All links and images seem broken in the list given on this page: http://www.oracle.com/technology/obe/obe10gdb/bidw/index.html

  • How can I fix a blueish photo?

    I have 2 sets of printed photos processed in 2 differents photo labs. I don't have the negatives any more. One set of prints was well developed and the colours are good (see photo labelled Picture 1 Good).  The other set of photos was not well develo

  • Sounds stops after few minutes of play time.

    I was wondering if anyone had this problem with I-Pod 60G. Video starts playing normaly, then after few minutes it freezes, but then starts again, but this time with no sound. I have to stop and start it again, just to get the same result. What's up

  • Is there any way to control automator through voice commands?

    is there any way to control automator through voice commands? Im simply trying to program my macbook pro early 2011 8gigs ram to resound to voice commands using automator but I haven't found any discuss on the subject.

  • EDI Salesorder

    Hi Please can anybody help me with the steps to configure EDI output type for VA01/VA02 (Sales order create /change) . The requirement is to generate Idoc every time a sales order is created or modified. Thanks in advance