This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Testing and the fly likes test won't go through try block in gui Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "test won Watch "test won New topic
Author

test won't go through try block in gui

Dan Maples
Ranch Hand

Joined: Jun 21, 2004
Posts: 153
I have written a test with a try and catch. When tested with the Text version of junit it runs perfectly. When tested with the gui version of junit, the try block never try's, and it always goes to the catch statment. I don't see what the difference is. I have had problems similar to this before (differences between text and gui results) and I am wondering if there is something wrong with the way my system is set up or something along those lines. Any help is greatly appriciated, thanks in advance -Dan

This calls on getcost(string,int) which returns string.length()*int;

[ June 28, 2004: Message edited by: dan maples ]

-Dan
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
Try clicking off the checkbox that says "Reload classes every run" (which requires JUnit to use its own custom classloader).

-j-


Books: Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
It would probably help if you told us what exception you do get...

Also take a look at the FAQ: http://junit.sourceforge.net/doc/faq/faq.htm#running_8


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Dan Maples
Ranch Hand

Joined: Jun 21, 2004
Posts: 153
Thanks for the help guys, the server that this calls on is down today, I will try again as soon as it comes up. When it does I will try unclicking the checkbox and if that doesn't work I will copy down the error and post it. Thanks-Dan
Dan Maples
Ranch Hand

Joined: Jun 21, 2004
Posts: 153
Jeff unchecking the box worked!, the test passed. What is the difference between having the box checked or unchecked, I don't understand how that effects the try/catch blocks. Ilja- the exception that I was receiving was:

java.lang.ClassCastException
at weblogic.xml.schema.binding.internal.TypeMappingBase.addTypeMapping(T
ypeMappingBase.java:549)
at weblogic.xml.schema.binding.internal.TypeMappingBase.readXML(TypeMapp
ingBase.java:782)
at weblogic.xml.schema.binding.internal.TypeMappingBase.readXML(TypeMapp
ingBase.java:511)
at weblogic.webservice.core.encoding.DefaultRegistry.<init>(DefaultRegis
try.java:70)
at weblogic.webservice.core.rpc.ServiceImpl.<init>(ServiceImpl.java:72)
at weblogic.jws.proxies.CostAnalysisService_Impl.<init>(CostAnalysisServ
ice_Impl.java:23)
at weblogic.jws.proxies.CostAnalysisService_Impl.<init>(CostAnalysisServ
ice_Impl.java:17)
at CostTest.testSoapProxy(CostTest.java:9)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.swingui.TestRunner$16.run(TestRunner.java:623)

what does that mean? Thank you both again!
[ July 02, 2004: Message edited by: dan maples ]
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
The checkbox allows JUnit to dynamically reload classes when they change. In order to do so, JUnit uses a custom classloader. This classloader can't deal with whatever dynamic classloading is going on in the rpc mechanism embedded in the code in the try block.

Or something like that.

-j-
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: test won't go through try block in gui