Java Code Examples for org.springframework.expression.spel.support.standardevaluationcontext#addConstructorResolver()

The following examples show how to use org.springframework.expression.spel.support.standardevaluationcontext#addConstructorResolver() . 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: ConstructorInvocationTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testAddingConstructorResolvers() {
	StandardEvaluationContext ctx = new StandardEvaluationContext();

	// reflective constructor accessor is the only one by default
	List<ConstructorResolver> constructorResolvers = ctx.getConstructorResolvers();
	assertEquals(1, constructorResolvers.size());

	ConstructorResolver dummy = new DummyConstructorResolver();
	ctx.addConstructorResolver(dummy);
	assertEquals(2, ctx.getConstructorResolvers().size());

	List<ConstructorResolver> copy = new ArrayList<>();
	copy.addAll(ctx.getConstructorResolvers());
	assertTrue(ctx.removeConstructorResolver(dummy));
	assertFalse(ctx.removeConstructorResolver(dummy));
	assertEquals(1, ctx.getConstructorResolvers().size());

	ctx.setConstructorResolvers(copy);
	assertEquals(2, ctx.getConstructorResolvers().size());
}
 
Example 2
Source File: ConstructorInvocationTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testAddingConstructorResolvers() {
	StandardEvaluationContext ctx = new StandardEvaluationContext();

	// reflective constructor accessor is the only one by default
	List<ConstructorResolver> constructorResolvers = ctx.getConstructorResolvers();
	assertEquals(1, constructorResolvers.size());

	ConstructorResolver dummy = new DummyConstructorResolver();
	ctx.addConstructorResolver(dummy);
	assertEquals(2, ctx.getConstructorResolvers().size());

	List<ConstructorResolver> copy = new ArrayList<>();
	copy.addAll(ctx.getConstructorResolvers());
	assertTrue(ctx.removeConstructorResolver(dummy));
	assertFalse(ctx.removeConstructorResolver(dummy));
	assertEquals(1, ctx.getConstructorResolvers().size());

	ctx.setConstructorResolvers(copy);
	assertEquals(2, ctx.getConstructorResolvers().size());
}
 
Example 3
Source File: ConstructorInvocationTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddingConstructorResolvers() {
	StandardEvaluationContext ctx = new StandardEvaluationContext();

	// reflective constructor accessor is the only one by default
	List<ConstructorResolver> constructorResolvers = ctx.getConstructorResolvers();
	assertEquals(1, constructorResolvers.size());

	ConstructorResolver dummy = new DummyConstructorResolver();
	ctx.addConstructorResolver(dummy);
	assertEquals(2, ctx.getConstructorResolvers().size());

	List<ConstructorResolver> copy = new ArrayList<ConstructorResolver>();
	copy.addAll(ctx.getConstructorResolvers());
	assertTrue(ctx.removeConstructorResolver(dummy));
	assertFalse(ctx.removeConstructorResolver(dummy));
	assertEquals(1, ctx.getConstructorResolvers().size());

	ctx.setConstructorResolvers(copy);
	assertEquals(2, ctx.getConstructorResolvers().size());
}