INTEXT-27 + INTEXT-46 Upgrade to Gradle 1.4
* INTEXT-46 - Make Build JDK7 Ready + Cleanup
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -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
|
||||
|
||||
4
spring-integration-smb/gradlew
vendored
4
spring-integration-smb/gradlew
vendored
@@ -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
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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?
|
||||
}
|
||||
|
||||
@@ -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<SmbFile> {
|
||||
|
||||
|
||||
@@ -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<SmbFile> {
|
||||
|
||||
|
||||
@@ -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<SmbFile> {
|
||||
|
||||
@@ -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<SmbFile> _sessionFactory) {
|
||||
|
||||
@@ -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<SmbFile> {
|
||||
|
||||
// CHECKSTYLE:OFF
|
||||
private final static String componentType = "smb:inbound-channel-adapter";
|
||||
// CHECKSTYLE:ON
|
||||
private final String toString;
|
||||
|
||||
public SmbInboundFileSynchronizingMessageSource(AbstractInboundFileSynchronizer<SmbFile> _synchronizer) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -45,13 +45,14 @@ import org.springframework.util.StringUtils;
|
||||
* See <a href="http://en.wikipedia.org/wiki/Server_Message_Block">Server Message Block</a>
|
||||
* 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<SmbFile> {
|
||||
|
||||
@@ -131,11 +132,11 @@ public class SmbSession implements Session<SmbFile> {
|
||||
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<SmbFile> {
|
||||
|
||||
/**
|
||||
* 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<SmbFile> {
|
||||
|
||||
/**
|
||||
* 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<SmbFile> {
|
||||
* @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 <code>jcifs.util.loglevel</code>
|
||||
*/
|
||||
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 {
|
||||
|
||||
@@ -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<SmbFile> {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SmbSessionFactory extends SmbConfig implements SessionFactory<SmbFi
|
||||
|
||||
public SmbSessionFactory() {
|
||||
logger.debug("New " + getClass().getName() + " created.");
|
||||
}
|
||||
}
|
||||
|
||||
public final SmbSession getSession() {
|
||||
try {
|
||||
@@ -56,11 +56,11 @@ public class SmbSessionFactory extends SmbConfig implements SessionFactory<SmbFi
|
||||
logger.debug("SMB share initialized.");
|
||||
|
||||
return new SmbSession(smbShare);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.NestedIOException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Markus Spann
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SmbShare extends SmbFile {
|
||||
|
||||
private final Log logger = LogFactory.getLog(SmbShare.class);
|
||||
@@ -93,8 +97,8 @@ public class SmbShare extends SmbFile {
|
||||
}
|
||||
|
||||
public String newTempFileSuffix() {
|
||||
return "-" + Long.toHexString(Double.doubleToLongBits(Math.random())) + ".tmp";
|
||||
}
|
||||
return "-" + Long.toHexString(Double.doubleToLongBits(Math.random())) + ".tmp";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -21,30 +21,34 @@ import java.io.IOException;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
/**
|
||||
* @author Markus Spann
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract class SmbUtils {
|
||||
|
||||
private SmbUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the specified file into a byte array.
|
||||
* @param _file file
|
||||
* @return byte array of file contents
|
||||
* @throws IOException
|
||||
*/
|
||||
public static byte[] readFile(File _file) throws IOException {
|
||||
FileInputStream stream = new FileInputStream(_file);
|
||||
try {
|
||||
FileChannel fc = stream.getChannel();
|
||||
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
|
||||
return bb.array();
|
||||
|
||||
/* Instead of using default, pass in a decoder. */
|
||||
// return Charset.defaultCharset().decode(bb).toString();
|
||||
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
* Read the specified file into a byte array.
|
||||
* @param _file file
|
||||
* @return byte array of file contents
|
||||
* @throws IOException
|
||||
*/
|
||||
public static byte[] readFile(File _file) throws IOException {
|
||||
FileInputStream stream = new FileInputStream(_file);
|
||||
try {
|
||||
FileChannel fc = stream.getChannel();
|
||||
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
|
||||
return bb.array();
|
||||
|
||||
/* Instead of using default, pass in a decoder. */
|
||||
// return Charset.defaultCharset().decode(bb).toString();
|
||||
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
http\://www.springframework.org/schema/integration/smb/spring-integration-smb-2.0.xsd=org/springframework/integration/smb/config/spring-integration-smb-2.0.xsd
|
||||
http\://www.springframework.org/schema/integration/smb/spring-integration-smb.xsd=org/springframework/integration/smb/config/spring-integration-smb-2.0.xsd
|
||||
http\://www.springframework.org/schema/integration/smb/spring-integration-smb-1.0.xsd=org/springframework/integration/smb/config/spring-integration-smb-1.0.xsd
|
||||
http\://www.springframework.org/schema/integration/smb/spring-integration-smb.xsd=org/springframework/integration/smb/config/spring-integration-smb-1.0.xsd
|
||||
|
||||
@@ -11,22 +11,24 @@
|
||||
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
|
||||
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
|
||||
<xsd:import namespace="http://www.springframework.org/schema/integration"
|
||||
schemaLocation="http://www.springframework.org/schema/integration/spring-integration-2.0.xsd"/>
|
||||
schemaLocation="http://www.springframework.org/schema/integration/spring-integration-2.0.xsd"/>
|
||||
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The handler for namespace 'http://www.springframework.org/schema/integration/smb' is set to
|
||||
'org.springframework.integration.smb.config.SmbNamespaceHandler' in file 'spring.handlers'.
|
||||
SmbNamespaceHandler sets the implemenation of 'inbound-channel-adapter'
|
||||
to class 'SmbInboundChannelAdapterParser' etc.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The handler for namespace 'http://www.springframework.org/schema/integration/smb'
|
||||
is set to 'org.springframework.integration.smb.config.SmbNamespaceHandler'
|
||||
in file 'spring.handlers'. SmbNamespaceHandler sets the implemenation
|
||||
of 'inbound-channel-adapter' to class 'SmbInboundChannelAdapterParser'
|
||||
etc.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
<xsd:element name="outbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Builds an outbound-channel-adapter that writes files to a remote SMB endpoint.
|
||||
]]></xsd:documentation>
|
||||
Builds an outbound-channel-adapter that writes files to a remote
|
||||
SMB endpoint.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
@@ -34,61 +36,70 @@
|
||||
<xsd:attribute name="remote-directory" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
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.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="remote-directory-expression" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
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'");
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="remote-file-separator" type="xsd:string" default="/">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Allows you to provide remote file/directory separator character. DEFAULT: '/'
|
||||
Allows you to provide remote file/directory separator
|
||||
character. DEFAULT: '/'
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="temporary-file-suffix" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
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.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="remote-filename-generator" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Allows you to specify a reference to
|
||||
[org.springframework.integration.file.FileNameGenerator] bean.
|
||||
</xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.file.FileNameGenerator"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Allows you to specify a reference to a
|
||||
[org.springframework.integration.file.FileNameGenerator] bean.
|
||||
</xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.file.FileNameGenerator"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="remote-filename-generator-expression" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
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'");
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="order" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
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.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
@@ -100,9 +111,11 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
<xsd:element name="inbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
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).
|
||||
]]></xsd:documentation>
|
||||
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).
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
@@ -115,27 +128,31 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
<xsd:attribute name="filename-pattern" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
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.)
|
||||
</xsd:documentation>
|
||||
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.)
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="filename-regex" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Allows you to provide Regular Expression to determine the file names that needs to be scanned.
|
||||
(e.g., "f[o]+\.txt" etc.)
|
||||
</xsd:documentation>
|
||||
Allows you to provide Regular Expression to determine
|
||||
the file names that needs to be scanned. (e.g., "f[o]+\.txt" etc.)
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="comparator" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Specify a Comparator to be used when ordering Files. If none is provided, the
|
||||
order will be determined by the java.io.File implementation of Comparable.
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Specify a Comparator to be used when ordering
|
||||
Files. If none is provided, the order will be
|
||||
determined by the java.io.File implementation of
|
||||
Comparable.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="filter" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
@@ -144,43 +161,48 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
<xsd:documentation>
|
||||
Allows you to specify a reference to
|
||||
[org.springframework.integration.file.filters.FileListFilter] bean.
|
||||
</xsd:documentation>
|
||||
Allows you to specify a reference to
|
||||
[org.springframework.integration.file.filters.FileListFilter] bean.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="temporary-file-suffix" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
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.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="remote-directory" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Identifies directory path (e.g., "/temp/mytransfers") where file will be transferred FROM.
|
||||
<xsd:documentation>
|
||||
Identifies directory path (e.g., "/temp/mytransfers")
|
||||
where file will be transferred FROM.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="remote-file-separator" type="xsd:string" default="/">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Allows you to provide remote file/directory separator character. DEFAULT: '/'
|
||||
Allows you to provide remote file/directory separator
|
||||
character. DEFAULT: '/'
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="local-directory" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
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.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="auto-create-local-directory" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
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.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
@@ -196,7 +218,7 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
||||
<xsd:complexType name="base-smb-adapter-type">
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="session-factory" type="xsd:string" use="required">
|
||||
@@ -207,14 +229,14 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
<xsd:documentation><![CDATA[
|
||||
Reference to a [org.springframework.integration.smb.session.SmbSessionFactory] bean.
|
||||
]]></xsd:documentation>
|
||||
Reference to a [org.springframework.integration.smb.session.SmbSessionFactory] bean.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="cache-sessions" type="xsd:string" default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Specify whether the Sessions should be cached. Default is true.
|
||||
Specify whether the Sessions should be cached. Default is true.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
@@ -226,19 +248,21 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
<xsd:documentation>
|
||||
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).
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="charset" type="xsd:string" default="UTF-8">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
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).
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="charset" type="xsd:string" default="UTF-8">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Allows you to specify Charset (e.g., US-ASCII, ISO-8859-1, UTF-8).
|
||||
[UTF-8] is the default.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 540 B After Width: | Height: | Size: 539 B |
@@ -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<? extends AbstractBaseTest> _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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
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
|
||||
">
|
||||
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">
|
||||
|
||||
<int:message-history/>
|
||||
|
||||
|
||||
<bean id="smbSessionFactory" class="org.springframework.integration.smb.session.SmbSessionFactory">
|
||||
<property name="host" value="localhost"/>
|
||||
<property name="port" value="0"/>
|
||||
<property name="domain" value=""/>
|
||||
<property name="domain" value=""/>
|
||||
<property name="username" value="sambaguest"/>
|
||||
<property name="password" value="sambaguest"/>
|
||||
<property name="shareAndDir" value="smb-share/"/>
|
||||
<property name="replaceFile" value="true"/>
|
||||
<property name="shareAndDir" value="smb-share/"/>
|
||||
<property name="replaceFile" value="true"/>
|
||||
</bean>
|
||||
|
||||
<int-smb:inbound-channel-adapter id="smbInboundChannelAdapter"
|
||||
session-factory="smbSessionFactory"
|
||||
channel="smbInboundChannel"
|
||||
auto-create-local-directory="true"
|
||||
local-directory="file:test-temp/local-5"
|
||||
remote-directory="test-temp/remote-9"
|
||||
delete-remote-files="false">
|
||||
<int-smb:inbound-channel-adapter id="smbInboundChannelAdapter"
|
||||
session-factory="smbSessionFactory"
|
||||
channel="smbInboundChannel"
|
||||
auto-create-local-directory="true"
|
||||
local-directory="file:test-temp/local-5"
|
||||
remote-directory="test-temp/remote-9"
|
||||
delete-remote-files="false">
|
||||
<int:poller fixed-rate="1000"/>
|
||||
</int-smb:inbound-channel-adapter>
|
||||
|
||||
|
||||
<int:channel id="smbInboundChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,51 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
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
|
||||
">
|
||||
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">
|
||||
|
||||
<bean id="smbSessionFactory" class="org.springframework.integration.smb.session.SmbSessionFactory">
|
||||
<property name="host" value="localhost"/>
|
||||
<property name="domain" value=""/>
|
||||
<property name="username" value="sambaguest"/>
|
||||
<property name="password" value="sambaguest"/>
|
||||
<property name="shareAndDir" value="smb-share/"/>
|
||||
<property name="host" value="localhost"/>
|
||||
<property name="domain" value=""/>
|
||||
<property name="username" value="sambaguest"/>
|
||||
<property name="password" value="sambaguest"/>
|
||||
<property name="shareAndDir" value="smb-share/"/>
|
||||
</bean>
|
||||
|
||||
<int-smb:inbound-channel-adapter id="adapterSmb"
|
||||
session-factory="smbSessionFactory"
|
||||
cache-sessions="false"
|
||||
channel="smbIn"
|
||||
filename-pattern="foo"
|
||||
local-directory="test-temp/local-10"
|
||||
remote-directory="test-temp/remote-10"
|
||||
auto-create-local-directory="true"
|
||||
delete-remote-files="false">
|
||||
|
||||
<int-smb:inbound-channel-adapter id="adapterSmb"
|
||||
session-factory="smbSessionFactory"
|
||||
cache-sessions="false"
|
||||
channel="smbIn"
|
||||
filename-pattern="foo"
|
||||
local-directory="test-temp/local-10"
|
||||
remote-directory="test-temp/remote-10"
|
||||
auto-create-local-directory="true"
|
||||
delete-remote-files="false">
|
||||
<int:poller ref="smbPoller" />
|
||||
</int-smb:inbound-channel-adapter>
|
||||
|
||||
<int-smb:inbound-channel-adapter id="adapterSmb2"
|
||||
session-factory="smbSessionFactory"
|
||||
cache-sessions="false"
|
||||
channel="smbIn"
|
||||
filter="filter"
|
||||
local-directory="test-temp"
|
||||
remote-directory="test-temp/remote-11"
|
||||
auto-create-local-directory="true"
|
||||
delete-remote-files="false">
|
||||
<int-smb:inbound-channel-adapter id="adapterSmb2"
|
||||
session-factory="smbSessionFactory"
|
||||
cache-sessions="false"
|
||||
channel="smbIn"
|
||||
filter="filter"
|
||||
local-directory="test-temp"
|
||||
remote-directory="test-temp/remote-11"
|
||||
auto-create-local-directory="true"
|
||||
delete-remote-files="false">
|
||||
<int:poller ref="smbPoller" />
|
||||
</int-smb:inbound-channel-adapter>
|
||||
|
||||
|
||||
<bean id="filter" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.file.filters.FileListFilter"/>
|
||||
</bean>
|
||||
|
||||
<int:poller fixed-rate="3000" id="smbPoller" />
|
||||
<int:poller fixed-rate="3000" id="smbPoller" />
|
||||
|
||||
<int:channel id="smbIn">
|
||||
<int:queue/>
|
||||
|
||||
@@ -1,38 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
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
|
||||
">
|
||||
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">
|
||||
|
||||
<bean id="smbSessionFactory" class="org.springframework.integration.smb.session.SmbSessionFactory">
|
||||
<property name="host" value="localhost"/>
|
||||
<property name="domain" value=""/>
|
||||
<property name="username" value="sambaguest"/>
|
||||
<property name="password" value="sambaguest"/>
|
||||
<property name="shareAndDir" value="smb-share/"/>
|
||||
<property name="host" value="localhost"/>
|
||||
<property name="domain" value=""/>
|
||||
<property name="username" value="sambaguest"/>
|
||||
<property name="password" value="sambaguest"/>
|
||||
<property name="shareAndDir" value="smb-share/"/>
|
||||
</bean>
|
||||
|
||||
<int-smb:inbound-channel-adapter id="adapterSmbDontAutoCreate"
|
||||
channel="smbIn"
|
||||
session-factory="smbSessionFactory"
|
||||
filter="filter"
|
||||
local-directory="file:test-temp/local-6"
|
||||
remote-directory="test-temp/remote-12"
|
||||
auto-create-local-directory="false"
|
||||
delete-remote-files="false">
|
||||
<int-smb:inbound-channel-adapter id="adapterSmbDontAutoCreate"
|
||||
channel="smbIn"
|
||||
session-factory="smbSessionFactory"
|
||||
filter="filter"
|
||||
local-directory="file:test-temp/local-6"
|
||||
remote-directory="test-temp/remote-12"
|
||||
auto-create-local-directory="false"
|
||||
delete-remote-files="false">
|
||||
<int:poller fixed-rate="1000"/>
|
||||
</int-smb:inbound-channel-adapter>
|
||||
|
||||
<bean id="filter" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.file.entries.EntryListFilter"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<int:channel id="smbIn">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
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
|
||||
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
|
||||
">
|
||||
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">
|
||||
|
||||
<bean id="smbSessionFactory"
|
||||
<bean id="smbSessionFactory"
|
||||
class="org.springframework.integration.smb.config.SmbInboundChannelAdapterParserTests.TestSessionFactoryBean"/>
|
||||
|
||||
<int-smb:inbound-channel-adapter id="smbInbound"
|
||||
channel="smbChannel"
|
||||
channel="smbChannel"
|
||||
session-factory="smbSessionFactory"
|
||||
cache-sessions="false"
|
||||
charset="UTF-8"
|
||||
@@ -28,7 +27,6 @@
|
||||
comparator="comparator"
|
||||
temporary-file-suffix=".working.tmp"
|
||||
remote-directory="test-temp/remote-1">
|
||||
<int:poller fixed-rate="1000"/>
|
||||
</int-smb:inbound-channel-adapter>
|
||||
|
||||
<bean id="comparator" class="org.mockito.Mockito" factory-method="mock">
|
||||
@@ -36,31 +34,31 @@
|
||||
</bean>
|
||||
|
||||
<int-smb:inbound-channel-adapter
|
||||
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">
|
||||
<int:poller fixed-rate="1000"/>
|
||||
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">
|
||||
</int-smb:inbound-channel-adapter>
|
||||
|
||||
<int-smb:inbound-channel-adapter id="simpleAdapter"
|
||||
channel="smbChannel"
|
||||
session-factory="smbSessionFactory"
|
||||
local-directory="file:test-temp/local-3"
|
||||
remote-directory="test-temp/remote-3">
|
||||
<int:poller fixed-rate="1000"/>
|
||||
channel="smbChannel"
|
||||
session-factory="smbSessionFactory"
|
||||
local-directory="file:test-temp/local-3"
|
||||
remote-directory="test-temp/remote-3">
|
||||
</int-smb:inbound-channel-adapter>
|
||||
|
||||
<int:channel id="smbChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
|
||||
<bean id="entryListFilter" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.file.filters.FileListFilter"/>
|
||||
</bean>
|
||||
|
||||
<int:poller fixed-rate="10000" default="true"/>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -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<File> 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<String, SourcePollingChannelAdapter> spcas = ac.getBeansOfType(SourcePollingChannelAdapter.class);
|
||||
|
||||
Map<String, SourcePollingChannelAdapter> 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<SmbSessionFactory> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
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
|
||||
">
|
||||
http://www.springframework.org/schema/integration/smb http://www.springframework.org/schema/integration/smb/spring-integration-smb.xsd">
|
||||
|
||||
<bean id="smbSessionFactory"
|
||||
class="org.springframework.integration.smb.session.SmbSessionFactory"
|
||||
p:host="localhost"
|
||||
p:port="0"
|
||||
p:domain="sambaguest"
|
||||
p:username="sambaguest"
|
||||
p:password="sambaguest"
|
||||
p:shareAndDir="smb-share/"
|
||||
p:replaceFile="false"
|
||||
/>
|
||||
<bean id="smbSessionFactory"
|
||||
class="org.springframework.integration.smb.session.SmbSessionFactory"
|
||||
p:host="localhost"
|
||||
p:port="0"
|
||||
p:domain="sambaguest"
|
||||
p:username="sambaguest"
|
||||
p:password="sambaguest"
|
||||
p:shareAndDir="smb-share/"
|
||||
p:replaceFile="false"/>
|
||||
|
||||
<int-smb:inbound-channel-adapter id="smbInboundChannelAdapter"
|
||||
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">
|
||||
|
||||
<int:poller fixed-rate="5000" error-channel="nullChannel"/>
|
||||
|
||||
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">
|
||||
<int:poller fixed-rate="5000" error-channel="nullChannel"/>
|
||||
</int-smb:inbound-channel-adapter>
|
||||
|
||||
<int:channel id="smbInboundChannel">
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
<bean id="smbSessionFactory" class="org.springframework.integration.smb.session.SmbSessionFactory">
|
||||
<property name="host" value="localhost"/>
|
||||
<property name="port" value="0"/>
|
||||
<property name="domain" value=""/>
|
||||
<property name="username" value="sambaguest"/>
|
||||
<property name="password" value="sambaguest"/>
|
||||
<property name="shareAndDir" value="smb-share/"/>
|
||||
<property name="replaceFile" value="false"/>
|
||||
<property name="host" value="localhost"/>
|
||||
<property name="port" value="0"/>
|
||||
<property name="domain" value=""/>
|
||||
<property name="username" value="sambaguest"/>
|
||||
<property name="password" value="sambaguest"/>
|
||||
<property name="shareAndDir" value="smb-share/"/>
|
||||
<property name="replaceFile" value="false"/>
|
||||
</bean>
|
||||
|
||||
<int-smb:outbound-channel-adapter id="smbOutboundChannelAdapter"
|
||||
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"
|
||||
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"/>
|
||||
|
||||
<int-smb:outbound-channel-adapter id="smbOutboundChannelAdapter2"
|
||||
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-6"
|
||||
charset="UTF-8"
|
||||
remote-file-separator="."
|
||||
temporary-file-suffix=".working.tmp"
|
||||
remote-filename-generator="fileNameGenerator"
|
||||
order="12"/>
|
||||
|
||||
<int-smb:outbound-channel-adapter id="simpleAdapter"
|
||||
channel="smbPubSubChannel"
|
||||
session-factory="smbSessionFactory"
|
||||
remote-directory="test-temp/remote-7"/>
|
||||
channel="smbPubSubChannel"
|
||||
session-factory="smbSessionFactory"
|
||||
remote-directory="test-temp/remote-7"/>
|
||||
|
||||
<int:publish-subscribe-channel id="smbPubSubChannel"/>
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
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">
|
||||
|
||||
<bean id="smbSessionFactory"
|
||||
class="org.springframework.integration.smb.session.SmbSessionFactory"
|
||||
p:host="localhost"
|
||||
p:port="0"
|
||||
p:domain="sambaguest"
|
||||
p:username="sambaguest"
|
||||
p:password="sambaguest"
|
||||
p:shareAndDir="smb-share/"
|
||||
p:replaceFile="false"
|
||||
/>
|
||||
<bean id="smbSessionFactory"
|
||||
class="org.springframework.integration.smb.session.SmbSessionFactory"
|
||||
p:host="localhost"
|
||||
p:port="0"
|
||||
p:domain="sambaguest"
|
||||
p:username="sambaguest"
|
||||
p:password="sambaguest"
|
||||
p:shareAndDir="smb-share/"
|
||||
p:replaceFile="false"/>
|
||||
|
||||
<int:channel id="smbOutboundChannel" />
|
||||
|
||||
<int-smb:outbound-channel-adapter id="smbOutboundChannelAdapter"
|
||||
session-factory="smbSessionFactory"
|
||||
remote-directory="test-temp/remote-8"
|
||||
channel="smbOutboundChannel"/>
|
||||
session-factory="smbSessionFactory"
|
||||
remote-directory="test-temp/remote-8"
|
||||
channel="smbOutboundChannel"/>
|
||||
</beans>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.integration.smb.session;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class MySmbSessionTest {
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user