Also, we have a facility in our test framework for generating unique names. Not sure that we'll be using this framework for long, but the base class defines a method 'u()' which takes in a string and returns something unique (based on the time and a counter).
-- Jon
On Nov 29, 2006, at 3:15 PM, Jon Travis wrote:
> The idiom for this type of test is usually: > > try { > doSomethingThatFails(); > fail("Somehow it succeeded!"); > } catch(ObjectNotFoundException e) { > // correct > } > > -- Jon > > > On Nov 29, 2006, at 2:38 PM, youngl@hyperic.com wrote: > >> Author: youngl >> Date: 2006-11-29 14:38:47 -0800 (Wed, 29 Nov 2006) >> New Revision: 1601 >> URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=1601 >> >> Modified: >> trunk/src/org/hyperic/hq/events/test/EscalationTest.java >> Log: >> add ObjectNotFoundException catch clause >> >> Modified: trunk/src/org/hyperic/hq/events/test/EscalationTest.java >> =================================================================== >> --- trunk/src/org/hyperic/hq/events/test/EscalationTest.java >> 2006-11-29 22:24:58 UTC (rev 1600) >> +++ trunk/src/org/hyperic/hq/events/test/EscalationTest.java >> 2006-11-29 22:38:47 UTC (rev 1601) >> @@ -42,9 +42,9 @@ >> public class EscalationTest >> extends HQEJBTestBase { >> private final String BOGUS_NAME1 = >> - "escalation " + (new Random()).nextInt(10000); >> + "bogus1 " + (new Random()).nextInt(10000); >> private final String BOGUS_NAME2 = >> - "escalation " + (new Random()).nextInt(10000); >> + "bogus2 " + (new Random()).nextInt(10000); >> private final Integer ALERT_DEF_ID1 = new Integer(10001); >> private final Integer ALERT_DEF_ID2 = new Integer(10002); >> >> @@ -131,6 +131,8 @@ >> // object should not be found >> Exception ex = ignore.getCausedByException(); >> assertTrue(ex instanceof ObjectNotFoundException); >> + } catch (ObjectNotFoundException ignore) { >> + // object should not be found >> } >> } >> >> @@ -192,6 +194,8 @@ >> // object should not be found >> Exception ex = ignore.getCausedByException(); >> assertTrue(ex instanceof ObjectNotFoundException); >> + } catch (ObjectNotFoundException ignore) { >> + // object should not be found >> } >> } >> >> >