public void testConfigure_ExceptionConstructingBean() throws Exception { JavaActor actor = new JavaActor(); actor.setName("MultiplyActor"); assertNull(actor.getWrappedBean()); assertNull(actor.getWrappedBeanClass()); actor.setBeanClassName("org.restflow.actors.TestJavaActor$MultiplyBean"); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); MultiplyBean.throwExceptionInConstructor = true; Exception exception = null; try { actor.configure(); } catch (WorkflowRuntimeException e) { exception = e; } assertEquals( "org.restflow.exceptions.WorkflowRuntimeException: " + "Error instantiating instance of bean class " + "class org.restflow.actors.TestJavaActor$MultiplyBean " + "for actor MultiplyActor", exception.toString()); assertNotNull(exception.getCause()); assertEquals("java.lang.Exception: Exception in constructor", exception.getCause().toString()); assertNull(actor.getWrappedBean()); }
public void testConfigure_BeanClassNameSet_NotFound() throws Exception { JavaActor actor = new JavaActor(); actor.setName("MultiplyActor"); actor.setBeanClassName("org.restflow.actors.TestJavaActor$MissingBean"); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); assertNull(actor.getWrappedBean()); assertNull(actor.getWrappedBeanClass()); Exception exception = null; try { actor.configure(); } catch (ActorDeclarationException e) { exception = e; } assertEquals( "org.restflow.exceptions.ActorDeclarationException: " + "Bean class org.restflow.actors.TestJavaActor$MissingBean " + "not found for actor MultiplyActor", exception.toString()); assertNotNull(exception.getCause()); assertEquals( "java.lang.ClassNotFoundException: " + "org.restflow.actors.TestJavaActor$MissingBean", exception.getCause().toString()); assertNull(actor.getWrappedBean()); assertNull(actor.getWrappedBeanClass()); }
public void testConfigure_BeanClassNameSet() throws Exception { JavaActor actor = new JavaActor(); actor.setBeanClassName("org.restflow.actors.TestJavaActor$MultiplyBean"); assertNull(actor.getWrappedBean()); assertNull(actor.getWrappedBeanClass()); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); assertEquals(MultiplyBean.class, actor.getWrappedBeanClass()); Object bean = actor.getWrappedBean(); assertSame(MultiplyBean.class, bean.getClass()); }
public void testConfigure_BothBeanAndClassNameSet() throws Exception { JavaActor actor = new JavaActor(); actor.setName("MultiplyActor"); actor.setWrappedBean(new MultiplyBean()); actor.setBeanClassName("org.restflow.actors.TestJavaActor$MultiplyBean"); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); Exception exception = null; try { actor.configure(); } catch (ActorDeclarationException e) { exception = e; } assertNotNull(exception); assertEquals( "org.restflow.exceptions.ActorDeclarationException: " + "Actor MultiplyActor declared both a bean instance and a bean class.", exception.toString()); }
public void testConfigure_ExceptionPrivateBeanConstructor() throws Exception { JavaActor actor = new JavaActor(); actor.setName("MultiplyActor"); assertNull(actor.getWrappedBean()); assertNull(actor.getWrappedBeanClass()); actor.setBeanClassName("org.restflow.actors.TestJavaActor$BeanWithPrivateConstructor"); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); Exception exception = null; try { actor.configure(); } catch (WorkflowRuntimeException e) { exception = e; } assertEquals( "org.restflow.exceptions.WorkflowRuntimeException: " + "Error instantiating instance of bean class " + "class org.restflow.actors.TestJavaActor$BeanWithPrivateConstructor " + "for actor MultiplyActor", exception.toString()); assertNotNull(exception.getCause()); assertEquals( "java.lang.IllegalAccessException: " + "Class org.restflow.actors.JavaActor can not access a member of class " + "org.restflow.actors.TestJavaActor$BeanWithPrivateConstructor " + "with modifiers \"private\"", exception.getCause().toString()); assertNull(actor.getWrappedBean()); }