Search in sources :

Example 51 with StopWatch

use of org.springframework.util.StopWatch in project spring-framework by spring-projects.

the class QuartzSchedulerLifecycleTests method destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang.

// SPR-6354
@Test
public void destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang() {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("quartzSchedulerLifecycleTests.xml", getClass());
    assertThat(context.getBean("lazyInitSchedulerWithDefaultShutdownOrder")).isNotNull();
    StopWatch sw = new StopWatch();
    sw.start("lazyScheduler");
    context.close();
    sw.stop();
    assertThat(sw.getTotalTimeMillis() < 500).as("Quartz Scheduler with lazy-init is hanging on destruction: " + sw.getTotalTimeMillis()).isTrue();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) StopWatch(org.springframework.util.StopWatch) Test(org.junit.jupiter.api.Test)

Example 52 with StopWatch

use of org.springframework.util.StopWatch in project spring-framework by spring-projects.

the class TraceBeforeAdvice method testRepeatedAroundAdviceInvocations.

private long testRepeatedAroundAdviceInvocations(String file, int howmany, String technology) {
    ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);
    StopWatch sw = new StopWatch();
    sw.start(howmany + " repeated around advice invocations with " + technology);
    ITestBean adrian = (ITestBean) bf.getBean("adrian");
    assertThat(AopUtils.isAopProxy(adrian)).isTrue();
    assertThat(adrian.getAge()).isEqualTo(68);
    for (int i = 0; i < howmany; i++) {
        adrian.getAge();
    }
    sw.stop();
    System.out.println(sw.prettyPrint());
    return sw.getLastTaskTimeMillis();
}
Also used : ITestBean(org.springframework.beans.testfixture.beans.ITestBean) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) StopWatch(org.springframework.util.StopWatch)

Example 53 with StopWatch

use of org.springframework.util.StopWatch in project spring-framework by spring-projects.

the class TraceBeforeAdvice method testAfterReturningAdviceWithoutJoinPoint.

private long testAfterReturningAdviceWithoutJoinPoint(String file, int howmany, String technology) {
    ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);
    StopWatch sw = new StopWatch();
    sw.start(howmany + " repeated after returning advice invocations with " + technology);
    ITestBean adrian = (ITestBean) bf.getBean("adrian");
    assertThat(AopUtils.isAopProxy(adrian)).isTrue();
    Advised a = (Advised) adrian;
    assertThat(a.getAdvisors().length >= 3).isTrue();
    // Hits joinpoint
    adrian.setAge(25);
    for (int i = 0; i < howmany; i++) {
        adrian.setAge(i);
    }
    sw.stop();
    System.out.println(sw.prettyPrint());
    return sw.getLastTaskTimeMillis();
}
Also used : ITestBean(org.springframework.beans.testfixture.beans.ITestBean) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Advised(org.springframework.aop.framework.Advised) StopWatch(org.springframework.util.StopWatch)

Example 54 with StopWatch

use of org.springframework.util.StopWatch in project spring-framework by spring-projects.

the class TraceBeforeAdvice method testMix.

private long testMix(String file, int howmany, String technology) {
    ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);
    StopWatch sw = new StopWatch();
    sw.start(howmany + " repeated mixed invocations with " + technology);
    ITestBean adrian = (ITestBean) bf.getBean("adrian");
    assertThat(AopUtils.isAopProxy(adrian)).isTrue();
    Advised a = (Advised) adrian;
    assertThat(a.getAdvisors().length >= 3).isTrue();
    for (int i = 0; i < howmany; i++) {
        // Hit all 3 joinpoints
        adrian.getAge();
        adrian.getName();
        adrian.setAge(i);
        // Invoke three non-advised methods
        adrian.getDoctor();
        adrian.getLawyer();
        adrian.getSpouse();
    }
    sw.stop();
    System.out.println(sw.prettyPrint());
    return sw.getLastTaskTimeMillis();
}
Also used : ITestBean(org.springframework.beans.testfixture.beans.ITestBean) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Advised(org.springframework.aop.framework.Advised) StopWatch(org.springframework.util.StopWatch)

Example 55 with StopWatch

use of org.springframework.util.StopWatch in project spring-framework by spring-projects.

the class TraceBeforeAdvice method testBeforeAdviceWithoutJoinPoint.

private long testBeforeAdviceWithoutJoinPoint(String file, int howmany, String technology) {
    ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);
    StopWatch sw = new StopWatch();
    sw.start(howmany + " repeated before advice invocations with " + technology);
    ITestBean adrian = (ITestBean) bf.getBean("adrian");
    assertThat(AopUtils.isAopProxy(adrian)).isTrue();
    Advised a = (Advised) adrian;
    assertThat(a.getAdvisors().length >= 3).isTrue();
    assertThat(adrian.getName()).isEqualTo("adrian");
    for (int i = 0; i < howmany; i++) {
        adrian.getName();
    }
    sw.stop();
    System.out.println(sw.prettyPrint());
    return sw.getLastTaskTimeMillis();
}
Also used : ITestBean(org.springframework.beans.testfixture.beans.ITestBean) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Advised(org.springframework.aop.framework.Advised) StopWatch(org.springframework.util.StopWatch)

Aggregations

StopWatch (org.springframework.util.StopWatch)112 Test (org.junit.Test)44 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)12 ArrayList (java.util.ArrayList)9 Test (org.junit.jupiter.api.Test)9 ITestBean (org.springframework.tests.sample.beans.ITestBean)9 TestBean (org.springframework.tests.sample.beans.TestBean)9 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)8 List (java.util.List)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ITestBean (org.springframework.beans.testfixture.beans.ITestBean)6 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)6 ApplicationMap (com.navercorp.pinpoint.web.applicationmap.ApplicationMap)5 Ignore (org.junit.Ignore)5 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)5 NestedTestBean (org.springframework.tests.sample.beans.NestedTestBean)5 Range (com.navercorp.pinpoint.web.vo.Range)4 Dataset (org.apache.jena.query.Dataset)4