diff --git a/spring-integration-smb/README.md b/spring-integration-smb/README.md index e7a0038..9a5e40c 100644 --- a/spring-integration-smb/README.md +++ b/spring-integration-smb/README.md @@ -1,3 +1,9 @@ -Spring Integration Smb Adapter -================================================= +Spring Integration Smb Support +============================== + +## Introduction + +This module add Spring Integration* support for [Server Message Block][] (SMB). + +[Server Message Block]: http://en.wikipedia.org/wiki/Server_Message_Block diff --git a/spring-integration-smb/build.gradle b/spring-integration-smb/build.gradle index d94da70..c121430 100644 --- a/spring-integration-smb/build.gradle +++ b/spring-integration-smb/build.gradle @@ -14,7 +14,7 @@ apply from: "${rootProject.projectDir}/publish-maven.gradle" apply plugin: 'eclipse' apply plugin: 'idea' -group = 'org.springframework.integration.smb' +group = 'org.springframework.integration' repositories { maven { url 'http://repo.springsource.org/libs-milestone' } @@ -29,16 +29,17 @@ ext { aspectjVersion = '1.6.8' cglibVersion = '2.2' commonsNetVersion = '3.0.1' - easymockVersion = '2.3' groovyVersion = '1.8.5' jacksonVersion = '1.9.2' javaxActivationVersion = '1.1.1' - junitVersion = '4.10' + junitVersion = '4.11' log4jVersion = '1.2.12' mockitoVersion = '1.9.0' springVersion = '3.1.3.RELEASE' - springIntegrationVersion = '2.2.0.RC2' + springIntegrationVersion = '2.2.1.RELEASE' + + idPrefix = 'smb' } @@ -49,7 +50,7 @@ dependencies { compile "org.springframework.integration:spring-integration-stream:$springIntegrationVersion" compile "jcifs:jcifs:1.3.17" compile "org.springframework:spring-context-support:$springVersion" - compile("javax.activation:activation:$javaxActivationVersion") { optional = true } + compile("javax.activation:activation:$javaxActivationVersion", optional) testCompile "org.springframework.integration:spring-integration-test:$springIntegrationVersion" } @@ -80,8 +81,6 @@ dependencies { testCompile "cglib:cglib-nodep:$cglibVersion" testCompile "junit:junit-dep:$junitVersion" testCompile "log4j:log4j:$log4jVersion" - testCompile "org.easymock:easymock:$easymockVersion" - testCompile "org.easymock:easymockclassextension:$easymockVersion" testCompile "org.hamcrest:hamcrest-all:1.1" testCompile "org.mockito:mockito-all:$mockitoVersion" testCompile "org.springframework:spring-test:$springVersion" @@ -155,19 +154,16 @@ sonar { task api(type: Javadoc) { group = 'Documentation' - description = 'Generates aggregated Javadoc API documentation.' + description = 'Generates the Javadoc API documentation.' title = "${rootProject.description} ${version} API" options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED options.author = true options.header = rootProject.description options.overview = 'src/api/overview.html' - source subprojects.collect { project -> - project.sourceSets.main.allJava - } + + source = sourceSets.main.allJava + classpath = project.sourceSets.main.compileClasspath destinationDir = new File(buildDir, "api") - classpath = files(subprojects.collect { project -> - project.sourceSets.main.compileClasspath - }) } task schemaZip(type: Zip) { @@ -176,27 +172,23 @@ task schemaZip(type: Zip) { description = "Builds -${classifier} archive containing all " + "XSDs for deployment at static.springframework.org/schema." - subprojects.each { subproject -> - def Properties schemas = new Properties(); - def shortName = subproject.name.replaceFirst("${rootProject.name}-", '') - if (subproject.name.endsWith("-core")) { - shortName = '' + def Properties schemas = new Properties(); + def shortName = idPrefix.replaceFirst("${idPrefix}-", '') + + project.sourceSets.main.resources.find { + it.path.endsWith('META-INF/spring.schemas') + }?.withInputStream { schemas.load(it) } + + for (def key : schemas.keySet()) { + File xsdFile = project.sourceSets.main.resources.find { + it.path.endsWith(schemas.get(key)) } - - subproject.sourceSets.main.resources.find { - it.path.endsWith('META-INF/spring.schemas') - }?.withInputStream { schemas.load(it) } - - for (def key : schemas.keySet()) { - File xsdFile = subproject.sourceSets.main.resources.find { - it.path.endsWith(schemas.get(key)) - } - assert xsdFile != null - into ("integration/${shortName}") { - from xsdFile.path - } + assert xsdFile != null + into ("integration/${shortName}") { + from xsdFile.path } } + } task docsZip(type: Zip) { @@ -241,12 +233,10 @@ task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) { into "${baseDir}/schema" } - subprojects.each { subproject -> - into ("${baseDir}/libs") { - from subproject.jar - from subproject.sourcesJar - from subproject.javadocJar - } + into ("${baseDir}/libs") { + from project.jar + from project.sourcesJar + from project.javadocJar } } @@ -262,14 +252,13 @@ task depsZip(type: Zip, dependsOn: distZip) { zipTask -> gradle.taskGraph.whenReady { taskGraph -> if (taskGraph.hasTask(":${zipTask.name}")) { - def projectNames = rootProject.subprojects*.name + def projectName = rootProject.name def artifacts = new HashSet() - subprojects.each { subproject -> - subproject.configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { artifact -> - def dependency = artifact.moduleVersion.id - if (!projectNames.contains(dependency.name)) { - artifacts << artifact.file - } + + rootProject.configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { artifact -> + def dependency = artifact.moduleVersion.id + if (!projectName.equals(dependency.name)) { + artifacts << artifact.file } } @@ -293,5 +282,5 @@ task dist(dependsOn: assemble) { task wrapper(type: Wrapper) { description = 'Generates gradlew[.bat] scripts' - gradleVersion = '1.2' + gradleVersion = '1.4' } diff --git a/spring-integration-smb/gradle/wrapper/gradle-wrapper.jar b/spring-integration-smb/gradle/wrapper/gradle-wrapper.jar index 7b359d7..b6b646b 100644 Binary files a/spring-integration-smb/gradle/wrapper/gradle-wrapper.jar and b/spring-integration-smb/gradle/wrapper/gradle-wrapper.jar differ diff --git a/spring-integration-smb/gradle/wrapper/gradle-wrapper.properties b/spring-integration-smb/gradle/wrapper/gradle-wrapper.properties index b05f438..589a827 100644 --- a/spring-integration-smb/gradle/wrapper/gradle-wrapper.properties +++ b/spring-integration-smb/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Nov 08 10:44:45 EST 2012 +#Fri Feb 22 11:59:38 EST 2013 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-1.2-bin.zip +distributionUrl=http\://services.gradle.org/distributions/gradle-1.4-bin.zip diff --git a/spring-integration-smb/gradlew b/spring-integration-smb/gradlew index 3851082..91a7e26 100755 --- a/spring-integration-smb/gradlew +++ b/spring-integration-smb/gradlew @@ -61,9 +61,9 @@ while [ -h "$PRG" ] ; do fi done SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" +cd "`dirname \"$PRG\"`/" >&- APP_HOME="`pwd -P`" -cd "$SAVED" +cd "$SAVED" >&- CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar diff --git a/spring-integration-smb/publish-maven.gradle b/spring-integration-smb/publish-maven.gradle index 0e43ef0..06eb14e 100644 --- a/spring-integration-smb/publish-maven.gradle +++ b/spring-integration-smb/publish-maven.gradle @@ -31,7 +31,7 @@ def customizePom(pom, gradleProject) { generatedPom.project { name = gradleProject.description description = gradleProject.description - url = 'https://github.com/SpringSource/spring-integration' + url = 'https://github.com/SpringSource/spring-integration-extensions' organization { name = 'SpringSource' url = 'http://springsource.org' @@ -44,9 +44,9 @@ def customizePom(pom, gradleProject) { } } scm { - url = 'https://github.com/SpringSource/spring-integration' - connection = 'scm:git:git://github.com/SpringSource/spring-integration' - developerConnection = 'scm:git:git://github.com/SpringSource/spring-integration' + url = 'https://github.com/SpringSource/spring-integration-extensions' + connection = 'scm:git:git://github.com/SpringSource/spring-integration-extensions' + developerConnection = 'scm:git:git://github.com/SpringSource/spring-integration-extensions' } developers { diff --git a/spring-integration-smb/src/main/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParser.java b/spring-integration-smb/src/main/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParser.java index 29e0695..03f3e0b 100644 --- a/spring-integration-smb/src/main/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParser.java +++ b/spring-integration-smb/src/main/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParser.java @@ -21,7 +21,7 @@ import org.springframework.integration.file.config.AbstractRemoteFileInboundChan * Parser for the SMB 'inbound-channel-adapter' element. * * @author Markus Spann - * @since 2.1.1 + * @since 1.0 */ public class SmbInboundChannelAdapterParser extends AbstractRemoteFileInboundChannelAdapterParser { diff --git a/spring-integration-smb/src/main/java/org/springframework/integration/smb/config/SmbNamespaceHandler.java b/spring-integration-smb/src/main/java/org/springframework/integration/smb/config/SmbNamespaceHandler.java index cfef762..ab0b041 100644 --- a/spring-integration-smb/src/main/java/org/springframework/integration/smb/config/SmbNamespaceHandler.java +++ b/spring-integration-smb/src/main/java/org/springframework/integration/smb/config/SmbNamespaceHandler.java @@ -22,11 +22,11 @@ import org.springframework.integration.file.config.RemoteFileOutboundChannelAdap * Provides namespace support for using SMB. * * @author Markus Spann - * @since 2.1.1 + * @since 1.0 */ public class SmbNamespaceHandler extends AbstractIntegrationNamespaceHandler { - public void init() { + public void init() { registerBeanDefinitionParser("inbound-channel-adapter", new SmbInboundChannelAdapterParser()); registerBeanDefinitionParser("outbound-channel-adapter", new RemoteFileOutboundChannelAdapterParser()); // TODO need implementation for SMB? } diff --git a/spring-integration-smb/src/main/java/org/springframework/integration/smb/filters/SmbRegexPatternFileListFilter.java b/spring-integration-smb/src/main/java/org/springframework/integration/smb/filters/SmbRegexPatternFileListFilter.java index aa4a730..1feab84 100644 --- a/spring-integration-smb/src/main/java/org/springframework/integration/smb/filters/SmbRegexPatternFileListFilter.java +++ b/spring-integration-smb/src/main/java/org/springframework/integration/smb/filters/SmbRegexPatternFileListFilter.java @@ -23,9 +23,9 @@ import org.springframework.integration.file.filters.AbstractRegexPatternFileList /** * Implementation of {@link AbstractRegexPatternFileListFilter} for SMB. - * + * * @author Markus Spann - * @since 2.1.1 + * @since 1.0 */ public class SmbRegexPatternFileListFilter extends AbstractRegexPatternFileListFilter { diff --git a/spring-integration-smb/src/main/java/org/springframework/integration/smb/filters/SmbSimplePatternFileListFilter.java b/spring-integration-smb/src/main/java/org/springframework/integration/smb/filters/SmbSimplePatternFileListFilter.java index 4d5bf3c..ee89e20 100644 --- a/spring-integration-smb/src/main/java/org/springframework/integration/smb/filters/SmbSimplePatternFileListFilter.java +++ b/spring-integration-smb/src/main/java/org/springframework/integration/smb/filters/SmbSimplePatternFileListFilter.java @@ -21,8 +21,10 @@ import org.springframework.integration.file.filters.AbstractSimplePatternFileLis /** * Implementation of {@link AbstractSimplePatternFileListFilter} for SMB. - * + * * @author Markus Spann + * @since 1.0 + * */ public class SmbSimplePatternFileListFilter extends AbstractSimplePatternFileListFilter { diff --git a/spring-integration-smb/src/main/java/org/springframework/integration/smb/inbound/SmbInboundFileSynchronizer.java b/spring-integration-smb/src/main/java/org/springframework/integration/smb/inbound/SmbInboundFileSynchronizer.java index b5f0bb9..6f4132e 100644 --- a/spring-integration-smb/src/main/java/org/springframework/integration/smb/inbound/SmbInboundFileSynchronizer.java +++ b/spring-integration-smb/src/main/java/org/springframework/integration/smb/inbound/SmbInboundFileSynchronizer.java @@ -26,7 +26,7 @@ import org.springframework.integration.file.remote.synchronizer.AbstractInboundF * An implementation of {@link AbstractInboundFileSynchronizer} for SMB. * * @author Markus Spann - * @since 2.1.1 + * @since 1.0 */ public class SmbInboundFileSynchronizer extends AbstractInboundFileSynchronizer { @@ -35,7 +35,7 @@ public class SmbInboundFileSynchronizer extends AbstractInboundFileSynchronizer< private final String toString; /** - * Create a synchronizer with the {@link SessionFactory} used to acquire + * Create a synchronizer with the {@link SessionFactory} used to acquire * {@link org.springframework.integration.file.remote.session.Session} instances. */ public SmbInboundFileSynchronizer(SessionFactory _sessionFactory) { diff --git a/spring-integration-smb/src/main/java/org/springframework/integration/smb/inbound/SmbInboundFileSynchronizingMessageSource.java b/spring-integration-smb/src/main/java/org/springframework/integration/smb/inbound/SmbInboundFileSynchronizingMessageSource.java index 8407b99..1b8c0fb 100644 --- a/spring-integration-smb/src/main/java/org/springframework/integration/smb/inbound/SmbInboundFileSynchronizingMessageSource.java +++ b/spring-integration-smb/src/main/java/org/springframework/integration/smb/inbound/SmbInboundFileSynchronizingMessageSource.java @@ -27,13 +27,11 @@ import org.springframework.integration.file.remote.synchronizer.AbstractInboundF * A {@link org.springframework.integration.core.MessageSource} implementation for SMB. * * @author Markus Spann - * @since 2.1.1 + * @since 1.0 */ public class SmbInboundFileSynchronizingMessageSource extends AbstractInboundFileSynchronizingMessageSource { - // CHECKSTYLE:OFF private final static String componentType = "smb:inbound-channel-adapter"; - // CHECKSTYLE:ON private final String toString; public SmbInboundFileSynchronizingMessageSource(AbstractInboundFileSynchronizer _synchronizer) { diff --git a/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbConfig.java b/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbConfig.java index 26a5856..e6b8d61 100644 --- a/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbConfig.java +++ b/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbConfig.java @@ -28,7 +28,7 @@ import org.springframework.util.StringUtils; * smb://[[[domain;]username[:password]@]server[:port]/[[share/[dir/]file]]][?[param=value[param2=value2[...]]] * * @author Markus Spann - * @since 2.1.1 + * @since 1.0 */ public class SmbConfig { @@ -149,8 +149,8 @@ public class SmbConfig { * @return the object */ public final SmbConfig validate() { - Assert.hasText(getHost(), "host must not be empty in " + this); - Assert.isTrue(getPort() >= 0, "port must be >= 0 in " + this); + Assert.hasText(getHost(), "host must not be empty in " + this); + Assert.isTrue(getPort() >= 0, "port must be >= 0 in " + this); Assert.hasText(getShareAndDir(), "share must not be empty in " + this); return this; } @@ -160,17 +160,17 @@ public class SmbConfig { } public final String getUrl(boolean _includePassword) { - String domainUserPass = getDomainUserPass(_includePassword); + String domainUserPass = getDomainUserPass(_includePassword); if (domainUserPass != null) { try { domainUserPass = URLEncoder.encode(domainUserPass, "UTF8"); - // CHECKSTYLE:OFF - } catch (UnsupportedEncodingException _ex) { - // CHECKSTYLE:ON + } + catch (UnsupportedEncodingException ex) { + throw new IllegalStateException(ex); } } return String.format("smb://%s@%s/%s", domainUserPass, getHostPort(), StringUtils.cleanPath(this.shareAndDir)); - } + } @Override public String toString() { diff --git a/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbSession.java b/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbSession.java index 963ea4c..f2ad2c5 100644 --- a/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbSession.java +++ b/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbSession.java @@ -45,13 +45,14 @@ import org.springframework.util.StringUtils; * See Server Message Block * for more details. * - * Inspired by the sprint-integration-ftp implementation done by Mark Fisher and Oleg Zhurakousky. + * Inspired by the spring-integration-ftp implementation done by Mark Fisher + * and Oleg Zhurakousky. * * @author Markus Spann * @author Mark Fisher * @author Oleg Zhurakousky * - * @since 2.1.1 + * @since 1.0 */ public class SmbSession implements Session { @@ -131,11 +132,11 @@ public class SmbSession implements Session { try { SmbFile smbDir = createSmbDirectoryObject(_path); if (!smbDir.exists()) { - logger.warn("Remote directory [" + _path + "] does not exist. Cannot list resources."); - return files; + logger.warn("Remote directory [" + _path + "] does not exist. Cannot list resources."); + return files; } else if (!smbDir.isDirectory()) { throw new NestedIOException("Resource [" + _path + "] is not a directory. Cannot list resources."); - } + } files = smbDir.listFiles(); @@ -224,7 +225,7 @@ public class SmbSession implements Session { /** * Convenience method to write a local file object to a remote location. - * @see org.springframework.integration.smb.session.SmbSession.write(InputStream, String) + * @see org.springframework.integration.smb.session.SmbSession#write(InputStream, String) */ public SmbFile write(File _file, String _path) throws IOException { return writeAndClose(new FileInputStream(_file), _path); @@ -232,7 +233,7 @@ public class SmbSession implements Session { /** * Convenience method to write a byte array to a remote location. - * @see org.springframework.integration.smb.session.SmbSession.write(InputStream, String) + * @see org.springframework.integration.smb.session.SmbSession#write(InputStream, String) */ public SmbFile write(byte[] _contents, String _path) throws IOException { return writeAndClose(new ByteArrayInputStream(_contents), _path); @@ -370,80 +371,80 @@ public class SmbSession implements Session { * @throws IOException on error conditions returned by a CIFS server */ SmbFile writeAndClose(InputStream _inputStream, String _path) throws IOException { - write(_inputStream, _path); - _inputStream.close(); - return createSmbFileObject(_path); - } + write(_inputStream, _path); + _inputStream.close(); + return createSmbFileObject(_path); + } /** - * Factory method for new SmbFile objects under this session's share for the specified path. - * @param _path remote path - * @param _isDirectory Boolean object to indicate the path is a directory, may be null - * @return SmbFile object for path - * @throws IOException in case of I/O errors - */ - private SmbFile createSmbFileObject(String _path, Boolean _isDirectory) throws IOException { + * Factory method for new SmbFile objects under this session's share for the specified path. + * @param _path remote path + * @param _isDirectory Boolean object to indicate the path is a directory, may be null + * @return SmbFile object for path + * @throws IOException in case of I/O errors + */ + private SmbFile createSmbFileObject(String _path, Boolean _isDirectory) throws IOException { String path = StringUtils.cleanPath(_path); if (!StringUtils.hasText(path)) { return smbShare; } - SmbFile smbFile = new SmbFile(smbShare, path); + SmbFile smbFile = new SmbFile(smbShare, path); - boolean appendFileSeparator = !path.endsWith(FILE_SEPARATOR); - if (appendFileSeparator) { - try { - appendFileSeparator = smbFile.isDirectory() || (_isDirectory != null && _isDirectory); - } catch (Exception _ex) { - appendFileSeparator = false; - } - } - if (appendFileSeparator) { - smbFile = createSmbFileObject(path + FILE_SEPARATOR); - } - if (logger.isDebugEnabled()) { - logger.debug("Created new " + SmbFile.class.getName() + "[" + smbFile + "] for path [" + path + "]."); - } - return smbFile; - } + boolean appendFileSeparator = !path.endsWith(FILE_SEPARATOR); + if (appendFileSeparator) { + try { + appendFileSeparator = smbFile.isDirectory() || (_isDirectory != null && _isDirectory); + } catch (Exception _ex) { + appendFileSeparator = false; + } + } + if (appendFileSeparator) { + smbFile = createSmbFileObject(path + FILE_SEPARATOR); + } + if (logger.isDebugEnabled()) { + logger.debug("Created new " + SmbFile.class.getName() + "[" + smbFile + "] for path [" + path + "]."); + } + return smbFile; + } /** * Creates an SMB file object pointing to a remote file. */ public SmbFile createSmbFileObject(String _path) throws IOException { - return createSmbFileObject(_path, null); - } + return createSmbFileObject(_path, null); + } /** * Creates an SMB file object pointing to a remote directory. */ public SmbFile createSmbDirectoryObject(String _path) throws IOException { - return createSmbFileObject(_path, true); - } + return createSmbFileObject(_path, true); + } /** * Static configuration of the JCIFS library. * The log level of this class is mapped to a suitable jcifs.util.loglevel */ static void configureJcifs() { - // TODO jcifs.Config.setProperty("jcifs.smb.client.useExtendedSecurity", "false"); - // TODO jcifs.Config.setProperty("jcifs.smb.client.disablePlainTextPasswords", "false"); + // TODO jcifs.Config.setProperty("jcifs.smb.client.useExtendedSecurity", "false"); + // TODO jcifs.Config.setProperty("jcifs.smb.client.disablePlainTextPasswords", "false"); - // set JCIFS SMB client library' log level unless already configured by system property - final String sysPropLogLevel = "jcifs.util.loglevel"; + // set JCIFS SMB client library' log level unless already configured by system property + final String sysPropLogLevel = "jcifs.util.loglevel"; - if (jcifs.Config.getProperty(sysPropLogLevel) == null) { - // set log level according to this class' logger's log level. - Log log = LogFactory.getLog(SmbSession.class); - if (log.isTraceEnabled()) { - jcifs.Config.setProperty(sysPropLogLevel, "N"); - } else if (log.isDebugEnabled()) { - jcifs.Config.setProperty(sysPropLogLevel, "3"); - } else { - jcifs.Config.setProperty(sysPropLogLevel, "1"); - } - } - } + if (jcifs.Config.getProperty(sysPropLogLevel) == null) { + // set log level according to this class' logger's log level. + Log log = LogFactory.getLog(SmbSession.class); + if (log.isTraceEnabled()) { + jcifs.Config.setProperty(sysPropLogLevel, "N"); + } else if (log.isDebugEnabled()) { + jcifs.Config.setProperty(sysPropLogLevel, "3"); + } else { + jcifs.Config.setProperty(sysPropLogLevel, "1"); + } + } + } @Override public String[] listNames(String path) throws IOException { diff --git a/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbSessionFactory.java b/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbSessionFactory.java index cf89a49..58ec31b 100644 --- a/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbSessionFactory.java +++ b/spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbSessionFactory.java @@ -27,7 +27,7 @@ import org.springframework.integration.file.remote.session.SessionFactory; * The SMB session factory. * * @author Markus Spann - * @since 2.1.1 + * @since 1.0 */ public class SmbSessionFactory extends SmbConfig implements SessionFactory { @@ -35,7 +35,7 @@ public class SmbSessionFactory extends SmbConfig implements SessionFactory + schemaLocation="http://www.springframework.org/schema/integration/spring-integration-2.0.xsd"/> - - - + + + + Builds an outbound-channel-adapter that writes files to a remote + SMB endpoint. + ]]> @@ -34,61 +36,70 @@ - Identifies directory path (e.g., "/temp/mytransfers/") where file will be transferred to + Identifies directory path (e.g., "/temp/mytransfers/") + where file will be transferred to. - Allows you to provide SpEL expression which will compute directory path - where file will be transferred to (e.g., "headers.['remote_dir'] + '/myTransfers'"); + Allows you to provide SpEL expression which will + compute directory path where file will be + transferred to (e.g., "headers.['remote_dir'] + '/myTransfers'"); - Allows you to provide remote file/directory separator character. DEFAULT: '/' + Allows you to provide remote file/directory separator + character. DEFAULT: '/' - Extension used when uploading files. We change it right after we know it's uploaded. + Extension used when uploading files. We change + it right after we know it's uploaded. - - - Allows you to specify a reference to - [org.springframework.integration.file.FileNameGenerator] bean. - - - - - - - - + + + Allows you to specify a reference to a + [org.springframework.integration.file.FileNameGenerator] bean. + + + + + + + + - Allows you to provide SpEL expression which will compute file name of - the remote file (e.g., assuming payload is java.io.File "payload.getName() + '.transfered'"); + Allows you to provide SpEL expression which will + compute file name of the remote file (e.g., assuming + payload is java.io.File "payload.getName() + '.transfered'"); - Specifies the order for invocation when this endpoint is connected as a -subscriber to a channel. This is particularly relevant when that channel -is using a "failover" dispatching strategy, or when a failure in the delivery to one subscriber should signal that -the message should not be sent to subscribers with a higher 'order' attribute. It has no effect when this -endpoint itself is a Polling Consumer for a channel with a queue. + Specifies the order for invocation when this + endpoint is connected as a subscriber to a channel. + This is particularly relevant when that channel + is using a "failover" dispatching strategy, or + when a failure in the delivery to one subscriber + should signal that the message should not be sent + to subscribers with a higher 'order' attribute. + It has no effect when this endpoint itself is a + Polling Consumer for a channel with a queue. @@ -100,9 +111,11 @@ endpoint itself is a Polling Consumer for a channel with a queue. + Builds an inbound-channel-adapter that synchronizes a local directory + with the contents of a remote SMB endpoint. The adapter requires + either no or exactly one file selection pattern (may be simple + pattern or regular expression). + ]]> @@ -115,27 +128,31 @@ endpoint itself is a Polling Consumer for a channel with a queue. - Allows you to provide file name pattern to determine the file names that needs to be scanned - and is based on simple pattern matching algorithm (e.g., "*.txt, fo*.txt" etc.) - + Allows you to provide file name pattern to determine + the file names that needs to be scanned and is + based on simple pattern matching algorithm + (e.g., "*.txt, fo*.txt" etc.) + - Allows you to provide Regular Expression to determine the file names that needs to be scanned. - (e.g., "f[o]+\.txt" etc.) - + Allows you to provide Regular Expression to determine + the file names that needs to be scanned. (e.g., "f[o]+\.txt" etc.) + - - + - - + + @@ -144,43 +161,48 @@ endpoint itself is a Polling Consumer for a channel with a queue. - Allows you to specify a reference to - [org.springframework.integration.file.filters.FileListFilter] bean. - + Allows you to specify a reference to + [org.springframework.integration.file.filters.FileListFilter] bean. + - Extension used when downloading files. We change it right after we know it's downloaded. + Extension used when downloading files. We change + it right after we know it's downloaded. - - Identifies directory path (e.g., "/temp/mytransfers") where file will be transferred FROM. + + Identifies directory path (e.g., "/temp/mytransfers") + where file will be transferred FROM. - Allows you to provide remote file/directory separator character. DEFAULT: '/' + Allows you to provide remote file/directory separator + character. DEFAULT: '/' - Identifies directory path (e.g., "/local/mytransfers") where file will be transferred TO. + Identifies directory path (e.g., "/local/mytransfers") + where file will be transferred to. - Tells this adapter if local directory must be auto-created if it doesn''t exist. Default is TRUE. + Tells this adapter if local directory must be + auto-created if it doesn''t exist. Default is TRUE. @@ -196,7 +218,7 @@ endpoint itself is a Polling Consumer for a channel with a queue. - + @@ -207,14 +229,14 @@ endpoint itself is a Polling Consumer for a channel with a queue. + Reference to a [org.springframework.integration.smb.session.SmbSessionFactory] bean. + ]]> @@ -226,19 +248,21 @@ endpoint itself is a Polling Consumer for a channel with a queue. - Identifies channel attached to this adapter. Depending on the type of the adapter - this channel could be the receiving channel (e.g., outbound-channel-adapter) or channel where - messages will be sent to by this adapter (e.g., inbound-channel-adapter). - - - - - - - Allows you to specify Charset (e.g., US-ASCII, ISO-8859-1, UTF-8). [UTF-8] is the default. + Identifies channel attached to this adapter. Depending on the + type of the adapter this channel could be the receiving channel + (e.g., outbound-channel-adapter) or channel where messages + will be sent to by this adapter (e.g., inbound-channel-adapter). - + + + + + Allows you to specify Charset (e.g., US-ASCII, ISO-8859-1, UTF-8). + [UTF-8] is the default. + + + diff --git a/spring-integration-smb/src/main/resources/org/springframework/integration/smb/config/spring-integration-smb.gif b/spring-integration-smb/src/main/resources/org/springframework/integration/smb/config/spring-integration-smb.gif index 66a798e..210e076 100644 Binary files a/spring-integration-smb/src/main/resources/org/springframework/integration/smb/config/spring-integration-smb.gif and b/spring-integration-smb/src/main/resources/org/springframework/integration/smb/config/spring-integration-smb.gif differ diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/AbstractBaseTest.java b/spring-integration-smb/src/test/java/org/springframework/integration/smb/AbstractBaseTest.java index aac00a8..ca75631 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/AbstractBaseTest.java +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/AbstractBaseTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -15,8 +15,8 @@ */ package org.springframework.integration.smb; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileOutputStream; @@ -48,14 +48,12 @@ public abstract class AbstractBaseTest { return logger; } - // CHECKSTYLE:OFF @Rule // requires JUnit 4.7 or later public final TestName testMethodName = new TestName(); - // CHECKSTYLE:ON private String getTestMethodName() { - return getClass().getSimpleName() + '.' + testMethodName.getMethodName() + "()"; - } + return getClass().getSimpleName() + '.' + testMethodName.getMethodName() + "()"; + } @Before public final void logTestBegin() { @@ -98,38 +96,38 @@ public abstract class AbstractBaseTest { * Writes the specified input stream to file. * @param _inputStream input stream * @param _path output file path - * @throws IOException in case of I/O errors + * @throws IOException in case of I/O errors */ public static void writeToFile(InputStream _inputStream, String _path) throws IOException { - FileOutputStream fos = new FileOutputStream(_path); + FileOutputStream fos = new FileOutputStream(_path); try { - FileCopyUtils.copy(_inputStream, fos); - } finally { - fos.close(); - } - } + FileCopyUtils.copy(_inputStream, fos); + } finally { + fos.close(); + } + } /** * Writes the specified byte array to the output stream. * @param _bytes byte array * @param _outputStream output stream - * @throws IOException in case of I/O errors + * @throws IOException in case of I/O errors */ public static void writeToFile(byte[] _bytes, OutputStream _outputStream) throws IOException { FileCopyUtils.copy(_bytes, _outputStream); - } + } /** * Writes the specified byte array to the an output file. * @param _bytes byte array * @param _fileName output file - * @throws IOException in case of I/O errors + * @throws IOException in case of I/O errors */ - public static void writeToFile(byte[] _bytes, String _fileName) throws IOException { - FileOutputStream fos = new FileOutputStream(_fileName); - writeToFile(_bytes, fos); + public static void writeToFile(byte[] _bytes, String _fileName) throws IOException { + FileOutputStream fos = new FileOutputStream(_fileName); + writeToFile(_bytes, fos); fos.close(); - } + } /** * Creates a new file of the given name. @@ -158,29 +156,29 @@ public abstract class AbstractBaseTest { protected void delete(String... _files) { for (String fileName : _files) { if (fileName == null) { - continue; - } + continue; + } File file = new File(fileName); if (file.exists()) { getLogger().debug("Deleting file [" + fileName + "]."); if (!file.delete()) { file.deleteOnExit(); - } - } - } - } + } + } + } + } /** * Checks if a directory exists, if not creates it and adds it to the DeleteOnExit hook. * @param _dir directory */ protected void ensureExists(String _dir) { - File dir = new File(_dir); + File dir = new File(_dir); if (!dir.exists()) { dir.mkdirs(); dir.deleteOnExit(); } - } + } /** * Retrieves class name and method name at the specified stacktrace index. @@ -216,11 +214,11 @@ public abstract class AbstractBaseTest { */ public static final File assertFileExists(File _file) { return assertFileExists(_file, true); - } + } public static final File assertFileNotExists(File _file) { return assertFileExists(_file, false); - } + } /** * Asserts that the specified file exists or does not exists. @@ -232,15 +230,15 @@ public abstract class AbstractBaseTest { assertNotNull("File object is null.", _file); if (_exists) { assertTrue("File [" + _file.getAbsolutePath() + "] does not exist.", _file.exists()); - } else { - assertTrue("File [" + _file.getAbsolutePath() + "] exists.", !_file.exists()); - } + } else { + assertTrue("File [" + _file.getAbsolutePath() + "] exists.", !_file.exists()); + } return _file; - } + } public static final File assertFileExists(String _file) { return assertFileExists(new File(_file)); - } + } /** * Invokes one or more test methods on the specified test class. @@ -250,33 +248,33 @@ public abstract class AbstractBaseTest { */ protected static void runTests(Class _testClass, String... _methodNames) { AbstractBaseTest test; - Method[] methods = new Method[_methodNames.length]; - String methodName = null; + Method[] methods = new Method[_methodNames.length]; + String methodName = null; - try { - test = _testClass.newInstance(); - for (int i = 0; i < _methodNames.length; i++) { + try { + test = _testClass.newInstance(); + for (int i = 0; i < _methodNames.length; i++) { methodName = _methodNames[i]; methods[i] = _testClass.getMethod(methodName, (Class[]) null); - } - } catch (Exception _ex) { + } + } catch (Exception _ex) { System.err.println("Test setup failed for " + _testClass + "." + methodName + "()."); _ex.printStackTrace(); return; - } + } Method method = null; try { - for (int i = 0; i < methods.length; i++) { + for (int i = 0; i < methods.length; i++) { method = methods[i]; method.invoke(test, (Object[]) null); - } + } - } catch (Exception _ex) { + } catch (Exception _ex) { System.err.println("Test execution failed for " + _testClass + "." + method.getName() + "."); - _ex.printStackTrace(); - } + _ex.printStackTrace(); + } } diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbMessageHistoryTests-context.xml b/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbMessageHistoryTests-context.xml index 3e4fcb9..fd6782e 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbMessageHistoryTests-context.xml +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbMessageHistoryTests-context.xml @@ -1,37 +1,36 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:int="http://www.springframework.org/schema/integration" + xmlns:int-smb="http://www.springframework.org/schema/integration/smb" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/integration/smb http://www.springframework.org/schema/integration/smb/spring-integration-smb.xsd"> - + - + - - + + - + - + diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbMessageHistoryTests.java b/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbMessageHistoryTests.java index 1da73c1..fd7e034 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbMessageHistoryTests.java +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbMessageHistoryTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -15,7 +15,7 @@ */ package org.springframework.integration.smb; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; import org.junit.Test; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests-context.xml b/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests-context.xml index bab68cd..e99262f 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests-context.xml +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests-context.xml @@ -1,51 +1,50 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:int="http://www.springframework.org/schema/integration" + xmlns:int-smb="http://www.springframework.org/schema/integration/smb" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd + http://www.springframework.org/schema/integration/smb http://www.springframework.org/schema/integration/smb/spring-integration-smb.xsd"> - - - - - + + + + + - - + + - + - + - + diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests-fail-context.xml b/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests-fail-context.xml index 47ed218..3db9b7b 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests-fail-context.xml +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests-fail-context.xml @@ -1,38 +1,37 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:int="http://www.springframework.org/schema/integration" + xmlns:int-smb="http://www.springframework.org/schema/integration/smb" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd + http://www.springframework.org/schema/integration/smb http://www.springframework.org/schema/integration/smb/spring-integration-smb.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - - - - - + + + + + - + - + diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests.java b/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests.java index 04181c7..291d1dd 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests.java +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/SmbParserInboundTests.java @@ -46,7 +46,7 @@ public class SmbParserInboundTests extends AbstractBaseTest { @Test(expected = BeanCreationException.class) public void testLocalFilesAutoCreationFalse() throws Exception { assertFileNotExists(new File("test-temp/local-6")); - new ClassPathXmlApplicationContext(getApplicationContextXmlFile("-fail"), this.getClass()); + new ClassPathXmlApplicationContext(getApplicationContextXmlFile("-fail"), this.getClass()); } @After diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParserTests-context.xml b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParserTests-context.xml index ad996a5..c244600 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParserTests-context.xml +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParserTests-context.xml @@ -1,22 +1,21 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/integration + http://www.springframework.org/schema/integration/spring-integration.xsd + http://www.springframework.org/schema/integration/smb + http://www.springframework.org/schema/integration/smb/spring-integration-smb.xsd"> - - @@ -36,31 +34,31 @@ - + channel="smbChannel" + session-factory="smbSessionFactory" + charset="UTF-8" + auto-create-local-directory="true" + delete-remote-files="true" + filter="entryListFilter" + local-directory="file:test-temp/local-2" + remote-directory="test-temp/remote-2"> - + channel="smbChannel" + session-factory="smbSessionFactory" + local-directory="file:test-temp/local-3" + remote-directory="test-temp/remote-3"> - + + + diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParserTests.java b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParserTests.java index 1d603eb..208cfa1 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParserTests.java +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -15,51 +15,57 @@ */ package org.springframework.integration.smb.config; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.io.File; -import java.util.Comparator; import java.util.Map; +import java.util.concurrent.PriorityBlockingQueue; import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; import org.springframework.integration.file.remote.session.CachingSessionFactory; -import org.springframework.integration.smb.AbstractBaseTest; import org.springframework.integration.smb.filters.SmbSimplePatternFileListFilter; import org.springframework.integration.smb.inbound.SmbInboundFileSynchronizer; import org.springframework.integration.smb.inbound.SmbInboundFileSynchronizingMessageSource; import org.springframework.integration.smb.session.SmbSession; import org.springframework.integration.smb.session.SmbSessionFactory; import org.springframework.integration.test.util.TestUtils; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Markus Spann + * @author Gunnar Hillert */ -public class SmbInboundChannelAdapterParserTests extends AbstractBaseTest { +@ContextConfiguration +@RunWith(SpringJUnit4ClassRunner.class) +public class SmbInboundChannelAdapterParserTests { - @SuppressWarnings("unchecked") - @Test(timeout = 10000) + @Autowired + ApplicationContext applicationContext; + + @Test(timeout = 100000) public void testSmbInboundChannelAdapterComplete() throws Exception{ - ApplicationContext ac = - new ClassPathXmlApplicationContext(getApplicationContextXmlFile(), this.getClass()); - SourcePollingChannelAdapter adapter = ac.getBean("smbInbound", SourcePollingChannelAdapter.class); - Comparator comparator = TestUtils.getPropertyValue(adapter, "source.fileSource.toBeReceived.q.comparator", Comparator.class); - assertNotNull(comparator); + + final SourcePollingChannelAdapter adapter = this.applicationContext.getBean("smbInbound", SourcePollingChannelAdapter.class); + final PriorityBlockingQueue queue = TestUtils.getPropertyValue(adapter, "source.fileSource.toBeReceived", PriorityBlockingQueue.class); + + assertNotNull(queue.comparator()); assertEquals("smbInbound", adapter.getComponentName()); assertEquals("smb:inbound-channel-adapter", adapter.getComponentType()); assertNotNull(TestUtils.getPropertyValue(adapter, "poller")); - assertEquals(ac.getBean("smbChannel"), TestUtils.getPropertyValue(adapter, "outputChannel")); - SmbInboundFileSynchronizingMessageSource inbound = + assertEquals(applicationContext.getBean("smbChannel"), TestUtils.getPropertyValue(adapter, "outputChannel")); + SmbInboundFileSynchronizingMessageSource inbound = (SmbInboundFileSynchronizingMessageSource) TestUtils.getPropertyValue(adapter, "source"); - - SmbInboundFileSynchronizer fisync = + + SmbInboundFileSynchronizer fisync = (SmbInboundFileSynchronizer) TestUtils.getPropertyValue(inbound, "synchronizer"); assertEquals(".working.tmp", TestUtils.getPropertyValue(fisync, "temporaryFileSuffix", String.class)); String remoteFileSeparator = (String) TestUtils.getPropertyValue(fisync, "remoteFileSeparator"); @@ -73,11 +79,10 @@ public class SmbInboundChannelAdapterParserTests extends AbstractBaseTest { @Test(timeout = 10000) public void cachingSessionFactoryByDefault() throws Exception{ - ApplicationContext ac = new ClassPathXmlApplicationContext(getApplicationContextXmlFile(), this.getClass()); - SourcePollingChannelAdapter adapter = ac.getBean("simpleAdapter", SourcePollingChannelAdapter.class); + SourcePollingChannelAdapter adapter = applicationContext.getBean("simpleAdapter", SourcePollingChannelAdapter.class); Object sessionFactory = TestUtils.getPropertyValue(adapter, "source.synchronizer.sessionFactory"); assertEquals(CachingSessionFactory.class, sessionFactory.getClass()); - SmbInboundFileSynchronizer fisync = + SmbInboundFileSynchronizer fisync = TestUtils.getPropertyValue(adapter, "source.synchronizer", SmbInboundFileSynchronizer.class); String remoteFileSeparator = (String) TestUtils.getPropertyValue(fisync, "remoteFileSeparator"); assertNotNull(remoteFileSeparator); @@ -86,9 +91,8 @@ public class SmbInboundChannelAdapterParserTests extends AbstractBaseTest { @Test(timeout = 10000) public void testSmbInboundChannelAdapterCompleteNoId() throws Exception{ - ApplicationContext ac = - new ClassPathXmlApplicationContext(getApplicationContextXmlFile(), this.getClass()); - Map spcas = ac.getBeansOfType(SourcePollingChannelAdapter.class); + + Map spcas = applicationContext.getBeansOfType(SourcePollingChannelAdapter.class); SourcePollingChannelAdapter adapter = null; for (String key : spcas.keySet()) { if (!key.equals("smbInbound") && !key.equals("simpleAdapter")){ @@ -101,18 +105,18 @@ public class SmbInboundChannelAdapterParserTests extends AbstractBaseTest { public static class TestSessionFactoryBean implements FactoryBean { - public SmbSessionFactory getObject() throws Exception { + public SmbSessionFactory getObject() throws Exception { SmbSessionFactory smbFactory = mock(SmbSessionFactory.class); SmbSession session = mock(SmbSession.class); when(smbFactory.getSession()).thenReturn(session); return smbFactory; } - public Class getObjectType() { + public Class getObjectType() { return SmbSessionFactory.class; } - public boolean isSingleton() { + public boolean isSingleton() { return true; } } diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterSample-context.xml b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterSample-context.xml index e9efed5..6558107 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterSample-context.xml +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterSample-context.xml @@ -1,40 +1,36 @@ + http://www.springframework.org/schema/integration/smb http://www.springframework.org/schema/integration/smb/spring-integration-smb.xsd"> - + - - - + channel="smbInboundChannel" + session-factory="smbSessionFactory" + cache-sessions="true" + charset="UTF-8" + remote-directory="test-temp/remote-4" + remote-file-separator="/" + filename-regex=".*\.txt$" + delete-remote-files="true" + temporary-file-suffix=".working.tmp" + auto-create-local-directory="true" + local-directory="file:test-temp/local-4"> + diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundOutboundSample.java b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundOutboundSample.java index ae5e88f..d2b4468 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundOutboundSample.java +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundOutboundSample.java @@ -1,5 +1,5 @@ /** - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -15,7 +15,7 @@ */ package org.springframework.integration.smb.config; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertTrue; import java.io.File; @@ -35,12 +35,13 @@ import org.springframework.integration.test.util.TestUtils; /** * System tests that perform SMB access without any mocking. - * These tests are annotated with '@Ignore', as they requires real SMB share configured + * These tests are annotated with '@Ignore', as they requires real SMB share configured * in the application context/smbClientFactory in order to succeed. * The test cases create directories and files autonomously and perform clean-up * on a best effort basis. * * @author Markus Spann + * @author Gunnar Hillert */ public class SmbInboundOutboundSample extends AbstractBaseTest { diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterParserTests-context.xml b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterParserTests-context.xml index fdea976..176369b 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterParserTests-context.xml @@ -3,45 +3,45 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-smb="http://www.springframework.org/schema/integration/smb" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/integration/smb http://www.springframework.org/schema/integration/smb/spring-integration-smb.xsd"> - - - - - - - + + + + + + + - + channel="smbPubSubChannel" + session-factory="smbSessionFactory" + cache-sessions="false" + remote-directory="test-temp/remote-5" + charset="UTF-8" + remote-file-separator="." + temporary-file-suffix=".working.tmp" + remote-filename-generator="fileNameGenerator" + order="23"/> + + channel="smbPubSubChannel" + session-factory="smbSessionFactory" + remote-directory="test-temp/remote-6" + charset="UTF-8" + remote-file-separator="." + temporary-file-suffix=".working.tmp" + remote-filename-generator="fileNameGenerator" + order="12"/> + channel="smbPubSubChannel" + session-factory="smbSessionFactory" + remote-directory="test-temp/remote-7"/> diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterParserTests.java b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterParserTests.java index 99b0204..eaac811 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterParserTests.java +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -15,9 +15,9 @@ */ package org.springframework.integration.smb.config; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertSame; import java.util.Iterator; @@ -36,7 +36,8 @@ import org.springframework.integration.test.util.TestUtils; /** * @author Markus Spann - * @since 2.1.1 + * @author Gunnar Hillert + * @since 1.0 */ public class SmbOutboundChannelAdapterParserTests extends AbstractBaseTest { diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterSample-context.xml b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterSample-context.xml index b0bff06..589352c 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterSample-context.xml +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbOutboundChannelAdapterSample-context.xml @@ -1,28 +1,27 @@ - + + session-factory="smbSessionFactory" + remote-directory="test-temp/remote-8" + channel="smbOutboundChannel"/> diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/inbound/SmbInboundRemoteFileSystemSynchronizerTest.java b/spring-integration-smb/src/test/java/org/springframework/integration/smb/inbound/SmbInboundRemoteFileSystemSynchronizerTest.java index 81b6b91..998cc05 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/inbound/SmbInboundRemoteFileSystemSynchronizerTest.java +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/inbound/SmbInboundRemoteFileSystemSynchronizerTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -15,14 +15,8 @@ */ package org.springframework.integration.smb.inbound; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; @@ -33,19 +27,17 @@ import java.util.List; import jcifs.smb.SmbFile; import org.junit.Before; -import org.junit.Test; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.springframework.integration.Message; import org.springframework.integration.smb.AbstractBaseTest; -import org.springframework.integration.smb.filters.SmbRegexPatternFileListFilter; import org.springframework.integration.smb.session.SmbSession; import org.springframework.integration.smb.session.SmbSessionFactory; /** * @author Markus Spann - * @since 2.1.1 + * @author Gunnar Hillert + * @since 1.0 */ public class SmbInboundRemoteFileSystemSynchronizerTest extends AbstractBaseTest { diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/session/MySmbSessionTest.java b/spring-integration-smb/src/test/java/org/springframework/integration/smb/session/MySmbSessionTest.java index 83b2190..5f0035b 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/session/MySmbSessionTest.java +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/session/MySmbSessionTest.java @@ -15,9 +15,6 @@ */ package org.springframework.integration.smb.session; -import static org.junit.Assert.fail; - -import org.junit.Test; public class MySmbSessionTest { diff --git a/spring-integration-smb/src/test/resources/log4j.properties b/spring-integration-smb/src/test/resources/log4j.properties index f336d51..0f8376e 100644 --- a/spring-integration-smb/src/test/resources/log4j.properties +++ b/spring-integration-smb/src/test/resources/log4j.properties @@ -6,4 +6,4 @@ log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m log4j.category.org.springframework=WARN log4j.category.org.springframework.integration=DEBUG -log4j.category.org.springframework.integration.file=DEBUG +log4j.category.org.springframework.integration.smb=DEBUG