diff options
author | Nils Schwabe | 2014-04-11 12:09:58 +0200 |
---|---|---|
committer | Nils Schwabe | 2014-04-11 12:09:58 +0200 |
commit | 7e776645ecd93190221b188b3c1c3de749fb03a7 (patch) | |
tree | 1730cbe9d06a56e3f3005558d4ed064d4169aff3 /src/test | |
parent | Added some functionallity to the ImageProcessor. (diff) | |
download | masterserver-7e776645ecd93190221b188b3c1c3de749fb03a7.tar.gz masterserver-7e776645ecd93190221b188b3c1c3de749fb03a7.tar.xz masterserver-7e776645ecd93190221b188b3c1c3de749fb03a7.zip |
added connection to image database
--> images are now processed after ftp upload
--> image is moved to image_dir
--> DB is updated with imageData
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/openslx/imagemaster/AppTest.java | 77 |
1 files changed, 27 insertions, 50 deletions
diff --git a/src/test/java/org/openslx/imagemaster/AppTest.java b/src/test/java/org/openslx/imagemaster/AppTest.java index 6fc478a..5b5988b 100644 --- a/src/test/java/org/openslx/imagemaster/AppTest.java +++ b/src/test/java/org/openslx/imagemaster/AppTest.java @@ -4,6 +4,10 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.ConnectException; +import java.util.Date; +import java.util.UUID; + +import javax.swing.text.html.ImageView; import junit.framework.Test; import junit.framework.TestCase; @@ -82,59 +86,12 @@ public class AppTest 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); + //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. */ public void testServerAuth() { @@ -163,7 +120,27 @@ 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.vmdk"), data); + + // Create ImageData + int version = 1; + String imageName = "maschine.vmkd"; + UUID uuid = UUID.randomUUID(); + int imageCreateTime = (int) new Date().getTime(); + int imageUpdateTime = imageCreateTime; + String imageOwner = "ns202"; + String contentOperatingSystem = "win7"; + boolean statusIsValid = true; + boolean statusIsDeleted = false; + String imageShortDescrption = "EIN SUPER TOLLES IMAGE!"; + String imageLongDescription = "Lorem ipsum dolor sit amet."; + + ImageData imageData = new ImageData(uuid.toString(), version, imageName, + imageCreateTime, imageUpdateTime, imageOwner, contentOperatingSystem, + statusIsValid, statusIsDeleted, imageShortDescrption, imageLongDescription); + + System.out.println("Created imageData"); + + FtpCredentials ftpCredentials = client.submitImage(imageData, data); System.out.println("Got FTP credentials. User: " + ftpCredentials.username + ", password: " + ftpCredentials.password); FTPClient FtpClient = new FTPClient(); |