diff --git a/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/ConstraintsBuilder.java b/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/ConstraintsBuilder.java deleted file mode 100644 index ce437fac6d..0000000000 --- a/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/ConstraintsBuilder.java +++ /dev/null @@ -1,15 +0,0 @@ -package reminderapplication; - -import java.awt.GridBagConstraints; -import java.awt.Insets; - -public class ConstraintsBuilder { - - static GridBagConstraints constraint(int x, int y) { - final GridBagConstraints gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = x; - gridBagConstraints.gridy = y; - gridBagConstraints.insets = new Insets(5, 5, 5, 5); - return gridBagConstraints; - } -} diff --git a/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/EditReminderFrame.java b/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/EditReminderFrame.java deleted file mode 100644 index 818cea403e..0000000000 --- a/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/EditReminderFrame.java +++ /dev/null @@ -1,194 +0,0 @@ -package reminderapplication; - -import static reminderapplication.ConstraintsBuilder.*; - -import java.awt.GridBagLayout; -import java.awt.HeadlessException; -import java.lang.reflect.InvocationTargetException; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.TimeUnit; -import javax.swing.DefaultComboBoxModel; -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.SwingUtilities; - -public class EditReminderFrame extends JFrame { - - private static Timer TIMER = new Timer(); - - private final TimeReminderApplication reminderApplication; - private final JLabel reminderTextLabel; - private final JLabel repeatPeriodLabel; - private final JLabel setDelayLabel; - private final JComboBox delay; - private final JComboBox period; - private final JButton cancelButton; - private final JButton okButton; - private final JTextField textField; - private final JLabel delaysLabel; - private final JLabel periodLabel; - - private final int reminderIndex; - - public EditReminderFrame(TimeReminderApplication reminderApp, String reminderText, int delayInSeconds, int periodInSeconds, int index) throws HeadlessException { - this.reminderApplication = reminderApp; - reminderIndex = index; - textField = createTextField(reminderText); - delay = createDelayComboBox(delayInSeconds); - period = createPeriodComboBox(periodInSeconds); - cancelButton = createCancelButton(); - okButton = createOkButton(); - reminderTextLabel = createReminderTextLabel(); - repeatPeriodLabel = createRepeatPeriodLabel(); - setDelayLabel = createSetDelayLabel(); - delaysLabel = createDelaysLabel(); - periodLabel = createPeriodLabel(); - configureVisualRepresentation(); - configureActions(); - } - - private void configureActions() { - updateReminder(); - } - - private void configureVisualRepresentation() { - configureFrame(); - setLocationRelativeTo(null); - setLayout(new GridBagLayout()); - add(reminderTextLabel, constraint(0,0)); - add(repeatPeriodLabel, constraint(1,0)); - add(setDelayLabel, constraint(2,0)); - add(textField, constraint(0, 1)); - add(delay, constraint(1, 1)); - add(period, constraint(2, 1)); - add(delaysLabel, constraint(1,3)); - add(periodLabel, constraint(2,3)); - add(okButton, constraint(1, 4)); - add(cancelButton, constraint(2, 4)); - pack(); - setVisible(true); - } - - private void configureFrame() { - setTitle("Set Reminder"); - setName("Set Reminder"); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - } - - private static JLabel createSetDelayLabel() { - return createLabel("Set Delay", "Set Delay Label"); - } - - private static JLabel createRepeatPeriodLabel() { - return createLabel("Set Period", "Set Repeat Period Label"); - } - - private static JLabel createReminderTextLabel() { - return createLabel("Reminder Text", "Reminder Text Label"); - } - - private JLabel createPeriodLabel() { - return createLabel("0", "Period label"); - } - - private JLabel createDelaysLabel() { - return createLabel("30", "Delays Label"); - } - - private JComboBox createPeriodComboBox(final int periodInSeconds) { - final JComboBox comboBox = new JComboBox<>(new DefaultComboBoxModel<>(new Integer[]{0, 5, 10, 20})); - comboBox.setSelectedItem(periodInSeconds); - comboBox.setName("set Period"); - comboBox.addActionListener(e -> periodLabel.setText(comboBox.getSelectedItem().toString())); - return comboBox; - } - - private JComboBox createDelayComboBox(final int delayInSeconds) { - final JComboBox comboBox = new JComboBox<>(new DefaultComboBoxModel<>(new Integer[]{30, 25, 15, 5})); - comboBox.setSelectedItem(delayInSeconds); - comboBox.setName("set Delay"); - comboBox.addActionListener(e -> delaysLabel.setText(comboBox.getSelectedItem().toString())); - return comboBox; - } - - private JTextField createTextField(final String reminderText) { - final JTextField textField = new JTextField(20); - textField.setName("Field"); - textField.setText(reminderText); - return textField; - } - - private JButton createOkButton() { - final JButton button = new JButton("ok"); - button.setName("OK"); - return button; - } - - private void updateReminder() { - okButton.addActionListener(e -> this.dispose()); - okButton.addActionListener(e -> { - final int periodInSeconds = getTimeInSeconds(period); - final int delayInSeconds = getTimeInSeconds(delay); - final Reminder reminder = new Reminder(textField.getText(), delayInSeconds, periodInSeconds); - ((DefaultListModel) reminderApplication.getReminders()).set(reminderIndex, reminder); - }); - okButton.addActionListener(e -> scheduleReminder(textField, delay, period)); - } - - private void scheduleReminder(final JTextField textField, final JComboBox delay, final JComboBox period) { - final int periodInSeconds = getTimeInSeconds(period); - if (periodInSeconds == 0) - scheduleNonRepeatedReminder(textField, delay); - else - scheduleRepeatedReminder(textField, delay, period); - } - - private void scheduleRepeatedReminder(final JTextField textField, final JComboBox delay, final JComboBox period) { - final int delayInSeconds = getTimeInSeconds(delay); - final int periodInSeconds = getTimeInSeconds(period); - final TimerTask timerTask = getTimerTask(textField.getText(), delayInSeconds, periodInSeconds); - TIMER.schedule(timerTask, TimeUnit.SECONDS.toMillis(delayInSeconds), TimeUnit.SECONDS.toMillis(periodInSeconds)); - } - - private void scheduleNonRepeatedReminder(final JTextField textField, final JComboBox delay) { - final int delayInSeconds = getTimeInSeconds(delay); - final int periodInSeconds = 0; - final TimerTask timerTask = getTimerTask(textField.getText(), delayInSeconds, periodInSeconds); - TIMER.schedule(timerTask, TimeUnit.SECONDS.toMillis(delayInSeconds)); - - } - - private int getTimeInSeconds(final JComboBox comboBox) { - if (comboBox != null && comboBox.getSelectedItem() != null) - return ((Integer) comboBox.getSelectedItem()); - else - return 0; - } - - private TimerTask getTimerTask(final String reminderText, final Integer delayInSeconds, final Integer periodInSeconds) { - return new TimerTask() { - @Override - public void run() { - new ReminderPopupFrame(reminderApplication, reminderText, delayInSeconds, periodInSeconds); - } - }; - } - - private JButton createCancelButton() { - final JButton button = new JButton("cancel"); - button.setName("Cancel"); - button.addActionListener(e -> this.dispose()); - return button; - } - - private static JLabel createLabel(final String text, final String name) { - JLabel label = new JLabel(text); - label.setName(name); - return label; - } -} diff --git a/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/Reminder.java b/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/Reminder.java deleted file mode 100644 index 8f6ff336ed..0000000000 --- a/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/Reminder.java +++ /dev/null @@ -1,33 +0,0 @@ -package reminderapplication; - -public class Reminder { - - private static String REMINDER_FORMAT = "Reminder Text: %s; Delay: %d; Period: %d;"; - - private final String name; - private final int delay; - private final int period; - - public Reminder(final String name, final int delay, final int period) { - this.name = name; - this.delay = delay; - this.period = period; - } - - public String getName() { - return name; - } - - public int getDelay() { - return delay; - } - - public int getPeriod() { - return period; - } - - @Override - public String toString() { - return REMINDER_FORMAT.formatted(name, delay, period); - } -} diff --git a/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/ReminderFrame.java b/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/ReminderFrame.java deleted file mode 100644 index 3a1623219c..0000000000 --- a/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/ReminderFrame.java +++ /dev/null @@ -1,186 +0,0 @@ -package reminderapplication; - -import static reminderapplication.ConstraintsBuilder.*; - -import java.awt.GridBagLayout; -import java.awt.HeadlessException; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.TimeUnit; -import javax.swing.DefaultComboBoxModel; -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; - -public class ReminderFrame extends JFrame { - - private static Timer TIMER = new Timer(); - private final TimeReminderApplication reminderApplication; - private final JLabel reminderTextLabel; - private final JLabel repeatPeriodLabel; - private final JLabel setDelayLabel; - private final JComboBox delay; - private final JComboBox period; - private final JButton cancelButton; - private final JButton okButton; - private final JTextField textField; - private final JLabel delaysLabel; - private final JLabel periodLabel; - - public ReminderFrame(TimeReminderApplication reminderApp) throws HeadlessException { - this.reminderApplication = reminderApp; - textField = createTextField(); - delay = createDelayComboBox(); - period = createPeriodComboBox(); - cancelButton = createCancelButton(); - okButton = createOkButton(); - reminderTextLabel = createReminderTextLabel(); - repeatPeriodLabel = createRepeatPeriodLabel(); - setDelayLabel = createSetDelayLabel(); - delaysLabel = createDelaysLabel(); - periodLabel = createPeriodLabel(); - configureVisualRepresentation(); - configureActions(); - } - - private void configureActions() { - createNewReminder(); - } - - private void configureVisualRepresentation() { - configureFrame(); - setLocationRelativeTo(null); - setLayout(new GridBagLayout()); - add(reminderTextLabel, constraint(0,0)); - add(repeatPeriodLabel, constraint(1,0)); - add(setDelayLabel, constraint(2,0)); - add(textField, constraint(0, 1)); - add(delay, constraint(1, 1)); - add(period, constraint(2, 1)); - add(delaysLabel, constraint(1,3)); - add(periodLabel, constraint(2,3)); - add(okButton, constraint(1, 4)); - add(cancelButton, constraint(2, 4)); - pack(); - setVisible(true); - } - - private void configureFrame() { - setTitle("Set Reminder"); - setName("Set Reminder"); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - } - - private static JLabel createSetDelayLabel() { - return createLabel("Set Delay", "Set Delay Label"); - } - - private static JLabel createRepeatPeriodLabel() { - return createLabel("Set Period", "Set Repeat Period Label"); - } - - private static JLabel createReminderTextLabel() { - return createLabel("Reminder Text", "Reminder Text Label"); - } - - private JLabel createPeriodLabel() { - return createLabel("0", "Period label"); - } - - private JLabel createDelaysLabel() { - return createLabel("30", "Delays Label"); - } - - private JComboBox createPeriodComboBox() { - final JComboBox comboBox = new JComboBox<>(new DefaultComboBoxModel<>(new Integer[]{0, 5, 10, 20})); - comboBox.setName("set Period"); - comboBox.addActionListener(e -> periodLabel.setText(comboBox.getSelectedItem().toString())); - return comboBox; - } - - private JComboBox createDelayComboBox() { - final JComboBox comboBox = new JComboBox<>(new DefaultComboBoxModel<>(new Integer[]{30, 25, 15, 5})); - comboBox.setName("set Delay"); - comboBox.addActionListener(e -> delaysLabel.setText(comboBox.getSelectedItem().toString())); - return comboBox; - } - - private JTextField createTextField() { - final JTextField textField = new JTextField(20); - textField.setName("Field"); - return textField; - } - - private JButton createOkButton() { - final JButton button = new JButton("ok"); - button.setName("OK"); - return button; - } - - private void createNewReminder() { - - okButton.addActionListener(e -> this.dispose()); - okButton.addActionListener(e -> { - final int periodInSeconds = getTimeInSeconds(period); - final int delayInSeconds = getTimeInSeconds(delay); - final Reminder reminder = new Reminder(textField.getText(), delayInSeconds, periodInSeconds); - ((DefaultListModel) reminderApplication.getReminders()).addElement(reminder); - }); - okButton.addActionListener(e -> scheduleReminder(textField, delay, period)); - } - - private void scheduleReminder(final JTextField textField, final JComboBox delay, final JComboBox period) { - final int periodInSeconds = getTimeInSeconds(period); - if (periodInSeconds == 0) - scheduleNonRepeatedReminder(textField, delay); - else - scheduleRepeatedReminder(textField, delay, period); - } - - private void scheduleRepeatedReminder(final JTextField textField, final JComboBox delay, final JComboBox period) { - final int delayInSeconds = getTimeInSeconds(delay) + 200; - final int periodInSeconds = getTimeInSeconds(period); - final TimerTask timerTask = getTimerTask(textField.getText(), delayInSeconds, periodInSeconds); - TIMER.schedule(timerTask, TimeUnit.SECONDS.toMillis(delayInSeconds), TimeUnit.SECONDS.toMillis(periodInSeconds)); - } - - private void scheduleNonRepeatedReminder(final JTextField textField, final JComboBox delay) { - final int delayInSeconds = getTimeInSeconds(delay); - final int periodInSeconds = 0; - final TimerTask timerTask = getTimerTask(textField.getText(), delayInSeconds, periodInSeconds); - TIMER.schedule(timerTask, TimeUnit.SECONDS.toMillis(delayInSeconds)); - - } - - private int getTimeInSeconds(final JComboBox comboBox) { - if (comboBox != null && comboBox.getSelectedItem() != null) - return ((Integer) comboBox.getSelectedItem()); - else - return 0; - } - - private TimerTask getTimerTask(final String reminderText, final Integer delayInSeconds, final Integer periodInSeconds) { - return new TimerTask() { - @Override - public void run() { - new ReminderPopupFrame(reminderApplication, reminderText, delayInSeconds, periodInSeconds); - } - }; - } - - private JButton createCancelButton() { - final JButton button = new JButton("cancel"); - button.setName("Cancel"); - button.addActionListener(e -> this.dispose()); - return button; - } - - private static JLabel createLabel(final String text, final String name) { - JLabel label = new JLabel(text); - label.setName(name); - return label; - } -} diff --git a/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/ReminderPopupFrame.java b/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/ReminderPopupFrame.java deleted file mode 100644 index d41343cb6d..0000000000 --- a/core-java-modules/Reminder Application/Reminder Application/task/src/reminderapplication/ReminderPopupFrame.java +++ /dev/null @@ -1,151 +0,0 @@ -package reminderapplication; - -import static reminderapplication.ConstraintsBuilder.*; - -import java.awt.GridBagLayout; -import java.awt.HeadlessException; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.TimeUnit; -import javax.swing.DefaultComboBoxModel; -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; - -public class ReminderPopupFrame extends JFrame { - - private static final Timer TIMER = new Timer(); - private final int AUTOMATIC_CLOSE_TIME_IN_SECONDS = 10; - private final TimeReminderApplication reminderApplication; - private final JLabel reminderTextLabel; - private final JLabel repeatPeriodLabel; - private final JLabel setDelayLabel; - private final JComboBox delay; - private final JComboBox period; - private final JButton cancelButton; - private final JButton okButton; - private final JTextField textField; - private final JLabel delaysLabel; - private final JLabel periodLabel; - - public ReminderPopupFrame(TimeReminderApplication reminderApp, final String text, final Integer delayInSeconds, final Integer periodInSeconds) throws HeadlessException { - this.reminderApplication = reminderApp; - textField = createTextField(text); - delay = createDelayComboBox(delayInSeconds); - period = createPeriodComboBox(periodInSeconds); - cancelButton = createCancelButton(); - okButton = createDisabledOkButton(); - reminderTextLabel = createReminderTextLabel(); - repeatPeriodLabel = createRepeatPeriodLabel(); - setDelayLabel = createSetDelayLabel(); - delaysLabel = createDelaysLabel(); - periodLabel = createPeriodLabel(); - configureVisualRepresentation(); - configureActions(); - } - - private void configureActions() { - scheduleClosing(); - } - - private void scheduleClosing() { - final TimerTask timerTask = new TimerTask() { - @Override - public void run() { - ReminderPopupFrame.this.dispose(); - } - }; - TIMER.schedule(timerTask, TimeUnit.SECONDS.toMillis(AUTOMATIC_CLOSE_TIME_IN_SECONDS)); - } - - private void configureVisualRepresentation() { - configureFrame(); - setLocationRelativeTo(null); - setLayout(new GridBagLayout()); - add(reminderTextLabel, constraint(0,0)); - add(repeatPeriodLabel, constraint(1,0)); - add(setDelayLabel, constraint(2,0)); - add(textField, constraint(0, 1)); - add(delay, constraint(1, 1)); - add(period, constraint(2, 1)); - add(delaysLabel, constraint(1,3)); - add(periodLabel, constraint(2,3)); - add(okButton, constraint(1, 4)); - add(cancelButton, constraint(2, 4)); - pack(); - setVisible(true); - } - - private void configureFrame() { - setTitle("Set Reminder"); - setName("Set Reminder"); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - } - - private static JLabel createSetDelayLabel() { - return createLabel("Set Delay", "Set Delay Label"); - } - - private static JLabel createRepeatPeriodLabel() { - return createLabel("Set Period", "Set Repeat Period Label"); - } - - private static JLabel createReminderTextLabel() { - return createLabel("Reminder Text", "Reminder Text Label"); - } - - private JLabel createPeriodLabel() { - return createLabel("0", "Period label"); - } - - private JLabel createDelaysLabel() { - return createLabel("30", "Delays Label"); - } - - private JComboBox createPeriodComboBox(final Integer periodInSeconds) { - final JComboBox comboBox = new JComboBox<>(new DefaultComboBoxModel<>(new Integer[]{0, 5, 10, 20})); - comboBox.setName("set Period"); - comboBox.setSelectedItem(periodInSeconds); - comboBox.addActionListener(e -> periodLabel.setText(comboBox.getSelectedItem().toString())); - return comboBox; - } - - private JComboBox createDelayComboBox(Integer delay) { - final JComboBox comboBox = new JComboBox<>(new DefaultComboBoxModel<>(new Integer[]{30, 25, 15, 5})); - comboBox.setSelectedItem(delay); - comboBox.setName("set Delay"); - comboBox.addActionListener(e -> delaysLabel.setText(comboBox.getSelectedItem().toString())); - return comboBox; - } - - private JTextField createTextField(final String text) { - final JTextField textField = new JTextField(20); - textField.setName("Field"); - textField.setText(text); - return textField; - } - - private JButton createDisabledOkButton() { - final JButton button = new JButton("ok"); - button.setName("OK"); - button.setEnabled(false); - return button; - } - - private JButton createCancelButton() { - final JButton button = new JButton("cancel"); - button.setName("Cancel"); - button.addActionListener(e -> this.dispose()); - return button; - } - - private static JLabel createLabel(final String text, final String name) { - JLabel label = new JLabel(text); - label.setName(name); - return label; - } - -} diff --git a/guest/README.md b/guest/README.md deleted file mode 100644 index ff12555376..0000000000 --- a/guest/README.md +++ /dev/null @@ -1 +0,0 @@ -## Relevant articles: diff --git a/guest/memory-leaks/pom.xml b/guest/memory-leaks/pom.xml deleted file mode 100644 index 42bb71617d..0000000000 --- a/guest/memory-leaks/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - 4.0.0 - memory-leaks - 0.0.1-SNAPSHOT - memory-leaks - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - - - - - - src/main/resources/ - - **/*.java - - - - src/test/resources/ - - - - \ No newline at end of file diff --git a/guest/memory-leaks/src/test/java/com/baeldung/Key.java b/guest/memory-leaks/src/test/java/com/baeldung/Key.java deleted file mode 100644 index 6ae2fe7fcf..0000000000 --- a/guest/memory-leaks/src/test/java/com/baeldung/Key.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung; - -public class Key { - - public static String key; - - public Key(String key) { - Key.key = key; - } - -} diff --git a/guest/memory-leaks/src/test/java/com/baeldung/MemoryLeaksTest.java b/guest/memory-leaks/src/test/java/com/baeldung/MemoryLeaksTest.java deleted file mode 100644 index a8a094b4db..0000000000 --- a/guest/memory-leaks/src/test/java/com/baeldung/MemoryLeaksTest.java +++ /dev/null @@ -1,98 +0,0 @@ -//package com.baeldung; -// -//import java.io.BufferedReader; -//import java.io.File; -//import java.io.IOException; -//import java.io.InputStream; -//import java.io.InputStreamReader; -//import java.net.URISyntaxException; -//import java.net.URL; -//import java.net.URLConnection; -//import java.nio.charset.StandardCharsets; -//import java.nio.file.Files; -//import java.nio.file.Paths; -//import java.nio.file.StandardOpenOption; -//import java.util.ArrayList; -//import java.util.Map; -//import java.util.Random; -//import java.util.Scanner; -// -//import org.junit.FixMethodOrder; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.junit.runners.JUnit4; -//import org.junit.runners.MethodSorters; -// -//@FixMethodOrder(MethodSorters.NAME_ASCENDING) -//@RunWith(JUnit4.class) -//public class MemoryLeaksTest { -// private Random random = new Random(); -// public static final ArrayList list = new ArrayList(1000000); -// -// @Test -// public void givenStaticField_whenLotsOfOperations_thenMemoryLeak() throws InterruptedException { -// for (int i = 0; i < 1000000; i++) { -// list.add(random.nextDouble()); -// } -// System.gc(); -// Thread.sleep(10000); //to allow GC do its job -// } -// -// -// @Test -// public void givenNormalField_whenLotsOfOperations_thenGCWorksFine() throws InterruptedException { -// addElementsToTheList(); -// System.gc(); -// Thread.sleep(10000); //to allow GC do its job -// } -// -// private void addElementsToTheList(){ -// ArrayList list = new ArrayList(1000000); -// for (int i = 0; i < 1000000; i++) { -// list.add(random.nextDouble()); -// } -// } -// -// @SuppressWarnings({ "resource" }) -// @Test(expected = OutOfMemoryError.class) -// public void givenLengthString_whenIntern_thenOutOfMemory() throws IOException, InterruptedException { -// Thread.sleep(15000); -// String str = new Scanner(new File("src/test/resources/large.txt"), "UTF-8").useDelimiter("\\A") -// .next(); -// System.gc(); -// str.intern(); -// Thread.sleep(10000); -// } -// -// @Test(expected = OutOfMemoryError.class) -// public void givenURL_whenUnclosedStream_thenOutOfMemory() throws IOException, URISyntaxException { -// String str = ""; -// URLConnection conn = new URL("http:norvig.com/big.txt").openConnection(); -// BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)); -// while (br.readLine() != null) { -// str += br.readLine(); -// } -// Files.write(Paths.get("src/main/resources/"), str.getBytes(), StandardOpenOption.CREATE); -// } -// -// @SuppressWarnings("unused") -// @Test(expected = OutOfMemoryError.class) -// public void givenConnection_whenUnclosed_thenOutOfMemory() throws IOException, URISyntaxException { -// URL url = new URL("ftp:speedtest.tele2.net"); -// URLConnection urlc = url.openConnection(); -// InputStream is = urlc.getInputStream(); -// String str = ""; -// while (true) { -// str += is.toString() -// .intern(); -// } -// } -// -// @Test(expected = OutOfMemoryError.class) -// public void givenMap_whenNoEqualsNoHashCodeMethods_thenOutOfMemory() throws IOException, URISyntaxException { -// Map map = System.getProperties(); -// while (true) { -// map.put(new Key("key"), "value"); -// } -// } -//}