Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Add Junit to v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericBregier committed Jul 22, 2019
1 parent a30ac88 commit 4872455
Show file tree
Hide file tree
Showing 162 changed files with 1,774 additions and 20 deletions.
62 changes: 62 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,31 @@ local.properties
#################
## Java
#################
# Compiled class file
*.class
*.jardesc

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

#################
## Visual Studio
#################
Expand Down Expand Up @@ -132,3 +154,43 @@ Thumbs.db
Desktop.ini

runtime.properties

###############
## Intellij
###############
# User-specific stuff
.idea/

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr

# CMake
cmake-build-*/

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

*.log

5 changes: 2 additions & 3 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>Waarp</groupId>
<artifactId>WaarpFtp</artifactId>
<version>3.0.8</version>
<version>3.1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>WaarpFtp-Core</name>
Expand All @@ -17,7 +17,6 @@
</dependencies>

<build>
<sourceDirectory>../src/main/java</sourceDirectory>

<plugins>
<plugin>
Expand All @@ -38,7 +37,7 @@
<source>1.6</source>
<target>1.6</target>
<optimize>true</optimize>
<showDeprecations>true</showDeprecations>
<showDeprecation>true</showDeprecation>
<includes>
<include>**/${filtermodule}/**</include>
<include>**/${filterextra}/**</include>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,21 @@ public void setFtpTransfer(FtpTransfer ftpTransfer) {
@Override
public void channelRead0(ChannelHandlerContext ctx, DataBlock dataBlock) {
if (ftpTransfer == null) {
try {
ftpTransfer = session.getDataConn().getFtpTransferControl().getExecutingFtpTransfer();
} catch (FtpNoTransferException e) {
logger.debug(e);
session.getDataConn().getFtpTransferControl()
.setTransferAbortedFromInternal(true);
for (int i = 0; i < 10; i++) {
try {
ftpTransfer = session.getDataConn().getFtpTransferControl()
.getExecutingFtpTransfer();
if (ftpTransfer != null) {
break;
}
} catch (FtpNoTransferException e) {
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
break;
}
continue;
}
}
if (ftpTransfer == null) {
logger.debug("No ExecutionFtpTransfer found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.waarp.common.logging.WaarpLogger;
import org.waarp.common.logging.WaarpLoggerFactory;
import org.waarp.common.utility.DetectionUtils;
import org.waarp.ftp.core.config.FtpConfiguration;

/**
Expand Down Expand Up @@ -69,7 +70,7 @@ public void run() {
switch (type) {
case TIMER_EXIT:
logger.error("System will force EXIT");
System.exit(0);
DetectionUtils.SystemExit(0);
break;
case TIMER_CONTROL:
logger.info("Exit Shutdown Command");
Expand Down
Empty file added core/src/test/java/.gitkeep
Empty file.
5 changes: 2 additions & 3 deletions filesystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>Waarp</groupId>
<artifactId>WaarpFtp</artifactId>
<version>3.0.8</version>
<version>3.1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>WaarpFtp-Filesystem</name>
Expand All @@ -21,7 +21,6 @@
</dependencies>

<build>
<sourceDirectory>../src/main/java</sourceDirectory>

<plugins>
<plugin>
Expand All @@ -42,7 +41,7 @@
<source>1.6</source>
<target>1.6</target>
<optimize>true</optimize>
<showDeprecations>true</showDeprecations>
<showDeprecation>true</showDeprecation>
<includes>
<include>**/${filtermodule}/**</include>
</includes>
Expand Down
Empty file.
19 changes: 15 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>WaarpFtp</artifactId>
<name>WaarpFtp</name>
<version>3.0.8</version>
<version>3.1.0</version>
<packaging>pom</packaging>
<description>
The Waarp FTP project is a proposal of a new fresh FTP server implementation,
Expand Down Expand Up @@ -65,7 +65,7 @@
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpCommon</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand All @@ -79,6 +79,18 @@
<version>1.2.3</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>it.sauronsoftware</groupId>
<artifactId>ftp4j</artifactId>
<version>1.7.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -106,7 +118,7 @@
<source>1.6</source>
<target>1.6</target>
<optimize>true</optimize>
<showDeprecations>true</showDeprecations>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -241,7 +253,6 @@
<xmlOutputDirectory>target/site</xmlOutputDirectory>
<failOnError>false</failOnError>
<effort>Default</effort>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
Expand Down
5 changes: 2 additions & 3 deletions simpleimpl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>Waarp</groupId>
<artifactId>WaarpFtp</artifactId>
<version>3.0.8</version>
<version>3.1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>WaarpFtp-SimpleServer</name>
Expand All @@ -26,7 +26,6 @@
</dependencies>

<build>
<sourceDirectory>../src/main/java</sourceDirectory>

<plugins>
<plugin>
Expand All @@ -47,7 +46,7 @@
<source>1.6</source>
<target>1.6</target>
<optimize>true</optimize>
<showDeprecations>true</showDeprecations>
<showDeprecation>true</showDeprecation>
<includes>
<include>**/${filtermodule}/**</include>
</includes>
Expand Down
Empty file.
80 changes: 80 additions & 0 deletions simpleimpl/src/test/java/org/waarp/ftp/FtpServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*******************************************************************************
* This file is part of Waarp Project (named also Waarp or GG).
*
* Copyright (c) 2019, Waarp SAS, and individual contributors by the @author
* tags. See the COPYRIGHT.txt in the distribution for a full listing of
* individual contributors.
*
* All Waarp Project is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Waarp . If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

package org.waarp.ftp;

import org.waarp.common.file.FileUtils;
import org.waarp.common.file.filesystembased.FilesystemBasedFileParameterImpl;
import org.waarp.common.logging.WaarpLogger;
import org.waarp.common.logging.WaarpLoggerFactory;
import org.waarp.common.logging.WaarpSlf4JLoggerFactory;
import org.waarp.ftp.core.exception.FtpNoConnectionException;
import org.waarp.ftp.simpleimpl.SimpleGatewayFtpServer;
import org.waarp.ftp.simpleimpl.config.FileBasedConfiguration;
import org.waarp.ftp.simpleimpl.control.SimpleBusinessHandler;
import org.waarp.ftp.simpleimpl.data.FileSystemBasedDataBusinessHandler;

import java.io.File;

public class FtpServer {
/**
* Internal Logger
*/
protected static WaarpLogger logger;
protected static File dir;
protected static FileBasedConfiguration configuration;

