From 5cf6e48004d7af71786ccae3c8225167067f11c4 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Thu, 8 Feb 2024 16:38:15 +0100 Subject: [PATCH 01/25] test_ Konstruktortest --- pom.xml | 57 ++++++++++++++++++------------- src/test/java/ChatServerTest.java | 26 ++++++++++++++ 2 files changed, 59 insertions(+), 24 deletions(-) create mode 100644 src/test/java/ChatServerTest.java diff --git a/pom.xml b/pom.xml index 21c5d05..d427c1a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,24 +1,33 @@ - - 4.0.0 - org.progmethoden - java-chat - 0.0.1-SNAPSHOT - - - - - com.google.code.gson - gson - 2.10.1 - - - - org.mockito - mockito-core - 4.1.10 - test - - - - - \ No newline at end of file + + + RELEASE + + + 4.0.0 + org.progmethoden + java-chat + 0.0.1-SNAPSHOT + + + + + com.google.code.gson + gson + 2.10.1 + + + junit + junit + 4.13.2 + test + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter-version} + test + + + + + diff --git a/src/test/java/ChatServerTest.java b/src/test/java/ChatServerTest.java new file mode 100644 index 0000000..80b714d --- /dev/null +++ b/src/test/java/ChatServerTest.java @@ -0,0 +1,26 @@ +import static org.junit.jupiter.api.Assertions.*; + +import java.util.List; + +import org.junit.jupiter.api.Test; + +class ChatServerTest { + + @Test + public void testConstructor() { + // Arrange + ChatServer chatServer = null; + + // Act + try { + chatServer = new ChatServer(1234); + } catch (Exception e) { + fail("Exception occurred: " + e.getMessage()); + } + + // Assert + assertNotNull(chatServer); + } +} + + From 962bc1688aa40702fe1ac590060b54923243b402 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Thu, 8 Feb 2024 22:57:55 +0100 Subject: [PATCH 02/25] test_lastMessage Test --- src/main/java/ClientHandler.java | 5 +++++ src/test/java/ChatServerTest.java | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/ClientHandler.java b/src/main/java/ClientHandler.java index e4104da..45570aa 100644 --- a/src/main/java/ClientHandler.java +++ b/src/main/java/ClientHandler.java @@ -9,6 +9,7 @@ public class ClientHandler implements Runnable { private String name; private BufferedReader fromClientReader; private PrintWriter toClientWriter; + private String lastMessage; // Constructor for ClientHandler public ClientHandler(ChatServer chatServer, Socket connectionToClient) { @@ -33,6 +34,7 @@ public class ClientHandler implements Runnable { while (message!=null) { // Broadcast the client's message to all connected clients chatServer.broadcastMessage(name + ": " + message); + lastMessage = message; message = fromClientReader.readLine(); } } @@ -64,4 +66,7 @@ public class ClientHandler implements Runnable { toClientWriter.println(message); // Send the message to the client toClientWriter.flush(); // Flush the stream } + public String getLastMessage() { + return lastMessage; + } } diff --git a/src/test/java/ChatServerTest.java b/src/test/java/ChatServerTest.java index 80b714d..4b7eb79 100644 --- a/src/test/java/ChatServerTest.java +++ b/src/test/java/ChatServerTest.java @@ -21,6 +21,24 @@ class ChatServerTest { // Assert assertNotNull(chatServer); } + @Test + public void testBroadcastMessage() { + // Arrange + ChatServer chatServer = new ChatServer(1234); + ClientHandler client1 = new ClientHandler(chatServer, null); + ClientHandler client2 = new ClientHandler(chatServer, null); + chatServer.getClients().add(client1); + chatServer.getClients().add(client2); + + // Act + chatServer.broadcastMessage("Test message"); + + // Assert + List clients = chatServer.getClients(); + for (ClientHandler client : clients) { + assertEquals("Test message", client.getLastMessage()); + } + } } From 62d3eb5578a363ae0a8c640bbed3c84bf674fbf2 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 01:37:30 +0100 Subject: [PATCH 03/25] neue ChatGUI(noch nicht eingebunden --- src/main/java/ChatGUI.java | 52 +++++++++++++++++++++++++++++++ src/main/java/ClientHandler.java | 1 + src/test/java/ChatServerTest.java | 44 -------------------------- 3 files changed, 53 insertions(+), 44 deletions(-) create mode 100644 src/main/java/ChatGUI.java delete mode 100644 src/test/java/ChatServerTest.java diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java new file mode 100644 index 0000000..852f623 --- /dev/null +++ b/src/main/java/ChatGUI.java @@ -0,0 +1,52 @@ +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +public class ChatGUI implements ActionListener { + + JTextField inputTextField = new JTextField(); + JTextArea outputTextArea = new JTextArea(); + + JFrame gui; + + public ChatGUI() { + gui = new JFrame(); + + gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + gui.setTitle("java-chat"); + + gui.setLayout(new BorderLayout()); + + + JScrollPane outputScrollPane = new JScrollPane(outputTextArea); + gui.add(outputScrollPane, BorderLayout.CENTER); + + inputTextField.setPreferredSize(new Dimension(0, 30)); + gui.add(inputTextField, BorderLayout.SOUTH); + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + int quarterWidth = screenSize.width / 2; + int quarterHeight = screenSize.height / 2; + gui.setSize(quarterWidth, quarterHeight); + gui.setVisible(true); + } + + public static void main(String[] args) { + + new ChatGUI(); + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + } + + +} diff --git a/src/main/java/ClientHandler.java b/src/main/java/ClientHandler.java index 45570aa..b30e37a 100644 --- a/src/main/java/ClientHandler.java +++ b/src/main/java/ClientHandler.java @@ -66,6 +66,7 @@ public class ClientHandler implements Runnable { toClientWriter.println(message); // Send the message to the client toClientWriter.flush(); // Flush the stream } + //Test method public String getLastMessage() { return lastMessage; } diff --git a/src/test/java/ChatServerTest.java b/src/test/java/ChatServerTest.java deleted file mode 100644 index 4b7eb79..0000000 --- a/src/test/java/ChatServerTest.java +++ /dev/null @@ -1,44 +0,0 @@ -import static org.junit.jupiter.api.Assertions.*; - -import java.util.List; - -import org.junit.jupiter.api.Test; - -class ChatServerTest { - - @Test - public void testConstructor() { - // Arrange - ChatServer chatServer = null; - - // Act - try { - chatServer = new ChatServer(1234); - } catch (Exception e) { - fail("Exception occurred: " + e.getMessage()); - } - - // Assert - assertNotNull(chatServer); - } - @Test - public void testBroadcastMessage() { - // Arrange - ChatServer chatServer = new ChatServer(1234); - ClientHandler client1 = new ClientHandler(chatServer, null); - ClientHandler client2 = new ClientHandler(chatServer, null); - chatServer.getClients().add(client1); - chatServer.getClients().add(client2); - - // Act - chatServer.broadcastMessage("Test message"); - - // Assert - List clients = chatServer.getClients(); - for (ClientHandler client : clients) { - assertEquals("Test message", client.getLastMessage()); - } - } -} - - From 2d6074f6ae5177b3254fe20716d589170637313e Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 01:43:21 +0100 Subject: [PATCH 04/25] =?UTF-8?q?refactoring:=20Einr=C3=BCcken=20und=20Kom?= =?UTF-8?q?mentare?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 59 ++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 852f623..109f0f1 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -11,42 +11,45 @@ import javax.swing.JTextField; public class ChatGUI implements ActionListener { - JTextField inputTextField = new JTextField(); - JTextArea outputTextArea = new JTextArea(); - - JFrame gui; - - public ChatGUI() { - gui = new JFrame(); - - gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - gui.setTitle("java-chat"); - - gui.setLayout(new BorderLayout()); - - - JScrollPane outputScrollPane = new JScrollPane(outputTextArea); - gui.add(outputScrollPane, BorderLayout.CENTER); - - inputTextField.setPreferredSize(new Dimension(0, 30)); - gui.add(inputTextField, BorderLayout.SOUTH); - - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - int quarterWidth = screenSize.width / 2; - int quarterHeight = screenSize.height / 2; - gui.setSize(quarterWidth, quarterHeight); + JTextField inputTextField = new JTextField(); + JTextArea outputTextArea = new JTextArea(); + + JFrame gui; + + public ChatGUI() { + gui = new JFrame(); + + // Set up the main frame + gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + gui.setTitle("java-chat"); + + gui.setLayout(new BorderLayout()); + + // Set up the output text area with scrolling + JScrollPane outputScrollPane = new JScrollPane(outputTextArea); + gui.add(outputScrollPane, BorderLayout.CENTER); + + // Set up the input text field + inputTextField.setPreferredSize(new Dimension(0, 30)); + gui.add(inputTextField, BorderLayout.SOUTH); + + // Set the size of the GUI to be a quarter of the screen size + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + int quarterWidth = screenSize.width / 2; + int quarterHeight = screenSize.height / 2; + gui.setSize(quarterWidth, quarterHeight); gui.setVisible(true); - } - + } + public static void main(String[] args) { new ChatGUI(); } + @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub - + } - } From 3048bfdef80163ce08aeebc82c9cd8992c425337 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 01:46:50 +0100 Subject: [PATCH 05/25] =?UTF-8?q?menue-Bar=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 109f0f1..645f2c4 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -5,6 +5,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; @@ -25,6 +27,13 @@ public class ChatGUI implements ActionListener { gui.setLayout(new BorderLayout()); + JMenuBar bar = new JMenuBar(); + gui.setJMenuBar(bar); + + JMenu menu = new JMenu("File"); + + bar.add(menu); + // Set up the output text area with scrolling JScrollPane outputScrollPane = new JScrollPane(outputTextArea); gui.add(outputScrollPane, BorderLayout.CENTER); From 5e256aee19856cc04331a64354ff392c50bfbd71 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 01:50:55 +0100 Subject: [PATCH 06/25] =?UTF-8?q?Menue=20Punkte=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 645f2c4..33a6cb7 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -7,12 +7,14 @@ import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; +import javax.swing.JMenuItem; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; public class ChatGUI implements ActionListener { - + + JMenuItem exit = new JMenuItem("Exit"); JTextField inputTextField = new JTextField(); JTextArea outputTextArea = new JTextArea(); @@ -29,8 +31,13 @@ public class ChatGUI implements ActionListener { JMenuBar bar = new JMenuBar(); gui.setJMenuBar(bar); + + JMenu options = new JMenu("options"); JMenu menu = new JMenu("File"); + menu.add(exit); + menu.add(options); + bar.add(menu); bar.add(menu); From c5487e0bd1b47c4959992eb304d5ce43053e4add Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 01:53:43 +0100 Subject: [PATCH 07/25] =?UTF-8?q?action=20f=C3=BCr=20exitbutton=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 33a6cb7..124332e 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -38,6 +38,7 @@ public class ChatGUI implements ActionListener { menu.add(exit); menu.add(options); bar.add(menu); + exit.addActionListener(this); bar.add(menu); @@ -64,7 +65,9 @@ public class ChatGUI implements ActionListener { @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub + if (e.getSource() == exit) { + System.exit(0); + } } From e1ea0eaa7917e42a416afddffb4a3812d78643ab Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 01:55:42 +0100 Subject: [PATCH 08/25] =?UTF-8?q?Logik=20f=C3=BCr=20Eingabe-Ausgabe=20hinz?= =?UTF-8?q?ugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 124332e..f6d09d7 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -50,6 +50,8 @@ public class ChatGUI implements ActionListener { inputTextField.setPreferredSize(new Dimension(0, 30)); gui.add(inputTextField, BorderLayout.SOUTH); + inputTextField.addActionListener(this); + // Set the size of the GUI to be a quarter of the screen size Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int quarterWidth = screenSize.width / 2; @@ -68,7 +70,12 @@ public class ChatGUI implements ActionListener { if (e.getSource() == exit) { System.exit(0); } + if (e.getSource() == inputTextField) { + String inputText = inputTextField.getText(); + outputTextArea.append(inputText + "\n"); + inputTextField.setText(""); } } +} From caa676b5a4f8e864ef3497e5d17d0a37635ef421 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 01:58:21 +0100 Subject: [PATCH 09/25] =?UTF-8?q?farben=20als=20men=C3=BCpunkte=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index f6d09d7..0781edc 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -15,6 +15,10 @@ import javax.swing.JTextField; public class ChatGUI implements ActionListener { JMenuItem exit = new JMenuItem("Exit"); + JMenuItem black = new JMenuItem("black"); + JMenuItem red = new JMenuItem("red"); + JMenuItem blue = new JMenuItem("blue"); + JMenuItem green = new JMenuItem("green"); JTextField inputTextField = new JTextField(); JTextArea outputTextArea = new JTextArea(); @@ -33,11 +37,19 @@ public class ChatGUI implements ActionListener { gui.setJMenuBar(bar); JMenu options = new JMenu("options"); + JMenu colors = new JMenu("font-colors"); JMenu menu = new JMenu("File"); menu.add(exit); menu.add(options); bar.add(menu); + options.add(colors); + + colors.add(black); + colors.add(red); + colors.add(blue); + colors.add(green); + exit.addActionListener(this); bar.add(menu); From 9686707419612ab0f685efc4b22ae157f6789986 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:00:47 +0100 Subject: [PATCH 10/25] =?UTF-8?q?Schriftfarboptionen=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 0781edc..3651223 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -1,4 +1,5 @@ import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; @@ -50,6 +51,11 @@ public class ChatGUI implements ActionListener { colors.add(blue); colors.add(green); + red.addActionListener(this); + blue.addActionListener(this); + black.addActionListener(this); + green.addActionListener(this); + exit.addActionListener(this); bar.add(menu); @@ -86,6 +92,16 @@ public class ChatGUI implements ActionListener { String inputText = inputTextField.getText(); outputTextArea.append(inputText + "\n"); inputTextField.setText(""); + } + if (e.getSource() == red) { + outputTextArea.setForeground(Color.RED); + } + if (e.getSource() == blue) { + outputTextArea.setForeground(Color.BLUE); + }else if (e.getSource() == black) { + outputTextArea.setForeground(Color.BLACK); + } else if (e.getSource() == green) { + outputTextArea.setForeground(Color.GREEN); } From 080c6393cd127f111b4173c623a17ec112826c41 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:02:37 +0100 Subject: [PATCH 11/25] refactoring: Verschoerung Code --- src/main/java/ChatGUI.java | 98 +++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 3651223..b33e153 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -14,12 +14,12 @@ import javax.swing.JTextArea; import javax.swing.JTextField; public class ChatGUI implements ActionListener { - + JMenuItem exit = new JMenuItem("Exit"); - JMenuItem black = new JMenuItem("black"); - JMenuItem red = new JMenuItem("red"); - JMenuItem blue = new JMenuItem("blue"); - JMenuItem green = new JMenuItem("green"); + JMenuItem black = new JMenuItem("black"); + JMenuItem red = new JMenuItem("red"); + JMenuItem blue = new JMenuItem("blue"); + JMenuItem green = new JMenuItem("green"); JTextField inputTextField = new JTextField(); JTextArea outputTextArea = new JTextArea(); @@ -27,49 +27,49 @@ public class ChatGUI implements ActionListener { public ChatGUI() { gui = new JFrame(); - + // Set up the main frame gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gui.setTitle("java-chat"); gui.setLayout(new BorderLayout()); - + JMenuBar bar = new JMenuBar(); - gui.setJMenuBar(bar); - - JMenu options = new JMenu("options"); - JMenu colors = new JMenu("font-colors"); - - JMenu menu = new JMenu("File"); - menu.add(exit); - menu.add(options); - bar.add(menu); - options.add(colors); - - colors.add(black); - colors.add(red); - colors.add(blue); - colors.add(green); - - red.addActionListener(this); - blue.addActionListener(this); - black.addActionListener(this); - green.addActionListener(this); - - exit.addActionListener(this); - - bar.add(menu); - + gui.setJMenuBar(bar); + + JMenu options = new JMenu("options"); + JMenu colors = new JMenu("font-colors"); + + JMenu menu = new JMenu("File"); + menu.add(exit); + menu.add(options); + bar.add(menu); + options.add(colors); + + colors.add(black); + colors.add(red); + colors.add(blue); + colors.add(green); + + red.addActionListener(this); + blue.addActionListener(this); + black.addActionListener(this); + green.addActionListener(this); + + exit.addActionListener(this); + + bar.add(menu); + // Set up the output text area with scrolling JScrollPane outputScrollPane = new JScrollPane(outputTextArea); gui.add(outputScrollPane, BorderLayout.CENTER); - + // Set up the input text field inputTextField.setPreferredSize(new Dimension(0, 30)); gui.add(inputTextField, BorderLayout.SOUTH); - + inputTextField.addActionListener(this); - + // Set the size of the GUI to be a quarter of the screen size Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int quarterWidth = screenSize.width / 2; @@ -89,21 +89,21 @@ public class ChatGUI implements ActionListener { System.exit(0); } if (e.getSource() == inputTextField) { - String inputText = inputTextField.getText(); - outputTextArea.append(inputText + "\n"); - inputTextField.setText(""); + String inputText = inputTextField.getText(); + outputTextArea.append(inputText + "\n"); + inputTextField.setText(""); + } + if (e.getSource() == red) { + outputTextArea.setForeground(Color.RED); } - if (e.getSource() == red) { - outputTextArea.setForeground(Color.RED); - } - if (e.getSource() == blue) { - outputTextArea.setForeground(Color.BLUE); - }else if (e.getSource() == black) { - outputTextArea.setForeground(Color.BLACK); - } else if (e.getSource() == green) { - outputTextArea.setForeground(Color.GREEN); + if (e.getSource() == blue) { + outputTextArea.setForeground(Color.BLUE); + } else if (e.getSource() == black) { + outputTextArea.setForeground(Color.BLACK); + } else if (e.getSource() == green) { + outputTextArea.setForeground(Color.GREEN); - } + } -} + } } From b2083f814d47495f3dd0da725f60b4235ed3b413 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:11:04 +0100 Subject: [PATCH 12/25] =?UTF-8?q?Optionspunkte=20Schriftgr=C3=B6=C3=9Fe=20?= =?UTF-8?q?hinzugef=C3=BCgt(noch=20keine=20Funktion)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index b33e153..a63cbcc 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -14,7 +14,10 @@ import javax.swing.JTextArea; import javax.swing.JTextField; public class ChatGUI implements ActionListener { - + + JMenuItem small = new JMenuItem("small-font"); + JMenuItem medium = new JMenuItem("medium-font"); + JMenuItem large = new JMenuItem("large-font"); JMenuItem exit = new JMenuItem("Exit"); JMenuItem black = new JMenuItem("black"); JMenuItem red = new JMenuItem("red"); @@ -39,17 +42,23 @@ public class ChatGUI implements ActionListener { JMenu options = new JMenu("options"); JMenu colors = new JMenu("font-colors"); + JMenu size = new JMenu("font-size"); JMenu menu = new JMenu("File"); menu.add(exit); menu.add(options); bar.add(menu); options.add(colors); + options.add(size); colors.add(black); colors.add(red); colors.add(blue); colors.add(green); + + size.add(small); + size.add(medium); + size.add(large); red.addActionListener(this); blue.addActionListener(this); @@ -95,15 +104,13 @@ public class ChatGUI implements ActionListener { } if (e.getSource() == red) { outputTextArea.setForeground(Color.RED); - } - if (e.getSource() == blue) { + + } else if (e.getSource() == blue) { outputTextArea.setForeground(Color.BLUE); } else if (e.getSource() == black) { outputTextArea.setForeground(Color.BLACK); } else if (e.getSource() == green) { outputTextArea.setForeground(Color.GREEN); - } - } } From 24c7f1d6ab1dc5eb003ab99470565e288235a9e1 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:24:07 +0100 Subject: [PATCH 13/25] =?UTF-8?q?Schriftgr=C3=B6=C3=9Fenwahl=20implementie?= =?UTF-8?q?rt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index a63cbcc..4340cd3 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -1,6 +1,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; +import java.awt.Font; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -64,6 +65,9 @@ public class ChatGUI implements ActionListener { blue.addActionListener(this); black.addActionListener(this); green.addActionListener(this); + small.addActionListener(this); + medium.addActionListener(this); + large.addActionListener(this); exit.addActionListener(this); @@ -112,5 +116,17 @@ public class ChatGUI implements ActionListener { } else if (e.getSource() == green) { outputTextArea.setForeground(Color.GREEN); } + if(e.getSource() == small) { + outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 12)); + } + if(e.getSource() == medium) { + outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 16)); + } + if(e.getSource() == large) { + outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 20)); + } + + + } } From 4ed49f7d4bd1e2b0363d38b04f0c9c272989659f Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:30:54 +0100 Subject: [PATCH 14/25] =?UTF-8?q?refactoring:=20Kommentare=20und=20=C3=9Cb?= =?UTF-8?q?ersicht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 4340cd3..de20bd9 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -16,14 +16,19 @@ import javax.swing.JTextField; public class ChatGUI implements ActionListener { + // Menu items for font sizes JMenuItem small = new JMenuItem("small-font"); JMenuItem medium = new JMenuItem("medium-font"); JMenuItem large = new JMenuItem("large-font"); - JMenuItem exit = new JMenuItem("Exit"); + + // Menu items for font colors JMenuItem black = new JMenuItem("black"); JMenuItem red = new JMenuItem("red"); JMenuItem blue = new JMenuItem("blue"); JMenuItem green = new JMenuItem("green"); + + JMenuItem exit = new JMenuItem("Exit"); + JTextField inputTextField = new JTextField(); JTextArea outputTextArea = new JTextArea(); @@ -35,12 +40,13 @@ public class ChatGUI implements ActionListener { // Set up the main frame gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gui.setTitle("java-chat"); - gui.setLayout(new BorderLayout()); - + + // Set up the menu bar JMenuBar bar = new JMenuBar(); gui.setJMenuBar(bar); - + + // Create menu items and menus JMenu options = new JMenu("options"); JMenu colors = new JMenu("font-colors"); JMenu size = new JMenu("font-size"); @@ -60,7 +66,8 @@ public class ChatGUI implements ActionListener { size.add(small); size.add(medium); size.add(large); - + + // Register action listeners for menu items red.addActionListener(this); blue.addActionListener(this); black.addActionListener(this); @@ -90,7 +97,7 @@ public class ChatGUI implements ActionListener { gui.setSize(quarterWidth, quarterHeight); gui.setVisible(true); } - + // main methode zum Testen, müsste bei Implementation entfernt werden public static void main(String[] args) { new ChatGUI(); From ea503cdf962649f9d1d6fd65dd218c8113525346 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:45:40 +0100 Subject: [PATCH 15/25] test_Farbtest1 + Hilfklasse --- src/test/java/ChatGUITest.java | 22 ++++++++++++++++++++++ src/test/java/TestActionEvent.java | 10 ++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/test/java/ChatGUITest.java create mode 100644 src/test/java/TestActionEvent.java diff --git a/src/test/java/ChatGUITest.java b/src/test/java/ChatGUITest.java new file mode 100644 index 0000000..ab84b47 --- /dev/null +++ b/src/test/java/ChatGUITest.java @@ -0,0 +1,22 @@ +import static org.junit.Assert.assertEquals; + +import java.awt.Color; + +import org.junit.Before; +import org.junit.Test; + +public class ChatGUITest { + + private ChatGUI chatGUI; + + @Before + public void setUp() { + chatGUI = new ChatGUI(); + } + @Test + public void testSetOutputTextColorRed() { + chatGUI.actionPerformed(new TestActionEvent(chatGUI.red)); + assertEquals(Color.RED, chatGUI.outputTextArea.getForeground()); + } +} + diff --git a/src/test/java/TestActionEvent.java b/src/test/java/TestActionEvent.java new file mode 100644 index 0000000..1a60355 --- /dev/null +++ b/src/test/java/TestActionEvent.java @@ -0,0 +1,10 @@ +import java.awt.event.ActionEvent; + +public class TestActionEvent extends ActionEvent { + + private static final long serialVersionUID = 1L; + + public TestActionEvent(Object source) { + super(source, ActionEvent.ACTION_PERFORMED, "Test command"); + } +} \ No newline at end of file From 971ec214b6d3bed0ffd47cf044046f6cb05a7de2 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:47:14 +0100 Subject: [PATCH 16/25] test_weiterer Test --- src/test/java/ChatGUITest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/ChatGUITest.java b/src/test/java/ChatGUITest.java index ab84b47..8d8eaf6 100644 --- a/src/test/java/ChatGUITest.java +++ b/src/test/java/ChatGUITest.java @@ -18,5 +18,11 @@ public class ChatGUITest { chatGUI.actionPerformed(new TestActionEvent(chatGUI.red)); assertEquals(Color.RED, chatGUI.outputTextArea.getForeground()); } + @Test + public void testSetOutputTextColorBlue() { + chatGUI.actionPerformed(new TestActionEvent(chatGUI.blue)); + assertEquals(Color.BLUE, chatGUI.outputTextArea.getForeground()); + } + } From 9b6b6e1291df0842b6e9bddba19390f26cf119f3 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:48:47 +0100 Subject: [PATCH 17/25] =?UTF-8?q?test=5Fweitere=20Testf=C3=A4lle=20hinzuge?= =?UTF-8?q?f=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/ChatGUITest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/ChatGUITest.java b/src/test/java/ChatGUITest.java index 8d8eaf6..3afb790 100644 --- a/src/test/java/ChatGUITest.java +++ b/src/test/java/ChatGUITest.java @@ -23,6 +23,17 @@ public class ChatGUITest { chatGUI.actionPerformed(new TestActionEvent(chatGUI.blue)); assertEquals(Color.BLUE, chatGUI.outputTextArea.getForeground()); } + @Test + public void testSetOutputTextColorBlack() { + chatGUI.actionPerformed(new TestActionEvent(chatGUI.black)); + assertEquals(Color.BLACK, chatGUI.outputTextArea.getForeground()); + } + + @Test + public void testSetOutputTextColorGreen() { + chatGUI.actionPerformed(new TestActionEvent(chatGUI.green)); + assertEquals(Color.GREEN, chatGUI.outputTextArea.getForeground()); + } } From ef68912273314f128255d42ef15a3f11daa34281 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:50:06 +0100 Subject: [PATCH 18/25] test_fonttest --- src/test/java/ChatGUITest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/java/ChatGUITest.java b/src/test/java/ChatGUITest.java index 3afb790..8b06bf4 100644 --- a/src/test/java/ChatGUITest.java +++ b/src/test/java/ChatGUITest.java @@ -1,6 +1,7 @@ import static org.junit.Assert.assertEquals; import java.awt.Color; +import java.awt.Font; import org.junit.Before; import org.junit.Test; @@ -34,6 +35,12 @@ public class ChatGUITest { chatGUI.actionPerformed(new TestActionEvent(chatGUI.green)); assertEquals(Color.GREEN, chatGUI.outputTextArea.getForeground()); } + @Test + public void testSetOutputTextFontSizeSmall() { + chatGUI.actionPerformed(new TestActionEvent(chatGUI.small)); + Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 12); + assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); + } } From 29de7c748dfa1cf53dc07a4479187e130059da49 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:51:14 +0100 Subject: [PATCH 19/25] test_medium-font-test --- src/test/java/ChatGUITest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/ChatGUITest.java b/src/test/java/ChatGUITest.java index 8b06bf4..94a4fc2 100644 --- a/src/test/java/ChatGUITest.java +++ b/src/test/java/ChatGUITest.java @@ -41,6 +41,12 @@ public class ChatGUITest { Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 12); assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); } + @Test + public void testSetOutputTextFontSizeMedium() { + chatGUI.actionPerformed(new TestActionEvent(chatGUI.medium)); + Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 16); + assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); + } } From 0d0efe54b3734e9ba6fe5ad2e8a6a27a2b742bc8 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:54:36 +0100 Subject: [PATCH 20/25] =?UTF-8?q?test=5FSchriftgr=C3=B6=C3=9Fe=20large?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/ChatGUITest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/java/ChatGUITest.java b/src/test/java/ChatGUITest.java index 94a4fc2..42065b8 100644 --- a/src/test/java/ChatGUITest.java +++ b/src/test/java/ChatGUITest.java @@ -47,6 +47,12 @@ public class ChatGUITest { Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 16); assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); } - + @Test + public void testSetOutputTextFontSizeLarge() { + chatGUI.actionPerformed(new TestActionEvent(chatGUI.large)); + Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 20); + assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); + } } + From 14c221315bb4233553831551a62ed4a69070f3e3 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 03:40:32 +0100 Subject: [PATCH 21/25] =?UTF-8?q?hinzuf=C3=BCgen=20senden-button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index de20bd9..d5efb58 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -6,10 +6,12 @@ import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; +import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; @@ -31,6 +33,7 @@ public class ChatGUI implements ActionListener { JTextField inputTextField = new JTextField(); JTextArea outputTextArea = new JTextArea(); + JButton sendButton = new JButton("Senden"); JFrame gui; @@ -79,17 +82,19 @@ public class ChatGUI implements ActionListener { exit.addActionListener(this); bar.add(menu); - + // Set up the output text area with scrolling JScrollPane outputScrollPane = new JScrollPane(outputTextArea); gui.add(outputScrollPane, BorderLayout.CENTER); - - // Set up the input text field - inputTextField.setPreferredSize(new Dimension(0, 30)); - gui.add(inputTextField, BorderLayout.SOUTH); + + JPanel inputPanel = new JPanel(new BorderLayout()); + inputPanel.add(inputTextField, BorderLayout.CENTER); + inputPanel.add(sendButton, BorderLayout.EAST); + gui.add(inputPanel, BorderLayout.SOUTH); inputTextField.addActionListener(this); - + sendButton.addActionListener(this); + // Set the size of the GUI to be a quarter of the screen size Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int quarterWidth = screenSize.width / 2; @@ -108,10 +113,10 @@ public class ChatGUI implements ActionListener { if (e.getSource() == exit) { System.exit(0); } - if (e.getSource() == inputTextField) { - String inputText = inputTextField.getText(); - outputTextArea.append(inputText + "\n"); - inputTextField.setText(""); + if (e.getSource() == inputTextField || e.getSource() == sendButton) { + String inputText = inputTextField.getText(); + outputTextArea.append(inputText + "\n"); + inputTextField.setText(""); } if (e.getSource() == red) { outputTextArea.setForeground(Color.RED); From c089275208d580e5672221fd647ad47a6322d431 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 03:43:24 +0100 Subject: [PATCH 22/25] refactoring: Kommentare + formatieren --- src/main/java/ChatGUI.java | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index d5efb58..743e4f4 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -17,7 +17,7 @@ import javax.swing.JTextArea; import javax.swing.JTextField; public class ChatGUI implements ActionListener { - + // Menu items for font sizes JMenuItem small = new JMenuItem("small-font"); JMenuItem medium = new JMenuItem("medium-font"); @@ -28,9 +28,9 @@ public class ChatGUI implements ActionListener { JMenuItem red = new JMenuItem("red"); JMenuItem blue = new JMenuItem("blue"); JMenuItem green = new JMenuItem("green"); - + JMenuItem exit = new JMenuItem("Exit"); - + JTextField inputTextField = new JTextField(); JTextArea outputTextArea = new JTextArea(); JButton sendButton = new JButton("Senden"); @@ -44,11 +44,11 @@ public class ChatGUI implements ActionListener { gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gui.setTitle("java-chat"); gui.setLayout(new BorderLayout()); - + // Set up the menu bar JMenuBar bar = new JMenuBar(); gui.setJMenuBar(bar); - + // Create menu items and menus JMenu options = new JMenu("options"); JMenu colors = new JMenu("font-colors"); @@ -65,11 +65,11 @@ public class ChatGUI implements ActionListener { colors.add(red); colors.add(blue); colors.add(green); - + size.add(small); size.add(medium); size.add(large); - + // Register action listeners for menu items red.addActionListener(this); blue.addActionListener(this); @@ -82,19 +82,20 @@ public class ChatGUI implements ActionListener { exit.addActionListener(this); bar.add(menu); - + // Set up the output text area with scrolling JScrollPane outputScrollPane = new JScrollPane(outputTextArea); gui.add(outputScrollPane, BorderLayout.CENTER); + // Set up the input panel with text field and send button JPanel inputPanel = new JPanel(new BorderLayout()); - inputPanel.add(inputTextField, BorderLayout.CENTER); - inputPanel.add(sendButton, BorderLayout.EAST); - gui.add(inputPanel, BorderLayout.SOUTH); + inputPanel.add(inputTextField, BorderLayout.CENTER); + inputPanel.add(sendButton, BorderLayout.EAST); + gui.add(inputPanel, BorderLayout.SOUTH); inputTextField.addActionListener(this); sendButton.addActionListener(this); - + // Set the size of the GUI to be a quarter of the screen size Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int quarterWidth = screenSize.width / 2; @@ -102,6 +103,7 @@ public class ChatGUI implements ActionListener { gui.setSize(quarterWidth, quarterHeight); gui.setVisible(true); } + // main methode zum Testen, müsste bei Implementation entfernt werden public static void main(String[] args) { @@ -114,13 +116,13 @@ public class ChatGUI implements ActionListener { System.exit(0); } if (e.getSource() == inputTextField || e.getSource() == sendButton) { - String inputText = inputTextField.getText(); - outputTextArea.append(inputText + "\n"); - inputTextField.setText(""); + String inputText = inputTextField.getText(); + outputTextArea.append(inputText + "\n"); + inputTextField.setText(""); } if (e.getSource() == red) { outputTextArea.setForeground(Color.RED); - + } else if (e.getSource() == blue) { outputTextArea.setForeground(Color.BLUE); } else if (e.getSource() == black) { @@ -128,17 +130,15 @@ public class ChatGUI implements ActionListener { } else if (e.getSource() == green) { outputTextArea.setForeground(Color.GREEN); } - if(e.getSource() == small) { - outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 12)); - } - if(e.getSource() == medium) { - outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 16)); - } - if(e.getSource() == large) { - outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 20)); - } - - + if (e.getSource() == small) { + outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 12)); + } + if (e.getSource() == medium) { + outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 16)); + } + if (e.getSource() == large) { + outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 20)); + } } } From 0f07791c8751fb50b9f55a48784cd21b07d36879 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 03:46:31 +0100 Subject: [PATCH 23/25] test_ButtonTest --- src/test/java/ChatGUITest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/ChatGUITest.java b/src/test/java/ChatGUITest.java index 42065b8..04fa7d0 100644 --- a/src/test/java/ChatGUITest.java +++ b/src/test/java/ChatGUITest.java @@ -53,6 +53,14 @@ public class ChatGUITest { Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 20); assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); } + @Test + public void testSendButtonActionPerformed() { + chatGUI.inputTextField.setText("Testnachricht"); + chatGUI.sendButton.doClick(); + + String expectedOutput = "Testnachricht\n"; + assertEquals(expectedOutput, chatGUI.outputTextArea.getText()); + } } From a73279496a01d9d10bef8438dd7b324e7bfef124 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 03:49:02 +0100 Subject: [PATCH 24/25] test_Inputfield-Test --- src/test/java/ChatGUITest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/ChatGUITest.java b/src/test/java/ChatGUITest.java index 04fa7d0..47cc055 100644 --- a/src/test/java/ChatGUITest.java +++ b/src/test/java/ChatGUITest.java @@ -2,6 +2,7 @@ import static org.junit.Assert.assertEquals; import java.awt.Color; import java.awt.Font; +import java.awt.event.ActionEvent; import org.junit.Before; import org.junit.Test; @@ -61,6 +62,19 @@ public class ChatGUITest { String expectedOutput = "Testnachricht\n"; assertEquals(expectedOutput, chatGUI.outputTextArea.getText()); } + @Test + public void testInputTextFieldActionPerformed() { + + chatGUI.inputTextField.setText("Testnachricht"); + chatGUI.actionPerformed(new ActionEvent(chatGUI.inputTextField, ActionEvent.ACTION_PERFORMED, "")); + + + String expectedOutput = "Testnachricht\n"; + assertEquals(expectedOutput, chatGUI.outputTextArea.getText()); + + + assertEquals("", chatGUI.inputTextField.getText()); + } } From 6f67832da65d86bc3d7c26bc18dd5705dfc08b6d Mon Sep 17 00:00:00 2001 From: fdai7599 Date: Fri, 9 Feb 2024 02:58:35 +0000 Subject: [PATCH 25/25] =?UTF-8?q?merge=20conflict=20aufl=C3=B6sen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index d427c1a..4b4d00b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,8 +1,4 @@ - - RELEASE - - 4.0.0 org.progmethoden java-chat @@ -24,7 +20,7 @@ org.junit.jupiter junit-jupiter - ${junit-jupiter-version} + RELEASE test