Java Code Examples for org.springframework.tests.Assume#notLogging()

The following examples show how to use org.springframework.tests.Assume#notLogging() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultListableBeanFactoryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference("spouse"));
	lbf.registerBeanDefinition("test", rbd);
	lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
	lbf.freezeConfiguration();
	TestBean spouse = (TestBean) lbf.getBean("spouse");
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		TestBean tb = (TestBean) lbf.getBean("test");
		assertSame(spouse, tb.getSpouse());
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000);
}
 
Example 2
Source File: AspectJAutoProxyCreatorTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testAspectsAndAdvisorAppliedToPrototypeIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);

	ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");

	StopWatch sw = new StopWatch();
	sw.start("Prototype Creation");
	for (int i = 0; i < 10000; i++) {
		ITestBean shouldBeWeaved = (ITestBean) ac.getBean("adrian2");
		if (i < 10) {
			doTestAspectsAndAdvisorAreApplied(ac, shouldBeWeaved);
		}
	}
	sw.stop();

	// What's a reasonable expectation for _any_ server or developer machine load?
	// 9 seconds?
	assertStopWatchTimeLimit(sw, 9000);
}
 
Example 3
Source File: DefaultListableBeanFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testSingletonLookupByNameIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class));
	lbf.freezeConfiguration();
	StopWatch sw = new StopWatch();
	sw.start("singleton");
	for (int i = 0; i < 1000000; i++) {
		lbf.getBean("test");
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Singleton lookup took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 1000);
}
 
Example 4
Source File: AspectJAutoProxyCreatorTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);

	ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");

	StopWatch sw = new StopWatch();
	sw.start("Prototype Creation");
	for (int i = 0; i < 100000; i++) {
		INestedTestBean shouldNotBeWeaved = (INestedTestBean) ac.getBean("i21");
		if (i < 10) {
			assertFalse(AopUtils.isAopProxy(shouldNotBeWeaved));
		}
	}
	sw.stop();

	// What's a reasonable expectation for _any_ server or developer machine load?
	// 3 seconds?
	assertStopWatchTimeLimit(sw, 6000);
}
 
Example 5
Source File: DefaultListableBeanFactoryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testPrototypeCreationWithResolvedPropertiesIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse"));
	lbf.registerBeanDefinition("test", rbd);
	lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
	TestBean spouse = (TestBean) lbf.getBean("spouse");
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		TestBean tb = (TestBean) lbf.getBean("test");
		assertSame(spouse, tb.getSpouse());
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000);
}
 
Example 6
Source File: DefaultListableBeanFactoryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testSingletonLookupByTypeIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class));
	lbf.freezeConfiguration();
	StopWatch sw = new StopWatch();
	sw.start("singleton");
	for (int i = 0; i < 1000000; i++) {
		lbf.getBean(TestBean.class);
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Singleton lookup took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 1000);
}
 
Example 7
Source File: DefaultListableBeanFactoryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testPrototypeCreationWithPropertiesIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.getPropertyValues().add("name", "juergen");
	rbd.getPropertyValues().add("age", "99");
	lbf.registerBeanDefinition("test", rbd);
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		TestBean tb = (TestBean) lbf.getBean("test");
		assertEquals("juergen", tb.getName());
		assertEquals(99, tb.getAge());
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000);
}
 
Example 8
Source File: DefaultListableBeanFactoryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * @Test
 * public void testPrototypeCreationIsFastEnough2() throws Exception {
 * if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
 * // Skip this test: Trace logging blows the time limit.
 * return;
 * }
 * DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 * Method setBeanNameMethod = TestBean.class.getMethod("setBeanName", String.class);
 * Method setBeanFactoryMethod = TestBean.class.getMethod("setBeanFactory", BeanFactory.class);
 * StopWatch sw = new StopWatch();
 * sw.start("prototype");
 * for (int i = 0; i < 100000; i++) {
 * TestBean tb = TestBean.class.newInstance();
 * setBeanNameMethod.invoke(tb, "test");
 * setBeanFactoryMethod.invoke(tb, lbf);
 * }
 * sw.stop();
 * // System.out.println(sw.getTotalTimeMillis());
 * assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 500);
 * }
 */

@Test
@Ignore  // TODO re-enable when ConstructorResolver TODO sorted out
public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.getConstructorArgumentValues().addGenericArgumentValue("juergen");
	rbd.getConstructorArgumentValues().addGenericArgumentValue("99");
	lbf.registerBeanDefinition("test", rbd);
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		TestBean tb = (TestBean) lbf.getBean("test");
		assertEquals("juergen", tb.getName());
		assertEquals(99, tb.getAge());
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000);
}
 
Example 9
Source File: DefaultListableBeanFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testPrototypeCreationWithDependencyCheckIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
	lbf.registerBeanDefinition("test", rbd);
	lbf.addBeanPostProcessor(new LifecycleBean.PostProcessor());
	lbf.freezeConfiguration();
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		lbf.getBean("test");
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000);
}
 
Example 10
Source File: AspectJAutoProxyCreatorTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testAspectsAndAdvisorAppliedToPrototypeIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");
	StopWatch sw = new StopWatch();
	sw.start("Prototype Creation");
	for (int i = 0; i < 10000; i++) {
		ITestBean shouldBeWeaved = (ITestBean) ac.getBean("adrian2");
		if (i < 10) {
			doTestAspectsAndAdvisorAreApplied(ac, shouldBeWeaved);
		}
	}
	sw.stop();

	// What's a reasonable expectation for _any_ server or developer machine load?
	// 9 seconds?
	assertStopWatchTimeLimit(sw, 9000);
}
 
