private List<ConfigurationListener> getListeners(Configuration configuration) { try { return ClassUtils.getFieldValue(configuration, "listeners", true); } catch (Exception e) { throw new MuleRuntimeException(createStaticMessage("Could not get listeners. Unexpected configuration type"), e); } }
@Test public void getFieldValueRecursive() throws Exception { final int hash = hashCode(); HashBlob blob = new ExtendedHashBlob(hash); assertThat(hash, equalTo(ClassUtils.getFieldValue(blob, "hash", true))); }
@Test public void getFieldValue() throws Exception { final int hash = hashCode(); HashBlob blob = new HashBlob(hash); assertThat(hash, equalTo(ClassUtils.getFieldValue(blob, "hash", false))); }
@Test(expected = NoSuchFieldException.class) public void getUnexistentFieldValueRecursive() throws Exception { ClassUtils.getFieldValue(new ExtendedHashBlob(1), "fake", true); }
@Test(expected = NoSuchFieldException.class) public void getInheritedFieldValueWithoutRecurse() throws Exception { ClassUtils.getFieldValue(new ExtendedHashBlob(1), "hash", false); }
@Test(expected = NoSuchFieldException.class) public void getUnexistentFieldValue() throws Exception { ClassUtils.getFieldValue(new HashBlob(0), "fake", false); }
@Test public void disableShutdownHook() throws Exception { contextConfigurer.configure(context); assertThat((boolean) ClassUtils.getFieldValue(context.getConfiguration(), SHUTDOWN_HOOK_PROPERTY, true), is(false)); }
@Test public void perAppDefaultAppender() throws Exception { when(context.isArtifactClassloader()).thenReturn(true); when(context.getArtifactDescriptor().getDeploymentProperties()).thenReturn(empty()); contextConfigurer.update(context); ArgumentCaptor<RollingFileAppender> appenderCaptor = ArgumentCaptor.forClass(RollingFileAppender.class); verify(context.getConfiguration()).addAppender(appenderCaptor.capture()); Appender perAppAppender = appenderCaptor.getValue(); assertThat(perAppAppender, notNullValue()); assertThat(perAppAppender.getName(), equalTo(PER_APP_FILE_APPENDER_NAME)); assertThat(perAppAppender.isStarted(), is(true)); String filePattern = ClassUtils.getFieldValue(perAppAppender, FILE_PATTERN_PROPERTY, true); String filePatternTemplate = filePattern.substring(filePattern.lastIndexOf('/') + 1); String filePatternTemplateDateSuffix = filePatternTemplate.substring(filePatternTemplate.lastIndexOf('.') + 1); assertThat(filePatternTemplateDateSuffix, equalTo(FILE_PATTERN_TEMPLATE_DATE_SECTION)); LoggerConfig rootLogger = context.getConfiguration().getRootLogger(); verify(rootLogger).addAppender(perAppAppender, Level.ALL, null); }
@Test public void verifySameProcessorInstance() throws Exception { Object getChainFirst = runFlow("getChain").getMessage().getPayload().getValue(); Object getChainSecond = runFlow("getChain").getMessage().getPayload().getValue(); assertThat(getChainFirst, is(not(sameInstance(getChainSecond)))); Object firstChain = ClassUtils.getFieldValue(getChainFirst, "chain", false); Object secondChain = ClassUtils.getFieldValue(getChainSecond, "chain", false); assertThat(firstChain, is(sameInstance(secondChain))); }
private List<ConfigurationListener> getListeners(Configuration configuration) { try { return ClassUtils.getFieldValue(configuration, "listeners", true); } catch (Exception e) { throw new MuleRuntimeException(createStaticMessage("Could not get listeners. Unexpected configuration type"), e); } }
@Test public void getFieldValue() throws Exception { final int hash = hashCode(); HashBlob blob = new HashBlob(hash); assertThat(hash, equalTo(ClassUtils.getFieldValue(blob, "hash", false))); }
@Test public void getFieldValueRecursive() throws Exception { final int hash = hashCode(); HashBlob blob = new ExtendedHashBlob(hash); assertThat(hash, equalTo(ClassUtils.getFieldValue(blob, "hash", true))); }
@Test(expected = NoSuchFieldException.class) public void getUnexistentFieldValue() throws Exception { ClassUtils.getFieldValue(new HashBlob(0), "fake", false); }
@Test(expected = NoSuchFieldException.class) public void getUnexistentFieldValueRecursive() throws Exception { ClassUtils.getFieldValue(new ExtendedHashBlob(1), "fake", true); }
@Test(expected = NoSuchFieldException.class) public void getInheritedFieldValueWithoutRecurse() throws Exception { ClassUtils.getFieldValue(new ExtendedHashBlob(1), "hash", false); }
@Test public void verifySameProcessorInstance() throws Exception { Object getChainFirst = runFlow("getChain").getMessage().getPayload().getValue(); Object getChainSecond = runFlow("getChain").getMessage().getPayload().getValue(); assertThat(getChainFirst, is(not(sameInstance(getChainSecond)))); Object firstChain = ClassUtils.getFieldValue(getChainFirst, "chain", false); Object secondChain = ClassUtils.getFieldValue(getChainSecond, "chain", false); assertThat(firstChain, is(sameInstance(secondChain))); }