From 5182612b765d5772f6dfc0d74ac0001ff7094435 Mon Sep 17 00:00:00 2001 From: binsky Date: Wed, 26 Jan 2022 09:44:59 +0100 Subject: [PATCH 1/9] add jar file configuration to pom.xml --- pom.xml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index d27a545..4958ea9 100644 --- a/pom.xml +++ b/pom.xml @@ -55,24 +55,22 @@ org.apache.maven.plugins - maven-surefire-plugin - 2.19.1 + maven-jar-plugin - - - org.junit.platform - junit-platform-surefire-provider - 1.0.1 - org.junit.jupiter junit-jupiter-engine 5.7.0 - + + + + true + PasswordManager + + + From 4ab40a8edb63bcaa107dd8b830c1a38b8ceedff6 Mon Sep 17 00:00:00 2001 From: binsky Date: Wed, 26 Jan 2022 09:45:31 +0100 Subject: [PATCH 2/9] add basic storage class and interface --- src/main/java/Storage.java | 11 +++++++++++ src/main/java/StorageInterface.java | 4 ++++ src/test/java/StorageTest.java | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 src/main/java/Storage.java create mode 100644 src/main/java/StorageInterface.java create mode 100644 src/test/java/StorageTest.java diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java new file mode 100644 index 0000000..104ed41 --- /dev/null +++ b/src/main/java/Storage.java @@ -0,0 +1,11 @@ +public class Storage implements StorageInterface{ + @Override + public void export() { + + } + + @Override + public void load() { + + } +} diff --git a/src/main/java/StorageInterface.java b/src/main/java/StorageInterface.java new file mode 100644 index 0000000..796d12b --- /dev/null +++ b/src/main/java/StorageInterface.java @@ -0,0 +1,4 @@ +public interface StorageInterface { + public void export(); + public void load(); +} diff --git a/src/test/java/StorageTest.java b/src/test/java/StorageTest.java new file mode 100644 index 0000000..1d67ee7 --- /dev/null +++ b/src/test/java/StorageTest.java @@ -0,0 +1,19 @@ +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class StorageTest { + + @Test + void constructor() { + assertInstanceOf(Storage.class, new Storage()); + } + + @Test + void export() { + } + + @Test + void load() { + } +} \ No newline at end of file From c3a4d47d307c33b9a1e957eb5b04d45b6e6b880b Mon Sep 17 00:00:00 2001 From: binsky Date: Wed, 26 Jan 2022 09:57:11 +0100 Subject: [PATCH 3/9] add writeFile storage method --- src/main/java/Storage.java | 9 ++++++++- src/test/java/StorageTest.java | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java index 104ed41..e5fc3de 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/Storage.java @@ -1,4 +1,4 @@ -public class Storage implements StorageInterface{ +public class Storage implements StorageInterface { @Override public void export() { @@ -8,4 +8,11 @@ public class Storage implements StorageInterface{ public void load() { } + + public boolean writeFile(String path, String content) { + if (!path.isEmpty() && !content.isEmpty()) { + return true; + } + return false; + } } diff --git a/src/test/java/StorageTest.java b/src/test/java/StorageTest.java index 1d67ee7..b1d6098 100644 --- a/src/test/java/StorageTest.java +++ b/src/test/java/StorageTest.java @@ -1,12 +1,20 @@ +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; class StorageTest { + static Storage storage; + + @BeforeAll + static void init() { + storage = new Storage(); + } + @Test void constructor() { - assertInstanceOf(Storage.class, new Storage()); + assertInstanceOf(Storage.class, storage); } @Test @@ -16,4 +24,9 @@ class StorageTest { @Test void load() { } + + @Test + void writeFile() { + assertTrue(storage.writeFile("/tmp/test.txt", "test")); + } } \ No newline at end of file From 6e8aefc25f40033e6eedc444feec3931ed5ae4f9 Mon Sep 17 00:00:00 2001 From: binsky Date: Wed, 26 Jan 2022 10:06:32 +0100 Subject: [PATCH 4/9] implement writeFile storage method --- src/main/java/Storage.java | 13 +++++++++++++ src/test/java/StorageTest.java | 16 +++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java index e5fc3de..fdbaf25 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/Storage.java @@ -1,3 +1,7 @@ +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; + public class Storage implements StorageInterface { @Override public void export() { @@ -11,6 +15,15 @@ public class Storage implements StorageInterface { public boolean writeFile(String path, String content) { if (!path.isEmpty() && !content.isEmpty()) { + try { + BufferedWriter writer = new BufferedWriter(new FileWriter(path, false)); + writer.append(content); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + return true; } return false; diff --git a/src/test/java/StorageTest.java b/src/test/java/StorageTest.java index b1d6098..5ef0e42 100644 --- a/src/test/java/StorageTest.java +++ b/src/test/java/StorageTest.java @@ -1,17 +1,27 @@ +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import java.io.File; + import static org.junit.jupiter.api.Assertions.*; class StorageTest { static Storage storage; + static String testFilePath = "/tmp/test.txt"; @BeforeAll static void init() { storage = new Storage(); } + @AfterAll + static void clear() { + File myObj = new File(testFilePath); + myObj.delete(); + } + @Test void constructor() { assertInstanceOf(Storage.class, storage); @@ -27,6 +37,10 @@ class StorageTest { @Test void writeFile() { - assertTrue(storage.writeFile("/tmp/test.txt", "test")); + String content = "test"; + assertTrue(storage.writeFile(testFilePath, content)); + + File f = new File(testFilePath); + assertTrue(f.isFile()); } } \ No newline at end of file From c652890b0498ccd9f25c528eccc809a46eb4cbd5 Mon Sep 17 00:00:00 2001 From: binsky Date: Wed, 26 Jan 2022 10:11:57 +0100 Subject: [PATCH 5/9] refactor storage test for windows systems --- src/test/java/StorageTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/StorageTest.java b/src/test/java/StorageTest.java index 5ef0e42..4dddcbd 100644 --- a/src/test/java/StorageTest.java +++ b/src/test/java/StorageTest.java @@ -14,6 +14,10 @@ class StorageTest { @BeforeAll static void init() { storage = new Storage(); + + if (System.getProperty("os.name").toLowerCase().contains("win")) { + testFilePath = "C:\\test.txt"; + } } @AfterAll From ac48e8f8f689fb161092e166fd89e72b2a590f24 Mon Sep 17 00:00:00 2001 From: binsky Date: Wed, 26 Jan 2022 10:25:41 +0100 Subject: [PATCH 6/9] add build instructions, dependencies and contributors to readme --- README.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fd63811..164d20a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,24 @@ -# ciip-gruppe8-password-manager +# ciip-grp8-password-manager +## Dependencies +- productive + - java 11 +- development + - java 11 + - maven + +## Build jar file artifact +- requires development dependencies + +`mvn package` + +## Run jar file artifact +- requires productive dependencies +- requires a built jar file to run + +`java -jar target/ciip-grp8-password-manager-1.0-SNAPSHOT.jar` + +## Contributors +- binsky - Timo Triebensky +- fdai6352 - Pascal Schubert +- Claud11 - Claudia Metzler From 933252a64510a48c6e1ad2d0ab93b89edbae4702 Mon Sep 17 00:00:00 2001 From: binsky Date: Wed, 26 Jan 2022 10:35:35 +0100 Subject: [PATCH 7/9] implement readFile storage method --- src/main/java/Storage.java | 25 ++++++++++++++++++++++--- src/test/java/StorageTest.java | 12 ++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java index fdbaf25..bf2e353 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/Storage.java @@ -1,6 +1,5 @@ -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.IOException; +import java.io.*; +import java.util.Scanner; public class Storage implements StorageInterface { @Override @@ -28,4 +27,24 @@ public class Storage implements StorageInterface { } return false; } + + public String readFile(String path) { + if (!path.isEmpty()) { + StringBuilder data = new StringBuilder(); + try { + File f = new File(path); + Scanner myReader = new Scanner(f); + while (myReader.hasNextLine()) { + data.append(myReader.nextLine()); + } + myReader.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + return null; + } + + return data.toString(); + } + return null; + } } diff --git a/src/test/java/StorageTest.java b/src/test/java/StorageTest.java index 4dddcbd..4f7c595 100644 --- a/src/test/java/StorageTest.java +++ b/src/test/java/StorageTest.java @@ -47,4 +47,16 @@ class StorageTest { File f = new File(testFilePath); assertTrue(f.isFile()); } + + @Test + void readFile() { + String content = "test"; + + File f = new File(testFilePath); + if (!f.isFile()) { + assertTrue(storage.writeFile(testFilePath, content)); + } + + assertEquals(content, storage.readFile(testFilePath)); + } } \ No newline at end of file From 30b9d3e4763efb101bd9c93390044abf65936919 Mon Sep 17 00:00:00 2001 From: binsky Date: Wed, 26 Jan 2022 10:41:02 +0100 Subject: [PATCH 8/9] add claudias fdai number to readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 164d20a..471c5eb 100644 --- a/README.md +++ b/README.md @@ -21,4 +21,4 @@ ## Contributors - binsky - Timo Triebensky - fdai6352 - Pascal Schubert -- Claud11 - Claudia Metzler +- fdai5728 - Claudia Metzler From a81194074a49eabe723e7ad599411d45545a5b1d Mon Sep 17 00:00:00 2001 From: binsky Date: Wed, 26 Jan 2022 10:50:37 +0100 Subject: [PATCH 9/9] fix pom.xml artifact definition --- pom.xml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4958ea9..5e9fa46 100644 --- a/pom.xml +++ b/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.ciip-gruppe8-password-manager - ciip-gruppe8-password-manager + org.ciip-grp8-password-manager + ciip-grp8-password-manager 1.0-SNAPSHOT @@ -53,9 +53,28 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + + + org.junit.platform + junit-platform-surefire-provider + 1.0.1 + + + org.junit.jupiter + junit-jupiter-engine + 5.7.0 + + + org.apache.maven.plugins maven-jar-plugin + 2.4 org.junit.jupiter