summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorNils Schwabe2014-04-10 16:34:34 +0200
committerNils Schwabe2014-04-10 16:34:34 +0200
commit3e35775012d2800d53d83ebe5083121479d83720 (patch)
treeeafcb93cdffc15f48a918f7a599948cf4a769e5d /src/test
parentMerge branch 'master' of git.openslx.org:bwlp/masterserver (diff)
downloadmasterserver-3e35775012d2800d53d83ebe5083121479d83720.tar.gz
masterserver-3e35775012d2800d53d83ebe5083121479d83720.tar.xz
masterserver-3e35775012d2800d53d83ebe5083121479d83720.zip
Added some functionallity to the ImageProcessor.
Database using is missing!
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/openslx/imagemaster/AppTest.java156
1 files changed, 78 insertions, 78 deletions
diff --git a/src/test/java/org/openslx/imagemaster/AppTest.java b/src/test/java/org/openslx/imagemaster/AppTest.java
index e978478..6fc478a 100644
--- a/src/test/java/org/openslx/imagemaster/AppTest.java
+++ b/src/test/java/org/openslx/imagemaster/AppTest.java
@@ -57,82 +57,82 @@ public class AppTest
assertTrue( true );
}
-// /**
-// * Test the authentication
-// */
-// public void testAuthentication() {
-// TTransport transport = new TSocket("localhost", 9090);
-// try {
-// transport.open();
-// } catch (TTransportException e) {
-// assertTrue("Could not connect", false);
-// }
-//
-// TProtocol protocol = new TBinaryProtocol(transport);
-// Client client = new Client(protocol);
-//
-// try {
-// assertTrue("Could not ping server", client.ping());
-// } catch (TException e) {
-// assertTrue("Could not ping server", false);
-// }
-// try {
-// SessionData sessionData = client.authenticate("ns202", "xxxxxxxxxxxx");
-// UserInfo userInfo = client.getUserFromToken(sessionData.getAuthToken());
-// System.out.println("User info: " + userInfo);
-// System.out.println("Server address from MySQL: " + sessionData.serverAddress);
-// } catch (TException e) {
-// e.printStackTrace();
-// assertTrue("Could not login", false);
-// }
-// }
-//
-// /**
-// * Test FTP connection
-// */
-// public void testFtpConnection() {
-// FTPClient client = new FTPClient();
-// String host = "localhost";
-// int port = 2221;
-// String user = "admin";
-// String password = "SI*HoZCC!]V)p>B2";
-// String fileName = "/home/nils/file_to_upload.bin";
-//
-// try {
-// client.connect(host, port);
-// System.out.println("Connected to " + host + ":" + port + ". Reply code: " + client.getReplyCode());
-// if ( !FTPReply.isPositiveCompletion( client.getReplyCode() ) ) {
-// ConnectException ce = new ConnectException("No positive reply code.");
-// throw ce;
-// }
-// if ( !client.login(user, password) ) {
-// ConnectException ce = new ConnectException("Could not login.");
-// throw ce;
-// }
-// System.out.println("Logged in with user: " + user);
-// client.setFileType(FTP.BINARY_FILE_TYPE);
-// client.enterLocalPassiveMode();
-// System.out.println("Entered PASSIVE MODE");
-// InputStream input = new FileInputStream(fileName);
-// client.makeDirectory("myFolder");
-// System.out.println("Made directory 'myFolder'");
-// System.out.print("Starting file upload ... ");
-// client.storeFile("myFolder/myFile.txt", input);
-// System.out.println("done.");
-// client.noop();
-// } catch (IOException e) {
-// e.printStackTrace();
-// } finally {
-// if (client.isConnected()) {
-// try {
-// client.logout();
-// client.disconnect();
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
-// }
-// }
-// }
+ /**
+ * Test the authentication
+ */
+ public void testAuthentication() {
+ TTransport transport = new TSocket("localhost", 9090);
+ try {
+ transport.open();
+ } catch (TTransportException e) {
+ assertTrue("Could not connect", false);
+ }
+
+ TProtocol protocol = new TBinaryProtocol(transport);
+ Client client = new Client(protocol);
+
+ try {
+ assertTrue("Could not ping server", client.ping());
+ } catch (TException e) {
+ assertTrue("Could not ping server", false);
+ }
+ try {
+ SessionData sessionData = client.authenticate("ns202", "xxxxxxxxxxxx");
+ UserInfo userInfo = client.getUserFromToken(sessionData.getAuthToken());
+ System.out.println("User info: " + userInfo);
+ System.out.println("Server address from MySQL: " + sessionData.serverAddress);
+ } catch (TException e) {
+ e.printStackTrace();
+ assertTrue("Could not login", false);
+ }
+ }
+
+ /**
+ * Test FTP connection
+ */
+ public void testFtpConnection() {
+ FTPClient client = new FTPClient();
+ String host = "localhost";
+ int port = 2221;
+ String user = "admin";
+ String password = "SI*HoZCC!]V)p>B2";
+ String fileName = "/home/nils/file_to_upload.bin";
+
+ try {
+ client.connect(host, port);
+ System.out.println("Connected to " + host + ":" + port + ". Reply code: " + client.getReplyCode());
+ if ( !FTPReply.isPositiveCompletion( client.getReplyCode() ) ) {
+ ConnectException ce = new ConnectException("No positive reply code.");
+ throw ce;
+ }
+ if ( !client.login(user, password) ) {
+ ConnectException ce = new ConnectException("Could not login.");
+ throw ce;
+ }
+ System.out.println("Logged in with user: " + user);
+ client.setFileType(FTP.BINARY_FILE_TYPE);
+ client.enterLocalPassiveMode();
+ System.out.println("Entered PASSIVE MODE");
+ InputStream input = new FileInputStream(fileName);
+ client.makeDirectory("myFolder");
+ System.out.println("Made directory 'myFolder'");
+ System.out.print("Starting file upload ... ");
+ client.storeFile("myFolder/myFile.txt", input);
+ System.out.println("done.");
+ client.noop();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (client.isConnected()) {
+ try {
+ client.logout();
+ client.disconnect();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
/**
* Test the server authentification.
@@ -163,7 +163,7 @@ public class AppTest
ServerSessionData data = client.serverAuthenticate("Test Organization", response);
System.out.println("Authenticated and got sid: '" + data.getSessionId() + "'");
- FtpCredentials ftpCredentials = client.submitImage(new ImageData("123", "maschine"), data);
+ FtpCredentials ftpCredentials = client.submitImage(new ImageData("123", "maschine.vmdk"), data);
System.out.println("Got FTP credentials. User: " + ftpCredentials.username + ", password: " + ftpCredentials.password);
FTPClient FtpClient = new FTPClient();
@@ -190,7 +190,7 @@ public class AppTest
System.out.println("Entered PASSIVE MODE");
InputStream input = new FileInputStream(fileName);
System.out.print("Starting file upload ... ");
- FtpClient.storeFile("maschine.vmdk", input);
+ FtpClient.storeFile("xcvb.vmdk", input);
System.out.println("done.");
FtpClient.noop();
} catch (IOException e) {