diff --git a/core-java-modules/core-java-exceptions-3/README.md b/core-java-modules/core-java-exceptions-3/README.md index 4e3dd22bb8..f136a73daf 100644 --- a/core-java-modules/core-java-exceptions-3/README.md +++ b/core-java-modules/core-java-exceptions-3/README.md @@ -3,3 +3,4 @@ - [NoSuchMethodError in Java](https://www.baeldung.com/java-nosuchmethod-error) - [IllegalArgumentException or NullPointerException for a Null Parameter?](https://www.baeldung.com/java-illegalargumentexception-or-nullpointerexception) - [IllegalMonitorStateException in Java](https://www.baeldung.com/java-illegalmonitorstateexception) +- [AbstractMethodError in Java](https://www.baeldung.com/java-abstractmethoderror) diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/transientkw/Book.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/transientkw/Book.java new file mode 100644 index 0000000000..5822d83841 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/transientkw/Book.java @@ -0,0 +1,42 @@ +package com.baeldung.transientkw; + +import java.io.Serializable; + +public class Book implements Serializable { + + private static final long serialVersionUID = -2936687026040726549L; + + private String bookName; + private transient String description; + private transient int copies; + private final transient String bookCategory = "Fiction"; + + public String getBookName() { + return bookName; + } + + public void setBookName(String bookName) { + this.bookName = bookName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getCopies() { + return copies; + } + + public void setCopies(int copies) { + this.copies = copies; + } + + public String getBookCategory() { + return bookCategory; + } + +} diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/transientkw/BookSerDe.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/transientkw/BookSerDe.java new file mode 100644 index 0000000000..38e018baa3 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/transientkw/BookSerDe.java @@ -0,0 +1,44 @@ +package com.baeldung.transientkw; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +public class BookSerDe { + static String fileName = "book.ser"; + + /** + * Method to serialize Book objects to the file + * @throws FileNotFoundException + */ + public static void serialize(Book book) throws Exception { + FileOutputStream file = new FileOutputStream(fileName); + ObjectOutputStream out = new ObjectOutputStream(file); + + out.writeObject(book); + + out.close(); + file.close(); + } + + /** + * Method to deserialize the person object + * @return book + * @throws IOException, ClassNotFoundException + */ + public static Book deserialize() throws Exception { + FileInputStream file = new FileInputStream(fileName); + ObjectInputStream in = new ObjectInputStream(file); + + Book book = (Book) in.readObject(); + + in.close(); + file.close(); + + return book; + } + +} diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/transientkw/TransientUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/transientkw/TransientUnitTest.java new file mode 100644 index 0000000000..cf63a0ddda --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/transientkw/TransientUnitTest.java @@ -0,0 +1,35 @@ +package com.baeldung.transientkw; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.junit.jupiter.api.Test; + +class TransientUnitTest { + + @Test + void givenTransient_whenSerDe_thenVerifyValues() throws Exception { + Book book = new Book(); + book.setBookName("Java Reference"); + book.setDescription("will not be saved"); + book.setCopies(25); + + BookSerDe.serialize(book); + Book book2 = BookSerDe.deserialize(); + + assertEquals("Java Reference", book2.getBookName()); + assertNull(book2.getDescription()); + assertEquals(0, book2.getCopies()); + } + + @Test + void givenFinalTransient_whenSerDe_thenValuePersisted() throws Exception { + Book book = new Book(); + + BookSerDe.serialize(book); + Book book2 = BookSerDe.deserialize(); + + assertEquals("Fiction", book2.getBookCategory()); + } + +} diff --git a/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/tostring/StringCastUtils.java b/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/tostring/StringCastUtils.java new file mode 100644 index 0000000000..e96c87dfe4 --- /dev/null +++ b/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/tostring/StringCastUtils.java @@ -0,0 +1,17 @@ +package com.baeldung.tostring; + +public class StringCastUtils { + public static String castToString(Object object) { + if (object instanceof String) { + return (String) object; + } + return null; + } + + public static String getStringRepresentation(Object object) { + if (object != null) { + return object.toString(); + } + return null; + } +} diff --git a/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/tostring/ToStringUnitTest.java b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/tostring/ToStringUnitTest.java new file mode 100644 index 0000000000..51a27e1b5c --- /dev/null +++ b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/tostring/ToStringUnitTest.java @@ -0,0 +1,104 @@ +package com.baeldung.tostring; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; + +public class ToStringUnitTest { + @Test + public void givenString_whenCastToObjectAndString_thenSameAndNoException() { + String input = "baeldung"; + + Object obj = input; + String str = (String) obj; + + assertEquals(obj, str); + assertEquals(str, input); + assertSame(input, str); + } + + @Test(expected = ClassCastException.class) + public void givenIntegerObject_whenCastToObjectAndString_thenCastClassException() { + Integer input = 1234; + + Object obj = input; + String str = (String) obj; + } + + @Test + public void givenNullInteger_whenCastToObjectAndString_thenSameAndNoException() { + Integer input = null; + + Object obj = input; + String str = (String) obj; + + assertEquals(obj, str); + assertEquals(str, input); + assertSame(input, str); + } + + @Test(expected = NullPointerException.class) + public void givenNullInteger_whenToString_thenNullPointerException() { + Integer input = null; + + String str = input.toString(); + } + + @Test + public void givenInteger_whenCastToObject_thenToStringEquals() { + Integer input = 1234; + + Object obj = input; + + assertEquals("1234", input.toString()); + assertEquals("1234", obj.toString()); + assertEquals(input.toString(), obj.toString()); + } + + @Test + public void givenString_whenToString_thenSame() { + String str = "baeldung"; + + assertEquals("baeldung", str.toString()); + assertSame(str, str.toString()); + } + + @Test + public void givenString_whenCastToObject_thenCastToStringReturnsSame() { + String input = "baeldung"; + + Object obj = input; + + assertSame(input, StringCastUtils.castToString(obj)); + } + + @Test + public void givenInteger_whenCastToObject_thenCastToStringReturnsNull() { + Integer input = 1234; + + Object obj = input; + + assertEquals(null, StringCastUtils.castToString(obj)); + } + + @Test + public void givenIntegerNull_whenCastToObject_thenCastToStringReturnsNull() { + Integer input = null; + + Object obj = input; + + assertEquals(null, StringCastUtils.castToString(obj)); + } + + @Test + public void givenIntegerNotNull_whenCastToObject_thenGetToStringReturnsString() { + Integer input = 1234; + + Object obj = input; + + assertEquals("1234", StringCastUtils.getStringRepresentation(obj)); + assertNotSame("1234", StringCastUtils.getStringRepresentation(obj)); + } +} diff --git a/core-kotlin-modules/core-kotlin-lang-oop-2/pom.xml b/core-kotlin-modules/core-kotlin-lang-oop-2/pom.xml index f0adea121e..f952911ae1 100644 --- a/core-kotlin-modules/core-kotlin-lang-oop-2/pom.xml +++ b/core-kotlin-modules/core-kotlin-lang-oop-2/pom.xml @@ -22,4 +22,57 @@ - \ No newline at end of file + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-stdlib-jdk7 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-stdlib-common + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-reflect + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-junit + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-common + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-annotations-common + ${kotlin.version} + + + + + + 1.4.10 + + diff --git a/core-kotlin-modules/core-kotlin-lang-oop-2/src/test/kotlin/com/baeldung/kotlin/delegates/DelegateProviderTest.kt b/core-kotlin-modules/core-kotlin-lang-oop-2/src/test/kotlin/com/baeldung/kotlin/delegates/DelegateProviderTest.kt new file mode 100644 index 0000000000..2959ea0e3c --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang-oop-2/src/test/kotlin/com/baeldung/kotlin/delegates/DelegateProviderTest.kt @@ -0,0 +1,42 @@ +package com.baeldung.kotlin.delegates + +import org.junit.Test +import kotlin.properties.PropertyDelegateProvider +import kotlin.reflect.KProperty +import kotlin.test.assertEquals + +class DelegateProvider(private val field: String, private val id: Int) + : PropertyDelegateProvider> { + override operator fun provideDelegate(thisRef: T, prop: KProperty<*>): DatabaseDelegate { + println("Providing delegate for field $field and ID $id") + prop.returnType.isMarkedNullable + return DatabaseDelegate(field, id) + } +} + +class DelegateProvidingUser(val id: Int) { + var name: String by DelegateProvider("name", id) + var age: Int by DelegateProvider("age", id) +} + +class DelegateProviderTest { + @Test + fun testGetKnownFields() { + val user = DelegateProvidingUser(1) + assertEquals("George", user.name) + assertEquals(4, user.age) + } + + @Test + fun testSetKnownFields() { + val user = DelegateProvidingUser(2) + user.age = 3 + assertEquals(3, user.age) + } + + @Test(expected = NoRecordFoundException::class) + fun testGetKnownField() { + val user = DelegateProvidingUser(3) + user.name + } +} diff --git a/gradle/README.md b/gradle/README.md index 84a8508e2c..cf002a7114 100644 --- a/gradle/README.md +++ b/gradle/README.md @@ -8,3 +8,4 @@ This module contains articles about Gradle - [Creating a Fat Jar in Gradle](https://www.baeldung.com/gradle-fat-jar) - [A Custom Task in Gradle](https://www.baeldung.com/gradle-custom-task) - [Using JUnit 5 with Gradle](https://www.baeldung.com/junit-5-gradle) +- [Dependency Management in Gradle](https://www.baeldung.com/gradle-dependency-management) diff --git a/java-native/src/main/java/com/baeldung/jvmbitversion/JVMBitVersion.java b/java-native/src/main/java/com/baeldung/jvmbitversion/JVMBitVersion.java new file mode 100644 index 0000000000..63684fec49 --- /dev/null +++ b/java-native/src/main/java/com/baeldung/jvmbitversion/JVMBitVersion.java @@ -0,0 +1,24 @@ +package com.baeldung.jvmbitversion; + +import com.sun.jna.Platform; + +public class JVMBitVersion { + + public String getUsingSystemClass() { + return System.getProperty("sun.arch.data.model") + "-bit"; + } + + public String getUsingNativeClass() { + if (com.sun.jna.Native.POINTER_SIZE == 8) { + return "64-bit"; + } else if (com.sun.jna.Native.POINTER_SIZE == 4) { + return "32-bit"; + } else + return "unknown"; + } + + public boolean getUsingPlatformClass() { + return (Platform.is64Bit()); + } + +} diff --git a/java-native/src/test/java/com/baeldung/jvmbitversion/JVMBitVersionUnitTest.java b/java-native/src/test/java/com/baeldung/jvmbitversion/JVMBitVersionUnitTest.java new file mode 100644 index 0000000000..152008e5e2 --- /dev/null +++ b/java-native/src/test/java/com/baeldung/jvmbitversion/JVMBitVersionUnitTest.java @@ -0,0 +1,46 @@ +package com.baeldung.jvmbitversion; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +import com.baeldung.jvmbitversion.JVMBitVersion; +import com.sun.jna.Platform; + +public class JVMBitVersionUnitTest { + + private JVMBitVersion jvmVersion; + + @Before + public void setup() { + jvmVersion = new JVMBitVersion(); + } + + @Test + public void whenUsingSystemClass_thenOutputIsAsExpected() { + if (System.getProperty("sun.arch.data.model") == "64") { + assertEquals("64-bit", jvmVersion.getUsingSystemClass()); + } else if (System.getProperty("sun.arch.data.model") == "32") { + assertEquals("32-bit", jvmVersion.getUsingSystemClass()); + } + } + + @Test + public void whenUsingNativeClass_thenResultIsAsExpected() { + if (com.sun.jna.Native.POINTER_SIZE == 8) { + assertEquals("64-bit", jvmVersion.getUsingNativeClass()); + } else if (com.sun.jna.Native.POINTER_SIZE == 4) { + assertEquals("32-bit", jvmVersion.getUsingNativeClass()); + } + } + + @Test + public void whenUsingPlatformClass_thenResultIsAsExpected() { + if (Platform.is64Bit() == Boolean.TRUE) { + assertEquals(Boolean.TRUE, jvmVersion.getUsingPlatformClass()); + } else if (com.sun.jna.Native.POINTER_SIZE == 4) { + assertEquals(Boolean.FALSE, jvmVersion.getUsingPlatformClass()); + } + } +} diff --git a/java-numbers-4/README.md b/java-numbers-4/README.md index 344d348733..7db25b283c 100644 --- a/java-numbers-4/README.md +++ b/java-numbers-4/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Probability in Java](https://www.baeldung.com/java-probability) +- [Understanding the & 0xff Value in Java](https://www.baeldung.com/java-and-0xff) diff --git a/libraries-6/README.md b/libraries-6/README.md index f91ad43bbe..ecad499e07 100644 --- a/libraries-6/README.md +++ b/libraries-6/README.md @@ -17,4 +17,5 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Introduction to Protonpack](https://www.baeldung.com/java-protonpack) - [Java-R Integration](https://www.baeldung.com/java-r-integration) - [Using libphonenumber to Validate Phone Numbers](https://www.baeldung.com/java-libphonenumber) +- [Apache Commons Collections vs Google Guava](https://www.baeldung.com/apache-commons-collections-vs-guava) - More articles [[<-- prev]](/libraries-5) diff --git a/libraries-6/pom.xml b/libraries-6/pom.xml index 7bb6028f17..0f129c27c9 100644 --- a/libraries-6/pom.xml +++ b/libraries-6/pom.xml @@ -76,6 +76,11 @@ commons-lang3 ${commons-lang3.version} + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + commons-net commons-net @@ -156,6 +161,7 @@ RELEASE 3.0 1.8.1 + 4.4 8.12.9 diff --git a/libraries-http-2/README.md b/libraries-http-2/README.md index 5ba45eb4a9..c0d6e76f1b 100644 --- a/libraries-http-2/README.md +++ b/libraries-http-2/README.md @@ -6,5 +6,6 @@ This module contains articles about HTTP libraries. - [Jetty ReactiveStreams HTTP Client](https://www.baeldung.com/jetty-reactivestreams-http-client) - [Decode an OkHttp JSON Response](https://www.baeldung.com/okhttp-json-response) +- [Retrofit 2 – Dynamic URL](https://www.baeldung.com/retrofit-dynamic-url) - More articles [[<-- prev]](/libraries-http) diff --git a/persistence-modules/spring-boot-persistence-2/README.md b/persistence-modules/spring-boot-persistence-2/README.md index e7f32053e4..d7c13fd363 100644 --- a/persistence-modules/spring-boot-persistence-2/README.md +++ b/persistence-modules/spring-boot-persistence-2/README.md @@ -6,4 +6,5 @@ - [List of In-Memory Databases](https://www.baeldung.com/java-in-memory-databases) - [Oracle Connection Pooling With Spring](https://www.baeldung.com/spring-oracle-connection-pooling) - [Object States in Hibernate’s Session](https://www.baeldung.com/hibernate-session-object-states) +- [Storing Files Indexed by a Database](https://www.baeldung.com/java-db-storing-files) - More articles: [[<-- prev]](../spring-boot-persistence) diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/db/indexing/Image.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/db/indexing/Image.java index 5348788c12..e3fcf53f81 100644 --- a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/db/indexing/Image.java +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/db/indexing/Image.java @@ -22,6 +22,10 @@ class Image { public Image() { } + public Image(Long id) { + this.id = id; + } + public Image(String name, String location) { this.name = name; this.location = location; diff --git a/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/db/indexing/FileSystemImageIntegrationTest.java b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/db/indexing/FileSystemImageIntegrationTest.java index 3082f16a78..83f5bae095 100644 --- a/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/db/indexing/FileSystemImageIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/db/indexing/FileSystemImageIntegrationTest.java @@ -35,8 +35,12 @@ class FileSystemImageIntegrationTest { ClassLoader classLoader = ClassLoader.getSystemClassLoader(); InputStream image = classLoader.getResourceAsStream("baeldung.jpeg"); + MockMultipartFile jpegImage = new MockMultipartFile("image", "baeldung", MediaType.TEXT_PLAIN_VALUE, image); MockMultipartHttpServletRequestBuilder multipartRequest = MockMvcRequestBuilders.multipart("/file-system/image") - .file(new MockMultipartFile("image", "baeldung", MediaType.TEXT_PLAIN_VALUE, image)); + .file(jpegImage); + + given(fileLocationService.save(jpegImage.getBytes(), "baeldung")) + .willReturn(1L); MvcResult result = mockMvc.perform(multipartRequest) .andExpect(status().isOk()) diff --git a/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/db/indexing/ImageIntegrationTest.java b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/db/indexing/ImageIntegrationTest.java index f7d4ecf129..e38e0a21a9 100644 --- a/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/db/indexing/ImageIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/db/indexing/ImageIntegrationTest.java @@ -1,6 +1,7 @@ package com.baeldung.db.indexing; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -34,13 +35,10 @@ class ImageIntegrationTest { @Test void givenBaeldungJpegImage_whenUploadIt_thenReturnItsId() throws Exception { - ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - InputStream image = classLoader.getResourceAsStream("baeldung.jpeg"); + given(imageRepository.save(any())) + .willReturn(new Image(1L)); - MockMultipartHttpServletRequestBuilder multipartRequest = MockMvcRequestBuilders.multipart("/image") - .file(new MockMultipartFile("image", "baeldung", MediaType.TEXT_PLAIN_VALUE, image)); - - MvcResult result = mockMvc.perform(multipartRequest) + MvcResult result = mockMvc.perform(createUploadImageRequest()) .andExpect(status().isOk()) .andReturn(); @@ -60,6 +58,14 @@ class ImageIntegrationTest { .andExpect(status().isOk()); } + private MockMultipartHttpServletRequestBuilder createUploadImageRequest() throws IOException { + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + InputStream image = classLoader.getResourceAsStream("baeldung.jpeg"); + + return MockMvcRequestBuilders.multipart("/image") + .file(new MockMultipartFile("multipartImage", "baeldung", MediaType.TEXT_PLAIN_VALUE, image)); + } + private Image baeldungImage() throws IOException { ClassLoader classLoader = ClassLoader.getSystemClassLoader(); diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java index 1e5e88921a..c435f9e320 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java @@ -1,13 +1,10 @@ package com.baeldung.properties; -import com.baeldung.buildproperties.Application; +import com.baeldung.configurationproperties.ConfigProperties; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.annotation.ComponentScan; -import com.baeldung.configurationproperties.ConfigProperties; - @SpringBootApplication @ComponentScan(basePackageClasses = {ConfigProperties.class, AdditionalProperties.class}) public class ConfigPropertiesDemoApplication { diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java index 3b80fa66fe..7f239cbcff 100644 --- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java @@ -4,12 +4,10 @@ import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.configurationproperties.ConfigProperties; import com.baeldung.properties.AdditionalProperties; import com.baeldung.properties.ConfigPropertiesDemoApplication; @@ -19,34 +17,34 @@ import com.baeldung.properties.ConfigPropertiesDemoApplication; public class ConfigPropertiesIntegrationTest { @Autowired - private ConfigProperties properties; + private ConfigProperties configProperties; @Autowired private AdditionalProperties additionalProperties; @Test public void whenSimplePropertyQueriedthenReturnsProperty() throws Exception { - Assert.assertTrue("From address is read as null!", properties.getFrom() != null); + Assert.assertTrue("From address is read as null!", configProperties.getFrom() != null); } @Test public void whenListPropertyQueriedthenReturnsProperty() throws Exception { - Assert.assertTrue("Couldn't bind list property!", properties.getDefaultRecipients().size() == 2); - Assert.assertTrue("Incorrectly bound list property. Expected 2 entries!", properties.getDefaultRecipients().size() == 2); + Assert.assertTrue("Couldn't bind list property!", configProperties.getDefaultRecipients().size() == 2); + Assert.assertTrue("Incorrectly bound list property. Expected 2 entries!", configProperties.getDefaultRecipients().size() == 2); } @Test public void whenMapPropertyQueriedthenReturnsProperty() throws Exception { - Assert.assertTrue("Couldn't bind map property!", properties.getAdditionalHeaders() != null); - Assert.assertTrue("Incorrectly bound map property. Expected 3 Entries!", properties.getAdditionalHeaders().size() == 3); + Assert.assertTrue("Couldn't bind map property!", configProperties.getAdditionalHeaders() != null); + Assert.assertTrue("Incorrectly bound map property. Expected 3 Entries!", configProperties.getAdditionalHeaders().size() == 3); } @Test public void whenObjectPropertyQueriedthenReturnsProperty() throws Exception { - Assert.assertTrue("Couldn't bind map property!", properties.getCredentials() != null); - Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials().getAuthMethod().equals("SHA1")); - Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials().getUsername().equals("john")); - Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials().getPassword().equals("password")); + Assert.assertTrue("Couldn't bind map property!", configProperties.getCredentials() != null); + Assert.assertTrue("Incorrectly bound object property!", configProperties.getCredentials().getAuthMethod().equals("SHA1")); + Assert.assertTrue("Incorrectly bound object property!", configProperties.getCredentials().getUsername().equals("john")); + Assert.assertTrue("Incorrectly bound object property!", configProperties.getCredentials().getPassword().equals("password")); } @Test diff --git a/spring-boot-modules/spring-boot-swagger-jwt/README.md b/spring-boot-modules/spring-boot-swagger-jwt/README.md index 97c76dc431..f04dd5957a 100644 --- a/spring-boot-modules/spring-boot-swagger-jwt/README.md +++ b/spring-boot-modules/spring-boot-swagger-jwt/README.md @@ -1,2 +1,3 @@ ## Relevant Articles: +- [Set JWT with Spring Boot and Swagger UI](https://www.baeldung.com/spring-boot-swagger-jwt) diff --git a/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerUnitTest.java b/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerManualTest.java similarity index 99% rename from spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerUnitTest.java rename to spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerManualTest.java index d23ec836f9..4d3cede534 100644 --- a/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerUnitTest.java +++ b/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerManualTest.java @@ -26,7 +26,7 @@ import org.springframework.test.context.junit4.SpringRunner; @AutoConfigureTestDatabase @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -public class GreetingControllerUnitTest { +public class GreetingControllerManualTest { private static final String SIMPLE_GREETING = "/greeting/simple"; private static final String ADVANCED_GREETING = "/greeting/advanced";