de.larmic.joinfaces.test.JsfSpringBeanBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of joinfaces-bean-test Show documentation
Show all versions of joinfaces-bean-test Show documentation
Demonstrates a way to create an JSF bean integration test
The newest version!
package de.larmic.joinfaces.test;
import org.springframework.context.ApplicationContext;
import java.util.HashMap;
import java.util.Map;
/**
* Simple chaining builder to create JSF scoped bean that should be unit tested.
*/
public class JsfSpringBeanBuilder {
private final Map parameterMap = new HashMap<>();
private final ApplicationContext context;
public JsfSpringBeanBuilder(ApplicationContext context) {
this.context = context;
}
public JsfSpringBeanBuilder withExternalParameter(String key, String value) {
this.parameterMap.put(key, value);
return this;
}
public T build(Class beanClass) {
new FacesContextMock()
.withExternalParameters(parameterMap)
.replaceIn(context);
return context.getBean(beanClass);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy