forked from pentaho/pentaho-kettle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BACKLOG-38519] SFTP Put Core To Plugin
- Loading branch information
1 parent
997a56e
commit 6299f7e
Showing
27 changed files
with
951 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ __List of the current core plugins:__ | |
* drools | ||
* dummy | ||
* gpload | ||
* sftpput | ||
* hl7 | ||
* json | ||
* openerp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.pentaho.di.plugins</groupId> | ||
<artifactId>sftpput-assemblies</artifactId> | ||
<version>10.1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>sftpput-plugin</artifactId> | ||
<version>10.1.0.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<name>PDI SFTP put Plugin Distribution</name> | ||
<description></description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.pentaho.di.plugins</groupId> | ||
<artifactId>sftpput-plugin-impl</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.pentaho.di.plugins</groupId> | ||
<artifactId>sftpput-plugin-ui</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>add-libs</id> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>copy-dependencies</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${project.build.directory}/assembly/lib</outputDirectory> | ||
<includeScope>compile</includeScope> | ||
<excludeArtifactIds>sftpput-plugin-impl,sftpput-plugin-ui</excludeArtifactIds> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
37 changes: 37 additions & 0 deletions
37
plugins/sftpput/assemblies/plugin/src/assembly/assembly.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd"> | ||
<id>sftpput-plugin</id> | ||
<formats> | ||
<format>zip</format> | ||
</formats> | ||
<baseDirectory>sftpput-plugin</baseDirectory> | ||
|
||
<files> | ||
<file> | ||
<source>${project.basedir}/src/main/resources/version.xml</source> | ||
<outputDirectory>.</outputDirectory> | ||
<filtered>true</filtered> | ||
</file> | ||
</files> | ||
|
||
<fileSets> | ||
<!-- the staging dir --> | ||
<fileSet> | ||
<directory>${project.build.directory}/assembly</directory> | ||
<outputDirectory>.</outputDirectory> | ||
</fileSet> | ||
</fileSets> | ||
|
||
<dependencySets> | ||
<dependencySet> | ||
<outputDirectory>.</outputDirectory> | ||
<includes> | ||
<include>org.pentaho.di.plugins:sftpput-plugin-impl:jar</include> | ||
<include>org.pentaho.di.plugins:sftpput-plugin-ui:jar</include> | ||
</includes> | ||
<useProjectArtifact>false</useProjectArtifact> | ||
</dependencySet> | ||
</dependencySets> | ||
</assembly> | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
plugins/sftpput/assemblies/plugin/src/main/resources/version.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<version>${project.version}</version> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.pentaho.di.plugins</groupId> | ||
<artifactId>sftpput</artifactId> | ||
<version>10.1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>sftpput-assemblies</artifactId> | ||
<version>10.1.0.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<name>PDI SFTP Put Plugins Assemblies</name> | ||
|
||
<modules> | ||
<module>plugin</module> | ||
</modules> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.pentaho.di.plugins</groupId> | ||
<artifactId>sftpput</artifactId> | ||
<version>10.1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>sftpput-plugin-impl</artifactId> | ||
<name>PDI SFTP Put Plugin Impl</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>pentaho-kettle</groupId> | ||
<artifactId>kettle-core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>pentaho-kettle</groupId> | ||
<artifactId>kettle-engine</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.healthmarketscience.jackcess</groupId> | ||
<artifactId>jackcess</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<!-- Test dependencies --> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-all</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-core</artifactId> | ||
<version>1.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>pentaho-kettle</groupId> | ||
<artifactId>kettle-core</artifactId> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>pentaho-kettle</groupId> | ||
<artifactId>kettle-engine</artifactId> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
136 changes: 136 additions & 0 deletions
136
plugins/sftpput/impl/src/it/org/pentaho/di/trans/steps/sftpput/SFTPPutIntegrationIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/*! ****************************************************************************** | ||
* | ||
* Pentaho Data Integration | ||
* | ||
* Copyright (C) 2002-2023 by Hitachi Vantara : http://www.pentaho.com | ||
* | ||
******************************************************************************* | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
******************************************************************************/ | ||
|
||
package org.pentaho.di.trans.steps.sftpput; | ||
|
||
import com.jcraft.jsch.ChannelSftp; | ||
import com.jcraft.jsch.Session; | ||
import org.junit.After; | ||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
import org.pentaho.di.TestUtilities; | ||
import org.pentaho.di.core.KettleEnvironment; | ||
import org.pentaho.di.job.entries.sftp.SftpServer; | ||
import org.pentaho.di.trans.Trans; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author Andrey Khayrutdinov | ||
*/ | ||
public class SFTPPutIntegrationIT { | ||
|
||
private static TemporaryFolder folder; | ||
|
||
private static SftpServer server; | ||
|
||
@BeforeClass | ||
public static void startServer() throws Exception { | ||
KettleEnvironment.init(); | ||
|
||
folder = new TemporaryFolder(); | ||
folder.create(); | ||
|
||
server = SftpServer.createDefaultServer( folder ); | ||
server.start(); | ||
} | ||
|
||
@AfterClass | ||
public static void stopServer() throws Exception { | ||
server.stop(); | ||
server = null; | ||
|
||
folder.delete(); | ||
folder = null; | ||
} | ||
|
||
|
||
private Session session; | ||
private ChannelSftp channel; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
session = server.createJschSession(); | ||
session.connect(); | ||
|
||
channel = (ChannelSftp) session.openChannel( "sftp" ); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
if ( channel != null && channel.isConnected() ) { | ||
channel.disconnect(); | ||
} | ||
channel = null; | ||
|
||
if ( session.isConnected() ) { | ||
session.disconnect(); | ||
} | ||
session = null; | ||
} | ||
|
||
|
||
/** | ||
* This case relates to <a href="http://jira.pentaho.com/browse/PDI-13897">PDI-13897</a>. | ||
* It executes a transformation with two steps: data grid and sftp put. | ||
* The latter uploads to an SFTP server a file <tt>pdi-13897/uploaded.txt</tt>, that contains a | ||
* <tt>qwerty</tt> string.<br/> | ||
* | ||
* Parameters of the transformation are: | ||
* <ul> | ||
* <li>server</li> | ||
* <li>port</li> | ||
* <li>username</li> | ||
* <li>password</li> | ||
* </ul> | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void putFileStreamingContentFromField() throws Exception { | ||
// prepare a directory for transformation's execution | ||
channel.connect(); | ||
channel.mkdir( "pdi-13897" ); | ||
|
||
// execute the transformation | ||
Trans trans = TestUtilities.loadAndRunTransformation( | ||
"src/it/resources/org/pentaho/di/trans/steps/sftpput/pdi-13897.ktr", | ||
"server", "localhost", | ||
"port", server.getPort(), | ||
"username", server.getUsername(), | ||
"password", server.getPassword() | ||
); | ||
assertEquals( 0, trans.getErrors() ); | ||
|
||
// verify the results | ||
ByteArrayOutputStream os = new ByteArrayOutputStream(); | ||
channel.cd( "pdi-13897" ); | ||
channel.get( "uploaded.txt", os ); | ||
String content = new String( os.toByteArray() ); | ||
assertEquals( "qwerty", content ); | ||
} | ||
} |
Oops, something went wrong.