Made fragile tests a little less fragile: increased max times.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1457 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Sam Brannen 2009-07-02 16:02:24 +00:00
parent ae1d521ff1
commit 3e06d46daa
1 changed files with 30 additions and 34 deletions

View File

@ -118,8 +118,11 @@ public final class AspectJAutoProxyCreatorTests {
} }
} }
sw.stop(); sw.stop();
System.out.println(sw.getTotalTimeMillis()); long totalTimeMillis = sw.getTotalTimeMillis();
assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); // System.out.println(totalTimeMillis);
// How was it decided that 4 seconds is a reasonable maximum time?
int maxTimeMillis = 5000; // 4000;
assertTrue("Prototype creation took too long: " + totalTimeMillis, totalTimeMillis < maxTimeMillis);
} }
@Test @Test
@ -138,8 +141,11 @@ public final class AspectJAutoProxyCreatorTests {
} }
} }
sw.stop(); sw.stop();
System.out.println(sw.getTotalTimeMillis()); long totalTimeMillis = sw.getTotalTimeMillis();
assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000); // System.out.println(totalTimeMillis);
// How was it decided that 3 seconds is a reasonable maximum time?
int maxTimeMillis = 3000;
assertTrue("Prototype creation took too long: " + totalTimeMillis, totalTimeMillis < maxTimeMillis);
} }
@Test @Test
@ -149,8 +155,8 @@ public final class AspectJAutoProxyCreatorTests {
return; return;
} }
GenericApplicationContext ac = new GenericApplicationContext(); GenericApplicationContext ac = new GenericApplicationContext();
new XmlBeanDefinitionReader(ac).loadBeanDefinitions( new XmlBeanDefinitionReader(ac).loadBeanDefinitions(new ClassPathResource(qName("aspectsPlusAdvisor.xml"),
new ClassPathResource(qName("aspectsPlusAdvisor.xml"), getClass())); getClass()));
for (int i = 0; i < 10000; i++) { for (int i = 0; i < 10000; i++) {
ac.registerBeanDefinition("singleton" + i, new RootBeanDefinition(NestedTestBean.class)); ac.registerBeanDefinition("singleton" + i, new RootBeanDefinition(NestedTestBean.class));
} }
@ -158,8 +164,11 @@ public final class AspectJAutoProxyCreatorTests {
sw.start("singleton"); sw.start("singleton");
ac.refresh(); ac.refresh();
sw.stop(); sw.stop();
System.out.println(sw.getTotalTimeMillis()); long totalTimeMillis = sw.getTotalTimeMillis();
assertTrue("Singleton creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); // System.out.println(totalTimeMillis);
// How was it decided that 4 seconds is a reasonable maximum time?
int maxTimeMillis = 5000; // 4000;
assertTrue("Singleton creation took too long: " + totalTimeMillis, totalTimeMillis < maxTimeMillis);
} }
@Test @Test
@ -168,12 +177,12 @@ public final class AspectJAutoProxyCreatorTests {
GenericApplicationContext childAc = new GenericApplicationContext(ac); GenericApplicationContext childAc = new GenericApplicationContext(ac);
// Create a child factory with a bean that should be weaved // Create a child factory with a bean that should be weaved
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
bd.getPropertyValues().addPropertyValue(new PropertyValue("name", "Adrian")). bd.getPropertyValues().addPropertyValue(new PropertyValue("name", "Adrian")).addPropertyValue(
addPropertyValue(new PropertyValue("age", new Integer(34))); new PropertyValue("age", new Integer(34)));
childAc.registerBeanDefinition("adrian2", bd); childAc.registerBeanDefinition("adrian2", bd);
// Register the advisor auto proxy creator with subclass // Register the advisor auto proxy creator with subclass
childAc.registerBeanDefinition(AnnotationAwareAspectJAutoProxyCreator.class.getName(), childAc.registerBeanDefinition(AnnotationAwareAspectJAutoProxyCreator.class.getName(), new RootBeanDefinition(
new RootBeanDefinition(AnnotationAwareAspectJAutoProxyCreator.class)); AnnotationAwareAspectJAutoProxyCreator.class));
childAc.refresh(); childAc.refresh();
ITestBean beanFromChildContextThatShouldBeWeaved = (ITestBean) childAc.getBean("adrian2"); ITestBean beanFromChildContextThatShouldBeWeaved = (ITestBean) childAc.getBean("adrian2");
@ -355,7 +364,6 @@ public final class AspectJAutoProxyCreatorTests {
} }
@Aspect("pertarget(execution(* *.getSpouse()))") @Aspect("pertarget(execution(* *.getSpouse()))")
class PerTargetAspect implements Ordered { class PerTargetAspect implements Ordered {
@ -392,7 +400,8 @@ class AdviceUsingThisJoinPoint {
} }
@Pointcut("execution(* *(..))") @Pointcut("execution(* *(..))")
public void methodExecution() {} public void methodExecution() {
}
@Before("methodExecution()") @Before("methodExecution()")
public void entryTrace(JoinPoint jp) { public void entryTrace(JoinPoint jp) {
@ -401,7 +410,6 @@ class AdviceUsingThisJoinPoint {
} }
@Aspect @Aspect
class DummyAspect { class DummyAspect {
@ -412,7 +420,6 @@ class DummyAspect {
} }
@Aspect @Aspect
class DummyAspectWithParameter { class DummyAspectWithParameter {
@ -423,7 +430,6 @@ class DummyAspectWithParameter {
} }
class DummyFactoryBean implements FactoryBean<Object> { class DummyFactoryBean implements FactoryBean<Object> {
public Object getObject() throws Exception { public Object getObject() throws Exception {
@ -440,7 +446,6 @@ class DummyFactoryBean implements FactoryBean<Object> {
} }
@Aspect @Aspect
@Order(10) @Order(10)
class IncreaseReturnValue { class IncreaseReturnValue {
@ -453,7 +458,6 @@ class IncreaseReturnValue {
} }
@Aspect @Aspect
class MultiplyReturnValue { class MultiplyReturnValue {
@ -478,7 +482,6 @@ class MultiplyReturnValue {
} }
@Aspect @Aspect
class RetryAspect { class RetryAspect {
@ -488,7 +491,6 @@ class RetryAspect {
private int rollbackCalls; private int rollbackCalls;
@Pointcut("execution(public * UnreliableBean.*(..))") @Pointcut("execution(public * UnreliableBean.*(..))")
public void execOfPublicMethod() { public void execOfPublicMethod() {
} }
@ -507,20 +509,17 @@ class RetryAspect {
try { try {
o = jp.proceed(); o = jp.proceed();
this.commitCalls++; this.commitCalls++;
} } catch (RetryableException e) {
catch (RetryableException e) {
this.rollbackCalls++; this.rollbackCalls++;
throw e; throw e;
} }
} } catch (RetryableException re) {
catch (RetryableException re) {
retry = true; retry = true;
} }
} }
return o; return o;
} }
public int getBeginCalls() { public int getBeginCalls() {
return this.beginCalls; return this.beginCalls;
} }
@ -535,7 +534,6 @@ class RetryAspect {
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
class RetryableException extends NestedRuntimeException { class RetryableException extends NestedRuntimeException {
@ -548,7 +546,6 @@ class RetryableException extends NestedRuntimeException {
} }
} }
class UnreliableBean { class UnreliableBean {
private int calls; private int calls;
@ -563,7 +560,6 @@ class UnreliableBean {
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
class TestBeanAdvisor extends StaticMethodMatcherPointcutAdvisor { class TestBeanAdvisor extends StaticMethodMatcherPointcutAdvisor {