INT-1094 refactored calls to getName() in File Channel Adapter tests and TestUtils

This commit is contained in:
Mark Fisher
2010-04-25 23:49:35 +00:00
parent da7b3b5260
commit 920e6d6c19
3 changed files with 57 additions and 41 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,24 +16,27 @@
package org.springframework.integration.file.config;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.file.CompositeFileListFilter;
import org.springframework.integration.file.DefaultDirectoryScanner;
import org.springframework.integration.file.FileReadingMessageSource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.Comparator;
import java.util.concurrent.PriorityBlockingQueue;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.channel.AbstractMessageChannel;
import org.springframework.integration.file.CompositeFileListFilter;
import org.springframework.integration.file.DefaultDirectoryScanner;
import org.springframework.integration.file.FileReadingMessageSource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Iwein Fuld
@@ -51,19 +54,20 @@ public class FileInboundChannelAdapterParserTests {
private DirectFieldAccessor accessor;
@Before
@Before
public void init() {
accessor = new DirectFieldAccessor(source);
}
@Test
public void channelName() throws Exception {
MessageChannel channel = (MessageChannel) context.getBean("inputDirPoller");
assertEquals("Channel should be available under specified id", "inputDirPoller", channel.getName());
AbstractMessageChannel channel = context.getBean("inputDirPoller", AbstractMessageChannel.class);
assertEquals("Channel should be available under specified id", "inputDirPoller", channel.getName());
}
@Test
public void inputDirectory() {
public void inputDirectory() {
File expected = new File(System.getProperty("java.io.tmpdir"));
File actual = (File) accessor.getPropertyValue("directory");
assertEquals("'directory' should be set", expected, actual);
@@ -71,11 +75,11 @@ public class FileInboundChannelAdapterParserTests {
@Test
public void filter() throws Exception {
DefaultDirectoryScanner scanner = (DefaultDirectoryScanner) accessor.getPropertyValue("scanner");
DirectFieldAccessor scannerAccessor = new DirectFieldAccessor(scanner);
assertTrue("'filter' should be set", scannerAccessor.getPropertyValue("filter") instanceof CompositeFileListFilter);
DefaultDirectoryScanner scanner = (DefaultDirectoryScanner) accessor.getPropertyValue("scanner");
DirectFieldAccessor scannerAccessor = new DirectFieldAccessor(scanner);
assertTrue("'filter' should be set",
scannerAccessor.getPropertyValue("filter") instanceof CompositeFileListFilter);
}
@Test
public void comparator() throws Exception {
@@ -87,6 +91,7 @@ public class FileInboundChannelAdapterParserTests {
assertSame("comparator reference not set, ", expected, actual);
}
static class TestComparator implements Comparator<File> {
public int compare(File f1, File f2) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,23 +16,31 @@
package org.springframework.integration.file.config;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.file.*;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.Set;
import java.util.regex.Pattern;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.channel.AbstractMessageChannel;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.file.AcceptOnceFileListFilter;
import org.springframework.integration.file.CompositeFileListFilter;
import org.springframework.integration.file.FileListFilter;
import org.springframework.integration.file.FileReadingMessageSource;
import org.springframework.integration.file.PatternMatchingFileListFilter;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
@@ -57,9 +65,10 @@ public class FileInboundChannelAdapterWithPatternParserTests {
this.accessor = new DirectFieldAccessor(source);
}
@Test
public void channelName() {
MessageChannel channel = (MessageChannel) context.getBean("adapterWithPattern");
AbstractMessageChannel channel = context.getBean("adapterWithPattern", AbstractMessageChannel.class);
assertEquals("adapterWithPattern", channel.getName());
}