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_NoBeanSet_NoClassNameSet() throws Exception { JavaActor actor = new JavaActor(); actor.setName("MultiplyActor"); 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: " + "No bean class provided for actor MultiplyActor", exception.toString()); assertNull(exception.getCause()); assertNull(actor.getWrappedBean()); assertNull(actor.getWrappedBeanClass()); }
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_BeanSet() throws Exception { JavaActor actor = new JavaActor(); MultiplyBean bean = new MultiplyBean(); assertNull(actor.getWrappedBean()); assertNull(actor.getWrappedBeanClass()); actor.setWrappedBean(bean); assertNull(actor.getWrappedBeanClass()); assertSame(bean, actor.getWrappedBean()); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); assertEquals(MultiplyBean.class, actor.getWrappedBeanClass()); assertSame(bean, actor.getWrappedBean()); }
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()); }
public void testClone_UncloneableBean() throws Exception { JavaActor actor = new JavaActor(); actor.setName("MultiplyActor"); UncloneableMultiplyBean bean = new UncloneableMultiplyBean(); actor.setWrappedBean(bean); Yaml yaml = new Yaml(); actor.setInputs((Map<String, Object>) yaml.load("originalValue:" + EOL)); actor.setOutputs((Map<String, Object>) yaml.load("multipliedValue:" + EOL)); actor.setSettings((Map<String, Object>) yaml.load("factor: 4" + EOL)); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); JavaActor clone = (JavaActor) actor.clone(); assertNotSame(bean, clone.getWrappedBean()); clone.setInputValue("originalValue", 5); clone.step(); assertEquals(20, clone.getOutputValue("multipliedValue")); }