JAVA-18445 Cleanup un-committed or un-ignored artifacts - Week 6 - 2023 (conti-1) (moved-1) (#13510)
Co-authored-by: timis1 <noreplay@yahoo.com>
This commit is contained in:
parent
95026e6b88
commit
253c01ef4f
3
.gitignore
vendored
3
.gitignore
vendored
@ -108,3 +108,6 @@ spring-boot-modules/spring-boot-properties-3/*.log
|
|||||||
|
|
||||||
# Localstack
|
# Localstack
|
||||||
**/.localstack
|
**/.localstack
|
||||||
|
|
||||||
|
#web-modules/ninja
|
||||||
|
devDb*.db
|
@ -48,7 +48,7 @@ class AESUtilUnitTest implements WithAssertions {
|
|||||||
IvParameterSpec ivParameterSpec = AESUtil.generateIv();
|
IvParameterSpec ivParameterSpec = AESUtil.generateIv();
|
||||||
File inputFile = Paths.get("src/test/resources/baeldung.txt")
|
File inputFile = Paths.get("src/test/resources/baeldung.txt")
|
||||||
.toFile();
|
.toFile();
|
||||||
File encryptedFile = new File("classpath:baeldung.encrypted");
|
File encryptedFile = new File("baeldung.encrypted");
|
||||||
File decryptedFile = new File("document.decrypted");
|
File decryptedFile = new File("document.decrypted");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -57,8 +57,8 @@ class AESUtilUnitTest implements WithAssertions {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(inputFile).hasSameTextualContentAs(decryptedFile);
|
assertThat(inputFile).hasSameTextualContentAs(decryptedFile);
|
||||||
encryptedFile.delete();
|
encryptedFile.deleteOnExit();
|
||||||
decryptedFile.delete();
|
decryptedFile.deleteOnExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.baeldung.serializable_singleton;
|
package com.baeldung.serializable_singleton;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
@ -11,7 +13,9 @@ import java.io.ObjectOutputStream;
|
|||||||
// Unit test for the EnumSingleton class.
|
// Unit test for the EnumSingleton class.
|
||||||
public class EnumSingletonUnitTest {
|
public class EnumSingletonUnitTest {
|
||||||
|
|
||||||
// Checks that when an EnumSingleton instance is serialized
|
private static final String ENUM_SINGLETON_TEST_TXT = "enum_singleton_test.txt";
|
||||||
|
|
||||||
|
// Checks that when an EnumSingleton instance is serialized
|
||||||
// and then deserialized, its state is preserved.
|
// and then deserialized, its state is preserved.
|
||||||
@Test
|
@Test
|
||||||
public void givenEnumSingleton_whenSerializedAndDeserialized_thenStatePreserved() {
|
public void givenEnumSingleton_whenSerializedAndDeserialized_thenStatePreserved() {
|
||||||
@ -19,11 +23,10 @@ public class EnumSingletonUnitTest {
|
|||||||
|
|
||||||
es1.setState("State One");
|
es1.setState("State One");
|
||||||
|
|
||||||
try (
|
try (FileOutputStream fos = new FileOutputStream(ENUM_SINGLETON_TEST_TXT);
|
||||||
FileOutputStream fos = new FileOutputStream("enum_singleton_test.txt");
|
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
FileInputStream fis = new FileInputStream(ENUM_SINGLETON_TEST_TXT);
|
||||||
FileInputStream fis = new FileInputStream("enum_singleton_test.txt");
|
ObjectInputStream ois = new ObjectInputStream(fis)) {
|
||||||
ObjectInputStream ois = new ObjectInputStream(fis)) {
|
|
||||||
|
|
||||||
// Serializing.
|
// Serializing.
|
||||||
oos.writeObject(es1);
|
oos.writeObject(es1);
|
||||||
@ -46,11 +49,10 @@ public class EnumSingletonUnitTest {
|
|||||||
public void givenEnumSingleton_whenSerializedAndDeserialized_thenOneInstance() {
|
public void givenEnumSingleton_whenSerializedAndDeserialized_thenOneInstance() {
|
||||||
EnumSingleton es1 = EnumSingleton.getInstance();
|
EnumSingleton es1 = EnumSingleton.getInstance();
|
||||||
|
|
||||||
try (
|
try (FileOutputStream fos = new FileOutputStream(ENUM_SINGLETON_TEST_TXT);
|
||||||
FileOutputStream fos = new FileOutputStream("enum_singleton_test.txt");
|
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
FileInputStream fis = new FileInputStream(ENUM_SINGLETON_TEST_TXT);
|
||||||
FileInputStream fis = new FileInputStream("enum_singleton_test.txt");
|
ObjectInputStream ois = new ObjectInputStream(fis)) {
|
||||||
ObjectInputStream ois = new ObjectInputStream(fis)) {
|
|
||||||
|
|
||||||
// Serializing.
|
// Serializing.
|
||||||
oos.writeObject(es1);
|
oos.writeObject(es1);
|
||||||
@ -66,4 +68,12 @@ public class EnumSingletonUnitTest {
|
|||||||
System.out.println(e);
|
System.out.println(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
public static void cleanUp() {
|
||||||
|
final File removeFile = new File(ENUM_SINGLETON_TEST_TXT);
|
||||||
|
if (removeFile.exists()) {
|
||||||
|
removeFile.deleteOnExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.baeldung.serializable_singleton;
|
package com.baeldung.serializable_singleton;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
@ -11,7 +13,9 @@ import java.io.ObjectOutputStream;
|
|||||||
// Unit test for the Singleton class.
|
// Unit test for the Singleton class.
|
||||||
public class SingletonUnitTest {
|
public class SingletonUnitTest {
|
||||||
|
|
||||||
// Checks that when a Singleton instance is serialized
|
private static final String SINGLETON_TEST_TXT = "singleton_test.txt";
|
||||||
|
|
||||||
|
// Checks that when a Singleton instance is serialized
|
||||||
// and then deserialized, its state is preserved.
|
// and then deserialized, its state is preserved.
|
||||||
@Test
|
@Test
|
||||||
public void givenSingleton_whenSerializedAndDeserialized_thenStatePreserved() {
|
public void givenSingleton_whenSerializedAndDeserialized_thenStatePreserved() {
|
||||||
@ -19,11 +23,10 @@ public class SingletonUnitTest {
|
|||||||
|
|
||||||
s1.setState("State One");
|
s1.setState("State One");
|
||||||
|
|
||||||
try (
|
try (FileOutputStream fos = new FileOutputStream(SINGLETON_TEST_TXT);
|
||||||
FileOutputStream fos = new FileOutputStream("singleton_test.txt");
|
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
FileInputStream fis = new FileInputStream(SINGLETON_TEST_TXT);
|
||||||
FileInputStream fis = new FileInputStream("singleton_test.txt");
|
ObjectInputStream ois = new ObjectInputStream(fis)) {
|
||||||
ObjectInputStream ois = new ObjectInputStream(fis)) {
|
|
||||||
|
|
||||||
// Serializing.
|
// Serializing.
|
||||||
oos.writeObject(s1);
|
oos.writeObject(s1);
|
||||||
@ -46,11 +49,10 @@ public class SingletonUnitTest {
|
|||||||
public void givenSingleton_whenSerializedAndDeserialized_thenTwoInstances() {
|
public void givenSingleton_whenSerializedAndDeserialized_thenTwoInstances() {
|
||||||
Singleton s1 = Singleton.getInstance();
|
Singleton s1 = Singleton.getInstance();
|
||||||
|
|
||||||
try (
|
try (FileOutputStream fos = new FileOutputStream(SINGLETON_TEST_TXT);
|
||||||
FileOutputStream fos = new FileOutputStream("singleton_test.txt");
|
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
FileInputStream fis = new FileInputStream(SINGLETON_TEST_TXT);
|
||||||
FileInputStream fis = new FileInputStream("singleton_test.txt");
|
ObjectInputStream ois = new ObjectInputStream(fis)) {
|
||||||
ObjectInputStream ois = new ObjectInputStream(fis)) {
|
|
||||||
|
|
||||||
// Serializing.
|
// Serializing.
|
||||||
oos.writeObject(s1);
|
oos.writeObject(s1);
|
||||||
@ -65,4 +67,12 @@ public class SingletonUnitTest {
|
|||||||
System.out.println(e);
|
System.out.println(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
public static void cleanUp() {
|
||||||
|
final File removeFile = new File(SINGLETON_TEST_TXT);
|
||||||
|
if (removeFile.exists()) {
|
||||||
|
removeFile.deleteOnExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user