diff --git a/OOP-Project.iml b/OOP-Project.iml
index b1907ae..391e562 100644
--- a/OOP-Project.iml
+++ b/OOP-Project.iml
@@ -2,7 +2,12 @@
-
+
+
+ file://$MODULE_DIR$/src/Server/src/main/java/hello/Application.java
+ file://$MODULE_DIR$/src/Client/src/main/java/hello/Application.java
+
+
@@ -13,20 +18,34 @@
+
+
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 547dea2..74ac535 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,6 +32,74 @@
spring-boot-autoconfigure
2.0.5.RELEASE
+
+ org.slf4j
+ slf4j-api
+ 1.7.25
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.25
+
+
+ org.springframework
+ spring-web
+ 5.0.9.RELEASE
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.3
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.25
+
+
+ org.springframework
+ spring-web
+ 5.0.9.RELEASE
+
+
+ org.springframework
+ spring-web
+ 5.0.9.RELEASE
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.10.0
+
+
+ org.testng
+ testng
+ RELEASE
+ compile
+
+
+ org.testng
+ testng
+ 7.0.0-beta3
+ compile
+
+
+ junit
+ junit
+ 4.13-beta-2
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ RELEASE
+ compile
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ 2.9.0
+
diff --git a/src/Client/.idea/compiler.xml b/src/Client/.idea/compiler.xml
new file mode 100644
index 0000000..3d94435
--- /dev/null
+++ b/src/Client/.idea/compiler.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Client/.idea/modules.xml b/src/Client/.idea/modules.xml
new file mode 100644
index 0000000..46edb73
--- /dev/null
+++ b/src/Client/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Client/.idea/modules/Client.iml b/src/Client/.idea/modules/Client.iml
new file mode 100644
index 0000000..642f2c3
--- /dev/null
+++ b/src/Client/.idea/modules/Client.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/src/Client/.idea/modules/Client.main.iml b/src/Client/.idea/modules/Client.main.iml
new file mode 100644
index 0000000..046df4e
--- /dev/null
+++ b/src/Client/.idea/modules/Client.main.iml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Client/.idea/modules/Client.test.iml b/src/Client/.idea/modules/Client.test.iml
new file mode 100644
index 0000000..ae12b55
--- /dev/null
+++ b/src/Client/.idea/modules/Client.test.iml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Client/.idea/vcs.xml b/src/Client/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/src/Client/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Client/src/main/java/hello/Application.java b/src/Client/src/main/java/hello/Application.java
index 0f4d931..c194ad3 100644
--- a/src/Client/src/main/java/hello/Application.java
+++ b/src/Client/src/main/java/hello/Application.java
@@ -1,4 +1,4 @@
-package hello;
+package main.java.hello;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -9,12 +9,14 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
+/*
+Application that connects to the server
+ */
@SpringBootApplication
public class Application {
-
private static final Logger log = LoggerFactory.getLogger(Application.class);
- public static void main(String args[]) {
+ public static void main(String[] args) {
SpringApplication.run(Application.class);
}
@@ -22,14 +24,11 @@ public class Application {
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
-
@Bean
public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
return args -> {
- Message message = restTemplate.getForObject(
- "http://localhost:8080/greeting?name=Ceren", Message.class);
+ Message message = restTemplate.getForObject("http://localhost:8080/greeting?name=Ceren", Message.class);
log.info(message.toString());
-
};
}
}
\ No newline at end of file
diff --git a/src/Client/src/main/java/hello/Message.java b/src/Client/src/main/java/hello/Message.java
index b02965e..b32368e 100644
--- a/src/Client/src/main/java/hello/Message.java
+++ b/src/Client/src/main/java/hello/Message.java
@@ -1,4 +1,4 @@
-package hello;
+package main.java.hello;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@@ -29,9 +29,9 @@ public class Message {
@Override
public String toString() {
- return "Message{" +
- "id='" + id + '\'' +
- ", content=" + content +
- '}';
+ return "Message{"
+ + "id='" + id + '\''
+ + ", content=" + content
+ + '}';
}
}
\ No newline at end of file
diff --git a/src/Client/src/test/java/ApplicationTest.java b/src/Client/src/test/java/ApplicationTest.java
index 25d7734..162aa0f 100644
--- a/src/Client/src/test/java/ApplicationTest.java
+++ b/src/Client/src/test/java/ApplicationTest.java
@@ -1,3 +1,5 @@
+package test.java;
+
import org.junit.Test;
public class ApplicationTest {
diff --git a/src/Client/src/test/java/MessageTest.java b/src/Client/src/test/java/MessageTest.java
index b0ad736..c5fb96f 100644
--- a/src/Client/src/test/java/MessageTest.java
+++ b/src/Client/src/test/java/MessageTest.java
@@ -1,4 +1,8 @@
-import hello.Message;
+package test.java;
+
+
+
+import main.java.hello.Message;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
diff --git a/src/GUI/GUIController.java b/src/GUI/GUIController.java
new file mode 100644
index 0000000..8769a82
--- /dev/null
+++ b/src/GUI/GUIController.java
@@ -0,0 +1,31 @@
+package GUI;
+
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.scene.control.Label;
+
+public class GUIController {
+ private int pressed;
+
+ //put @FXML to let the fxml file know that it can use this label,
+ //kind of the same as with @Test in jUnit tests
+
+ /**
+ *the label to be edited by pressing the button
+ */
+ @FXML
+ private Label txtLabel;
+
+ /**
+ * increments the counter when the button is presssed
+ * @param event an event that happens (button is clicked)
+ * @throws Exception
+ */
+ public void incrementLabel(ActionEvent event) throws Exception {
+// System.out.println("pressed button");
+ pressed++;
+ String labeltext = "Button pressed " + pressed + " times!";
+ //set the text of the label to the string above
+ txtLabel.setText(labeltext);
+ }
+}
diff --git a/src/GUI/GUIMain.fxml b/src/GUI/GUIMain.fxml
new file mode 100644
index 0000000..94ef759
--- /dev/null
+++ b/src/GUI/GUIMain.fxml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/GUI/GUIMain.java b/src/GUI/GUIMain.java
new file mode 100644
index 0000000..a728bea
--- /dev/null
+++ b/src/GUI/GUIMain.java
@@ -0,0 +1,38 @@
+package GUI;
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+
+public class GUIMain extends Application {
+
+ /**
+ * launches the stage
+ * @param args
+ */
+ public static void main(String[] args) {
+ launch(args);
+ }
+
+ /**
+ *
+ * @param primaryStage the stage to be started
+ * @throws Exception when the fxml file can't be found
+ */
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+ //link fxml file
+ Parent root = FXMLLoader.load(getClass().getResource("Login.fxml"));
+ //set the scene
+ Scene scene = new Scene(root, 400, 400);
+ //link the stylesheet with the scene
+ scene.getStylesheets().add(getClass().getResource("LoginStyle.css").toExternalForm());
+
+ //show the stagw
+ primaryStage.setScene(scene);
+ primaryStage.setTitle("login");
+ primaryStage.show();
+ }
+}
diff --git a/src/GUI/GUIStyle.css b/src/GUI/GUIStyle.css
new file mode 100644
index 0000000..642022f
--- /dev/null
+++ b/src/GUI/GUIStyle.css
@@ -0,0 +1,3 @@
+.root {
+ -fx-background-color: #eef9ee;
+}
\ No newline at end of file
diff --git a/src/GUI/Login.fxml b/src/GUI/Login.fxml
new file mode 100644
index 0000000..b943647
--- /dev/null
+++ b/src/GUI/Login.fxml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/GUI/LoginController.java b/src/GUI/LoginController.java
new file mode 100644
index 0000000..bbbb9a7
--- /dev/null
+++ b/src/GUI/LoginController.java
@@ -0,0 +1,69 @@
+package GUI;
+
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.PasswordField;
+import javafx.scene.control.TextField;
+import javafx.scene.paint.Color;
+import javafx.stage.Stage;
+
+
+public class LoginController {
+
+ //set labels and textfields, with the @FXML line to let the fxml file know it can use these
+ @FXML
+ private Label statustext;
+
+ @FXML
+ private TextField usertext;
+
+ @FXML
+ private PasswordField passwordField;
+
+ @FXML
+ private Button loginbutton;
+
+ /**
+ * redirects to the main stage when the login credentials are correct
+ * @param event the entered username and password, and clicking the button
+ * @throws Exception
+ * @author Sem van der Hoeven
+ */
+ public void Login(ActionEvent event) throws Exception {
+ //if the entered username and password are correct
+ if (usertext.getText().equals("user") && passwordField.getText().equals("pass")) {
+ //display green login succes message
+ statustext.setText("Login success!");
+ statustext.setTextFill(Color.GREEN);
+ //and open next window
+ openMainWindow();
+
+ } else {
+ //else display red login failed message
+ statustext.setText("Login failed! try again!");
+ statustext.setTextFill(Color.RED);
+ }
+
+ }
+
+ public void openMainWindow() throws Exception {
+ //basically the same thing as in the main class: open a new stage
+ Stage primaryStage = new Stage();
+ //link fxml file
+ Parent root = FXMLLoader.load(getClass().getResource("GUIMain.fxml"));
+ //set the scene
+ Scene scene = new Scene(root, 800, 600);
+ //link the stylesheet with the scene
+ scene.getStylesheets().add(getClass().getResource("GUIStyle.css").toExternalForm());
+
+ //show the stage
+ primaryStage.setScene(scene);
+ primaryStage.setTitle("oop project group 43");
+ primaryStage.show();
+ }
+}
diff --git a/src/GUI/LoginStyle.css b/src/GUI/LoginStyle.css
new file mode 100644
index 0000000..2205911
--- /dev/null
+++ b/src/GUI/LoginStyle.css
@@ -0,0 +1,6 @@
+.root {
+ -fx-background-color: #91daff;
+}
+#usertext {
+ -fx-text-fill: #670eed;
+}
\ No newline at end of file
diff --git a/src/Server/.idea/encodings.xml b/src/Server/.idea/encodings.xml
new file mode 100644
index 0000000..15a15b2
--- /dev/null
+++ b/src/Server/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Server/.idea/misc.xml b/src/Server/.idea/misc.xml
new file mode 100644
index 0000000..9870be1
--- /dev/null
+++ b/src/Server/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Server/src/main/java/hello/Greeting.java b/src/Server/src/main/java/hello/Greeting.java
index 4868c27..b4d6218 100644
--- a/src/Server/src/main/java/hello/Greeting.java
+++ b/src/Server/src/main/java/hello/Greeting.java
@@ -1,4 +1,4 @@
-package hello;
+package main.java.hello;
public class Greeting {
diff --git a/src/Server/src/main/java/hello/GreetingController.java b/src/Server/src/main/java/hello/GreetingController.java
index 49499f6..9de358f 100644
--- a/src/Server/src/main/java/hello/GreetingController.java
+++ b/src/Server/src/main/java/hello/GreetingController.java
@@ -1,10 +1,11 @@
-package hello;
+package main.java.hello;
-import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
+import java.util.concurrent.atomic.AtomicLong;
+
@RestController
public class GreetingController {
diff --git a/src/Server/src/main/java/hello/Application.java b/src/Server/src/main/java/hello/ServerApplication.java
similarity index 62%
rename from src/Server/src/main/java/hello/Application.java
rename to src/Server/src/main/java/hello/ServerApplication.java
index 09ac9d8..51639ef 100644
--- a/src/Server/src/main/java/hello/Application.java
+++ b/src/Server/src/main/java/hello/ServerApplication.java
@@ -1,12 +1,12 @@
-package hello;
+package main.java.hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
-public class Application {
+public class ServerApplication {
public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
+ SpringApplication.run(ServerApplication.class, args);
}
}
\ No newline at end of file
diff --git a/src/Server/src/test/java/GreetingControllerTest.java b/src/Server/src/test/java/GreetingControllerTest.java
index 6a147e4..97977a9 100644
--- a/src/Server/src/test/java/GreetingControllerTest.java
+++ b/src/Server/src/test/java/GreetingControllerTest.java
@@ -1,14 +1,15 @@
-import hello.Greeting;
-import hello.GreetingController;
-import org.junit.jupiter.api.Test;
+package test.java;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import main.java.hello.GreetingController;
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
public class GreetingControllerTest {
@Test
void nullTest() {
GreetingController controller = new GreetingController();
- assertThat(controller).isNotNull();
+// Assert.assertThat(controller).isNotNull();
+ Assert.assertNotNull(controller);
}
}
diff --git a/src/Server/src/test/java/GreetingTest.java b/src/Server/src/test/java/GreetingTest.java
index 94c4731..8e82f32 100644
--- a/src/Server/src/test/java/GreetingTest.java
+++ b/src/Server/src/test/java/GreetingTest.java
@@ -1,7 +1,8 @@
-import hello.Greeting;
-import org.junit.jupiter.api.Test;
+package test.java;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import main.java.hello.Greeting;
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
public class GreetingTest {
@Test
@@ -9,7 +10,9 @@ public class GreetingTest {
Greeting greeting = new Greeting(1, "hello");
long id = greeting.getId();
String content = greeting.getContent();
- assertThat(id).isEqualTo(1);
- assertThat(content).isEqualTo(content);
+// assertThat(id).isEqualTo(1);
+ Assert.assertEquals(id, 1);
+// assertThat(content).isEqualTo(content);
+ Assert.assertEquals(content,content);
}
}
\ No newline at end of file
diff --git a/src/Server/src/test/java/ApplicationTest.java b/src/Server/src/test/java/ServerApplicationTest.java
similarity index 53%
rename from src/Server/src/test/java/ApplicationTest.java
rename to src/Server/src/test/java/ServerApplicationTest.java
index c5e9bd9..d611083 100644
--- a/src/Server/src/test/java/ApplicationTest.java
+++ b/src/Server/src/test/java/ServerApplicationTest.java
@@ -1,5 +1,7 @@
+package test.java;
+
import org.junit.Test;
-public class ApplicationTest {
+public class ServerApplicationTest {
@Test
public void main() {
}