Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 37807 invoked from network); 29 Nov 2004 16:26:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 29 Nov 2004 16:26:07 -0000 Received: (qmail 10507 invoked by uid 500); 29 Nov 2004 16:25:39 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 10413 invoked by uid 500); 29 Nov 2004 16:25:37 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 10349 invoked by uid 99); 29 Nov 2004 16:25:36 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of melowe@gmail.com designates 64.233.184.205 as permitted sender) Received: from wproxy.gmail.com (HELO wproxy.gmail.com) (64.233.184.205) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 29 Nov 2004 08:25:34 -0800 Received: by wproxy.gmail.com with SMTP id 55so519856wri for ; Mon, 29 Nov 2004 08:25:30 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=VR+QYCBuTy7ZfuvMC30R90lfOHxqF94w6mFjEaz68QNtxl9Tg5gDBsucoW34Vq93+i9yz4ai0/180RzO3R32cDqRa3mFO+1QMnc51pyhY9REM6w/ygPuxmBqlxSwNFvzGUDO4pR6TSOKuODcC08sNMbVxNsRRBoWcPefy5TKWp4= Received: by 10.54.43.63 with SMTP id q63mr1150584wrq; Mon, 29 Nov 2004 08:25:29 -0800 (PST) Received: by 10.54.27.67 with HTTP; Mon, 29 Nov 2004 08:25:29 -0800 (PST) Message-ID: <3e1257da041129082547cd48b5@mail.gmail.com> Date: Mon, 29 Nov 2004 17:25:29 +0100 From: Mark Lowe Reply-To: Mark Lowe To: Corey Scott Subject: Re: [email] Exceptions Cc: Jakarta Commons Developers List , epugh@upstate.com In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <3e1257da04112906186de0d94a@mail.gmail.com> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Okay I'll take a look tommorrow and sumbit my patch with the test cases in with the Other test methods. Judging from you example, you agree that unexpected exceptions should just get thrown and that exceptions should be tested independently to normal tests, which all sounds good to me. Or am i wrong? If the method isn't there to invoke an exception then if one happens then surely just throw it, the fact that its unexpected will be evident by virtue of the test failing due to errors. Mark On Tue, 30 Nov 2004 00:04:16 +0800, Corey Scott wrote: > This is exactly what I was trying to say, just not so elegantly :-) > > Eg. Tests for the HtmlEmail class should be in teh HtmlEmailTest class > or is this becomes too big and you want to separate the exceptions, > then there should be two classes HtmlEmailTest (for normal test cases) > and HtmlEmailExceptionTest > > > > -Corey > > On Mon, 29 Nov 2004 16:59:29 +0100, Eric Pugh wrote: > > Humm... I typically make all my unit tests throw Exception. It reduces > > the length of each test, especially when all you are doing is logging that > > it failed with a fail(ex.getMessage). > > > > However, if you are actually TESTING that an exception gets thrown: > > > > try { > > email.doSomething(); > > fail("should have thrown ee"); > > } > > catch (EmailException ee){ > > assertTrue(ee.getMessage().indexOf("myerror")>-1) > > } > > > > then I argue they should go in with whatever class we are testing, because > > when someone adds a new method to the class, it will encourage them to add > > the corresponding test case for any exeption. Or, put the exception test > > into the test. > > > > public void testSomething() throws Exception{ > > email.doSomethign(); > > > > try { > > email.doSomething(); > > fail("should have thrown ee"); > > } > > catch (EmailException ee){ > > assertTrue(ee.getMessage().indexOf("myerror")>-1) > > > > } > > > > } > > > > That way everything stays together. If we aren't actually asserting the > > exception, then we shouldn't bother testing it.. > > > > > > > > Eric > > > > > -----Original Message----- > > > From: Mark Lowe [mailto:melowe@gmail.com] > > > Sent: Monday, November 29, 2004 3:19 PM > > > To: Corey Scott > > > Cc: Jakarta Commons Developers List > > > Subject: Re: [email] Exceptions > > > > > > > > > My thoughts on the test cases are that they should throw exception, > > > and then have the exception testing separate. This would make the > > > cases shorter also, perhaps this is what you mean. > > > > > > public void testFoo() throws Exception > > > { > > > Foo foo = new Foo(); > > > foo.setBar("testvar"); > > > } > > > > > > For example, if for some reason the exception for setBar() was ever > > > changed the case could remain the same as before, and the only change > > > would need to be in the exception test case. > > > > > > Mark > > > > > > > > > On Mon, 29 Nov 2004 21:59:44 +0800, Corey Scott > > > wrote: > > > > I would prefer an Exception Test case per base class, especially for > > > > the larger files. I know most of the tests I wrote, but I think that > > > > if anything the files are too long and would be much more usable if > > > > they were shorter and more focused. Does anyone have any objections > > > > to gave more (but shorter) files? > > > > > > > > -Corey > > > > > > > > > > > > > > > > > > > > On Mon, 29 Nov 2004 14:17:30 +0100, Mark Lowe wrote: > > > > > I've created the exceptions and I'm now working through the > > > test cases. > > > > > > > > > > If I summit a patch with the exception testing in a ExceptionTestCase > > > > > what's the likelyhood of this being patched? This isn't a question of > > > > > style its a question of maintainabilty and now, I'm faced with the > > > > > task of weeding out all these try catch statements. > > > > > > > > > > Any objection to a patch with these exception tests moved into a > > > > > specialised test case? > > > > > > > > > > > > > > > > > > > > Mark > > > > > > > > > > On Mon, 29 Nov 2004 11:23:50 +0100, Mark Lowe > > > wrote: > > > > > > Okay 2 commons.mail exceptions sounds like an improvement. > > > So the goal > > > > > > is to minimise the catch statements the user needs to use, sound > > > > > > reasonable. Throwing everything would mean 2 catches, so I > > > can see the > > > > > > value in catching once. > > > > > > > > > > > > I'll look into a way of having a 1.4+ build option in the > > > build files > > > > > > for folk that don't give a gnat's winnit about 1.3 et al. > > > > > > > > > > > > Anyone know the default behaviour for the > > > InternetAddress(email,name) > > > > > > constructor? Does it adopt the charset from the parent email? > > > > > > > > > > > > Mark > > > > > > > > > > > > > > > > > > > > > > > > On Mon, 29 Nov 2004 11:11:06 +0100, Eric Pugh > > > wrote: > > > > > > > My take on this is that users of [email] are looking for > > > a package that > > > > > > > simplifies the JavaMail api. And one of the big > > > simplifing aspects is that > > > > > > > the Exceptions that they have to catch are minimized. > > > Most users will > > > > > > > probably not care *what* the exception was, only that > > > there *was* an > > > > > > > exception, and just pass it up the chain. For folks who > > > actually have code > > > > > > > to deal with the specific exception, then they are either > > > going to use the > > > > > > > JavaMail api directly without the extra layer of [email], > > > or we should > > > > > > > provide a way for them to retrieve the specific Exception. > > > > > > > > > > > > > > Hence that is why I propose that we have two types of exceptions: > > > > > > > EmailException and RuntimeEmailException. For common > > > exceptions, we throw > > > > > > > an EmailException which is an extension of > > > NestableException and wraps > > > > > > > whatever the underlying JavaMail exception was. This > > > provides a nice facade > > > > > > > for people who don't care what the exception was, but > > > allows folks who do to > > > > > > > get the underlying exception. > > > > > > > > > > > > > > The other RuntimeEmailException will extend > > > NestableRuntimeException and can > > > > > > > be used for any runtime exceptions in the same manner as > > > EmailException. > > > > > > > > > > > > > > For the case of the UEE, that would be another exception > > > in the API to > > > > > > > throw, which goes against the charter that: > > > > > > > "contains a set of Java classes providing a thin > > > convenience layer over > > > > > > > JavaMail". So, in that case, throw the approapriate > > > EmailException and > > > > > > > that will wrap the UEE. > > > > > > > > > > > > > > Mark, is it possible to use the 1.4 io stuff > > > conditionally? I guess not, > > > > > > > but we could think about maybe how we compile the jar? > > > Our primary target > > > > > > > is definitly 1.3 for now though. > > > > > > > > > > > > > > Eric > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > From: Mark Lowe [mailto:melowe@gmail.com] > > > > > > > > Sent: Sunday, November 28, 2004 4:04 PM > > > > > > > > To: Commons dev list; Corey Scott > > > > > > > > Subject: [email] Exceptions > > > > > > > > > > > > > > > > > > > > > > > > The issue of exceptions has come up a few times, and > > > heres a summary > > > > > > > > of my understanding of whats been said and agreed and > > > disagreed about. > > > > > > > > > > > > > > > > The idea of throwing AddressException is favourable, > > > but not at the > > > > > > > > cost of needing to throw UnsupportingEncodingException. > > > When setting > > > > > > > > InternetAddress() this throws a UEE and AddressException. > > > > > > > > > > > > > > > > My position is that without 1.4's new io package > > > there's no means of > > > > > > > > checking supported charsets on a given JVM. If the user > > > enters a shady > > > > > > > > charset for a email address or name is there anything > > > wrong with them > > > > > > > > having a UEE thrown? > > > > > > > > > > > > > > > > The lightest means of doing this in my opinion is just > > > throw both, its > > > > > > > > consistent with the mailapi. It would work on all target JVMs. > > > > > > > > > > > > > > > > Of course you could just throw MessagingException for > > > everything , "oh > > > > > > > > thats what it does". But is this a useful and therefore > > > good thing? > > > > > > > > Having a commons.mail.EmailException was suggested, > > > but does that > > > > > > > > have any advantage over throwing AddressException and > > > UEE? I'm not > > > > > > > > sure. > > > > > > > > > > > > > > > > I don't mind summitting the patches, i need to do this > > > for a project > > > > > > > > I'm working on at present, so I need to do the work > > > anyway. It makes > > > > > > > > sense to submit this to the effort but I don't mind either way. > > > > > > > > > > > > > > > > Mark > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > To unsubscribe, e-mail: > > > commons-dev-unsubscribe@jakarta.apache.org > > > > > > > > For additional commands, e-mail: > > > commons-dev-help@jakarta.apache.org > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > > > > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org