[jboss-user] [JBoss Seam] - Re: Integration Testing with TestNG and embeddedEjb

b.reeve do-not-reply at jboss.com
Tue Oct 16 19:03:33 EDT 2007


These are the classes that I have


Employee.java

  | package test.injection;
  | 
  | import org.jboss.seam.ScopeType;
  | import org.jboss.seam.annotations.In;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.Scope;
  | 
  | @Name("employeeBean")
  | @Scope(ScopeType.SESSION)
  | public class Employee {
  | 	
  | 	private String name;
  | 	
  | 	@In("#{departmentSpring}")
  | 	private Department department;
  | 
  | 	public String getName() {
  | 		return name;
  | 	}
  | 
  | 	public void setName(String name) {
  | 		this.name = name;
  | 	}
  | 	
  | 	public String addEmployee(){
  | 		return "/success.xhtml";
  | 	}
  | 
  | }
Department.java

  | package test.injection;
  | 
  | 
  | public class Department {
  | 	
  | 	private String departmentName;	
  | 
  | 	public String getDepartmentName() {
  | 		return departmentName;
  | 	}
  | 
  | 	public void setDepartmentName(String departmentName) {
  | 		this.departmentName = departmentName;
  | 	}
  | 
  | }
  | 
  | 
InjectionTestNG.java

  | package test.testNG;
  | 
  | import org.jboss.seam.mock.SeamTest;
  | import org.testng.annotations.Test;
  | 
  | public class InjectionTestNG extends SeamTest{
  | 	
  | 	@Test
  | 	public void testInjection() throws Exception {
  | 		new FacesRequest(){
  | 			
  | 			@Override
  | 			protected void updateModelValues(){
  | 				setValue("#{employeeBean.name}","MyName");
  | 			}
  | 			
  | 			@Override
  | 			protected void invokeApplication(){
  | 				invokeMethod("#{employeeBean.addEmployee}");
  | 			}
  | 			
  | 			@Override
  | 			protected void renderResponse(){
  | 				assert (getValue("#{employeeBean.name}").equals("MyName"));
  | 			}
  | 		}.run();
  | 	}
  | 	
  | 
  | }
  | 
  | 

applicationContext.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
  | 
  | 
  | <beans>        
  |     <bean id="departmentSpring" class="test.injection.Department" />
  | </beans> 
  | 

And this is the exception stack trace

  | FAILED: testInjection
  | javax.el.ELException: Error writing 'name' on type test.injection.Employee_$$_javassist_0
  | 	at javax.el.BeanELResolver.setValue(BeanELResolver.java:112)
  | 	at javax.el.CompositeELResolver.setValue(CompositeELResolver.java:68)
  | 	at com.sun.el.parser.AstValue.setValue(AstValue.java:154)
  | 	at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:258)
  | 	at org.jboss.seam.util.UnifiedELValueBinding.setValue(UnifiedELValueBinding.java:44)
  | 	at org.jboss.seam.mock.SeamTest$Request.setValue(SeamTest.java:374)
  | 	at test.testNG.InjectionTestNG$1.updateModelValues(InjectionTestNG.java:23)
  | 	at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:476)
  | 	at test.testNG.InjectionTestNG.testInjection(InjectionTestNG.java:35)
  | Caused by: javax.el.PropertyNotFoundException: ELResolver cannot handle a null base Object with identifier 'departmentSpring'
  | 	at com.sun.el.lang.ELSupport.throwUnhandled(ELSupport.java:52)
  | 	at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:75)
  | 	at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:195)
  | 	at org.jboss.seam.util.UnifiedELValueBinding.getValue(UnifiedELValueBinding.java:34)
  | 	at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:69)
  | 	at org.jboss.seam.Component.getValueToInject(Component.java:1877)
  | 	at org.jboss.seam.Component.injectAttributes(Component.java:1368)
  | 	at org.jboss.seam.Component.inject(Component.java:1195)
  | 	at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
  | 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
  | 	at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
  | 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
  | 	at org.jboss.seam.interceptors.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:31)
  | 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
  | 	at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
  | 	at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
  | 	at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
  | 	at test.injection.Employee_$$_javassist_0.setName(Employee_$$_javassist_0.java)
  | 	at javax.el.BeanELResolver.setValue(BeanELResolver.java:108)
  | 	... 30 more
  | ... Removed 26 stack frames
  | 

Thanks !!!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4095830#4095830

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4095830



More information about the jboss-user mailing list