public static void startFtpServer(String config) {
WaarpLoggerFactory.setDefaultFactory(new WaarpSlf4JLoggerFactory(null));
if (logger == null) {
logger = WaarpLoggerFactory.getLogger(FtpServer.class);
}
ClassLoader classLoader = FtpServer.class.getClassLoader();
File file = new File(classLoader.getResource(config).getFile());
if (file.exists()) {
dir = file.getParentFile();
File base = new File("/tmp/GGFTP");
base.mkdirs();
FileUtils.forceDeleteRecursiveDir(base);
base.mkdirs();
configuration = new FileBasedConfiguration(
SimpleGatewayFtpServer.class, SimpleBusinessHandler.class,
FileSystemBasedDataBusinessHandler.class,
new FilesystemBasedFileParameterImpl());
if (!configuration.setConfigurationFromXml(file.getAbsolutePath())) {
logger.error("Bad configuration");
return;
}
configuration.setTIMEOUTCON(1000);
// Start server.
try {
configuration.serverStartup();
} catch (FtpNoConnectionException e) {
logger.error("FTP not started", e);
}
logger.info("FTP started");
}
}

public static void stopFtpServer() {
configuration.setShutdown(true);
configuration.getFtpInternalConfiguration().releaseResources();
}
}
Loading

0 comments on commit 4872455

Please sign in to comment.