diff --git a/apache-poi/README.md b/apache-poi/README.md index 34e7631087..ed30d9a4f3 100644 --- a/apache-poi/README.md +++ b/apache-poi/README.md @@ -14,4 +14,5 @@ This module contains articles about Apache POI. - [Set Background Color of a Cell with Apache POI](https://www.baeldung.com/apache-poi-background-color) - [Add Borders to Excel Cells With Apache POI](https://www.baeldung.com/apache-poi-add-borders) - [Reading Values From Excel in Java](https://www.baeldung.com/java-read-dates-excel) +- [Change Cell Font Style with Apache POI](https://www.baeldung.com/apache-poi-change-cell-font) - More articles: [[next -->]](../apache-poi-2) diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/cellstyle/CellStyler.java b/apache-poi/src/main/java/com/baeldung/poi/excel/cellstyle/CellStyler.java new file mode 100644 index 0000000000..6d8b303fd3 --- /dev/null +++ b/apache-poi/src/main/java/com/baeldung/poi/excel/cellstyle/CellStyler.java @@ -0,0 +1,26 @@ +package com.baeldung.poi.excel.cellstyle; + +import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.usermodel.Workbook; + +public class CellStyler { + public CellStyle createWarningColor(Workbook workbook) { + CellStyle style = workbook.createCellStyle(); + + Font font = workbook.createFont(); + font.setFontName("Courier New"); + font.setBold(true); + font.setUnderline(Font.U_SINGLE); + font.setColor(HSSFColorPredefined.DARK_RED.getIndex()); + style.setFont(font); + + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + return style; + } +} diff --git a/apache-poi/src/main/resources/com/baeldung/poi/excel/cellstyle/CellStyle.xlsx b/apache-poi/src/main/resources/com/baeldung/poi/excel/cellstyle/CellStyle.xlsx new file mode 100644 index 0000000000..ca9394246a Binary files /dev/null and b/apache-poi/src/main/resources/com/baeldung/poi/excel/cellstyle/CellStyle.xlsx differ diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/cellstyle/CellStylerUnitTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/cellstyle/CellStylerUnitTest.java new file mode 100644 index 0000000000..074e51919a --- /dev/null +++ b/apache-poi/src/test/java/com/baeldung/poi/excel/cellstyle/CellStylerUnitTest.java @@ -0,0 +1,52 @@ +package com.baeldung.poi.excel.cellstyle; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Paths; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Before; +import org.junit.Test; + +public class CellStylerUnitTest { + private static String FILE_NAME = "com/baeldung/poi/excel/cellstyle/CellStyle.xlsx"; + private static final String NEW_FILE_NAME = "CellStyleTest_output.xlsx"; + private String fileLocation; + + @Before + public void setup() throws IOException, URISyntaxException { + fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME) + .toURI()) + .toString(); + } + + @Test + public void testApplyWarningColor() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row1 = sheet.createRow(0); + row1.setHeightInPoints((short) 40); + + CellStyler styler = new CellStyler(); + CellStyle style = styler.createWarningColor(workbook); + + Cell cell1 = row1.createCell(0); + cell1.setCellStyle(style); + cell1.setCellValue("Hello"); + + Cell cell2 = row1.createCell(1); + cell2.setCellStyle(style); + cell2.setCellValue("world!"); + + FileOutputStream outputStream = new FileOutputStream(NEW_FILE_NAME); + workbook.write(outputStream); + outputStream.close(); + workbook.close(); + } +} diff --git a/core-java-modules/core-java-concurrency-collections-2/README.md b/core-java-modules/core-java-concurrency-collections-2/README.md index 6ad6529efc..692c218395 100644 --- a/core-java-modules/core-java-concurrency-collections-2/README.md +++ b/core-java-modules/core-java-concurrency-collections-2/README.md @@ -2,4 +2,5 @@ - [Introduction to Lock Striping](https://www.baeldung.com/java-lock-stripping) - [Guide to the Java TransferQueue](http://www.baeldung.com/java-transfer-queue) +- [Java Concurrent HashSet Equivalent to ConcurrentHashMap](https://www.baeldung.com/java-concurrent-hashset-concurrenthashmap) - [[<-- Prev]](/core-java-modules/core-java-concurrency-collections) diff --git a/core-java-modules/core-java-jndi/README.md b/core-java-modules/core-java-jndi/README.md index b0b23fc0d0..9c6f489841 100644 --- a/core-java-modules/core-java-jndi/README.md +++ b/core-java-modules/core-java-jndi/README.md @@ -3,3 +3,4 @@ - [Java Naming and Directory Interface Overview](https://www.baeldung.com/jndi) - [LDAP Authentication Using Pure Java](https://www.baeldung.com/java-ldap-auth) +- [Testing LDAP Connections With Java](https://www.baeldung.com/java-test-ldap-connections) diff --git a/core-java-modules/core-java-lang-oop-constructors/README.md b/core-java-modules/core-java-lang-oop-constructors/README.md index 6083f1d0df..ddd0ec6afb 100644 --- a/core-java-modules/core-java-lang-oop-constructors/README.md +++ b/core-java-modules/core-java-lang-oop-constructors/README.md @@ -10,3 +10,4 @@ This module contains article about constructors in Java - [Throwing Exceptions in Constructors](https://www.baeldung.com/java-constructors-exceptions) - [Constructors in Java Abstract Classes](https://www.baeldung.com/java-abstract-classes-constructors) - [Java Implicit Super Constructor is Undefined Error](https://www.baeldung.com/java-implicit-super-constructor-is-undefined-error) +- [Constructor Specification in Java](https://www.baeldung.com/java-constructor-specification) diff --git a/core-java-modules/core-java-nio-2/README.md b/core-java-modules/core-java-nio-2/README.md index 52efa0330a..9152a494d8 100644 --- a/core-java-modules/core-java-nio-2/README.md +++ b/core-java-modules/core-java-nio-2/README.md @@ -11,4 +11,5 @@ This module contains articles about core Java non-blocking input and output (IO) - [How to Lock a File in Java](https://www.baeldung.com/java-lock-files) - [Java NIO DatagramChannel](https://www.baeldung.com/java-nio-datagramchannel) - [Java – Path vs File](https://www.baeldung.com/java-path-vs-file) +- [What Is the Difference Between NIO and NIO.2?](https://www.baeldung.com/java-nio-vs-nio-2) - [[<-- Prev]](/core-java-modules/core-java-nio) diff --git a/core-java-modules/core-java-security-3/README.md b/core-java-modules/core-java-security-3/README.md index 30cfd8a947..31969cd270 100644 --- a/core-java-modules/core-java-security-3/README.md +++ b/core-java-modules/core-java-security-3/README.md @@ -8,4 +8,6 @@ This module contains articles about core Java Security - [Enabling Unlimited Strength Cryptography in Java](https://www.baeldung.com/jce-enable-unlimited-strength) - [Initialization Vector for Encryption](https://www.baeldung.com/java-encryption-iv) - [HMAC in Java](https://www.baeldung.com/java-hmac) +- [Generating a Secure AES Key in Java](https://www.baeldung.com/java-secure-aes-key) +- [Computing an X509 Certificate’s Thumbprint in Java](https://www.baeldung.com/java-x509-certificate-thumbprint) - More articles: [[<-- prev]](/core-java-modules/core-java-security-2) diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md index 87817331b5..75842c85a4 100644 --- a/java-collections-maps-3/README.md +++ b/java-collections-maps-3/README.md @@ -6,3 +6,4 @@ - [Optimizing HashMap’s Performance](https://www.baeldung.com/java-hashmap-optimize-performance) - [Update the Value Associated With a Key in a HashMap](https://www.baeldung.com/java-hashmap-update-value-by-key) - [Java Map – keySet() vs. entrySet() vs. values() Methods](https://www.baeldung.com/java-map-entries-methods) +- [Java IdentityHashMap Class and Its Use Cases](https://www.baeldung.com/java-identityhashmap) diff --git a/javafx/README.md b/javafx/README.md index 8ef06eb012..5e034adb38 100644 --- a/javafx/README.md +++ b/javafx/README.md @@ -3,6 +3,8 @@ This module contains articles about JavaFX. ### Relevant Articles: + - [Introduction to JavaFX](https://www.baeldung.com/javafx) - [Display Custom Items in JavaFX ListView](https://www.baeldung.com/javafx-listview-display-custom-items) +- [Adding EventHandler to JavaFX Button](https://www.baeldung.com/javafx-button-eventhandler) diff --git a/persistence-modules/spring-data-jpa-repo-2/README.md b/persistence-modules/spring-data-jpa-repo-2/README.md index be5bab1b56..6403510e6f 100644 --- a/persistence-modules/spring-data-jpa-repo-2/README.md +++ b/persistence-modules/spring-data-jpa-repo-2/README.md @@ -1,7 +1,9 @@ ## Spring Data JPA - Repositories ### Relevant Articles: + - [Introduction to Spring Data JPA](https://www.baeldung.com/the-persistence-layer-with-spring-data-jpa) - [Performance Difference Between save() and saveAll() in Spring Data](https://www.baeldung.com/spring-data-save-saveall) - [LIKE Queries in Spring JPA Repositories](https://www.baeldung.com/spring-jpa-like-queries) +- [How to Access EntityManager with Spring Data](https://www.baeldung.com/spring-data-entitymanager) - More articles: [[<-- prev]](../spring-data-jpa-repo) diff --git a/spring-cloud/spring-cloud-gateway/README.md b/spring-cloud/spring-cloud-gateway/README.md index 90e81fe9a2..6b199977e3 100644 --- a/spring-cloud/spring-cloud-gateway/README.md +++ b/spring-cloud/spring-cloud-gateway/README.md @@ -3,7 +3,9 @@ This module contains articles about Spring Cloud Gateway ### Relevant Articles: + - [Exploring the new Spring Cloud Gateway](http://www.baeldung.com/spring-cloud-gateway) - [Writing Custom Spring Cloud Gateway Filters](https://www.baeldung.com/spring-cloud-custom-gateway-filters) - [Spring Cloud Gateway Routing Predicate Factories](https://www.baeldung.com/spring-cloud-gateway-routing-predicate-factories) - [Spring Cloud Gateway WebFilter Factories](https://www.baeldung.com/spring-cloud-gateway-webfilter-factories) +- [Using Spring Cloud Gateway with OAuth 2.0 Patterns](https://www.baeldung.com/spring-cloud-gateway-oauth2) diff --git a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/secondservice/SecondServiceIntegrationTest.java b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/secondservice/SecondServiceIntegrationTest.java index 6b2a432d20..f4b3d0f00d 100644 --- a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/secondservice/SecondServiceIntegrationTest.java +++ b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/secondservice/SecondServiceIntegrationTest.java @@ -2,12 +2,14 @@ package com.baeldung.springcloudgateway.customfilters.secondservice; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration; import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.test.web.reactive.server.WebTestClient; import com.baeldung.springcloudgateway.customfilters.secondservice.web.SecondServiceRestController; -@WebFluxTest(SecondServiceRestController.class) +@WebFluxTest(controllers = SecondServiceRestController.class, + excludeAutoConfiguration = ReactiveSecurityAutoConfiguration.class) public class SecondServiceIntegrationTest { @Autowired diff --git a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/service/ServiceIntegrationTest.java b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/service/ServiceIntegrationTest.java index bfb3f23f0d..9990cd003c 100644 --- a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/service/ServiceIntegrationTest.java +++ b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/service/ServiceIntegrationTest.java @@ -2,13 +2,15 @@ package com.baeldung.springcloudgateway.customfilters.service; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration; import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.http.HttpHeaders; import org.springframework.test.web.reactive.server.WebTestClient; import com.baeldung.springcloudgateway.customfilters.service.web.ServiceRestController; -@WebFluxTest(ServiceRestController.class) +@WebFluxTest(controllers = ServiceRestController.class, + excludeAutoConfiguration = ReactiveSecurityAutoConfiguration.class) public class ServiceIntegrationTest { @Autowired