diff --git a/core-java-modules/core-java-serialization/README.md b/core-java-modules/core-java-serialization/README.md new file mode 100644 index 0000000000..fc6cfcf134 --- /dev/null +++ b/core-java-modules/core-java-serialization/README.md @@ -0,0 +1,9 @@ +## Core Java Serialization + +### Relevant Articles: + +- [Guide to the Externalizable Interface in Java](http://www.baeldung.com/java-externalizable) +- [Introduction to Java Serialization](http://www.baeldung.com/java-serialization) +- [Deserialization Vulnerabilities in Java](https://www.baeldung.com/java-deserialization-vulnerabilities) +- [Serialization Validation in Java](https://www.baeldung.com/java-validate-serializable) +- [What is the serialVersionUID?](http://www.baeldung.com/java-serial-version-uid) diff --git a/core-java-modules/core-java-serialization/pom.xml b/core-java-modules/core-java-serialization/pom.xml new file mode 100644 index 0000000000..74a78e8b48 --- /dev/null +++ b/core-java-modules/core-java-serialization/pom.xml @@ -0,0 +1,194 @@ + + + 4.0.0 + core-java-serialization + 0.1.0-SNAPSHOT + core-java-serialization + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../ + + + + + org.unix4j + unix4j-command + ${unix4j.version} + + + com.googlecode.grep4j + grep4j + ${grep4j.version} + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + log4j + log4j + ${log4j.version} + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + org.springframework + spring-core + ${spring.core.version} + + + org.springframework + spring-core + 4.3.20.RELEASE + test + + + + + core-java + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + prepare-package + + copy-dependencies + + + ${project.build.directory}/libs + + + + + + org.codehaus.mojo + exec-maven-plugin + + java + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + -Xmx300m + -XX:+UseParallelGC + -classpath + + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + ${source.version} + ${target.version} + + + + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*ManualTest.java + + + **/*IntegrationTest.java + **/*IntTest.java + + + + + + + json + + + + + org.codehaus.mojo + exec-maven-plugin + + + run-benchmarks + + none + + exec + + + test + java + + -classpath + + org.openjdk.jmh.Main + .* + + + + + + + + + + + + + 0.4 + 1.8.7 + + 3.10.0 + + 1.1 + 3.0.0-M1 + 1.8 + 1.8 + 4.3.20.RELEASE + + + \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/AppleProduct.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/AppleProduct.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/deserialization/DefaultSerial.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/DefaultSerial.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/deserialization/DefaultSerial.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/DefaultSerial.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/DeserializationUtility.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/DeserializationUtility.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/SerializationUtility.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/SerializationUtility.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Community.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Community.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Community.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Community.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Country.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Country.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Country.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Country.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Region.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Region.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Region.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Region.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/serialization/Address.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Address.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/serialization/Address.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Address.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/serialization/Employee.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Employee.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/serialization/Employee.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Employee.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/serialization/Person.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Person.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/serialization/Person.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Person.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/util/MySerializationUtils.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/util/MySerializationUtils.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/util/MySerializationUtils.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/util/MySerializationUtils.java diff --git a/core-java-modules/core-java-serialization/src/main/resources/log4j.properties b/core-java-modules/core-java-serialization/src/main/resources/log4j.properties new file mode 100644 index 0000000000..621cf01735 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/main/resources/log4j.properties @@ -0,0 +1,6 @@ +log4j.rootLogger=DEBUG, A1 + +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/main/resources/log4j2.xml b/core-java-modules/core-java-serialization/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..a824bef9b0 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/main/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/main/resources/log4jstructuraldp.properties b/core-java-modules/core-java-serialization/src/main/resources/log4jstructuraldp.properties new file mode 100644 index 0000000000..5bc2bfe4b9 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/main/resources/log4jstructuraldp.properties @@ -0,0 +1,9 @@ + +# Root logger +log4j.rootLogger=INFO, file, stdout + +# Write to console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/main/resources/logback.xml b/core-java-modules/core-java-serialization/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/core-java-modules/core-java-serialization/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java similarity index 92% rename from core-java-modules/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java rename to core-java-modules/core-java-serialization/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java index d7c1ee17d4..cc45cbc8e0 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java +++ b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.io.InvalidClassException; +import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -24,7 +25,7 @@ public class DeserializationUnitTest { @Test public void testDeserializeObj_compatible() throws IOException, ClassNotFoundException { - assertEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); + Assert.assertEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); AppleProduct macBook = new AppleProduct(); macBook.headphonePort = "headphonePort2020"; @@ -60,7 +61,7 @@ public class DeserializationUnitTest { @Test(expected = InvalidClassException.class) public void testDeserializeObj_incompatible() throws ClassNotFoundException, IOException { - assertNotEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); + Assert.assertNotEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); // attempts to deserialize the "AppleProduct" object DeserializationUtility.deSerializeObjectFromString(serializedObj); } diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/serialization/PersonUnitTest.java similarity index 100% rename from core-java-modules/core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java rename to core-java-modules/core-java-serialization/src/test/java/com/baeldung/serialization/PersonUnitTest.java diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/serialization/SerializationUnitTest.java similarity index 100% rename from core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java rename to core-java-modules/core-java-serialization/src/test/java/com/baeldung/serialization/SerializationUnitTest.java diff --git a/core-java-modules/core-java-serialization/src/test/resources/log4j.properties b/core-java-modules/core-java-serialization/src/test/resources/log4j.properties new file mode 100644 index 0000000000..621cf01735 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/test/resources/log4j.properties @@ -0,0 +1,6 @@ +log4j.rootLogger=DEBUG, A1 + +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/test/resources/log4j2.xml b/core-java-modules/core-java-serialization/src/test/resources/log4j2.xml new file mode 100644 index 0000000000..a824bef9b0 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/test/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/test/resources/log4jstructuraldp.properties b/core-java-modules/core-java-serialization/src/test/resources/log4jstructuraldp.properties new file mode 100644 index 0000000000..5bc2bfe4b9 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/test/resources/log4jstructuraldp.properties @@ -0,0 +1,9 @@ + +# Root logger +log4j.rootLogger=INFO, file, stdout + +# Write to console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/test/resources/logback.xml b/core-java-modules/core-java-serialization/src/test/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/core-java-modules/core-java-serialization/src/test/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/README.md b/core-java-modules/core-java-uuid/README.md new file mode 100644 index 0000000000..836552d798 --- /dev/null +++ b/core-java-modules/core-java-uuid/README.md @@ -0,0 +1,5 @@ +## Core Java UUID + +### Relevant Articles: +- [Generating Alphanumeric UUID String in Java](https://www.baeldung.com/java-generate-alphanumeric-uuid) +- [Guide to UUID in Java](http://www.baeldung.com/java-uuid) diff --git a/core-java-modules/core-java-uuid/pom.xml b/core-java-modules/core-java-uuid/pom.xml new file mode 100644 index 0000000000..fba36ada8e --- /dev/null +++ b/core-java-modules/core-java-uuid/pom.xml @@ -0,0 +1,156 @@ + + + 4.0.0 + core-java-uuid + 0.1.0-SNAPSHOT + core-java-uuid + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + + + + + log4j + log4j + ${log4j.version} + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + + core-java-uuid + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + prepare-package + + copy-dependencies + + + ${project.build.directory}/libs + + + + + + org.codehaus.mojo + exec-maven-plugin + + java + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + -Xmx300m + -XX:+UseParallelGC + -classpath + + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + ${source.version} + ${target.version} + + + + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*ManualTest.java + + + **/*IntegrationTest.java + **/*IntTest.java + + + + + + + json + + + + + org.codehaus.mojo + exec-maven-plugin + + + run-benchmarks + + none + + exec + + + test + java + + -classpath + + org.openjdk.jmh.Main + .* + + + + + + + + + + + + 3.10.0 + 3.0.0-M1 + 1.8 + 1.8 + + + \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/uuid/UUIDGenerator.java b/core-java-modules/core-java-uuid/src/main/java/com/baeldung/uuid/UUIDGenerator.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/uuid/UUIDGenerator.java rename to core-java-modules/core-java-uuid/src/main/java/com/baeldung/uuid/UUIDGenerator.java diff --git a/core-java-modules/core-java-uuid/src/main/resources/log4j.properties b/core-java-modules/core-java-uuid/src/main/resources/log4j.properties new file mode 100644 index 0000000000..621cf01735 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/main/resources/log4j.properties @@ -0,0 +1,6 @@ +log4j.rootLogger=DEBUG, A1 + +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/main/resources/log4j2.xml b/core-java-modules/core-java-uuid/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..a824bef9b0 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/main/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/main/resources/log4jstructuraldp.properties b/core-java-modules/core-java-uuid/src/main/resources/log4jstructuraldp.properties new file mode 100644 index 0000000000..5bc2bfe4b9 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/main/resources/log4jstructuraldp.properties @@ -0,0 +1,9 @@ + +# Root logger +log4j.rootLogger=INFO, file, stdout + +# Write to console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/main/resources/logback.xml b/core-java-modules/core-java-uuid/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/core-java-modules/core-java-uuid/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/uuid/UUIDGeneratorUnitTest.java b/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/UUIDGeneratorUnitTest.java similarity index 100% rename from core-java-modules/core-java/src/test/java/com/baeldung/uuid/UUIDGeneratorUnitTest.java rename to core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/UUIDGeneratorUnitTest.java diff --git a/core-java-modules/core-java-uuid/src/test/resources/log4j.properties b/core-java-modules/core-java-uuid/src/test/resources/log4j.properties new file mode 100644 index 0000000000..621cf01735 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/test/resources/log4j.properties @@ -0,0 +1,6 @@ +log4j.rootLogger=DEBUG, A1 + +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/test/resources/log4j2.xml b/core-java-modules/core-java-uuid/src/test/resources/log4j2.xml new file mode 100644 index 0000000000..a824bef9b0 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/test/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/test/resources/log4jstructuraldp.properties b/core-java-modules/core-java-uuid/src/test/resources/log4jstructuraldp.properties new file mode 100644 index 0000000000..5bc2bfe4b9 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/test/resources/log4jstructuraldp.properties @@ -0,0 +1,9 @@ + +# Root logger +log4j.rootLogger=INFO, file, stdout + +# Write to console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/test/resources/logback.xml b/core-java-modules/core-java-uuid/src/test/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/core-java-modules/core-java-uuid/src/test/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java/README.md b/core-java-modules/core-java/README.md index 3285a7e663..a75805e0c2 100644 --- a/core-java-modules/core-java/README.md +++ b/core-java-modules/core-java/README.md @@ -3,14 +3,7 @@ ### Relevant Articles: - [Getting Started with Java Properties](http://www.baeldung.com/java-properties) - [Java Money and the Currency API](http://www.baeldung.com/java-money-and-currency) -- [Introduction to Java Serialization](http://www.baeldung.com/java-serialization) -- [Guide to UUID in Java](http://www.baeldung.com/java-uuid) - [Compiling Java *.class Files with javac](http://www.baeldung.com/javac) - [Introduction to Javadoc](http://www.baeldung.com/javadoc) -- [Guide to the Externalizable Interface in Java](http://www.baeldung.com/java-externalizable) -- [What is the serialVersionUID?](http://www.baeldung.com/java-serial-version-uid) - [A Guide to the ResourceBundle](http://www.baeldung.com/java-resourcebundle) - [Merging java.util.Properties Objects](https://www.baeldung.com/java-merging-properties) -- [Deserialization Vulnerabilities in Java](https://www.baeldung.com/java-deserialization-vulnerabilities) -- [Generating Alphanumeric UUID String in Java](https://www.baeldung.com/java-generate-alphanumeric-uuid) -- [Serialization Validation in Java](https://www.baeldung.com/java-validate-serializable) diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java deleted file mode 100644 index 651364fb13..0000000000 --- a/core-java-modules/core-java/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.baeldung.externalizable; - -import org.junit.Test; - -import java.io.*; - -import static org.junit.Assert.assertTrue; - -public class ExternalizableUnitTest { - - private final static String OUTPUT_FILE = "externalizable.txt"; - - @Test - public void whenSerializing_thenUseExternalizable() throws IOException, ClassNotFoundException { - - Country c = new Country(); - c.setCapital("Yerevan"); - c.setCode(374); - c.setName("Armenia"); - - FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE); - ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream); - c.writeExternal(objectOutputStream); - - objectOutputStream.flush(); - objectOutputStream.close(); - fileOutputStream.close(); - - FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE); - ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); - - Country c2 = new Country(); - c2.readExternal(objectInputStream); - - objectInputStream.close(); - fileInputStream.close(); - - assertTrue(c2.getCode() == c.getCode()); - assertTrue(c2.getName().equals(c.getName())); - } - - @Test - public void whenInheritanceSerialization_then_UseExternalizable() throws IOException, ClassNotFoundException { - - Region r = new Region(); - r.setCapital("Yerevan"); - r.setCode(374); - r.setName("Armenia"); - r.setClimate("Mediterranean"); - r.setPopulation(120.000); - - FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE); - ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream); - r.writeExternal(objectOutputStream); - - objectOutputStream.flush(); - objectOutputStream.close(); - fileOutputStream.close(); - - FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE); - ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); - - Region r2 = new Region(); - r2.readExternal(objectInputStream); - - objectInputStream.close(); - fileInputStream.close(); - - assertTrue(r2.getPopulation() == null); - } -} diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index c3d17e7637..d8191e74d0 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -100,6 +100,7 @@ core-java-security core-java-security-2 core-java-security-3 + core-java-serialization core-java-streams core-java-streams-2 core-java-streams-3 @@ -115,6 +116,7 @@ core-java-sun core-java-regex core-java-regex-2 + core-java-uuid pre-jpms diff --git a/pom.xml b/pom.xml index 372bc5a9f3..4af2e422f4 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,9 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + + core-java-uuid + parent-modules pom