From 97fa99d1ea5befd32048d4c22e85bb4d963cb74e Mon Sep 17 00:00:00 2001 From: alyokhina-olya Date: Fri, 4 May 2018 05:37:44 +0300 Subject: [PATCH 01/10] first commit --- .travis.yml | 7 + 03.FTP/pom.xml | 31 +++ .../java/ru/spbau/mit/alyokhina/Client.java | 78 +++++++ .../java/ru/spbau/mit/alyokhina/Server.java | 105 +++++++++ 03.FTP/src/resources/testGet1/copyFile1 | 8 + 03.FTP/src/resources/testGet1/copyFile2 | 9 + 03.FTP/src/resources/testGet1/file1 | 8 + 03.FTP/src/resources/testGet1/file2 | 9 + 03.FTP/src/resources/testList1/file1 | 0 03.FTP/src/resources/testList1/file2 | 0 03.FTP/src/resources/testList1/file3 | 0 03.FTP/src/resources/testList2/file1 | 0 03.FTP/src/resources/testList2/file2 | 0 .../ru/spbau/mit/alyokhina/ClientTest.java | 220 ++++++++++++++++++ 14 files changed, 475 insertions(+) create mode 100644 .travis.yml create mode 100644 03.FTP/pom.xml create mode 100644 03.FTP/src/main/java/ru/spbau/mit/alyokhina/Client.java create mode 100644 03.FTP/src/main/java/ru/spbau/mit/alyokhina/Server.java create mode 100644 03.FTP/src/resources/testGet1/copyFile1 create mode 100644 03.FTP/src/resources/testGet1/copyFile2 create mode 100644 03.FTP/src/resources/testGet1/file1 create mode 100644 03.FTP/src/resources/testGet1/file2 create mode 100644 03.FTP/src/resources/testList1/file1 create mode 100644 03.FTP/src/resources/testList1/file2 create mode 100644 03.FTP/src/resources/testList1/file3 create mode 100644 03.FTP/src/resources/testList2/file1 create mode 100644 03.FTP/src/resources/testList2/file2 create mode 100644 03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6b8dde0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: java +jdk: + - oraclejdk8 +os: + - linux +script: + - chmod +x buildscript.sh && ./buildscript.sh diff --git a/03.FTP/pom.xml b/03.FTP/pom.xml new file mode 100644 index 0000000..7a4bf75 --- /dev/null +++ b/03.FTP/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + 03 + FTP + 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + junit + junit + 4.12 + + + + + \ No newline at end of file diff --git a/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Client.java b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Client.java new file mode 100644 index 0000000..c711a8d --- /dev/null +++ b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Client.java @@ -0,0 +1,78 @@ +package ru.spbau.mit.alyokhina; + +import javafx.util.Pair; + +import java.io.*; +import java.net.Socket; +import java.util.ArrayList; +import java.util.List; + +/** Client, which allows you to execute the requests list and get */ +public class Client { + /** OutputStream from Socket */ + private DataOutputStream dataOutputStream; + /**InputStream from Socket*/ + private DataInputStream dataInputStream; + + /** + * Constructor + * + * @throws IOException if Socket or Stream can't be created + */ + public Client(String host, int port) throws IOException { + Socket clientSocket = new Socket(host, port); + dataInputStream = new DataInputStream(clientSocket.getInputStream()); + dataOutputStream = new DataOutputStream(clientSocket.getOutputStream()); + + } + + + /** + * Listing files in the directory on the server + * + * @param path directory path + * @return list of Pair. Fist value - name of file. Second value - type of file ( if file is directory - true, else false) + * Count files in directory = length of list + * @throws IOException if we can't read/write in InputStream/OutputStream + */ + public List> list(String path) throws IOException { + List> listFiles = new ArrayList<>(); + dataOutputStream.writeInt(Server.LIST_REQUEST); + dataOutputStream.writeUTF(path); + dataOutputStream.flush(); + int count = dataInputStream.readInt(); + for (int i = 0; i < count; i++) { + String fileName = dataInputStream.readUTF(); + Boolean isDirectory = dataInputStream.readBoolean(); + listFiles.add(new Pair<>(fileName, isDirectory)); + } + return listFiles; + } + + /** + * Сopy the file from the server to the file + * + * @param path path of the file from server + * @param nameFileForSave the name of the file into which the content will be copied + * @return file into which the content will be copied + * @throws IOException if we can't read/write in InputStream/OutputStream + */ + public File get(String path, String nameFileForSave) throws IOException { + dataOutputStream.writeInt(Server.GET_REQUEST); + dataOutputStream.writeUTF(path); + dataOutputStream.flush(); + File fileForSave = new File(nameFileForSave); + int count = dataInputStream.readInt(); + if (count != 0) { + byte[] bytes = new byte[count]; + int countReadBytes = dataInputStream.read(bytes); + if (countReadBytes != count) { + throw new IOException("Impossible to read all data"); + } + DataOutputStream dataOutputStreamForSave = new DataOutputStream(new FileOutputStream(fileForSave)); + dataOutputStreamForSave.write(bytes); + } + return fileForSave; + } + +} diff --git a/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Server.java b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Server.java new file mode 100644 index 0000000..e8833e1 --- /dev/null +++ b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Server.java @@ -0,0 +1,105 @@ +package ru.spbau.mit.alyokhina; + +import java.io.*; +import java.net.ServerSocket; +import java.net.Socket; + +/** A server that processes two list requests and receives */ +public class Server { + /** Value for request list */ + public static int LIST_REQUEST = 1; + /** Value for request get */ + public static int GET_REQUEST = 2; + + /** Socket for connection with this server */ + private ServerSocket serverSocket; + + /** + * Constructor + * + * @param port port of connection + * @throws IOException if Socket can't be created + */ + public Server(int port) throws IOException { + serverSocket = new ServerSocket(port); + + } + + /** Start of the server */ + public void start() { + while (true) { + try { + final Socket socket = serverSocket.accept(); + Thread thread = new Thread(() -> { + try (DataInputStream dataInputStream = new DataInputStream(socket.getInputStream()); + DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream())) { + while (!Thread.interrupted()) { + int requestType = dataInputStream.readInt(); + String path = dataInputStream.readUTF(); + if (requestType == LIST_REQUEST) { + list(path, dataOutputStream); + } else if (requestType == GET_REQUEST) { + get(path, dataOutputStream); + } + } + } catch (IOException e) { + System.out.println(e.getMessage()); + } + }); + thread.start(); + } catch (IOException ignored) { + break; + } + } + } + + /** + * Write count files, names of files and their types from input directory to dataOutputStream + * + * @param path directory path + * @param dataOutputStream stream for write result + * @throws IOException if it is impossible to write in dataOutputStream + */ + private void list(String path, DataOutputStream dataOutputStream) throws IOException { + File directory = new File(path); + File[] files = directory.listFiles(); + dataOutputStream.writeInt(files == null ? 0 : files.length); + if (files != null) { + for (File file : files) { + dataOutputStream.writeUTF(file.getName()); + dataOutputStream.writeBoolean(file.isDirectory()); + } + } + dataOutputStream.flush(); + } + + /** + * Write file contents in dataOutputStream + * @param path name of file + * @param dataOutputStream OutputStream for write result + * @throws IOException + */ + private void get(String path, DataOutputStream dataOutputStream) throws IOException { + File file = new File(path); + int length = (int) file.length(); + if (length != 0) { + DataInputStream dataInputStreamForRequest = new DataInputStream(new FileInputStream(file)); + byte[] bytes = new byte[length]; + + if (dataInputStreamForRequest.read(bytes) == length) { + dataOutputStream.writeInt(length); + dataOutputStream.write(bytes); + } else { + throw new IOException("Impossible to read all data"); + } + dataInputStreamForRequest.close(); + } else { + dataOutputStream.writeInt(length); + } + } +} + + + + + diff --git a/03.FTP/src/resources/testGet1/copyFile1 b/03.FTP/src/resources/testGet1/copyFile1 new file mode 100644 index 0000000..4d20f7a --- /dev/null +++ b/03.FTP/src/resources/testGet1/copyFile1 @@ -0,0 +1,8 @@ +Я вас любил: любовь еще, быть может, +В душе моей угасла не совсем; +Но пусть она вас больше не тревожит; +Я не хочу печалить вас ничем. +Я вас любил безмолвно, безнадежно, +То робостью, то ревностью томим; +Я вас любил так искренно, так нежно, +Как дай вам бог любимой быть другим. \ No newline at end of file diff --git a/03.FTP/src/resources/testGet1/copyFile2 b/03.FTP/src/resources/testGet1/copyFile2 new file mode 100644 index 0000000..9d57e16 --- /dev/null +++ b/03.FTP/src/resources/testGet1/copyFile2 @@ -0,0 +1,9 @@ +Я выжила… Отчаянно, ознобно, +Легко. Светает. Снег сошёл на нет. +Не слышен плач, не ослепляет свет. +Глаза пусты, глаза беззлобны. + +Недостающий воздух – чушь, пустяк, +Совпал с полночным и привычным зноем. +А если будет что-нибудь не так… +Ты мне поможешь? Нас пока что двое? \ No newline at end of file diff --git a/03.FTP/src/resources/testGet1/file1 b/03.FTP/src/resources/testGet1/file1 new file mode 100644 index 0000000..4d20f7a --- /dev/null +++ b/03.FTP/src/resources/testGet1/file1 @@ -0,0 +1,8 @@ +Я вас любил: любовь еще, быть может, +В душе моей угасла не совсем; +Но пусть она вас больше не тревожит; +Я не хочу печалить вас ничем. +Я вас любил безмолвно, безнадежно, +То робостью, то ревностью томим; +Я вас любил так искренно, так нежно, +Как дай вам бог любимой быть другим. \ No newline at end of file diff --git a/03.FTP/src/resources/testGet1/file2 b/03.FTP/src/resources/testGet1/file2 new file mode 100644 index 0000000..9d57e16 --- /dev/null +++ b/03.FTP/src/resources/testGet1/file2 @@ -0,0 +1,9 @@ +Я выжила… Отчаянно, ознобно, +Легко. Светает. Снег сошёл на нет. +Не слышен плач, не ослепляет свет. +Глаза пусты, глаза беззлобны. + +Недостающий воздух – чушь, пустяк, +Совпал с полночным и привычным зноем. +А если будет что-нибудь не так… +Ты мне поможешь? Нас пока что двое? \ No newline at end of file diff --git a/03.FTP/src/resources/testList1/file1 b/03.FTP/src/resources/testList1/file1 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/resources/testList1/file2 b/03.FTP/src/resources/testList1/file2 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/resources/testList1/file3 b/03.FTP/src/resources/testList1/file3 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/resources/testList2/file1 b/03.FTP/src/resources/testList2/file1 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/resources/testList2/file2 b/03.FTP/src/resources/testList2/file2 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java new file mode 100644 index 0000000..789fc68 --- /dev/null +++ b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java @@ -0,0 +1,220 @@ +package ru.spbau.mit.alyokhina; + +import javafx.util.Pair; +import org.junit.Test; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + + +/** Test for client-server connection */ +public class ClientTest { + /** If a server was created, this flag will be true */ + private static boolean isCreateServer = false; + + + @Test + public void testCreateClientAndServer() { + try { + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; + } + Client client = new Client("localhost", 1408); + + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + + @Test + public void testListWithOneClient() { + try { + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; + } + Client client = new Client("localhost", 1408); + List> files = client.list("src/resources/testList1"); + List> rightAnswer = new ArrayList<>(); + rightAnswer.add(new Pair<>("dir1", true)); + rightAnswer.add(new Pair<>("dir2", true)); + rightAnswer.add(new Pair<>("file3", false)); + rightAnswer.add(new Pair<>("file1", false)); + rightAnswer.add(new Pair<>("file2", false)); + assertEquals(true, equalLists(rightAnswer, files)); + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + + + @Test + public void testListWithTwoClients() { + try { + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; + } + Client client1 = new Client("localhost", 1408); + Client client2 = new Client("localhost", 1408); + List> files1 = client1.list("src/resources/testList1"); + List> files2 = client2.list("src/resources/testList2"); + List> rightAnswer1 = new ArrayList<>(); + rightAnswer1.add(new Pair<>("dir1", true)); + rightAnswer1.add(new Pair<>("dir2", true)); + rightAnswer1.add(new Pair<>("file3", false)); + rightAnswer1.add(new Pair<>("file1", false)); + rightAnswer1.add(new Pair<>("file2", false)); + assertEquals(true, equalLists(rightAnswer1, files1)); + + List> rightAnswer2 = new ArrayList<>(); + rightAnswer2.add(new Pair<>("dir1", true)); + rightAnswer2.add(new Pair<>("dir2", true)); + rightAnswer2.add(new Pair<>("dir3", true)); + rightAnswer2.add(new Pair<>("dir4", true)); + rightAnswer2.add(new Pair<>("dir5", true)); + rightAnswer2.add(new Pair<>("file1", false)); + rightAnswer2.add(new Pair<>("file2", false)); + assertEquals(true, equalLists(files2, rightAnswer2)); + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + + @Test + public void testCreateWithNonexistentDirectory() { + try { + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; + } + Client client = new Client("localhost", 1408); + List> files = client.list("src/resources/testList3"); + assertEquals(0, files.size()); + + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + + + @Test + public void testGetWithOneClient() { + try { + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; + } + Client client = new Client("localhost", 1408); + File copyFile = client.get("src/resources/testGet1/file1", "src/resources/testGet1/copyFile1"); + File file = new File("src/resources/testGet1/file1"); + assertEquals(true, equalFiles(file, copyFile)); + + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + + + @Test + public void testGetWithTwoClients() { + try { + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; + } + Client client1 = new Client("localhost", 1408); + File copyFile1 = client1.get("src/resources/testGet1/file1", "src/resources/testGet1/copyFile1"); + File file1 = new File("src/resources/testGet1/file1"); + assertEquals(true, equalFiles(file1, copyFile1)); + + Client client2 = new Client("localhost", 1408); + File copyFile2 = client2.get("src/resources/testGet1/file2", "src/resources/testGet1/copyFile2"); + File file2 = new File("src/resources/testGet1/file2"); + assertEquals(true, equalFiles(file2, copyFile2)); + + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + + @Test + public void testGetWithNonexistentFiles() { + try { + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; + } + Client client = new Client("localhost", 1408); + File file = client.get("src/resources/testGet1/file3", "src/resources/testGet1/copyFile3"); + assertEquals(0, file.length()); + + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + + + /** Compare two List> */ + private static boolean equalLists(List> a, List> b) { + if (a.size() != b.size()) { + return false; + } + for (Pair elem1 : a) { + boolean flag = false; + for (Pair elem2 : b) { + if (elem1.getKey().equals(elem2.getKey()) && elem1.getValue() == elem2.getValue()) { + flag = true; + } + } + if (!flag) { + return false; + } + } + return true; + } + + /** Compare files */ + private static boolean equalFiles(File file, File copyFile) throws IOException { + if (file.length() != copyFile.length()) { + return false; + } + byte[] data1 = new byte[(int) file.length()]; + byte[] data2 = new byte[(int) file.length()]; + FileInputStream fisForFile = new FileInputStream(file); + FileInputStream fisForCopyFile = new FileInputStream(copyFile); + if (fisForFile.read(data1) != file.length()) { + throw new IOException("Can't read file"); + } + if (fisForCopyFile.read(data2) != copyFile.length()) { + throw new IOException("Can't read file"); + } + for (int i = 0; i < data1.length; i++) { + if (data1[i] != data2[i]) { + return false; + } + } + return true; + } + +} \ No newline at end of file From 03d8a5c5ad50e16e4524c1dfe1c801bf27e08009 Mon Sep 17 00:00:00 2001 From: alyokhina-olya Date: Fri, 4 May 2018 05:42:34 +0300 Subject: [PATCH 02/10] add buildscript for travis --- buildscript.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 buildscript.sh diff --git a/buildscript.sh b/buildscript.sh new file mode 100755 index 0000000..1cc07e7 --- /dev/null +++ b/buildscript.sh @@ -0,0 +1,9 @@ +#!/bin/bash +files=$(find . -maxdepth 1 -type d | grep "./0.*") +for file in $files +do + cd $file + mvn test -B + cd ../ +done + From e8a5d29fdede690eaadf37c3ac9637e42486d508 Mon Sep 17 00:00:00 2001 From: alyokhina-olya Date: Fri, 4 May 2018 06:00:40 +0300 Subject: [PATCH 03/10] fix compare List --- .../ru/spbau/mit/alyokhina/ClientTest.java | 16 ++-- .../ru/spbau/mit/alyokhina/Client.class | Bin 0 -> 2815 bytes .../ru/spbau/mit/alyokhina/Server.class | Bin 0 -> 4290 bytes .../compile/default-compile/createdFiles.lst | 2 + .../compile/default-compile/inputFiles.lst | 2 + .../default-testCompile/createdFiles.lst | 1 + .../default-testCompile/inputFiles.lst | 1 + ...TEST-ru.spbau.mit.alyokhina.ClientTest.xml | 69 ++++++++++++++++++ .../ru.spbau.mit.alyokhina.ClientTest.txt | 4 + .../ru/spbau/mit/alyokhina/ClientTest.class | Bin 0 -> 7208 bytes 10 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 03.FTP/target/classes/ru/spbau/mit/alyokhina/Client.class create mode 100644 03.FTP/target/classes/ru/spbau/mit/alyokhina/Server.class create mode 100644 03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst create mode 100644 03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst create mode 100644 03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml create mode 100644 03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt create mode 100644 03.FTP/target/test-classes/ru/spbau/mit/alyokhina/ClientTest.class diff --git a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java index 789fc68..0b5be76 100644 --- a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java +++ b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java @@ -51,7 +51,7 @@ public void testListWithOneClient() { rightAnswer.add(new Pair<>("file3", false)); rightAnswer.add(new Pair<>("file1", false)); rightAnswer.add(new Pair<>("file2", false)); - assertEquals(true, equalLists(rightAnswer, files)); + assertEquals(rightAnswer.size(), equalLists(rightAnswer, files)); } catch (IOException e) { System.out.println(e.getMessage()); } @@ -77,7 +77,7 @@ public void testListWithTwoClients() { rightAnswer1.add(new Pair<>("file3", false)); rightAnswer1.add(new Pair<>("file1", false)); rightAnswer1.add(new Pair<>("file2", false)); - assertEquals(true, equalLists(rightAnswer1, files1)); + assertEquals(rightAnswer1.size(), equalLists(rightAnswer1, files1)); List> rightAnswer2 = new ArrayList<>(); rightAnswer2.add(new Pair<>("dir1", true)); @@ -87,7 +87,7 @@ public void testListWithTwoClients() { rightAnswer2.add(new Pair<>("dir5", true)); rightAnswer2.add(new Pair<>("file1", false)); rightAnswer2.add(new Pair<>("file2", false)); - assertEquals(true, equalLists(files2, rightAnswer2)); + assertEquals(rightAnswer2.size(), equalLists(files2, rightAnswer2)); } catch (IOException e) { System.out.println(e.getMessage()); } @@ -176,10 +176,11 @@ public void testGetWithNonexistentFiles() { /** Compare two List> */ - private static boolean equalLists(List> a, List> b) { + private static int equalLists(List> a, List> b) { if (a.size() != b.size()) { - return false; + return -1; } + int i = 0; for (Pair elem1 : a) { boolean flag = false; for (Pair elem2 : b) { @@ -188,10 +189,11 @@ private static boolean equalLists(List> a, ListAY(=NO_o;uUK4`x?v#fnmctOls7a%_cddA<7axzmUO&bFD ztm!2J6C=fXE@#Xc&vLR%tlE}@-MvONO~KxrXW5B9dU0#nxMiFD#x$#`ux5{0u9@*1 zcV5B95Ug&;u}vdOcf}HHhBv98T=MjCH*>DPGjKHHcIqzn#qwWVu(gsG|v27~I!oQD|arR~l9TRPsxJ38LQdm7%?@c}-h1SLjTJ(A!f3PH!m_(aF2IKZ>C1W7m(2L}BN*Ow5G zr{uu$SyHeyIX&ad&RRU&4W84$t7ojiu_FlJ zqZfJj*#9CMLc|K6KtKvg8s%cDqUJ&!U~d|W(h4n5VOt8qloE?KV~0dp$0%X=;#>?9 zUSXVgG0ut=3G`33rc8Ivbjf~SGBq?Z*mLG=Pilx)&n4IL%%ofrYNLPA29~o!y$Wj9 zI7pHsI&SA?dHZP641X`F;4SIT{hgbZz=!V*3S2f6E;66L^Sn!arhUKV6>ZM2bLPOf zybsP7Xb5|dgFRtvLDxD$hrD1Bv?a#a*s5BVR++xycu$B9RRFTU#tYq2(1s$>qA$Nw zQJ=Ab&oFlKUA&vG@Cg5Sj{I*td3=^Yp}3oAZ{h43U$QEnZOwToi-@FKw&hXM-@FJl z-L`;e9;G*-aatzR@;qWUQSrSWu9aggqW-92GpewKujx2iu@!B!HV1*R7YWXo0{d_; zlgqdLI6weZ*umcz_YqP%tt!{*`MDnt&_Zy^CPvq|Vk|;W=TUj8`3F?oK-B`)$+wmT zte58kHt?Y>pt`f9U9C~;zrnu1u<=kd__FCo)Ep{pT|{j<9*vjgvH2%#iQwE-Rr&Vz zAFbc{>7}5(sNlGVKQS6nO`hsl#!iB1Vp;nMyn`OcSx}nu5tbu`K0=Tk*p3G|k8-sd zhd3{##{nGXNBA|CX)tiar=g57I`I%`Xkx(+)2{?w^wdc~u-47BqqI~aato~*jw#At z1X1Lwhl>&Pa>H?g@EfWm2%(I2TbQ|l_?=uWqAuN<$JYJ=X+qg`9H~)%DGTU|M;EZI zy|kvZM*SLOamZ_i`LZz6(4G^E?|*hwKA(&C!9?rIbIN?0z4t&-yr#8_H2i;J_c zT`a2w-R%BRt{>y9hiH2-$T5Q?e*~WNX&fZ(cIqLC6Re?&w45X}4A5 z0*zujMM5LYa{~Ps@U_$B6RP_3)gyA7$ute8HJtJP2New|D)CRswn(RfA*P7n?B9c$ BsQ>@~ literal 0 HcmV?d00001 diff --git a/03.FTP/target/classes/ru/spbau/mit/alyokhina/Server.class b/03.FTP/target/classes/ru/spbau/mit/alyokhina/Server.class new file mode 100644 index 0000000000000000000000000000000000000000..3632f17906d579849666c873d65312333606a5ac GIT binary patch literal 4290 zcmai2YjhN68GdGWc4sdGfxr?LBncsbWJw5ON$Un<xF7t>%CUb@f?5X@t6PQ9Bq8w+0AAG96X%NeBXP& zJnuURFTHW)Du6rimjJe7LPH_|7bg8^Mp8~G4e4?UsexKG1W071M*9`6mH z3ir$DeR6ugoIW6@56a_1a{aJ|k7#%xfHin9fDk?^kB5Z)un!*#ARv}PcqD+2;}aS_ zDeq4S`_tm^Gs1gR9*;>_pAGQwIXQh^PLGS+BO1OCKm=d(<1C&KgI@~Z%lL|huWI<3 z0=>H{)_3CYzC-={VtopfE(O8PeGZDAH8ZEpOe{4rVOk0*x=$IWjpn3jHOCx`Rt4T& z@nqa;Q=ry&H5}nVE7Vyxqsv^p%Vx{{@s zJ5rg$=Dj&nk`0$Eh);(Q!}knNS>nbuxSRD(n8`6~+=lsa=9(}jhewTCyJ5B46|62+ z%?4DVNm80%rr@b>DlHhgArj)$)bMpeTY+!aNTLY5KrEHZjF^%WEfnCnO}eb31?}wV zEukySJ9WWqxMj%#>P!!LCF z5-;g^8Bc3?MaQpjUcrXj&i|6;92h=DWG^8V#)N>eqhG`nacGRlzFEQU!uOHlUWTDwSdV6L#!3ft9FKe)Sr-x81Qfp58s?U6(( zD?5*oJ5;4k#RAIQEbbguu#BQk01}%HStp0W;l;?7aKv{op0vzNCYQEk!D|wzT}9@} zNbS2_sb$9KXe^gbXUuF?Bp0$>3Sv83$Et`;Wi4}(RZHdAnZ?h?L4F7pmOejQOs0o+ zjWHIXv?v@h3?wZYiKK?#>i8XA(_vs(L5&S*JBE1jbZWwE?zUGc7m{((C~o-Rx6xGDm9Tyv(;V6q?y^1Fqjj8^@LR?&SS0-g=<&1gwnAK#9!4HL!jL?#oaw*eY-3b2*Ix6%<^H6TOyicMg>dDB13Y$tR|&~TAR2TNE z=8_>jk2UiQ&1(bdq>ZF8dsN3j?OJ;6zm783Aq``}PCoYYXP&#ye=7y@WV*+K1gQ(E zQv~QGBhbNzn3*T8gG>2RKXPmX0k;_7KH%m!3GC+b3~&#PbEgz`e4V|42zm7q>O7aQ tMTS+eH@N(F1DLne!Hqc2E}X(2ZJL7L<4^blx6-}5>(t0lCJPJM{{cNx>fitX literal 0 HcmV?d00001 diff --git a/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..59423b9 --- /dev/null +++ b/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,2 @@ +ru/spbau/mit/alyokhina/Client.class +ru/spbau/mit/alyokhina/Server.class diff --git a/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..10c2f58 --- /dev/null +++ b/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,2 @@ +/home/olya/Java2/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Client.java +/home/olya/Java2/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Server.java diff --git a/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..b9d03ea --- /dev/null +++ b/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1 @@ +ru/spbau/mit/alyokhina/ClientTest.class diff --git a/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e20bdd4 --- /dev/null +++ b/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/home/olya/Java2/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java diff --git a/03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml b/03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml new file mode 100644 index 0000000..2f2560d --- /dev/null +++ b/03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt b/03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt new file mode 100644 index 0000000..a7552d2 --- /dev/null +++ b/03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: ru.spbau.mit.alyokhina.ClientTest +------------------------------------------------------------------------------- +Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.085 sec - in ru.spbau.mit.alyokhina.ClientTest diff --git a/03.FTP/target/test-classes/ru/spbau/mit/alyokhina/ClientTest.class b/03.FTP/target/test-classes/ru/spbau/mit/alyokhina/ClientTest.class new file mode 100644 index 0000000000000000000000000000000000000000..acc68b79196bc4cc138ecefc51841d4f447139d8 GIT binary patch literal 7208 zcmcIp33yc175?vRZm29?$x@~uG-Dk?u*uq{`b8%lQ&@k{opG}=G}MRz2~0upZ}bD z-f-y4eFp$c6$5=Z2b%_94sKF#vky*uUBN98Tja-91>3yX?t>3^D!6L^ z?#4Yn48#r}zKL&naj$%GpMv{+7=}#>9`ItP54-T74_SC90}tcdUUYi#h!?G11f}3n zAGdwXhwtEVFLrzJgcnbG@st-`UUYl0M{3-wV4n}U=#g{x%emk6;(!+iy?EM-@5x8c zNL|ln;5mF>e*8dg_`HH2`Y;_Y$eTk7Ui4umUXmX#d-002yGOyR3SJW!q(@65ni|up zwa98MA|O@>cxLG#JvK+cnUlLzz*QP<)C2~X>mjW&-d3+gYSj85C7I>n1~s@;jp*{; z61rk7dQ@P1c_bc)w%4oiK${*5sKJi#$`(DO216M)R?fu z6SYh_tv^-fOset3TIfWhw5U~Gtps5ww$$oN#y)GYIX9uAaMox7$%Yme#S5T6aK zj;ReRE7W$wdWM!ZT@Vk&^fqm&9@XjAyih0{Q{{AeHKaToX%4i;2~WUsAxpYYu190b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T4?$nAl%cBuQ>Zn(;O;I7TD?Sg07J}5vpycGpq z7~pyWjvn}GGc$~N{_eisIJVaVggPBSr!FL6%8jy#$ToJ@PNF%+j@0!~E^ zMxp?t`NB7jGsj>yom`0VhOK$DXej3_#uDn9058f>L2GAIPbI1h{fjJ5&ZA~8oCQ@1 z&iCO0-bt^kc@?Nh_$VIY3$lx{7mwS={LG0sWEgM`^-z`Pjp8-W}GkW2XT z2wXnz3ixv-VGfWvXEFGNxCoQcjwx7=so08X=;V9&e$F_Ev+*=$;1G(8Ff3xw(}iIs z*5N`dCBSoWC6-}1L$e4m)N>ZnWV zs3Q_dvWrX7ki8*6cH!fCS(8^BH`((uPnY#-K!F*ze#*xZVx1@-lX*q}4Yab6*lCPc z6XVs)c16qy0;rx&*6%+ShE}@%0z}$CaQWd#0ndR@^qTZLv0yk zaY)p3H4R3MNsNXQBU#g1PXMDcGADK+hgChdHuH>b$q)3%3%Uml~ts zppL?O9ymF>!$lzAorE@Dw7!jp(_ zkw-$D?a6i@735oRdlKXYgci7gAm7N*CW3quLB5$F-$IaYCCIlCpxX)ZHwf+>Jc+gt z@~wP&7p2>=8F%6ymX)Ix22#%~3?(GEZh=0Zw3ndkm}nFW7j=(h8ZW?fBi*39#JY509~;eNvT z0O8z8I3FaO4-w9XS&<**icUiD2y5SC$H?=cNxpgwmO8ku7m`{VB(hVx>>YpQH+g!!MLxaFO8gETe2Z20y=1*@=G%t^(<2=;xXJ-X zvdZ$?1)glz;93GPnv&}{a&m_{25=ognanV)=g4gUdpbOW4)e{$qhN#a`&9+}{ThGy zs`EJN#R6UTSzMffczORkqRsM53`6?yf*M#kTEt9+6K$!zK3YiH$ez)Zj UJ_atEh0c7FyPb13v)pa|FaL_VF8}}l literal 0 HcmV?d00001 From 4e3a50e8947923218965a3cd2d70362d93fc1d20 Mon Sep 17 00:00:00 2001 From: alyokhina-olya Date: Fri, 4 May 2018 06:06:37 +0300 Subject: [PATCH 04/10] check travis --- 03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java index 0b5be76..ae7c23c 100644 --- a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java +++ b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java @@ -51,7 +51,7 @@ public void testListWithOneClient() { rightAnswer.add(new Pair<>("file3", false)); rightAnswer.add(new Pair<>("file1", false)); rightAnswer.add(new Pair<>("file2", false)); - assertEquals(rightAnswer.size(), equalLists(rightAnswer, files)); + assertEquals(rightAnswer.size(), files.size()); } catch (IOException e) { System.out.println(e.getMessage()); } @@ -219,4 +219,4 @@ private static boolean equalFiles(File file, File copyFile) throws IOException { return true; } -} \ No newline at end of file +} From d21c50e5767f70a9e335e3383c4cf0f06f03a1c3 Mon Sep 17 00:00:00 2001 From: alyokhina-olya Date: Fri, 4 May 2018 06:12:48 +0300 Subject: [PATCH 05/10] check travis --- .../ru/spbau/mit/alyokhina/ClientTest.java | 2 +- ...TEST-ru.spbau.mit.alyokhina.ClientTest.xml | 14 ++++++++++---- .../ru.spbau.mit.alyokhina.ClientTest.txt | 8 +++++++- .../ru/spbau/mit/alyokhina/ClientTest.class | Bin 7208 -> 7426 bytes 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java index ae7c23c..44d3a72 100644 --- a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java +++ b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java @@ -51,7 +51,7 @@ public void testListWithOneClient() { rightAnswer.add(new Pair<>("file3", false)); rightAnswer.add(new Pair<>("file1", false)); rightAnswer.add(new Pair<>("file2", false)); - assertEquals(rightAnswer.size(), files.size()); + assertEquals("", files.get(0).getKey() + files.get(1).getKey() + files.get(2).getKey()); } catch (IOException e) { System.out.println(e.getMessage()); } diff --git a/03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml b/03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml index 2f2560d..64a4daf 100644 --- a/03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml +++ b/03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml @@ -1,5 +1,5 @@ - + @@ -59,11 +59,17 @@ - + - + - + + but was:<[dir2file1file2]> + at org.junit.Assert.assertEquals(Assert.java:115) + at org.junit.Assert.assertEquals(Assert.java:144) + at ru.spbau.mit.alyokhina.ClientTest.testListWithOneClient(ClientTest.java:54) +]]> + \ No newline at end of file diff --git a/03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt b/03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt index a7552d2..962f500 100644 --- a/03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt +++ b/03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt @@ -1,4 +1,10 @@ ------------------------------------------------------------------------------- Test set: ru.spbau.mit.alyokhina.ClientTest ------------------------------------------------------------------------------- -Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.085 sec - in ru.spbau.mit.alyokhina.ClientTest +Tests run: 7, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.102 sec <<< FAILURE! - in ru.spbau.mit.alyokhina.ClientTest +testListWithOneClient(ru.spbau.mit.alyokhina.ClientTest) Time elapsed: 0.007 sec <<< FAILURE! +org.junit.ComparisonFailure: expected:<[]> but was:<[dir2file1file2]> + at org.junit.Assert.assertEquals(Assert.java:115) + at org.junit.Assert.assertEquals(Assert.java:144) + at ru.spbau.mit.alyokhina.ClientTest.testListWithOneClient(ClientTest.java:54) + diff --git a/03.FTP/target/test-classes/ru/spbau/mit/alyokhina/ClientTest.class b/03.FTP/target/test-classes/ru/spbau/mit/alyokhina/ClientTest.class index acc68b79196bc4cc138ecefc51841d4f447139d8..a6db1b8a9e6ca715a09e46da015a5a9d0075d2bd 100644 GIT binary patch delta 3129 zcmai03wTt;75>leeeKQNY;r@gxsU{_M3+2_1R^AnhY=wmuUbV|sDXtnNgyU6S*(@T zSS=Q+eaO&SY?W%M+BR*4*iB+A(znp}yS3KVw%F35)s_}Y5qswDvf0+P?zi8aGiT16 zIsZRr&dj3=Zm%0YdhUrs0OnDViL0^OhoulY_L%VEBRW1RmG|0g@Cg$t?w6kjbnG+m zNfRa>)bWrHpTd3JZa#|a`=$R5k4g~hYftiz*h}?&A`_U ze8a#u<;vgE@wAC*9Fc}c4Sd_ccMN>j!1tu~`_jh`vhYLvNPd1?YT_dNL@xPL9X~U% z7(bVvUl{nM#B@Z*Gdg}X>LZ)zq0u7G5s&gLLmEAD9|$vG6ziUAj1_;~y6OiBklnvuCiH zpl<5vjm{;25S$AC+Sp)EUsuDnp5D&rpoP=;mxVLpWh0n#7Oz@3Cl`9n;#ntoAt$HW zA|j847`CyJyyB2PRCJmYf^|ONWxR}x;3W%p;JxBSy+jNcT_vQFW|2;Yj%O|Mk!evD z{%w(kQx^G!-&bNZQnp0_$`NyYJMCPuWwt&*@D6V4Bh-Y%V>EO0gztXxdAp)9LVl=8 zG+8C#X`$IIQ-InxY>sY>)f2SHz(BOGlTaB-8&2S@PoME$6!1hN)}K&`Jz2AY%23ZO zQ4S(Bo3~62tynSpdcwSrDE1eNV_6$Smo;C@vuGL>iv3m%O&8Bt$CVj`QgN9-D4z3I zuU^WBO|ovvL}Dq6WzH-9uHar3w@fe8vN6yB7CdO?ujVRq(898nFhDEXxJPK`$sVi_ z-PsXp7DuzI)=8@}D9FVOycO55%`6yr8?I%$g}m@}Sn2v`O!~NPC!U9ZO#Jkit*iB>we`w1BM=_K}o*gzY6a<^@d7DICo}&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u2+gHk-F9?#o&A)q|(vGAgWmpVp@pb&R-6l>3F z`hGgz;WKiCwaY>)x5*;2G*FIdE~ernfnl;$WXS7HduTcSD3H7&a#5tPA#(om!qd-f ztcxsl@hALQ?l99c{*sJoNd{ha@mIX!q8xv7@pnvc+YFAKrIy zK2}-yz{Q97NFbxBaYZwbP8~C3AZ1F+ZZftP6R`&+*o&|iz-(B9 zx>ky-F%M_(=&86I^Ra;L&PFq8DEVli-|>Ah#~0F_bZSNQYvcO0)K@_{!x_~V*f>aB zXU4L2Fr`+EkTZg75>+T6qo6OA7lPruWAtuhbRlymLK^0W%pRoG1V;|GI7*I7ElcuD z=pnPuMkGB|ZbhbQLjjw=tVl2MhA@)!8po+7|PZC5n$nf2o%+)vO?xVVcSR3 z$RG|bjngz8`o{E=h94U|t`j+xJs49HJhltDRSGr5)I5&e$R}5`h|87fWuCV`%*kV7 z-j*YTI^w6Xkdm;Rl8@;0b8^M^ifQ#AUY;BGat&dy$cL?uL6&5c&igTUd*IXr11Uyp z7u>KO(t`!Tv5YTlcmWnLz_6(z44ENgV2nfj8z6~{kM(#UW6uBQAoCpMU^&sOkHtD2 zE4*0iah%6XofVmdm0UB>LWCPAnb}-t{_6o7A#hBvkUhw_!76#@7AIc z2gMa&O1hAe;P0A?_1#GuuA<~a4jau{YUn6pDzBkr zc)^c`nRo;z!nDxleST_zpKJL6GQWW)QV&se9nI@lD9BrzY45w#hw(J^XZSjxsY_i9 kxYUC@_Getv@N=PP=kSM!DI6v@gpHi59w@1^2{&WYcZZ_))Bpeg From ac88ce0578f086286aac62c2d398936734d8dac7 Mon Sep 17 00:00:00 2001 From: alyokhina-olya Date: Fri, 4 May 2018 06:17:42 +0300 Subject: [PATCH 06/10] add directory --- 03.FTP/src/resources/testList1/dir1/1 | 0 03.FTP/src/resources/testList1/dir2/1 | 0 03.FTP/src/resources/testList2/dir1/1 | 0 03.FTP/src/resources/testList2/dir2/1 | 0 03.FTP/src/resources/testList2/dir3/1 | 0 03.FTP/src/resources/testList2/dir4/1 | 0 03.FTP/src/resources/testList2/dir5/1 | 0 03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java | 2 +- 8 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 03.FTP/src/resources/testList1/dir1/1 create mode 100644 03.FTP/src/resources/testList1/dir2/1 create mode 100644 03.FTP/src/resources/testList2/dir1/1 create mode 100644 03.FTP/src/resources/testList2/dir2/1 create mode 100644 03.FTP/src/resources/testList2/dir3/1 create mode 100644 03.FTP/src/resources/testList2/dir4/1 create mode 100644 03.FTP/src/resources/testList2/dir5/1 diff --git a/03.FTP/src/resources/testList1/dir1/1 b/03.FTP/src/resources/testList1/dir1/1 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/resources/testList1/dir2/1 b/03.FTP/src/resources/testList1/dir2/1 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/resources/testList2/dir1/1 b/03.FTP/src/resources/testList2/dir1/1 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/resources/testList2/dir2/1 b/03.FTP/src/resources/testList2/dir2/1 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/resources/testList2/dir3/1 b/03.FTP/src/resources/testList2/dir3/1 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/resources/testList2/dir4/1 b/03.FTP/src/resources/testList2/dir4/1 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/resources/testList2/dir5/1 b/03.FTP/src/resources/testList2/dir5/1 new file mode 100644 index 0000000..e69de29 diff --git a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java index 44d3a72..7ab94cf 100644 --- a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java +++ b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java @@ -51,7 +51,7 @@ public void testListWithOneClient() { rightAnswer.add(new Pair<>("file3", false)); rightAnswer.add(new Pair<>("file1", false)); rightAnswer.add(new Pair<>("file2", false)); - assertEquals("", files.get(0).getKey() + files.get(1).getKey() + files.get(2).getKey()); + assertEquals(rightAnswer.size(), equalLists(rightAnswer, files)); } catch (IOException e) { System.out.println(e.getMessage()); } From 1a8977bad44f0c09d981bd10528899785b6c58f8 Mon Sep 17 00:00:00 2001 From: alyokhina-olya Date: Fri, 4 May 2018 06:20:34 +0300 Subject: [PATCH 07/10] delete files --- .../ru/spbau/mit/alyokhina/Client.class | Bin 2815 -> 0 bytes .../ru/spbau/mit/alyokhina/Server.class | Bin 4290 -> 0 bytes .../compile/default-compile/createdFiles.lst | 2 - .../compile/default-compile/inputFiles.lst | 2 - .../default-testCompile/createdFiles.lst | 1 - .../default-testCompile/inputFiles.lst | 1 - ...TEST-ru.spbau.mit.alyokhina.ClientTest.xml | 75 ------------------ .../ru.spbau.mit.alyokhina.ClientTest.txt | 10 --- .../ru/spbau/mit/alyokhina/ClientTest.class | Bin 7426 -> 0 bytes 9 files changed, 91 deletions(-) delete mode 100644 03.FTP/target/classes/ru/spbau/mit/alyokhina/Client.class delete mode 100644 03.FTP/target/classes/ru/spbau/mit/alyokhina/Server.class delete mode 100644 03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst delete mode 100644 03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst delete mode 100644 03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst delete mode 100644 03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst delete mode 100644 03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml delete mode 100644 03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt delete mode 100644 03.FTP/target/test-classes/ru/spbau/mit/alyokhina/ClientTest.class diff --git a/03.FTP/target/classes/ru/spbau/mit/alyokhina/Client.class b/03.FTP/target/classes/ru/spbau/mit/alyokhina/Client.class deleted file mode 100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sd zhd3{##{nGXNBA|CX)tiar=g57I`I%`Xkx(+)2{?w^wdc~u-47BqqI~aato~*jw#At z1X1Lwhl>&Pa>H?g@EfWm2%(I2TbQ|l_?=uWqAuN<$JYJ=X+qg`9H~)%DGTU|M;EZI zy|kvZM*SLOamZ_i`LZz6(4G^E?|*hwKA(&C!9?rIbIN?0z4t&-yr#8_H2i;J_c zT`a2w-R%BRt{>y9hiH2-$T5Q?e*~WNX&fZ(cIqLC6Re?&w45X}4A5 z0*zujMM5LYa{~Ps@U_$B6RP_3)gyA7$ute8HJtJP2New|D)CRswn(RfA*P7n?B9c$ BsQ>@~ diff --git a/03.FTP/target/classes/ru/spbau/mit/alyokhina/Server.class b/03.FTP/target/classes/ru/spbau/mit/alyokhina/Server.class deleted file mode 100644 index 3632f17906d579849666c873d65312333606a5ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4290 zcmai2YjhN68GdGWc4sdGfxr?LBncsbWJw5ON$Un<xF7t>%CUb@f?5X@t6PQ9Bq8w+0AAG96X%NeBXP& zJnuURFTHW)Du6rimjJe7LPH_|7bg8^Mp8~G4e4?UsexKG1W071M*9`6mH z3ir$DeR6ugoIW6@56a_1a{aJ|k7#%xfHin9fDk?^kB5Z)un!*#ARv}PcqD+2;}aS_ zDeq4S`_tm^Gs1gR9*;>_pAGQwIXQh^PLGS+BO1OCKm=d(<1C&KgI@~Z%lL|huWI<3 z0=>H{)_3CYzC-={VtopfE(O8PeGZDAH8ZEpOe{4rVOk0*x=$IWjpn3jHOCx`Rt4T& z@nqa;Q=ry&H5}nVE7Vyxqsv^p%Vx{{@s zJ5rg$=Dj&nk`0$Eh);(Q!}knNS>nbuxSRD(n8`6~+=lsa=9(}jhewTCyJ5B46|62+ z%?4DVNm80%rr@b>DlHhgArj)$)bMpeTY+!aNTLY5KrEHZjF^%WEfnCnO}eb31?}wV zEukySJ9WWqxMj%#>P!!LCF z5-;g^8Bc3?MaQpjUcrXj&i|6;92h=DWG^8V#)N>eqhG`nacGRlzFEQU!uOHlUWTDwSdV6L#!3ft9FKe)Sr-x81Qfp58s?U6(( zD?5*oJ5;4k#RAIQEbbguu#BQk01}%HStp0W;l;?7aKv{op0vzNCYQEk!D|wzT}9@} zNbS2_sb$9KXe^gbXUuF?Bp0$>3Sv83$Et`;Wi4}(RZHdAnZ?h?L4F7pmOejQOs0o+ zjWHIXv?v@h3?wZYiKK?#>i8XA(_vs(L5&S*JBE1jbZWwE?zUGc7m{((C~o-Rx6xGDm9Tyv(;V6q?y^1Fqjj8^@LR?&SS0-g=<&1gwnAK#9!4HL!jL?#oaw*eY-3b2*Ix6%<^H6TOyicMg>dDB13Y$tR|&~TAR2TNE z=8_>jk2UiQ&1(bdq>ZF8dsN3j?OJ;6zm783Aq``}PCoYYXP&#ye=7y@WV*+K1gQ(E zQv~QGBhbNzn3*T8gG>2RKXPmX0k;_7KH%m!3GC+b3~&#PbEgz`e4V|42zm7q>O7aQ tMTS+eH@N(F1DLne!Hqc2E}X(2ZJL7L<4^blx6-}5>(t0lCJPJM{{cNx>fitX diff --git a/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index 59423b9..0000000 --- a/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ /dev/null @@ -1,2 +0,0 @@ -ru/spbau/mit/alyokhina/Client.class -ru/spbau/mit/alyokhina/Server.class diff --git a/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 10c2f58..0000000 --- a/03.FTP/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,2 +0,0 @@ -/home/olya/Java2/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Client.java -/home/olya/Java2/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Server.java diff --git a/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst deleted file mode 100644 index b9d03ea..0000000 --- a/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst +++ /dev/null @@ -1 +0,0 @@ -ru/spbau/mit/alyokhina/ClientTest.class diff --git a/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst deleted file mode 100644 index e20bdd4..0000000 --- a/03.FTP/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +++ /dev/null @@ -1 +0,0 @@ -/home/olya/Java2/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java diff --git a/03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml b/03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml deleted file mode 100644 index 64a4daf..0000000 --- a/03.FTP/target/surefire-reports/TEST-ru.spbau.mit.alyokhina.ClientTest.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - but was:<[dir2file1file2]> - at org.junit.Assert.assertEquals(Assert.java:115) - at org.junit.Assert.assertEquals(Assert.java:144) - at ru.spbau.mit.alyokhina.ClientTest.testListWithOneClient(ClientTest.java:54) -]]> - - - \ No newline at end of file diff --git a/03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt b/03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt deleted file mode 100644 index 962f500..0000000 --- a/03.FTP/target/surefire-reports/ru.spbau.mit.alyokhina.ClientTest.txt +++ /dev/null @@ -1,10 +0,0 @@ -------------------------------------------------------------------------------- -Test set: ru.spbau.mit.alyokhina.ClientTest -------------------------------------------------------------------------------- -Tests run: 7, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.102 sec <<< FAILURE! - in ru.spbau.mit.alyokhina.ClientTest -testListWithOneClient(ru.spbau.mit.alyokhina.ClientTest) Time elapsed: 0.007 sec <<< FAILURE! -org.junit.ComparisonFailure: expected:<[]> but was:<[dir2file1file2]> - at org.junit.Assert.assertEquals(Assert.java:115) - at org.junit.Assert.assertEquals(Assert.java:144) - at ru.spbau.mit.alyokhina.ClientTest.testListWithOneClient(ClientTest.java:54) - diff --git a/03.FTP/target/test-classes/ru/spbau/mit/alyokhina/ClientTest.class b/03.FTP/target/test-classes/ru/spbau/mit/alyokhina/ClientTest.class deleted file mode 100644 index a6db1b8a9e6ca715a09e46da015a5a9d0075d2bd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7426 zcmcIp33yc175?vR?=g8S8AvdK?3Mt5kyQzckgx@^SV1tL$Rl}49!zH9EJ)P4RIs>K zaY1mQbpf?eD{2D7B2`-}b*Lx#ymH?tlJ! z?zzK(&-d;FFi8vyVlFoKz#QD7;MO3#xJ|+BQn)2Vg}Z|A<8JwJkAm$gz7a$a-&AmK z58Q|QgXoC|g4ltbDjt+Q4=H#!h`!jY;9Dx%f_Mav22p^=^6+guu40#pCseekh^u%~ z!BasD#%9^qF10!o?3R)}@?&ohop@TscVzdzART;0O7^Sxu8L<>Jg4G$72i|weL3+9 z3Vsm81iUB}52*N|ikDQptl||ZeO20cEf25bNAly1Aco^jIpdENycNWmcw2tFqvBn; zq8AnXM8SIkz05>;+|ZN8Vk5rJhzp420)gpf)J)D4@D`6+D&Q-R)f)o6E6u1;ooZff z#Fyx+Bb06Cr^3xmYJv!nHCPXYZM0(^mTeTqDLFUODq|C1zjz$ zJIq+PqGs;;I-@0N#-i-&xj3oUt*z2qEbkd~`gC?Gnlzh@rDnq9vSvr4v7|25xvD;u zv3O&6O^Wb@oh1~=B~+S;bV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&+^I@KzlKNKk%X zLzc4y7Hj!b8SZOFTZwCo^|>8>Pn&lJMWq7OWA}hJp{-cW#&jXesZyVJil3_NE#>Ly z^iP&8M?op_*)>;@!e={XY(-xwnknCB?m)md#lQ3L3kCjd@DFU;;1N3y-)Vc$MrZ8$ zsuaE0ev(`9DFWBQ{~+4U%4!cQs=Z8zon+0^WW+u$o}!tZU9Z=0T0tDI+bC(f+pEoGK0ozAQsBU}C=A1OF{qg3Ibo}K7f8!GES`7^9> zWQSwT)#05ICZS3$(b(23s=A z@*59IHsWdmF^K2i*VyuMh83(zt|2HB7^Z94@>{^3ia@W!yzvASTxb1WuYkWd@RwJl z&)^Y#KcVW4H1DJ7o+S0xx$EtF-YI;_e||5oVDg?P=zaR07viip@y&yqMSnhn5TZa7 Vi9((Rcko@Fm0PK^jcIM$e*rzm_;UaN From 87db2c63828a8b04350fc3fc5403e9977ee0ea45 Mon Sep 17 00:00:00 2001 From: alyokhina-olya Date: Wed, 30 May 2018 01:36:56 +0300 Subject: [PATCH 08/10] add TemporaryFolder and add enum for request --- .../java/ru/spbau/mit/alyokhina/Client.java | 4 +- .../java/ru/spbau/mit/alyokhina/Main.java | 80 +++++++++++++ .../java/ru/spbau/mit/alyokhina/Request.java | 6 + .../java/ru/spbau/mit/alyokhina/Server.java | 11 +- 03.FTP/src/resources/testGet1/copyFile1 | 8 -- 03.FTP/src/resources/testGet1/copyFile2 | 9 -- 03.FTP/src/resources/testGet1/file1 | 8 -- 03.FTP/src/resources/testGet1/file2 | 9 -- 03.FTP/src/resources/testList1/dir1/1 | 0 03.FTP/src/resources/testList1/dir2/1 | 0 03.FTP/src/resources/testList1/file1 | 0 03.FTP/src/resources/testList1/file2 | 0 03.FTP/src/resources/testList1/file3 | 0 03.FTP/src/resources/testList2/dir1/1 | 0 03.FTP/src/resources/testList2/dir2/1 | 0 03.FTP/src/resources/testList2/dir3/1 | 0 03.FTP/src/resources/testList2/dir4/1 | 0 03.FTP/src/resources/testList2/dir5/1 | 0 03.FTP/src/resources/testList2/file1 | 0 03.FTP/src/resources/testList2/file2 | 0 .../ru/spbau/mit/alyokhina/ClientTest.java | 108 ++++++++++++++---- 21 files changed, 179 insertions(+), 64 deletions(-) create mode 100644 03.FTP/src/main/java/ru/spbau/mit/alyokhina/Main.java create mode 100644 03.FTP/src/main/java/ru/spbau/mit/alyokhina/Request.java delete mode 100644 03.FTP/src/resources/testGet1/copyFile1 delete mode 100644 03.FTP/src/resources/testGet1/copyFile2 delete mode 100644 03.FTP/src/resources/testGet1/file1 delete mode 100644 03.FTP/src/resources/testGet1/file2 delete mode 100644 03.FTP/src/resources/testList1/dir1/1 delete mode 100644 03.FTP/src/resources/testList1/dir2/1 delete mode 100644 03.FTP/src/resources/testList1/file1 delete mode 100644 03.FTP/src/resources/testList1/file2 delete mode 100644 03.FTP/src/resources/testList1/file3 delete mode 100644 03.FTP/src/resources/testList2/dir1/1 delete mode 100644 03.FTP/src/resources/testList2/dir2/1 delete mode 100644 03.FTP/src/resources/testList2/dir3/1 delete mode 100644 03.FTP/src/resources/testList2/dir4/1 delete mode 100644 03.FTP/src/resources/testList2/dir5/1 delete mode 100644 03.FTP/src/resources/testList2/file1 delete mode 100644 03.FTP/src/resources/testList2/file2 diff --git a/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Client.java b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Client.java index c711a8d..96350e5 100644 --- a/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Client.java +++ b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Client.java @@ -37,7 +37,7 @@ public Client(String host, int port) throws IOException { */ public List> list(String path) throws IOException { List> listFiles = new ArrayList<>(); - dataOutputStream.writeInt(Server.LIST_REQUEST); + dataOutputStream.writeInt(Request.LIST_REQUEST.ordinal()); dataOutputStream.writeUTF(path); dataOutputStream.flush(); int count = dataInputStream.readInt(); @@ -58,7 +58,7 @@ public List> list(String path) throws IOException { * @throws IOException if we can't read/write in InputStream/OutputStream */ public File get(String path, String nameFileForSave) throws IOException { - dataOutputStream.writeInt(Server.GET_REQUEST); + dataOutputStream.writeInt(Request.GET_REQUEST.ordinal()); dataOutputStream.writeUTF(path); dataOutputStream.flush(); File fileForSave = new File(nameFileForSave); diff --git a/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Main.java b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Main.java new file mode 100644 index 0000000..0a5d9e2 --- /dev/null +++ b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Main.java @@ -0,0 +1,80 @@ +package ru.spbau.mit.alyokhina; + + +import javafx.util.Pair; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Scanner; + +/** + * + */ +public class Main { + public static void main(String[] args) { + int type; + Scanner in = new Scanner(System.in); + do { + System.out.println("1 - запустить сервер"); + System.out.println("2 - запустить клиента"); + System.out.println("3 - выйти"); + type = in.nextInt(); + if (type == 1) { + System.out.println("Введите порт"); + int port = in.nextInt(); + try { + final Server server = new Server(port); + Thread thread = new Thread(server::start); + thread.start(); + System.out.println("Сервер создан"); + } + catch (IOException e) { + System.out.println(e.getMessage()); + } + } + if (type == 2) { + try { + System.out.println("Введите порт"); + int port = in.nextInt(); + Client client = new Client("localhost", port); + int typeRequest = 0; + do { + System.out.println("1 - list"); + System.out.println("2 - get"); + System.out.println("3 - назад"); + typeRequest = in.nextInt(); + if (typeRequest == 1) { + System.out.println("Введите путь к директории"); + String path = in.next(); + List> files = client.list(path); + for (Pair file : files) { + System.out.print(file.getKey()); + if (file.getValue()) { + System.out.println(" is directory"); + } else { + System.out.println(" is file"); + } + } + } + if (typeRequest == 2) { + System.out.println("Введите путь к файлу"); + String path = in.next(); + System.out.println("Введите путь для сохранения"); + String fileName = in.next(); + File file = client.get(path, fileName); + System.out.print("Размер файла = "); + System.out.println(file.length()); + } + }while (typeRequest != 3); + + + } + catch (IOException e) { + System.out.println(e.getMessage()); + } + } + }while (type != 3); + System.exit(0); + } +} diff --git a/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Request.java b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Request.java new file mode 100644 index 0000000..95e5340 --- /dev/null +++ b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Request.java @@ -0,0 +1,6 @@ +package ru.spbau.mit.alyokhina; + +public enum Request { + LIST_REQUEST, + GET_REQUEST +} diff --git a/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Server.java b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Server.java index e8833e1..e6a6ca8 100644 --- a/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Server.java +++ b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Server.java @@ -6,11 +6,6 @@ /** A server that processes two list requests and receives */ public class Server { - /** Value for request list */ - public static int LIST_REQUEST = 1; - /** Value for request get */ - public static int GET_REQUEST = 2; - /** Socket for connection with this server */ private ServerSocket serverSocket; @@ -36,9 +31,9 @@ public void start() { while (!Thread.interrupted()) { int requestType = dataInputStream.readInt(); String path = dataInputStream.readUTF(); - if (requestType == LIST_REQUEST) { + if (requestType == Request.LIST_REQUEST.ordinal()) { list(path, dataOutputStream); - } else if (requestType == GET_REQUEST) { + } else if (requestType == Request.GET_REQUEST.ordinal()) { get(path, dataOutputStream); } } @@ -77,7 +72,7 @@ private void list(String path, DataOutputStream dataOutputStream) throws IOExcep * Write file contents in dataOutputStream * @param path name of file * @param dataOutputStream OutputStream for write result - * @throws IOException + * @throws IOException if it is impossible to write in dataOutputStream */ private void get(String path, DataOutputStream dataOutputStream) throws IOException { File file = new File(path); diff --git a/03.FTP/src/resources/testGet1/copyFile1 b/03.FTP/src/resources/testGet1/copyFile1 deleted file mode 100644 index 4d20f7a..0000000 --- a/03.FTP/src/resources/testGet1/copyFile1 +++ /dev/null @@ -1,8 +0,0 @@ -Я вас любил: любовь еще, быть может, -В душе моей угасла не совсем; -Но пусть она вас больше не тревожит; -Я не хочу печалить вас ничем. -Я вас любил безмолвно, безнадежно, -То робостью, то ревностью томим; -Я вас любил так искренно, так нежно, -Как дай вам бог любимой быть другим. \ No newline at end of file diff --git a/03.FTP/src/resources/testGet1/copyFile2 b/03.FTP/src/resources/testGet1/copyFile2 deleted file mode 100644 index 9d57e16..0000000 --- a/03.FTP/src/resources/testGet1/copyFile2 +++ /dev/null @@ -1,9 +0,0 @@ -Я выжила… Отчаянно, ознобно, -Легко. Светает. Снег сошёл на нет. -Не слышен плач, не ослепляет свет. -Глаза пусты, глаза беззлобны. - -Недостающий воздух – чушь, пустяк, -Совпал с полночным и привычным зноем. -А если будет что-нибудь не так… -Ты мне поможешь? Нас пока что двое? \ No newline at end of file diff --git a/03.FTP/src/resources/testGet1/file1 b/03.FTP/src/resources/testGet1/file1 deleted file mode 100644 index 4d20f7a..0000000 --- a/03.FTP/src/resources/testGet1/file1 +++ /dev/null @@ -1,8 +0,0 @@ -Я вас любил: любовь еще, быть может, -В душе моей угасла не совсем; -Но пусть она вас больше не тревожит; -Я не хочу печалить вас ничем. -Я вас любил безмолвно, безнадежно, -То робостью, то ревностью томим; -Я вас любил так искренно, так нежно, -Как дай вам бог любимой быть другим. \ No newline at end of file diff --git a/03.FTP/src/resources/testGet1/file2 b/03.FTP/src/resources/testGet1/file2 deleted file mode 100644 index 9d57e16..0000000 --- a/03.FTP/src/resources/testGet1/file2 +++ /dev/null @@ -1,9 +0,0 @@ -Я выжила… Отчаянно, ознобно, -Легко. Светает. Снег сошёл на нет. -Не слышен плач, не ослепляет свет. -Глаза пусты, глаза беззлобны. - -Недостающий воздух – чушь, пустяк, -Совпал с полночным и привычным зноем. -А если будет что-нибудь не так… -Ты мне поможешь? Нас пока что двое? \ No newline at end of file diff --git a/03.FTP/src/resources/testList1/dir1/1 b/03.FTP/src/resources/testList1/dir1/1 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/resources/testList1/dir2/1 b/03.FTP/src/resources/testList1/dir2/1 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/resources/testList1/file1 b/03.FTP/src/resources/testList1/file1 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/resources/testList1/file2 b/03.FTP/src/resources/testList1/file2 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/resources/testList1/file3 b/03.FTP/src/resources/testList1/file3 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/resources/testList2/dir1/1 b/03.FTP/src/resources/testList2/dir1/1 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/resources/testList2/dir2/1 b/03.FTP/src/resources/testList2/dir2/1 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/resources/testList2/dir3/1 b/03.FTP/src/resources/testList2/dir3/1 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/resources/testList2/dir4/1 b/03.FTP/src/resources/testList2/dir4/1 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/resources/testList2/dir5/1 b/03.FTP/src/resources/testList2/dir5/1 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/resources/testList2/file1 b/03.FTP/src/resources/testList2/file1 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/resources/testList2/file2 b/03.FTP/src/resources/testList2/file2 deleted file mode 100644 index e69de29..0000000 diff --git a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java index 7ab94cf..7f81a8e 100644 --- a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java +++ b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java @@ -1,10 +1,14 @@ package ru.spbau.mit.alyokhina; import javafx.util.Pair; +import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -12,11 +16,73 @@ import static org.junit.Assert.assertEquals; -/** Test for client-server connection */ +/** + * Test for client-server connection + */ public class ClientTest { - /** If a server was created, this flag will be true */ + /** + * If a server was created, this flag will be true + */ private static boolean isCreateServer = false; + private static File dirTestList1; + private static File dirTestList2; + private static File dirTestGet; + private static File file1ForTestGet; + private static File file2ForTestGet; + private static File copyFile1ForTestGet; + private static File copyFile2ForTestGet; + @ClassRule + public static TemporaryFolder folderForTest = new TemporaryFolder(); + + @BeforeClass + public static void createFiles() throws IOException { + dirTestList1 = folderForTest.newFolder("testList1"); + folderForTest.newFolder("testList1", "dir1"); + folderForTest.newFolder("testList1", "dir2"); + folderForTest.newFile("testList1/file1"); + folderForTest.newFile("testList1/file2"); + folderForTest.newFile("testList1/file3"); + + dirTestList2 = folderForTest.newFolder("testList2"); + folderForTest.newFolder("testList2", "dir1"); + folderForTest.newFolder("testList2", "dir2"); + folderForTest.newFolder("testList2", "dir3"); + folderForTest.newFolder("testList2", "dir4"); + folderForTest.newFolder("testList2", "dir5"); + folderForTest.newFile("testList2/file1"); + folderForTest.newFile("testList2/file2"); + + dirTestGet = folderForTest.newFolder("testGet1"); + file1ForTestGet = folderForTest.newFile("testGet1/file1"); + file2ForTestGet = folderForTest.newFile("testGet1/file2"); + + copyFile1ForTestGet = folderForTest.newFile("testGet1/copyFile1"); + copyFile2ForTestGet = folderForTest.newFile("testGet1/copyFile2"); + + FileOutputStream fout = new FileOutputStream(file1ForTestGet); + String str = "Я вас любил: любовь еще, быть может,\n" + + "В душе моей угасла не совсем;\n" + + "Но пусть она вас больше не тревожит;\n" + + "Я не хочу печалить вас ничем.\n" + + "Я вас любил безмолвно, безнадежно,\n" + + "То робостью, то ревностью томим;\n" + + "Я вас любил так искренно, так нежно,\n" + + "Как дай вам бог любимой быть другим."; + fout.write(str.getBytes()); + + fout = new FileOutputStream(file2ForTestGet); + str = "Я выжила… Отчаянно, ознобно,\n" + + "Легко. Светает. Снег сошёл на нет.\n" + + "Не слышен плач, не ослепляет свет.\n" + + "Глаза пусты, глаза беззлобны.\n" + + "\n" + + "Недостающий воздух – чушь, пустяк,\n" + + "Совпал с полночным и привычным зноем.\n" + + "А если будет что-нибудь не так…\n" + + "Ты мне поможешь? Нас пока что двое?"; + fout.write(str.getBytes()); + } @Test public void testCreateClientAndServer() { @@ -27,13 +93,14 @@ public void testCreateClientAndServer() { thread.start(); isCreateServer = true; } - Client client = new Client("localhost", 1408); + new Client("localhost", 1408); } catch (IOException e) { System.out.println(e.getMessage()); } } + @Test public void testListWithOneClient() { try { @@ -44,7 +111,7 @@ public void testListWithOneClient() { isCreateServer = true; } Client client = new Client("localhost", 1408); - List> files = client.list("src/resources/testList1"); + List> files = client.list(dirTestList1.getAbsolutePath()); List> rightAnswer = new ArrayList<>(); rightAnswer.add(new Pair<>("dir1", true)); rightAnswer.add(new Pair<>("dir2", true)); @@ -69,8 +136,8 @@ public void testListWithTwoClients() { } Client client1 = new Client("localhost", 1408); Client client2 = new Client("localhost", 1408); - List> files1 = client1.list("src/resources/testList1"); - List> files2 = client2.list("src/resources/testList2"); + List> files1 = client1.list(dirTestList1.getAbsolutePath()); + List> files2 = client2.list(dirTestList2.getAbsolutePath()); List> rightAnswer1 = new ArrayList<>(); rightAnswer1.add(new Pair<>("dir1", true)); rightAnswer1.add(new Pair<>("dir2", true)); @@ -103,7 +170,7 @@ public void testCreateWithNonexistentDirectory() { isCreateServer = true; } Client client = new Client("localhost", 1408); - List> files = client.list("src/resources/testList3"); + List> files = client.list(dirTestList1.getAbsolutePath() + "/test3"); assertEquals(0, files.size()); } catch (IOException e) { @@ -122,9 +189,8 @@ public void testGetWithOneClient() { isCreateServer = true; } Client client = new Client("localhost", 1408); - File copyFile = client.get("src/resources/testGet1/file1", "src/resources/testGet1/copyFile1"); - File file = new File("src/resources/testGet1/file1"); - assertEquals(true, equalFiles(file, copyFile)); + client.get(file1ForTestGet.getAbsolutePath(), copyFile1ForTestGet.getAbsolutePath()); + assertEquals(true, equalFiles(file1ForTestGet, copyFile1ForTestGet)); } catch (IOException e) { System.out.println(e.getMessage()); @@ -142,14 +208,12 @@ public void testGetWithTwoClients() { isCreateServer = true; } Client client1 = new Client("localhost", 1408); - File copyFile1 = client1.get("src/resources/testGet1/file1", "src/resources/testGet1/copyFile1"); - File file1 = new File("src/resources/testGet1/file1"); - assertEquals(true, equalFiles(file1, copyFile1)); + client1.get(file1ForTestGet.getAbsolutePath(), copyFile1ForTestGet.getAbsolutePath()); + assertEquals(true, equalFiles(file1ForTestGet, copyFile1ForTestGet)); Client client2 = new Client("localhost", 1408); - File copyFile2 = client2.get("src/resources/testGet1/file2", "src/resources/testGet1/copyFile2"); - File file2 = new File("src/resources/testGet1/file2"); - assertEquals(true, equalFiles(file2, copyFile2)); + client2.get(file2ForTestGet.getAbsolutePath(), copyFile2ForTestGet.getAbsolutePath()); + assertEquals(true, equalFiles(file2ForTestGet, copyFile2ForTestGet)); } catch (IOException e) { System.out.println(e.getMessage()); @@ -166,7 +230,7 @@ public void testGetWithNonexistentFiles() { isCreateServer = true; } Client client = new Client("localhost", 1408); - File file = client.get("src/resources/testGet1/file3", "src/resources/testGet1/copyFile3"); + File file = client.get(dirTestGet.getAbsolutePath() + "/file3", dirTestGet.getAbsolutePath() + "/copyFile3"); assertEquals(0, file.length()); } catch (IOException e) { @@ -175,7 +239,9 @@ public void testGetWithNonexistentFiles() { } - /** Compare two List> */ + /** + * Compare two List> + */ private static int equalLists(List> a, List> b) { if (a.size() != b.size()) { return -1; @@ -196,7 +262,9 @@ private static int equalLists(List> a, List Date: Wed, 30 May 2018 01:42:16 +0300 Subject: [PATCH 09/10] add JavaDoc for Main --- .../main/java/ru/spbau/mit/alyokhina/Main.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Main.java b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Main.java index 0a5d9e2..def3386 100644 --- a/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Main.java +++ b/03.FTP/src/main/java/ru/spbau/mit/alyokhina/Main.java @@ -8,9 +8,7 @@ import java.util.List; import java.util.Scanner; -/** - * - */ +/** Console UI (list files on server and download files) */ public class Main { public static void main(String[] args) { int type; @@ -28,8 +26,7 @@ public static void main(String[] args) { Thread thread = new Thread(server::start); thread.start(); System.out.println("Сервер создан"); - } - catch (IOException e) { + } catch (IOException e) { System.out.println(e.getMessage()); } } @@ -66,15 +63,15 @@ public static void main(String[] args) { System.out.print("Размер файла = "); System.out.println(file.length()); } - }while (typeRequest != 3); + } while (typeRequest != 3); - } - catch (IOException e) { + } catch (IOException e) { System.out.println(e.getMessage()); } } - }while (type != 3); + } while (type != 3); System.exit(0); } } + From 44c8cf5676453e4b00f177a0d221e09efac3f7b4 Mon Sep 17 00:00:00 2001 From: alyokhina-olya Date: Sat, 16 Jun 2018 15:56:30 +0300 Subject: [PATCH 10/10] remove try/catch from test --- .../ru/spbau/mit/alyokhina/ClientTest.java | 220 ++++++++---------- 1 file changed, 103 insertions(+), 117 deletions(-) diff --git a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java index 7f81a8e..39acb8f 100644 --- a/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java +++ b/03.FTP/src/test/java/ru/spbau/mit/alyokhina/ClientTest.java @@ -85,157 +85,143 @@ public static void createFiles() throws IOException { } @Test - public void testCreateClientAndServer() { - try { - if (!isCreateServer) { - final Server server = new Server(1408); - Thread thread = new Thread(server::start); - thread.start(); - isCreateServer = true; - } - new Client("localhost", 1408); + public void testCreateClientAndServer() throws IOException { - } catch (IOException e) { - System.out.println(e.getMessage()); + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; } + new Client("localhost", 1408); + + } @Test - public void testListWithOneClient() { - try { - if (!isCreateServer) { - final Server server = new Server(1408); - Thread thread = new Thread(server::start); - thread.start(); - isCreateServer = true; - } - Client client = new Client("localhost", 1408); - List> files = client.list(dirTestList1.getAbsolutePath()); - List> rightAnswer = new ArrayList<>(); - rightAnswer.add(new Pair<>("dir1", true)); - rightAnswer.add(new Pair<>("dir2", true)); - rightAnswer.add(new Pair<>("file3", false)); - rightAnswer.add(new Pair<>("file1", false)); - rightAnswer.add(new Pair<>("file2", false)); - assertEquals(rightAnswer.size(), equalLists(rightAnswer, files)); - } catch (IOException e) { - System.out.println(e.getMessage()); + public void testListWithOneClient() throws IOException { + + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; } + Client client = new Client("localhost", 1408); + List> files = client.list(dirTestList1.getAbsolutePath()); + List> rightAnswer = new ArrayList<>(); + rightAnswer.add(new Pair<>("dir1", true)); + rightAnswer.add(new Pair<>("dir2", true)); + rightAnswer.add(new Pair<>("file3", false)); + rightAnswer.add(new Pair<>("file1", false)); + rightAnswer.add(new Pair<>("file2", false)); + assertEquals(rightAnswer.size(), equalLists(rightAnswer, files)); + } @Test - public void testListWithTwoClients() { - try { - if (!isCreateServer) { - final Server server = new Server(1408); - Thread thread = new Thread(server::start); - thread.start(); - isCreateServer = true; - } - Client client1 = new Client("localhost", 1408); - Client client2 = new Client("localhost", 1408); - List> files1 = client1.list(dirTestList1.getAbsolutePath()); - List> files2 = client2.list(dirTestList2.getAbsolutePath()); - List> rightAnswer1 = new ArrayList<>(); - rightAnswer1.add(new Pair<>("dir1", true)); - rightAnswer1.add(new Pair<>("dir2", true)); - rightAnswer1.add(new Pair<>("file3", false)); - rightAnswer1.add(new Pair<>("file1", false)); - rightAnswer1.add(new Pair<>("file2", false)); - assertEquals(rightAnswer1.size(), equalLists(rightAnswer1, files1)); - - List> rightAnswer2 = new ArrayList<>(); - rightAnswer2.add(new Pair<>("dir1", true)); - rightAnswer2.add(new Pair<>("dir2", true)); - rightAnswer2.add(new Pair<>("dir3", true)); - rightAnswer2.add(new Pair<>("dir4", true)); - rightAnswer2.add(new Pair<>("dir5", true)); - rightAnswer2.add(new Pair<>("file1", false)); - rightAnswer2.add(new Pair<>("file2", false)); - assertEquals(rightAnswer2.size(), equalLists(files2, rightAnswer2)); - } catch (IOException e) { - System.out.println(e.getMessage()); + public void testListWithTwoClients() throws IOException { + + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; } + Client client1 = new Client("localhost", 1408); + Client client2 = new Client("localhost", 1408); + List> files1 = client1.list(dirTestList1.getAbsolutePath()); + List> files2 = client2.list(dirTestList2.getAbsolutePath()); + List> rightAnswer1 = new ArrayList<>(); + rightAnswer1.add(new Pair<>("dir1", true)); + rightAnswer1.add(new Pair<>("dir2", true)); + rightAnswer1.add(new Pair<>("file3", false)); + rightAnswer1.add(new Pair<>("file1", false)); + rightAnswer1.add(new Pair<>("file2", false)); + assertEquals(rightAnswer1.size(), equalLists(rightAnswer1, files1)); + + List> rightAnswer2 = new ArrayList<>(); + rightAnswer2.add(new Pair<>("dir1", true)); + rightAnswer2.add(new Pair<>("dir2", true)); + rightAnswer2.add(new Pair<>("dir3", true)); + rightAnswer2.add(new Pair<>("dir4", true)); + rightAnswer2.add(new Pair<>("dir5", true)); + rightAnswer2.add(new Pair<>("file1", false)); + rightAnswer2.add(new Pair<>("file2", false)); + assertEquals(rightAnswer2.size(), equalLists(files2, rightAnswer2)); + } @Test - public void testCreateWithNonexistentDirectory() { - try { - if (!isCreateServer) { - final Server server = new Server(1408); - Thread thread = new Thread(server::start); - thread.start(); - isCreateServer = true; - } - Client client = new Client("localhost", 1408); - List> files = client.list(dirTestList1.getAbsolutePath() + "/test3"); - assertEquals(0, files.size()); + public void testCreateWithNonexistentDirectory() throws IOException { - } catch (IOException e) { - System.out.println(e.getMessage()); + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; } + Client client = new Client("localhost", 1408); + List> files = client.list(dirTestList1.getAbsolutePath() + "/test3"); + assertEquals(0, files.size()); + + } @Test - public void testGetWithOneClient() { - try { - if (!isCreateServer) { - final Server server = new Server(1408); - Thread thread = new Thread(server::start); - thread.start(); - isCreateServer = true; - } - Client client = new Client("localhost", 1408); - client.get(file1ForTestGet.getAbsolutePath(), copyFile1ForTestGet.getAbsolutePath()); - assertEquals(true, equalFiles(file1ForTestGet, copyFile1ForTestGet)); + public void testGetWithOneClient() throws IOException { - } catch (IOException e) { - System.out.println(e.getMessage()); + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; } + Client client = new Client("localhost", 1408); + client.get(file1ForTestGet.getAbsolutePath(), copyFile1ForTestGet.getAbsolutePath()); + assertEquals(true, equalFiles(file1ForTestGet, copyFile1ForTestGet)); + + } @Test - public void testGetWithTwoClients() { - try { - if (!isCreateServer) { - final Server server = new Server(1408); - Thread thread = new Thread(server::start); - thread.start(); - isCreateServer = true; - } - Client client1 = new Client("localhost", 1408); - client1.get(file1ForTestGet.getAbsolutePath(), copyFile1ForTestGet.getAbsolutePath()); - assertEquals(true, equalFiles(file1ForTestGet, copyFile1ForTestGet)); - - Client client2 = new Client("localhost", 1408); - client2.get(file2ForTestGet.getAbsolutePath(), copyFile2ForTestGet.getAbsolutePath()); - assertEquals(true, equalFiles(file2ForTestGet, copyFile2ForTestGet)); + public void testGetWithTwoClients() throws IOException { - } catch (IOException e) { - System.out.println(e.getMessage()); + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; } + Client client1 = new Client("localhost", 1408); + client1.get(file1ForTestGet.getAbsolutePath(), copyFile1ForTestGet.getAbsolutePath()); + assertEquals(true, equalFiles(file1ForTestGet, copyFile1ForTestGet)); + + Client client2 = new Client("localhost", 1408); + client2.get(file2ForTestGet.getAbsolutePath(), copyFile2ForTestGet.getAbsolutePath()); + assertEquals(true, equalFiles(file2ForTestGet, copyFile2ForTestGet)); + + } @Test - public void testGetWithNonexistentFiles() { - try { - if (!isCreateServer) { - final Server server = new Server(1408); - Thread thread = new Thread(server::start); - thread.start(); - isCreateServer = true; - } - Client client = new Client("localhost", 1408); - File file = client.get(dirTestGet.getAbsolutePath() + "/file3", dirTestGet.getAbsolutePath() + "/copyFile3"); - assertEquals(0, file.length()); + public void testGetWithNonexistentFiles() throws IOException { - } catch (IOException e) { - System.out.println(e.getMessage()); + if (!isCreateServer) { + final Server server = new Server(1408); + Thread thread = new Thread(server::start); + thread.start(); + isCreateServer = true; } + Client client = new Client("localhost", 1408); + File file = client.get(dirTestGet.getAbsolutePath() + "/file3", dirTestGet.getAbsolutePath() + "/copyFile3"); + assertEquals(0, file.length()); + + }