Example 11
Source File: DefaultListableBeanFactoryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testPrototypeCreationWithDependencyCheckIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
	lbf.registerBeanDefinition("test", rbd);
	lbf.addBeanPostProcessor(new LifecycleBean.PostProcessor());
	lbf.freezeConfiguration();
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		lbf.getBean("test");
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000);
}
 
Example 12
Source File: DefaultListableBeanFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference("spouse"));
	lbf.registerBeanDefinition("test", rbd);
	lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
	lbf.freezeConfiguration();
	TestBean spouse = (TestBean) lbf.getBean("spouse");
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		TestBean tb = (TestBean) lbf.getBean("test");
		assertSame(spouse, tb.getSpouse());
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000);
}
 
Example 13
Source File: AspectJAutoProxyCreatorTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testAspectsAndAdvisorNotAppliedToManySingletonsIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);

	GenericApplicationContext ac = new GenericApplicationContext();

	new XmlBeanDefinitionReader(ac).loadBeanDefinitions(new ClassPathResource(qName("aspectsPlusAdvisor.xml"),
			getClass()));
	for (int i = 0; i < 10000; i++) {
		ac.registerBeanDefinition("singleton" + i, new RootBeanDefinition(NestedTestBean.class));
	}
	StopWatch sw = new StopWatch();
	sw.start("Singleton Creation");
	ac.refresh();
	sw.stop();

	// What's a reasonable expectation for _any_ server or developer machine load?
	// 8 seconds?
	assertStopWatchTimeLimit(sw, 8000);
}
 
Example 14
Source File: DefaultListableBeanFactoryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference("spouse"));
	lbf.registerBeanDefinition("test", rbd);
	lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
	TestBean spouse = (TestBean) lbf.getBean("spouse");
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		TestBean tb = (TestBean) lbf.getBean("test");
		assertSame(spouse, tb.getSpouse());
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000);
}
 
Example 15
Source File: DefaultListableBeanFactoryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testPrototypeCreationWithDependencyCheckIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
	lbf.registerBeanDefinition("test", rbd);
	lbf.addBeanPostProcessor(new LifecycleBean.PostProcessor());
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		lbf.getBean("test");
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000);
}
 
Example 16
Source File: AspectJAutoProxyCreatorTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");
	StopWatch sw = new StopWatch();
	sw.start("Prototype Creation");
	for (int i = 0; i < 100000; i++) {
		INestedTestBean shouldNotBeWeaved = (INestedTestBean) ac.getBean("i21");
		if (i < 10) {
			assertFalse(AopUtils.isAopProxy(shouldNotBeWeaved));
		}
	}
	sw.stop();

	// What's a reasonable expectation for _any_ server or developer machine load?
	// 3 seconds?
	assertStopWatchTimeLimit(sw, 6000);
}
 
Example 17
Source File: ApplicationContextExpressionTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void prototypeCreationIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	GenericApplicationContext ac = new GenericApplicationContext();
	RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.getConstructorArgumentValues().addGenericArgumentValue("#{systemProperties.name}");
	rbd.getPropertyValues().add("country", "#{systemProperties.country}");
	ac.registerBeanDefinition("test", rbd);
	ac.refresh();
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	System.getProperties().put("name", "juergen");
	System.getProperties().put("country", "UK");
	try {
		for (int i = 0; i < 100000; i++) {
			TestBean tb = (TestBean) ac.getBean("test");
			assertEquals("juergen", tb.getName());
			assertEquals("UK", tb.getCountry());
		}
		sw.stop();
	}
	finally {
		System.getProperties().remove("country");
		System.getProperties().remove("name");
	}
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 6000);
}
 
Example 18
Source File: AnnotationProcessorPerformanceTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@BeforeClass
public static void commonAssumptions() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
}
 
Example 19
Source File: AnnotationProcessorPerformanceTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@BeforeClass
public static void commonAssumptions() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
}
 
Example 20
Source File: AbstractPropertyAccessorTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void setPrimitiveArrayPropertyLargeMatching() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(LogFactory.getLog(AbstractPropertyAccessorTests.class));

	PrimitiveArrayBean target = new PrimitiveArrayBean();
	AbstractPropertyAccessor accessor = createAccessor(target);
	int[] input = new int[1024];
	StopWatch sw = new StopWatch();
	sw.start("array1");
	for (int i = 0; i < 1000; i++) {
		accessor.setPropertyValue("array", input);
	}
	sw.stop();
	assertEquals(1024, target.getArray().length);
	assertEquals(0, target.getArray()[0]);
	long time1 = sw.getLastTaskTimeMillis();
	assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);

	accessor.registerCustomEditor(String.class, new StringTrimmerEditor(false));
	sw.start("array2");
	for (int i = 0; i < 1000; i++) {
		accessor.setPropertyValue("array", input);
	}
	sw.stop();
	assertTrue("Took too long", sw.getLastTaskTimeMillis() < 125);

	accessor.registerCustomEditor(int.class, "array.somePath", new CustomNumberEditor(Integer.class, false));
	sw.start("array3");
	for (int i = 0; i < 1000; i++) {
		accessor.setPropertyValue("array", input);
	}
	sw.stop();
	assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);

	accessor.registerCustomEditor(int.class, "array[0].somePath", new CustomNumberEditor(Integer.class, false));
	sw.start("array3");
	for (int i = 0; i < 1000; i++) {
		accessor.setPropertyValue("array", input);
	}
	sw.stop();
	assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);

	accessor.registerCustomEditor(int.class, new CustomNumberEditor(Integer.class, false));
	sw.start("array4");
	for (int i = 0; i < 100; i++) {
		accessor.setPropertyValue("array", input);
	}
	sw.stop();
	assertEquals(1024, target.getArray().length);
	assertEquals(0, target.getArray()[0]);
	assertTrue("Took too long", sw.getLastTaskTimeMillis() > time1);
}