Merge branch 'eugenp:master' into master
This commit is contained in:
commit
8f90fda9be
BIN
.local-db/todos.mv.db
Normal file
BIN
.local-db/todos.mv.db
Normal file
Binary file not shown.
BIN
.local-db/topics.mv.db
Normal file
BIN
.local-db/topics.mv.db
Normal file
Binary file not shown.
50
README.md
50
README.md
@ -18,27 +18,33 @@ Java and Spring Tutorials
|
||||
|
||||
This project is **a collection of small and focused tutorials** - each covering a single and well defined area of development in the Java ecosystem.
|
||||
A strong focus of these is, of course, the Spring Framework - Spring, Spring Boot and Spring Security.
|
||||
In additional to Spring, the modules here are covering a number of aspects in Java.
|
||||
In addition to Spring, the modules here cover a number of aspects of Java.
|
||||
|
||||
Profile based segregation
|
||||
====================
|
||||
|
||||
We are using maven build profiles to segregate the huge list of individual projects we have in our repository.
|
||||
|
||||
The projects are broadly divided into 3 list: first, second and heavy.
|
||||
As for now, vast majority of the modules require JDK8 to build and run correctly.
|
||||
|
||||
Next, they are segregated further on the basis of tests that we want to execute.
|
||||
The projects are broadly divided into 3 lists: first, second and heavy.
|
||||
|
||||
Therefore, we have a total of 6 profiles:
|
||||
Next, they are segregated further on the basis of the tests that we want to execute.
|
||||
|
||||
| Profile | Includes | Type of test enabled |
|
||||
| ----------------------- | --------------------------- | -------------------- |
|
||||
| default-first | First set of projects | *UnitTest |
|
||||
| integration-lite-first | First set of projects | *IntegrationTest |
|
||||
| default-second | Second set of projects | *UnitTest |
|
||||
| integration-lite-second | Second set of projects | *IntegrationTest |
|
||||
| default-heavy | Heavy/long running projects | *UnitTest |
|
||||
| integration-heavy | Heavy/long running projects | *IntegrationTest |
|
||||
Additionally, there are 2 profiles dedicated for JDK9 and above builds.
|
||||
|
||||
Therefore, we have a total of 8 profiles:
|
||||
|
||||
| Profile | Includes | Type of test enabled |
|
||||
| -------------------------- | --------------------------- | -------------------- |
|
||||
| default-first | First set of projects | *UnitTest |
|
||||
| integration-lite-first | First set of projects | *IntegrationTest |
|
||||
| default-second | Second set of projects | *UnitTest |
|
||||
| integration-lite-second | Second set of projects | *IntegrationTest |
|
||||
| default-heavy | Heavy/long running projects | *UnitTest |
|
||||
| integration-heavy | Heavy/long running projects | *IntegrationTest |
|
||||
| default-jdk9-and-above | JDK9 and above projects | *UnitTest |
|
||||
| integration-jdk9-and-above | JDK9 and above projects | *IntegrationTest |
|
||||
|
||||
Building the project
|
||||
====================
|
||||
@ -53,15 +59,22 @@ or if we want to build the entire repository with Integration Tests enabled, we
|
||||
|
||||
`mvn clean install -Pintegration-lite-first,integration-lite-second,integration-heavy`
|
||||
|
||||
Analogously, for the JDK9 and above projects the commands are:
|
||||
|
||||
`mvn clean install -Pdefault-jdk9-and-above`
|
||||
|
||||
and
|
||||
|
||||
`mvn clean install -Pintegration-jdk9-and-above`
|
||||
|
||||
Building a single module
|
||||
====================
|
||||
To build a specific module run the command: `mvn clean install` in the module directory
|
||||
To build a specific module, run the command: `mvn clean install` in the module directory.
|
||||
|
||||
|
||||
Running a Spring Boot module
|
||||
====================
|
||||
To run a Spring Boot module run the command: `mvn spring-boot:run` in the module directory
|
||||
To run a Spring Boot module, run the command: `mvn spring-boot:run` in the module directory.
|
||||
|
||||
|
||||
Working with the IDE
|
||||
@ -81,11 +94,8 @@ To run the integration tests, use the command:
|
||||
|
||||
`mvn clean install -Pintegration-lite-second` or
|
||||
|
||||
`mvn clean install -Pintegration-heavy`
|
||||
`mvn clean install -Pintegration-heavy` or
|
||||
|
||||
`mvn clean install -Pintegration-jdk9-and-above`
|
||||
|
||||
depending on the list where our module exists
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -35,18 +35,11 @@
|
||||
<artifactId>jenetics</artifactId>
|
||||
<version>${io.jenetics.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<io.jenetics.version>3.7.0</io.jenetics.version>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
</properties>
|
||||
|
||||
|
@ -18,15 +18,16 @@ public class Travel {
|
||||
}
|
||||
|
||||
public void generateInitialTravel() {
|
||||
if (travel.isEmpty())
|
||||
if (travel.isEmpty()) {
|
||||
new Travel(10);
|
||||
}
|
||||
Collections.shuffle(travel);
|
||||
}
|
||||
|
||||
public void swapCities() {
|
||||
int a = generateRandomIndex();
|
||||
int b = generateRandomIndex();
|
||||
previousTravel = travel;
|
||||
previousTravel = new ArrayList<>(travel);
|
||||
City x = travel.get(a);
|
||||
City y = travel.get(b);
|
||||
travel.set(a, y);
|
||||
|
@ -35,12 +35,6 @@
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.dpaukov</groupId>
|
||||
<artifactId>combinatoricslib3</artifactId>
|
||||
@ -70,9 +64,7 @@
|
||||
|
||||
<properties>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
<guava.version>27.0.1-jre</guava.version>
|
||||
<combinatoricslib3.version>3.3.0</combinatoricslib3.version>
|
||||
<cobertura.plugin.version>2.7</cobertura.plugin.version>
|
||||
</properties>
|
||||
|
@ -45,12 +45,6 @@
|
||||
<artifactId>tradukisto</artifactId>
|
||||
<version>${tradukisto.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<reporting>
|
||||
@ -78,7 +72,6 @@
|
||||
<tradukisto.version>1.0.1</tradukisto.version>
|
||||
<org.jgrapht.core.version>1.0.1</org.jgrapht.core.version>
|
||||
<org.jgrapht.ext.version>1.0.1</org.jgrapht.ext.version>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
<cobertura-maven-plugin.version>2.7</cobertura-maven-plugin.version>
|
||||
</properties>
|
||||
|
@ -14,12 +14,6 @@
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
@ -43,7 +37,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons.lang3.version}</version>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pl.pragmatists</groupId>
|
||||
@ -69,11 +63,7 @@
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<commons-collections4.version>4.3</commons-collections4.version>
|
||||
<guava.version>28.0-jre</guava.version>
|
||||
<retrofit.version>2.6.0</retrofit.version>
|
||||
<commons.lang3.version>3.8.1</commons.lang3.version>
|
||||
<JUnitParams.version>1.1.0</JUnitParams.version>
|
||||
</properties>
|
||||
|
||||
|
@ -25,17 +25,6 @@
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<guava.version>27.0.1-jre</guava.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -34,25 +34,12 @@
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-commons</artifactId>
|
||||
<version>${junit-platform.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<tradukisto.version>1.0.1</tradukisto.version>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<guava.version>28.1-jre</guava.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -19,17 +19,6 @@
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-commons</artifactId>
|
||||
<version>${junit-platform.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
@ -44,8 +33,6 @@
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<guava.version>28.1-jre</guava.version>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
</properties>
|
||||
|
||||
|
@ -1,11 +1,16 @@
|
||||
package com.baeldung.algorithms.caesarcipher;
|
||||
|
||||
import org.apache.commons.math3.stat.inference.ChiSquareTest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class CaesarCipher {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(CaesarCipher.class);
|
||||
|
||||
private static final char LETTER_A = 'a';
|
||||
private static final char LETTER_Z = 'z';
|
||||
private static final int ALPHABET_SIZE = LETTER_Z - LETTER_A + 1;
|
||||
@ -72,7 +77,7 @@ public class CaesarCipher {
|
||||
private int probableOffset(double[] chiSquares) {
|
||||
int probableOffset = 0;
|
||||
for (int offset = 0; offset < chiSquares.length; offset++) {
|
||||
System.out.println(String.format("Chi-Square for offset %d: %.2f", offset, chiSquares[offset]));
|
||||
log.debug(String.format("Chi-Square for offset %d: %.2f", offset, chiSquares[offset]));
|
||||
if (chiSquares[offset] < chiSquares[probableOffset]) {
|
||||
probableOffset = offset;
|
||||
}
|
||||
|
@ -13,15 +13,6 @@
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>algorithms-searching</finalName>
|
||||
<resources>
|
||||
@ -32,8 +23,4 @@
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -16,7 +16,7 @@ public class BreadthFirstSearchAlgorithm {
|
||||
Tree<T> currentNode;
|
||||
while (!queue.isEmpty()) {
|
||||
currentNode = queue.remove();
|
||||
LOGGER.info("Visited node with value: {}", currentNode.getValue());
|
||||
LOGGER.debug("Visited node with value: {}", currentNode.getValue());
|
||||
|
||||
if (currentNode.getValue().equals(value)) {
|
||||
return Optional.of(currentNode);
|
||||
@ -37,7 +37,7 @@ public class BreadthFirstSearchAlgorithm {
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
currentNode = queue.remove();
|
||||
LOGGER.info("Visited node with value: {}", currentNode.getValue());
|
||||
LOGGER.debug("Visited node with value: {}", currentNode.getValue());
|
||||
|
||||
if (currentNode.getValue().equals(value)) {
|
||||
return Optional.of(currentNode);
|
||||
|
@ -35,6 +35,7 @@ public class QuadTreeSearchUnitTest {
|
||||
public void givenQuadTree_whenSearchingForRange_thenReturn1MatchingItem() {
|
||||
Region searchArea = new Region(200, 200, 250, 250);
|
||||
List<Point> result = quadTree.search(searchArea, null, "");
|
||||
|
||||
LOGGER.debug(result.toString());
|
||||
LOGGER.debug(quadTree.printSearchTraversePath());
|
||||
|
||||
@ -47,6 +48,7 @@ public class QuadTreeSearchUnitTest {
|
||||
public void givenQuadTree_whenSearchingForRange_thenReturn2MatchingItems() {
|
||||
Region searchArea = new Region(0, 0, 100, 100);
|
||||
List<Point> result = quadTree.search(searchArea, null, "");
|
||||
|
||||
LOGGER.debug(result.toString());
|
||||
LOGGER.debug(quadTree.printSearchTraversePath());
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class SuffixTreeUnitTest {
|
||||
public void givenSuffixTree_whenSearchingForA_thenReturn6Matches() {
|
||||
List<String> matches = suffixTree.searchText("a");
|
||||
matches.stream()
|
||||
.forEach(m -> LOGGER.info(m));
|
||||
.forEach(m -> LOGGER.debug(m));
|
||||
Assert.assertArrayEquals(new String[] { "h[a]vanabanana", "hav[a]nabanana", "havan[a]banana", "havanab[a]nana", "havanaban[a]na", "havanabanan[a]" }, matches.toArray());
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ public class SuffixTreeUnitTest {
|
||||
public void givenSuffixTree_whenSearchingForNab_thenReturn1Match() {
|
||||
List<String> matches = suffixTree.searchText("nab");
|
||||
matches.stream()
|
||||
.forEach(m -> LOGGER.info(m));
|
||||
.forEach(m -> LOGGER.debug(m));
|
||||
Assert.assertArrayEquals(new String[] { "hava[nab]anana" }, matches.toArray());
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ public class SuffixTreeUnitTest {
|
||||
public void givenSuffixTree_whenSearchingForNag_thenReturnNoMatches() {
|
||||
List<String> matches = suffixTree.searchText("nag");
|
||||
matches.stream()
|
||||
.forEach(m -> LOGGER.info(m));
|
||||
.forEach(m -> LOGGER.debug(m));
|
||||
Assert.assertArrayEquals(new String[] {}, matches.toArray());
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ public class SuffixTreeUnitTest {
|
||||
public void givenSuffixTree_whenSearchingForBanana_thenReturn2Matches() {
|
||||
List<String> matches = suffixTree.searchText("ana");
|
||||
matches.stream()
|
||||
.forEach(m -> LOGGER.info(m));
|
||||
.forEach(m -> LOGGER.debug(m));
|
||||
Assert.assertArrayEquals(new String[] { "hav[ana]banana", "havanab[ana]na", "havanaban[ana]" }, matches.toArray());
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ public class SuffixTreeUnitTest {
|
||||
public void givenSuffixTree_whenSearchingForNa_thenReturn4Matches() {
|
||||
List<String> matches = suffixTree.searchText("na");
|
||||
matches.stream()
|
||||
.forEach(m -> LOGGER.info(m));
|
||||
.forEach(m -> LOGGER.debug(m));
|
||||
Assert.assertArrayEquals(new String[] { "hava[na]banana", "havanaba[na]na", "havanabana[na]" }, matches.toArray());
|
||||
}
|
||||
|
||||
@ -64,14 +64,14 @@ public class SuffixTreeUnitTest {
|
||||
public void givenSuffixTree_whenSearchingForX_thenReturnNoMatches() {
|
||||
List<String> matches = suffixTree.searchText("x");
|
||||
matches.stream()
|
||||
.forEach(m -> LOGGER.info(m));
|
||||
.forEach(m -> LOGGER.debug(m));
|
||||
Assert.assertArrayEquals(new String[] {}, matches.toArray());
|
||||
}
|
||||
|
||||
private static void printTree() {
|
||||
suffixTree.printTree();
|
||||
|
||||
LOGGER.info("\n" + suffixTree.printTree());
|
||||
LOGGER.info("==============================================");
|
||||
LOGGER.debug("\n" + suffixTree.printTree());
|
||||
LOGGER.debug("==============================================");
|
||||
}
|
||||
}
|
||||
|
@ -29,23 +29,10 @@
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
</properties>
|
||||
|
||||
|
@ -30,23 +30,10 @@
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
</properties>
|
||||
|
||||
|
@ -98,12 +98,6 @@
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>kafka</artifactId>
|
||||
@ -170,13 +164,11 @@
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<assertj.version>3.6.2</assertj.version>
|
||||
<kafka.version>2.8.0</kafka.version>
|
||||
<testcontainers-kafka.version>1.15.3</testcontainers-kafka.version>
|
||||
<testcontainers-jupiter.version>1.15.3</testcontainers-jupiter.version>
|
||||
<flink.version>1.5.0</flink.version>
|
||||
<awaitility.version>3.0.0</awaitility.version>
|
||||
<guava.version>29.0-jre</guava.version>
|
||||
<org.apache.spark.spark-core.version>2.4.8</org.apache.spark.spark-core.version>
|
||||
<graphframes.version>0.8.1-spark3.0-s_2.12</graphframes.version>
|
||||
<com.datastax.spark.spark-cassandra-connector.version>2.5.2</com.datastax.spark.spark-cassandra-connector.version>
|
||||
|
@ -156,13 +156,6 @@
|
||||
<artifactId>solr-solrj</artifactId>
|
||||
<version>${solr.solr-solrj.version}</version>
|
||||
</dependency>
|
||||
<!-- common -->
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -202,7 +195,6 @@
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<avro.version>1.8.2</avro.version>
|
||||
<beam.version>2.19.0</beam.version>
|
||||
<assertj.version>3.9.0</assertj.version>
|
||||
<bval.version>1.1.2</bval.version>
|
||||
<javax.validation.validation-api.version>1.1.0.Final</javax.validation.validation-api.version>
|
||||
<meecrowave-junit.version>1.2.0</meecrowave-junit.version>
|
||||
|
@ -27,3 +27,4 @@ HELP.md
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
@ -4,15 +4,15 @@ This following table contains test URLs that can be used with the Olingo V2 demo
|
||||
|
||||
| URL | Description |
|
||||
|------------------------------------------|-------------------------------------------------|
|
||||
| `http://localhost:8180/odata/$metadata` | fetch OData metadata document |
|
||||
| `http://localhost:8180/odata/CarMakers?$top=10&$skip=10` | Get 10 entities starting at offset 10 |
|
||||
| `http://localhost:8180/odata/CarMakers?$count` | Return total count of entities in this set |
|
||||
| `http://localhost:8180/odata/CarMakers?$filter=startswith(Name,'B')` | Return entities where the *Name* property starts with 'B' |
|
||||
| `http://localhost:8180/odata/CarModels?$filter=Year eq 2008 and CarMakerDetails/Name eq 'BWM'` | Return *CarModel* entities where the *Name* property of its maker starts with 'B' |
|
||||
| `http://localhost:8180/odata/CarModels(1L)?$expand=CarMakerDetails` | Return the *CarModel* with primary key '1', along with its maker|
|
||||
| `http://localhost:8180/odata/CarModels(1L)?$select=Name,Sku` | Return the *CarModel* with primary key '1', returing only its *Name* and *Sku* properties |
|
||||
| `http://localhost:8180/odata/CarModels?$orderBy=Name asc,Sku desc` | Return *CarModel* entities, ordered by the their *Name* and *Sku* properties |
|
||||
| `http://localhost:8180/odata/CarModels?$format=json` | Return *CarModel* entities, using a JSON representation|
|
||||
| `http://localhost:8080/odata/$metadata` | fetch OData metadata document |
|
||||
| `http://localhost:8080/odata/CarMakers?$top=10&$skip=10` | Get 10 entities starting at offset 10 |
|
||||
| `http://localhost:8080/odata/CarMakers?$count` | Return total count of entities in this set |
|
||||
| `http://localhost:8080/odata/CarMakers?$filter=startswith(Name,'B')` | Return entities where the *Name* property starts with 'B' |
|
||||
| `http://localhost:8080/odata/CarModels?$filter=Year eq 2008 and CarMakerDetails/Name eq 'BWM'` | Return *CarModel* entities where the *Name* property of its maker starts with 'B' |
|
||||
| `http://localhost:8080/odata/CarModels(1L)?$expand=CarMakerDetails` | Return the *CarModel* with primary key '1', along with its maker|
|
||||
| `http://localhost:8080/odata/CarModels(1L)?$select=Name,Sku` | Return the *CarModel* with primary key '1', returing only its *Name* and *Sku* properties |
|
||||
| `http://localhost:8080/odata/CarModels?$orderBy=Name asc,Sku desc` | Return *CarModel* entities, ordered by the their *Name* and *Sku* properties |
|
||||
| `http://localhost:8080/odata/CarModels?$format=json` | Return *CarModel* entities, using a JSON representation|
|
||||
|
||||
|
||||
|
||||
|
@ -3,16 +3,16 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.examples.olingo2</groupId>
|
||||
<artifactId>olingo2</artifactId>
|
||||
<name>olingo2</name>
|
||||
<description>Sample Olingo 2 Project</description>
|
||||
<groupId>com.baeldung.examples.olingo</groupId>
|
||||
<artifactId>apache-olingo</artifactId>
|
||||
<name>apache-olingo</name>
|
||||
<description>Sample Apache Olingo Project</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
<relativePath>../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@ -43,7 +43,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.olingo</groupId>
|
||||
<artifactId>olingo-odata2-core</artifactId>
|
||||
<version>${olingo2.version}</version>
|
||||
<version>${olingo.version}</version>
|
||||
<!-- Avoid jax-rs version conflict by excluding Olingo's version -->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@ -55,12 +55,12 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.olingo</groupId>
|
||||
<artifactId>olingo-odata2-jpa-processor-core</artifactId>
|
||||
<version>${olingo2.version}</version>
|
||||
<version>${olingo.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.olingo</groupId>
|
||||
<artifactId>olingo-odata2-jpa-processor-ref</artifactId>
|
||||
<version>${olingo2.version}</version>
|
||||
<version>${olingo.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.persistence</groupId>
|
||||
@ -80,7 +80,7 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<olingo2.version>2.0.11</olingo2.version>
|
||||
<olingo.version>2.0.11</olingo.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -27,11 +27,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* ODataJPAServiceFactory implementation for our sample domain
|
||||
* @author Philippe
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class CarsODataJPAServiceFactory extends ODataJPAServiceFactory {
|
||||
|
@ -1,6 +1,12 @@
|
||||
package com.baeldung.examples.olingo2;
|
||||
package com.baeldung.examples.olingo2;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.olingo.odata2.api.ODataServiceFactory;
|
||||
import org.apache.olingo.odata2.core.rest.ODataRootLocator;
|
||||
import org.apache.olingo.odata2.core.rest.app.ODataApplication;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
@ -15,19 +21,6 @@ import javax.ws.rs.container.ContainerResponseFilter;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import org.apache.olingo.odata2.api.ODataServiceFactory;
|
||||
import org.apache.olingo.odata2.core.rest.ODataRootLocator;
|
||||
import org.apache.olingo.odata2.core.rest.app.ODataApplication;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Jersey JAX-RS configuration
|
||||
* @author Philippe
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@ApplicationPath("/odata")
|
||||
public class JerseyConfig extends ResourceConfig {
|
||||
@ -72,7 +65,7 @@ public class JerseyConfig extends ResourceConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext ctx) throws IOException {
|
||||
public void filter(ContainerRequestContext ctx) {
|
||||
log.info("[I60] >>> filter");
|
||||
EntityManager em = this.emf.createEntityManager();
|
||||
httpRequest.setAttribute(EM_REQUEST_ATTRIBUTE, em);
|
||||
@ -85,7 +78,7 @@ public class JerseyConfig extends ResourceConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
|
||||
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) {
|
||||
|
||||
log.info("[I68] <<< filter");
|
||||
EntityManager em = (EntityManager) httpRequest.getAttribute(EM_REQUEST_ATTRIBUTE);
|
@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class Olingo2SampleApplicationUnitTest {
|
||||
public class Olingo2SampleApplicationIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
12
apache-olingo/src/test/resources/logback-test.xml
Normal file
12
apache-olingo/src/test/resources/logback-test.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="15 seconds" debug="false">
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>[%d{ISO8601}]-[%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
4
apache-poi-2/.gitignore
vendored
Normal file
4
apache-poi-2/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.docx
|
||||
temp.xls
|
||||
temp.xlsx
|
||||
number_test.xlsx
|
12
apache-poi-2/README.md
Normal file
12
apache-poi-2/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
## Apache POI
|
||||
|
||||
This module contains articles about Apache POI.
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Adding a Column to an Excel Sheet Using Apache POI](https://www.baeldung.com/java-excel-add-column)
|
||||
- [Add an Image to a Cell in an Excel File With Java](https://www.baeldung.com/java-add-image-excel)
|
||||
- [Numeric Format Using POI](https://www.baeldung.com/apache-poi-numeric-format)
|
||||
- [Microsoft Word Processing in Java with Apache POI](https://www.baeldung.com/java-microsoft-word-with-apache-poi)
|
||||
- [Creating a MS PowerPoint Presentation in Java](https://www.baeldung.com/apache-poi-slideshow)
|
||||
- More articles: [[<-- prev]](../apache-poi)
|
@ -1,28 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.stackify</groupId>
|
||||
<artifactId>logback-example</artifactId>
|
||||
<artifactId>apache-poi-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>logback-example</name>
|
||||
<name>apache-poi-2</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.janino</groupId>
|
||||
<artifactId>janino</artifactId>
|
||||
<version>${janino.version}</version>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<janino.version>3.0.7</janino.version>
|
||||
<poi.version>5.0.0</poi.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
@ -0,0 +1,16 @@
|
||||
package com.baeldung.poi.excel.newcolumn;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
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;
|
||||
|
||||
|
||||
public class ExcelColumn {
|
||||
|
||||
public void addColumn(Sheet sheet, CellType cellType) {
|
||||
for (Row currentRow : sheet) {
|
||||
currentRow.createCell(currentRow.getLastCellNum(), cellType);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.baeldung.poi.excel.newcolumn.numeric;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.DataFormat;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
public class ExcelNumericFormat {
|
||||
|
||||
public static void applyNumericFormat(Workbook outWorkbook, Row row, Cell cell, Double value, String styleFormat) {
|
||||
CellStyle style = outWorkbook.createCellStyle();
|
||||
DataFormat format = outWorkbook.createDataFormat();
|
||||
style.setDataFormat(format.getFormat(styleFormat));
|
||||
cell.setCellValue(value);
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.baeldung.poi.excel.write.addimageincell;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
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.util.IOUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFDrawing;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
/**
|
||||
* This Helper class Add an Image to a Cell of an Excel File With apache-poi api.
|
||||
*
|
||||
*/
|
||||
public class ExcelCellImageHelper {
|
||||
|
||||
public static void main(String[] args) throws IOException, InvalidFormatException {
|
||||
try (final Workbook workbook = new XSSFWorkbook();
|
||||
FileOutputStream saveExcel = new FileOutputStream("target/baeldung-apachepoi.xlsx");) {
|
||||
|
||||
Sheet sheet = workbook.createSheet("Avengers");
|
||||
|
||||
XSSFDrawing drawing = (XSSFDrawing) sheet.createDrawingPatriarch();
|
||||
XSSFClientAnchor ironManAnchor = new XSSFClientAnchor();
|
||||
XSSFClientAnchor spiderManAnchor = new XSSFClientAnchor();
|
||||
|
||||
// Fill row1 data
|
||||
Row row1 = sheet.createRow(0);
|
||||
row1.setHeight((short) 1000);
|
||||
row1.createCell(0)
|
||||
.setCellValue("IRON-MAN");
|
||||
updateCellWithImage(workbook, 1, drawing, ironManAnchor, "ironman.png");
|
||||
|
||||
// Fill row2 data
|
||||
Row row2 = sheet.createRow(1);
|
||||
row2.setHeight((short) 1000);
|
||||
row2.createCell(0)
|
||||
.setCellValue("SPIDER-MAN");
|
||||
updateCellWithImage(workbook, 2, drawing, spiderManAnchor, "spiderman.png");
|
||||
|
||||
// Resize all columns to fit the content size
|
||||
for (int i = 0; i < 2; i++) {
|
||||
sheet.autoSizeColumn(i);
|
||||
}
|
||||
workbook.write(saveExcel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method position the anchor for a given rowNum and add the image correctly.
|
||||
* @param workbook
|
||||
* @param rowNum
|
||||
* @param drawing
|
||||
* @param inputImageAnchor
|
||||
* @throws IOException
|
||||
*/
|
||||
private static void updateCellWithImage(Workbook workbook, int rowNum, XSSFDrawing drawing, XSSFClientAnchor inputImageAnchor, String inputImageName) throws IOException {
|
||||
InputStream inputImageStream = ExcelCellImageHelper.class.getClassLoader()
|
||||
.getResourceAsStream(inputImageName);
|
||||
byte[] inputImageBytes = IOUtils.toByteArray(inputImageStream);
|
||||
int inputImagePictureID = workbook.addPicture(inputImageBytes, Workbook.PICTURE_TYPE_PNG);
|
||||
inputImageStream.close();
|
||||
inputImageAnchor.setCol1(1);
|
||||
inputImageAnchor.setRow1(rowNum - 1);
|
||||
inputImageAnchor.setCol2(2);
|
||||
inputImageAnchor.setRow2(rowNum);
|
||||
drawing.createPicture(inputImageAnchor, inputImagePictureID);
|
||||
}
|
||||
|
||||
}
|
@ -5,7 +5,22 @@ import org.apache.poi.sl.usermodel.PictureData;
|
||||
import org.apache.poi.sl.usermodel.TableCell;
|
||||
import org.apache.poi.sl.usermodel.TextParagraph;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xslf.usermodel.*;
|
||||
import org.apache.poi.xslf.usermodel.SlideLayout;
|
||||
import org.apache.poi.xslf.usermodel.XMLSlideShow;
|
||||
import org.apache.poi.xslf.usermodel.XSLFAutoShape;
|
||||
import org.apache.poi.xslf.usermodel.XSLFHyperlink;
|
||||
import org.apache.poi.xslf.usermodel.XSLFPictureData;
|
||||
import org.apache.poi.xslf.usermodel.XSLFPictureShape;
|
||||
import org.apache.poi.xslf.usermodel.XSLFShape;
|
||||
import org.apache.poi.xslf.usermodel.XSLFSlide;
|
||||
import org.apache.poi.xslf.usermodel.XSLFSlideLayout;
|
||||
import org.apache.poi.xslf.usermodel.XSLFSlideMaster;
|
||||
import org.apache.poi.xslf.usermodel.XSLFTable;
|
||||
import org.apache.poi.xslf.usermodel.XSLFTableCell;
|
||||
import org.apache.poi.xslf.usermodel.XSLFTableRow;
|
||||
import org.apache.poi.xslf.usermodel.XSLFTextParagraph;
|
||||
import org.apache.poi.xslf.usermodel.XSLFTextRun;
|
||||
import org.apache.poi.xslf.usermodel.XSLFTextShape;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.FileInputStream;
|
@ -1,7 +1,11 @@
|
||||
package com.baeldung.poi.word;
|
||||
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
|
||||
import org.apache.poi.xwpf.usermodel.UnderlinePatterns;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
BIN
apache-poi-2/src/main/resources/ironman.png
Normal file
BIN
apache-poi-2/src/main/resources/ironman.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 782 B After Width: | Height: | Size: 782 B |
BIN
apache-poi-2/src/main/resources/spiderman.png
Normal file
BIN
apache-poi-2/src/main/resources/spiderman.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
@ -0,0 +1,40 @@
|
||||
package com.baeldung.poi.excel.newcolumn;
|
||||
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ExcelColumnUnitTest {
|
||||
private static final String FILE_NAME = "newColumnTest.xlsx";
|
||||
private String fileLocation;
|
||||
|
||||
@Before
|
||||
public void setup() throws URISyntaxException {
|
||||
fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenExistingRows_whenAddNewColumn_thenRowColumnNumberIncreased() throws IOException {
|
||||
Workbook workbook = new XSSFWorkbook(fileLocation);
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
Row row = sheet.getRow(0);
|
||||
assertEquals(5, row.getLastCellNum());
|
||||
|
||||
ExcelColumn excelColumn = new ExcelColumn();
|
||||
excelColumn.addColumn(sheet, CellType.STRING);
|
||||
assertEquals(6, row.getLastCellNum());
|
||||
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package com.baeldung.poi.excel.newcolumn.numeric;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
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.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class NumberCellValueUnitTest {
|
||||
|
||||
@Test
|
||||
public void decimalDisplay_whenAddedDouble_thenNumericCellCreated() throws IOException {
|
||||
File file = new File("number_test.xlsx");
|
||||
try (Workbook outWorkbook = new XSSFWorkbook()) {
|
||||
Sheet sheet = outWorkbook.createSheet("Numeric Sheet");
|
||||
Row row = sheet.createRow(0);
|
||||
Cell cell = row.createCell(0);
|
||||
ExcelNumericFormat.applyNumericFormat(outWorkbook, row, cell, 10.251, "0.00");
|
||||
FileOutputStream fileOut = new FileOutputStream(file);
|
||||
outWorkbook.write(fileOut);
|
||||
fileOut.close();
|
||||
}
|
||||
try (Workbook inWorkbook = new XSSFWorkbook("number_test.xlsx")) {
|
||||
Sheet sheet = inWorkbook.cloneSheet(0);
|
||||
Row row = sheet.getRow(0);
|
||||
Assertions.assertEquals(10.251, row.getCell(0)
|
||||
.getNumericCellValue());
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decimalRoundedDisplay_whenAddedDouble_thenNumericCellCreated() throws IOException {
|
||||
File file = new File("number_test.xlsx");
|
||||
try (Workbook outWorkbook = new XSSFWorkbook()) {
|
||||
Sheet sheet = outWorkbook.createSheet("Numeric Sheet");
|
||||
Row row = sheet.createRow(0);
|
||||
Cell cell = row.createCell(0);
|
||||
ExcelNumericFormat.applyNumericFormat(outWorkbook, row, cell, 10.251123, "#,##0.0000");
|
||||
FileOutputStream fileOut = new FileOutputStream(file);
|
||||
outWorkbook.write(fileOut);
|
||||
fileOut.close();
|
||||
}
|
||||
try (Workbook inWorkbook = new XSSFWorkbook("number_test.xlsx")) {
|
||||
Sheet sheet = inWorkbook.cloneSheet(0);
|
||||
Row row = sheet.getRow(0);
|
||||
Assertions.assertEquals(10.251123, row.getCell(0)
|
||||
.getNumericCellValue());
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decimalDisplayInXLS_whenAddedDouble_thenNumericCellCreated() throws IOException {
|
||||
File file = new File("number_test.xls");
|
||||
try (Workbook outWorkbook = new HSSFWorkbook()) {
|
||||
Sheet sheet = outWorkbook.createSheet("Numeric Sheet");
|
||||
Row row = sheet.createRow(0);
|
||||
Cell cell = row.createCell(0);
|
||||
ExcelNumericFormat.applyNumericFormat(outWorkbook, row, cell, 10.251, "0.00");
|
||||
FileOutputStream fileOut = new FileOutputStream(file);
|
||||
outWorkbook.write(fileOut);
|
||||
fileOut.close();
|
||||
}
|
||||
try (Workbook inWorkbook = new HSSFWorkbook(new FileInputStream(file))) {
|
||||
Sheet sheet = inWorkbook.cloneSheet(0);
|
||||
Row row = sheet.getRow(0);
|
||||
Assertions.assertEquals(10.251, row.getCell(0)
|
||||
.getNumericCellValue());
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decimalValue_whenAddedDouble_thenNumericCellCreated() throws IOException {
|
||||
File file = new File("number_test.xlsx");
|
||||
try (Workbook outWorkbook = new XSSFWorkbook()) {
|
||||
Sheet sheet = outWorkbook.createSheet("Numeric Sheet");
|
||||
Row row = sheet.createRow(0);
|
||||
Cell cell = row.createCell(0);
|
||||
DecimalFormat df = new DecimalFormat("#,###.##");
|
||||
ExcelNumericFormat.applyNumericFormat(outWorkbook, row, cell, Double.valueOf(df.format(10.251)), "#,###.##");
|
||||
|
||||
FileOutputStream fileOut = new FileOutputStream(file);
|
||||
outWorkbook.write(fileOut);
|
||||
fileOut.close();
|
||||
}
|
||||
try (Workbook inWorkbook = new XSSFWorkbook("number_test.xlsx")) {
|
||||
Sheet sheet = inWorkbook.cloneSheet(0);
|
||||
Row row = sheet.getRow(0);
|
||||
Assertions.assertEquals(10.25, row.getCell(0)
|
||||
.getNumericCellValue());
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
package com.baeldung.poi.powerpoint;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.xslf.usermodel.XMLSlideShow;
|
||||
import org.apache.poi.xslf.usermodel.XSLFShape;
|
||||
import org.apache.poi.xslf.usermodel.XSLFSlide;
|
||||
@ -13,6 +10,9 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class PowerPointIntegrationTest {
|
||||
|
||||
private PowerPointHelper pph;
|
@ -1,19 +1,19 @@
|
||||
package com.baeldung.poi.word;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class WordIntegrationTest {
|
||||
static WordDocument wordDocument;
|
||||
|
BIN
apache-poi-2/src/test/resources/newColumnTest.xlsx
Normal file
BIN
apache-poi-2/src/test/resources/newColumnTest.xlsx
Normal file
Binary file not shown.
2
apache-poi/.gitignore
vendored
2
apache-poi/.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
*.docx
|
||||
temp.xls
|
||||
temp.xlsx
|
||||
|
||||
CellStyleTest_output.xlsx
|
@ -1,14 +1,18 @@
|
||||
## Apache POI
|
||||
|
||||
This module contains articles about Apache POI
|
||||
This module contains articles about Apache POI.
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Microsoft Word Processing in Java with Apache POI](https://www.baeldung.com/java-microsoft-word-with-apache-poi)
|
||||
- [Working with Microsoft Excel in Java](https://www.baeldung.com/java-microsoft-excel)
|
||||
- [Creating a MS PowerPoint Presentation in Java](https://www.baeldung.com/apache-poi-slideshow)
|
||||
- [Merge Cells in Excel Using Apache POI](https://www.baeldung.com/java-apache-poi-merge-cells)
|
||||
- [Get String Value of Excel Cell with Apache POI](https://www.baeldung.com/java-apache-poi-cell-string-value)
|
||||
- [Read Excel Cell Value Rather Than Formula With Apache POI](https://www.baeldung.com/apache-poi-read-cell-value-formula)
|
||||
- [Setting Formulas in Excel with Apache POI](https://www.baeldung.com/java-apache-poi-set-formulas)
|
||||
- [Insert a Row in Excel Using Apache POI](https://www.baeldung.com/apache-poi-insert-excel-row)
|
||||
- [Multiline Text in Excel Cell Using Apache POI](https://www.baeldung.com/apache-poi-write-multiline-text)
|
||||
- [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)
|
||||
|
@ -32,9 +32,27 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>${maven.resources.plugin.version}</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<nonFilteredFileExtensions>
|
||||
<nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
|
||||
<nonFilteredFileExtension>xls</nonFilteredFileExtension>
|
||||
</nonFilteredFileExtensions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<poi.version>4.1.1</poi.version>
|
||||
<poi.version>5.2.0</poi.version>
|
||||
<jexcel.version>1.0.6</jexcel.version>
|
||||
<maven.resources.plugin.version>3.2.0</maven.resources.plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -1,25 +1,24 @@
|
||||
package com.baeldung.poi.excel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
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.apache.poi.xssf.usermodel.XSSFFont;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
public class ExcelPOIHelper {
|
||||
|
||||
@ -33,7 +32,7 @@ public class ExcelPOIHelper {
|
||||
for (Row row : sheet) {
|
||||
data.put(i, new ArrayList<String>());
|
||||
for (Cell cell : row) {
|
||||
switch (cell.getCellTypeEnum()) {
|
||||
switch (cell.getCellType()) {
|
||||
case STRING:
|
||||
data.get(i)
|
||||
.add(cell.getRichStringCellValue()
|
||||
|
@ -0,0 +1,76 @@
|
||||
package com.baeldung.poi.excel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
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;
|
||||
|
||||
public class ExcelUtility {
|
||||
private static final String ENDLINE = System.getProperty("line.separator");
|
||||
|
||||
public static String readExcel(String filePath) throws IOException {
|
||||
File file = new File(filePath);
|
||||
FileInputStream inputStream = null;
|
||||
StringBuilder toReturn = new StringBuilder();
|
||||
try {
|
||||
inputStream = new FileInputStream(file);
|
||||
Workbook baeuldungWorkBook = new XSSFWorkbook(inputStream);
|
||||
for (Sheet sheet : baeuldungWorkBook) {
|
||||
toReturn.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
toReturn.append("Worksheet :")
|
||||
.append(sheet.getSheetName())
|
||||
.append(ENDLINE);
|
||||
toReturn.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
int firstRow = sheet.getFirstRowNum();
|
||||
int lastRow = sheet.getLastRowNum();
|
||||
for (int index = firstRow + 1; index <= lastRow; index++) {
|
||||
Row row = sheet.getRow(index);
|
||||
toReturn.append("|| ");
|
||||
for (int cellIndex = row.getFirstCellNum(); cellIndex < row.getLastCellNum(); cellIndex++) {
|
||||
Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
printCellValue(cell, toReturn);
|
||||
}
|
||||
toReturn.append(" ||")
|
||||
.append(ENDLINE);
|
||||
}
|
||||
}
|
||||
inputStream.close();
|
||||
baeuldungWorkBook.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
}
|
||||
return toReturn.toString();
|
||||
}
|
||||
|
||||
public static void printCellValue(Cell cell, StringBuilder toReturn) {
|
||||
CellType cellType = cell.getCellType()
|
||||
.equals(CellType.FORMULA) ? cell.getCachedFormulaResultType() : cell.getCellType();
|
||||
if (cellType.equals(CellType.STRING)) {
|
||||
toReturn.append(cell.getStringCellValue())
|
||||
.append(" | ");
|
||||
}
|
||||
if (cellType.equals(CellType.NUMERIC)) {
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
toReturn.append(cell.getDateCellValue())
|
||||
.append(" | ");
|
||||
} else {
|
||||
toReturn.append(cell.getNumericCellValue())
|
||||
.append(" | ");
|
||||
}
|
||||
}
|
||||
if (cellType.equals(CellType.BOOLEAN)) {
|
||||
toReturn.append(cell.getBooleanCellValue())
|
||||
.append(" | ");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
package com.baeldung.poi.excel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
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;
|
||||
|
||||
public class ExcelUtility {
|
||||
<<<<<<< HEAD
|
||||
private static final String ENDLINE = System.getProperty("line.separator");
|
||||
|
||||
public static String readExcel(String filePath) throws IOException {
|
||||
File file = new File(filePath);
|
||||
FileInputStream inputStream = null;
|
||||
StringBuilder toReturn = new StringBuilder();
|
||||
try {
|
||||
inputStream = new FileInputStream(file);
|
||||
Workbook baeuldungWorkBook = new XSSFWorkbook(inputStream);
|
||||
for (Sheet sheet : baeuldungWorkBook) {
|
||||
toReturn.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
toReturn.append("Worksheet :")
|
||||
.append(sheet.getSheetName())
|
||||
.append(ENDLINE);
|
||||
toReturn.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
int firstRow = sheet.getFirstRowNum();
|
||||
int lastRow = sheet.getLastRowNum();
|
||||
for (int index = firstRow + 1; index <= lastRow; index++) {
|
||||
Row row = sheet.getRow(index);
|
||||
toReturn.append("|| ");
|
||||
for (int cellIndex = row.getFirstCellNum(); cellIndex < row.getLastCellNum(); cellIndex++) {
|
||||
Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
printCellValue(cell, toReturn);
|
||||
}
|
||||
toReturn.append(" ||")
|
||||
.append(ENDLINE);
|
||||
}
|
||||
}
|
||||
inputStream.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
}
|
||||
return toReturn.toString();
|
||||
}
|
||||
|
||||
public static void printCellValue(Cell cell, StringBuilder toReturn) {
|
||||
CellType cellType = cell.getCellType()
|
||||
.equals(CellType.FORMULA) ? cell.getCachedFormulaResultType() : cell.getCellType();
|
||||
if (cellType.equals(CellType.STRING)) {
|
||||
toReturn.append(cell.getStringCellValue())
|
||||
.append(" | ");
|
||||
}
|
||||
if (cellType.equals(CellType.NUMERIC)) {
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
toReturn.append(cell.getDateCellValue())
|
||||
.append(" | ");
|
||||
} else {
|
||||
toReturn.append(cell.getNumericCellValue())
|
||||
.append(" | ");
|
||||
}
|
||||
}
|
||||
if (cellType.equals(CellType.BOOLEAN)) {
|
||||
toReturn.append(cell.getBooleanCellValue())
|
||||
.append(" | ");
|
||||
}
|
||||
}
|
||||
=======
|
||||
private static final String ENDLINE = System.getProperty("line.separator");
|
||||
|
||||
public static String readExcel(String filePath) throws IOException {
|
||||
File file = new File(filePath);
|
||||
FileInputStream inputStream = null;
|
||||
StringBuilder toReturn = new StringBuilder();
|
||||
try {
|
||||
inputStream = new FileInputStream(file);
|
||||
Workbook baeuldungWorkBook = new XSSFWorkbook(inputStream);
|
||||
for (Sheet sheet : baeuldungWorkBook) {
|
||||
toReturn.append("--------------------------------------------------------------------").append(ENDLINE);
|
||||
toReturn.append("Worksheet :").append(sheet.getSheetName()).append(ENDLINE);
|
||||
toReturn.append("--------------------------------------------------------------------").append(ENDLINE);
|
||||
int firstRow = sheet.getFirstRowNum();
|
||||
int lastRow = sheet.getLastRowNum();
|
||||
for (int index = firstRow + 1; index <= lastRow; index++) {
|
||||
Row row = sheet.getRow(index);
|
||||
toReturn.append("|| ");
|
||||
for (int cellIndex = row.getFirstCellNum(); cellIndex < row.getLastCellNum(); cellIndex++) {
|
||||
Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
printCellValue(cell, toReturn);
|
||||
}
|
||||
toReturn.append(" ||").append(ENDLINE);
|
||||
}
|
||||
}
|
||||
inputStream.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
}
|
||||
return toReturn.toString();
|
||||
}
|
||||
|
||||
public static void printCellValue(Cell cell, StringBuilder toReturn) {
|
||||
CellType cellType = cell.getCellType().equals(CellType.FORMULA) ? cell.getCachedFormulaResultType()
|
||||
: cell.getCellType();
|
||||
if (cellType.equals(CellType.STRING)) {
|
||||
toReturn.append(cell.getStringCellValue()).append(" | ");
|
||||
}
|
||||
if (cellType.equals(CellType.NUMERIC)) {
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
toReturn.append(cell.getDateCellValue()).append(" | ");
|
||||
} else {
|
||||
toReturn.append(cell.getNumericCellValue()).append(" | ");
|
||||
}
|
||||
}
|
||||
if (cellType.equals(CellType.BOOLEAN)) {
|
||||
toReturn.append(cell.getBooleanCellValue()).append(" | ");
|
||||
}
|
||||
}
|
||||
>>>>>>> master
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.baeldung.poi.excel.cellstyle;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.RegionUtil;
|
||||
|
||||
public class CellBordersHandler {
|
||||
|
||||
public void setRegionBorder(CellRangeAddress region, Sheet sheet, BorderStyle borderStyle) {
|
||||
RegionUtil.setBorderTop(borderStyle, region, sheet);
|
||||
RegionUtil.setBorderBottom(borderStyle, region, sheet);
|
||||
RegionUtil.setBorderLeft(borderStyle, region, sheet);
|
||||
RegionUtil.setBorderRight(borderStyle, region, sheet);
|
||||
}
|
||||
|
||||
public void setRegionBorderWithColor(CellRangeAddress region, Sheet sheet, BorderStyle borderStyle, short color) {
|
||||
RegionUtil.setTopBorderColor(color, region, sheet);
|
||||
RegionUtil.setBottomBorderColor(color, region, sheet);
|
||||
RegionUtil.setLeftBorderColor(color, region, sheet);
|
||||
RegionUtil.setRightBorderColor(color, region, sheet);
|
||||
RegionUtil.setBorderTop(borderStyle, region, sheet);
|
||||
RegionUtil.setBorderBottom(borderStyle, region, sheet);
|
||||
RegionUtil.setBorderLeft(borderStyle, region, sheet);
|
||||
RegionUtil.setBorderRight(borderStyle, region, sheet);
|
||||
}
|
||||
|
||||
public void setCrazyBorder(CellRangeAddress region, Sheet sheet) {
|
||||
RegionUtil.setTopBorderColor(IndexedColors.RED.index, region, sheet);
|
||||
RegionUtil.setBottomBorderColor(IndexedColors.GREEN.index, region, sheet);
|
||||
RegionUtil.setLeftBorderColor(IndexedColors.BLUE.index, region, sheet);
|
||||
RegionUtil.setRightBorderColor(IndexedColors.VIOLET.index, region, sheet);
|
||||
RegionUtil.setBorderTop(BorderStyle.DASH_DOT, region, sheet);
|
||||
RegionUtil.setBorderBottom(BorderStyle.DOUBLE, region, sheet);
|
||||
RegionUtil.setBorderLeft(BorderStyle.DOTTED, region, sheet);
|
||||
RegionUtil.setBorderRight(BorderStyle.SLANTED_DASH_DOT, region, sheet);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.baeldung.poi.excel.cellstyle;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
|
||||
public class CellStyleHandler {
|
||||
|
||||
public void changeCellBackgroundColor(Cell cell) {
|
||||
CellStyle cellStyle = cell.getCellStyle();
|
||||
if(cellStyle == null) {
|
||||
cellStyle = cell.getSheet().getWorkbook().createCellStyle();
|
||||
}
|
||||
cellStyle.setFillForegroundColor(IndexedColors.LIGHT_BLUE.getIndex());
|
||||
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
|
||||
public void changeCellBackgroundColorWithPattern(Cell cell) {
|
||||
CellStyle cellStyle = cell.getCellStyle();
|
||||
if(cellStyle == null) {
|
||||
cellStyle = cell.getSheet().getWorkbook().createCellStyle();
|
||||
}
|
||||
cellStyle.setFillBackgroundColor(IndexedColors.BLACK.index);
|
||||
cellStyle.setFillPattern(FillPatternType.BIG_SPOTS);
|
||||
cellStyle.setFillForegroundColor(IndexedColors.LIGHT_BLUE.getIndex());
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.baeldung.poi.excel.cellstyle;
|
||||
|
||||
import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
|
||||
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;
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ package com.baeldung.poi.excel.multilinetext;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
|
||||
public class MultilineText {
|
||||
public void formatMultilineText(Cell cell, int cellNumber) {
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,25 +1,18 @@
|
||||
package com.baeldung.jexcel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import jxl.read.biff.BiffException;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.baeldung.jexcel.JExcelHelper;
|
||||
|
||||
import jxl.write.WriteException;
|
||||
import jxl.read.biff.BiffException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import jxl.read.biff.BiffException;
|
||||
import jxl.write.WriteException;
|
||||
|
||||
public class JExcelIntegrationTest {
|
||||
|
||||
|
@ -1,22 +1,15 @@
|
||||
package com.baeldung.poi.excel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import jxl.read.biff.BiffException;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.baeldung.poi.excel.ExcelPOIHelper;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ExcelIntegrationTest {
|
||||
|
||||
|
@ -0,0 +1,72 @@
|
||||
package com.baeldung.poi.excel;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ExcelUtilityUnitTest {
|
||||
private static final String FILE_NAME = "baeldung.xlsx";
|
||||
private String fileLocation;
|
||||
private static final String ENDLINE = System.getProperty("line.separator");
|
||||
private StringBuilder output;
|
||||
|
||||
@Before
|
||||
public void setupUnitTest() throws IOException, URISyntaxException, ParseException {
|
||||
output = new StringBuilder();
|
||||
output.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
output.append("Worksheet :Sheet1")
|
||||
.append(ENDLINE);
|
||||
output.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
output.append("|| Name1 | Surname1 | 3.55696564113E11 | ")
|
||||
.append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021")
|
||||
.toString())
|
||||
.append(" | ‡ | ||")
|
||||
.append(ENDLINE);
|
||||
output.append("|| Name2 | Surname2 | 5.646513512E9 | ")
|
||||
.append(new SimpleDateFormat("dd/MM/yyyy").parse("4/12/2021")
|
||||
.toString())
|
||||
.append(" | false | ||")
|
||||
.append(ENDLINE);
|
||||
output.append("|| Name3 | Surname3 | 3.55696564113E11 | ")
|
||||
.append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021")
|
||||
.toString())
|
||||
.append(" | 7.17039641738E11 | ||")
|
||||
.append(ENDLINE);
|
||||
output.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
output.append("Worksheet :Sheet2")
|
||||
.append(ENDLINE);
|
||||
output.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
output.append("|| Name4 | Surname4 | 3.55675623232E11 | 13/04/2021 | ||")
|
||||
.append(ENDLINE);
|
||||
|
||||
fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME)
|
||||
.toURI())
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStringPath_whenReadExcel_thenReturnStringValue() throws IOException {
|
||||
assertEquals(output.toString(), ExcelUtility.readExcel(fileLocation));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStringPath_whenReadExcel_thenThrowException() {
|
||||
assertThrows(IOException.class, () -> {
|
||||
ExcelUtility.readExcel("baeldung");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
package com.baeldung.poi.excel;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ExcelUtilityUnitTest {
|
||||
<<<<<<< HEAD
|
||||
private static final String FILE_NAME = "baeldung.xlsx";
|
||||
private String fileLocation;
|
||||
private static final String ENDLINE = System.getProperty("line.separator");
|
||||
private StringBuilder output;
|
||||
|
||||
@Before
|
||||
public void setupUnitTest() throws IOException, URISyntaxException, ParseException {
|
||||
output = new StringBuilder();
|
||||
output.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
output.append("Worksheet :Sheet1")
|
||||
.append(ENDLINE);
|
||||
output.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
output.append("|| Name1 | Surname1 | 3.55696564113E11 | ")
|
||||
.append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021")
|
||||
.toString())
|
||||
.append(" | ‡ | ||")
|
||||
.append(ENDLINE);
|
||||
output.append("|| Name2 | Surname2 | 5.646513512E9 | ")
|
||||
.append(new SimpleDateFormat("dd/MM/yyyy").parse("4/12/2021")
|
||||
.toString())
|
||||
.append(" | false | ||")
|
||||
.append(ENDLINE);
|
||||
output.append("|| Name3 | Surname3 | 3.55696564113E11 | ")
|
||||
.append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021")
|
||||
.toString())
|
||||
.append(" | 7.17039641738E11 | ||")
|
||||
.append(ENDLINE);
|
||||
output.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
output.append("Worksheet :Sheet2")
|
||||
.append(ENDLINE);
|
||||
output.append("--------------------------------------------------------------------")
|
||||
.append(ENDLINE);
|
||||
output.append("|| Name4 | Surname4 | 3.55675623232E11 | 13/04/2021 | ||")
|
||||
.append(ENDLINE);
|
||||
|
||||
fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME)
|
||||
.toURI())
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStringPath_whenReadExcel_thenReturnStringValue() throws IOException {
|
||||
assertEquals(output.toString(), ExcelUtility.readExcel(fileLocation));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStringPath_whenReadExcel_thenThrowException() {
|
||||
assertThrows(IOException.class, () -> {
|
||||
ExcelUtility.readExcel("baeldung");
|
||||
});
|
||||
}
|
||||
=======
|
||||
private static final String FILE_NAME = "baeldung.xlsx";
|
||||
private String fileLocation;
|
||||
private static final String ENDLINE = System.getProperty("line.separator");
|
||||
private StringBuilder output;
|
||||
|
||||
@Before
|
||||
public void setupUnitTest() throws IOException, URISyntaxException, ParseException {
|
||||
output = new StringBuilder();
|
||||
output.append("--------------------------------------------------------------------").append(ENDLINE);
|
||||
output.append("Worksheet :Sheet1").append(ENDLINE);
|
||||
output.append("--------------------------------------------------------------------").append(ENDLINE);
|
||||
output.append("|| Name1 | Surname1 | 3.55696564113E11 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021").toString()).append(" | ‡ | ||")
|
||||
.append(ENDLINE);
|
||||
output.append("|| Name2 | Surname2 | 5.646513512E9 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/12/2021").toString()).append(" | false | ||")
|
||||
.append(ENDLINE);
|
||||
output.append("|| Name3 | Surname3 | 3.55696564113E11 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021").toString()).append(" | 7.17039641738E11 | ||")
|
||||
.append(ENDLINE);
|
||||
output.append("--------------------------------------------------------------------").append(ENDLINE);
|
||||
output.append("Worksheet :Sheet2").append(ENDLINE);
|
||||
output.append("--------------------------------------------------------------------").append(ENDLINE);
|
||||
output.append("|| Name4 | Surname4 | 3.55675623232E11 | 13/04/2021 | ||").append(ENDLINE);
|
||||
|
||||
fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStringPath_whenReadExcel_thenReturnStringValue() throws IOException {
|
||||
assertEquals(output.toString(), ExcelUtility.readExcel(fileLocation));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStringPath_whenReadExcel_thenThrowException() {
|
||||
assertThrows(IOException.class, () -> {
|
||||
ExcelUtility.readExcel("baeldung");
|
||||
});
|
||||
}
|
||||
>>>>>>> master
|
||||
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package com.baeldung.poi.excel.cellstyle;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.junit.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CellBorderHandlerUnitTest {
|
||||
private static final String FILE_NAME = "cellstyle/CellStyleBorderHandlerTest.xlsx";
|
||||
private static final int SHEET_INDEX = 0;
|
||||
|
||||
private static CellBordersHandler cellBordersHandler;
|
||||
private static Workbook workbook;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws URISyntaxException, IOException {
|
||||
String fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString();
|
||||
cellBordersHandler = new CellBordersHandler();
|
||||
workbook = new XSSFWorkbook(fileLocation);
|
||||
createRowsAndCells(workbook);
|
||||
}
|
||||
|
||||
private static void createRowsAndCells(Workbook workbook) {
|
||||
Sheet sheet = workbook.getSheetAt(SHEET_INDEX);
|
||||
for (int rowIndex = 0; rowIndex < 10; rowIndex++) {
|
||||
Row row = sheet.getRow(rowIndex);
|
||||
if (row == null) {
|
||||
row = sheet.createRow(rowIndex);
|
||||
}
|
||||
for (int colIndex = 0; colIndex < 10; colIndex++) {
|
||||
Cell cell = row.getCell(colIndex);
|
||||
if (cell == null) {
|
||||
row.createCell(colIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWorkbookCell_whenSetRegionBorder() {
|
||||
Sheet sheet = workbook.getSheetAt(SHEET_INDEX);
|
||||
|
||||
CellRangeAddress region = new CellRangeAddress(1, 1, 1, 1);
|
||||
cellBordersHandler.setRegionBorder(region, sheet, BorderStyle.THICK);
|
||||
|
||||
Row row = sheet.getRow(1);
|
||||
Cell cell = row.getCell(1);
|
||||
assertEquals(cell.getCellStyle().getBorderTop(), BorderStyle.THICK);
|
||||
assertEquals(cell.getCellStyle().getBorderBottom(), BorderStyle.THICK);
|
||||
assertEquals(cell.getCellStyle().getBorderLeft(), BorderStyle.THICK);
|
||||
assertEquals(cell.getCellStyle().getBorderRight(), BorderStyle.THICK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWorkbookCell_whenSetRegionBorderWithColor() {
|
||||
Sheet sheet = workbook.getSheetAt(SHEET_INDEX);
|
||||
|
||||
CellRangeAddress region = new CellRangeAddress(1, 1, 3, 3);
|
||||
cellBordersHandler.setRegionBorderWithColor(region, sheet, BorderStyle.THICK, IndexedColors.MAROON.index);
|
||||
|
||||
Row row = sheet.getRow(1);
|
||||
Cell cell = row.getCell(1 + 2);
|
||||
assertEquals(cell.getCellStyle().getBorderTop(), BorderStyle.THICK);
|
||||
assertEquals(cell.getCellStyle().getBorderBottom(), BorderStyle.THICK);
|
||||
assertEquals(cell.getCellStyle().getBorderLeft(), BorderStyle.THICK);
|
||||
assertEquals(cell.getCellStyle().getBorderRight(), BorderStyle.THICK);
|
||||
assertEquals(cell.getCellStyle().getTopBorderColor(), IndexedColors.MAROON.index);
|
||||
assertEquals(cell.getCellStyle().getBottomBorderColor(), IndexedColors.MAROON.index);
|
||||
assertEquals(cell.getCellStyle().getLeftBorderColor(), IndexedColors.MAROON.index);
|
||||
assertEquals(cell.getCellStyle().getRightBorderColor(), IndexedColors.MAROON.index);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWorkbookCell_whenSetCrazyBorder() {
|
||||
Sheet sheet = workbook.getSheetAt(SHEET_INDEX);
|
||||
|
||||
CellRangeAddress region = new CellRangeAddress(1, 1, 5, 5);
|
||||
cellBordersHandler.setCrazyBorder(region, sheet);
|
||||
|
||||
Row row = sheet.getRow(1);
|
||||
Cell cell = row.getCell(5);
|
||||
assertEquals(cell.getCellStyle().getBorderTop(), BorderStyle.DASH_DOT);
|
||||
assertEquals(cell.getCellStyle().getBorderBottom(), BorderStyle.DOUBLE);
|
||||
assertEquals(cell.getCellStyle().getBorderLeft(), BorderStyle.DOTTED);
|
||||
assertEquals(cell.getCellStyle().getBorderRight(), BorderStyle.SLANTED_DASH_DOT);
|
||||
assertEquals(cell.getCellStyle().getTopBorderColor(), IndexedColors.RED.index);
|
||||
assertEquals(cell.getCellStyle().getBottomBorderColor(), IndexedColors.GREEN.index);
|
||||
assertEquals(cell.getCellStyle().getLeftBorderColor(), IndexedColors.BLUE.index);
|
||||
assertEquals(cell.getCellStyle().getRightBorderColor(), IndexedColors.VIOLET.index);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWorkbookRegion_whenSetRegionBorder() {
|
||||
Sheet sheet = workbook.getSheetAt(SHEET_INDEX);
|
||||
|
||||
CellRangeAddress region = new CellRangeAddress(3, 5, 1, 5);
|
||||
cellBordersHandler.setRegionBorder(region, sheet, BorderStyle.MEDIUM);
|
||||
|
||||
Row row = sheet.getRow(3);
|
||||
Cell cell = row.getCell(1);
|
||||
assertEquals(cell.getCellStyle().getBorderTop(), BorderStyle.MEDIUM);
|
||||
assertEquals(cell.getCellStyle().getBorderLeft(), BorderStyle.MEDIUM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWorkbookRegion_whenSetRegionBorderWithColor() {
|
||||
Sheet sheet = workbook.getSheetAt(SHEET_INDEX);
|
||||
|
||||
CellRangeAddress region = new CellRangeAddress(7, 8, 1, 5);
|
||||
cellBordersHandler.setRegionBorderWithColor(region, sheet, BorderStyle.MEDIUM, IndexedColors.ORANGE.index);
|
||||
|
||||
Row row = sheet.getRow(7);
|
||||
Cell cell = row.getCell(1);
|
||||
assertEquals(cell.getCellStyle().getBorderTop(), BorderStyle.MEDIUM);
|
||||
assertEquals(cell.getCellStyle().getBorderLeft(), BorderStyle.MEDIUM);
|
||||
assertEquals(cell.getCellStyle().getTopBorderColor(), IndexedColors.ORANGE.index);
|
||||
assertEquals(cell.getCellStyle().getLeftBorderColor(), IndexedColors.ORANGE.index);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void close() throws IOException {
|
||||
workbook.close();
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.baeldung.poi.excel.cellstyle;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
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.IndexedColors;
|
||||
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 CellStyleHandlerUnitTest {
|
||||
private static final String FILE_NAME = "cellstyle/CellStyleHandlerTest.xlsx";
|
||||
private static final int SHEET_INDEX = 0;
|
||||
private static final int ROW_INDEX = 0;
|
||||
private static final int CELL_INDEX = 0;
|
||||
|
||||
private String fileLocation;
|
||||
private CellStyleHandler cellStyleHandler;
|
||||
|
||||
@Before
|
||||
public void setup() throws URISyntaxException {
|
||||
fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString();
|
||||
cellStyleHandler = new CellStyleHandler();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWorkbookCell_whenChangeCellBackgroundColor() throws IOException {
|
||||
Workbook workbook = new XSSFWorkbook(fileLocation);
|
||||
Sheet sheet = workbook.getSheetAt(SHEET_INDEX);
|
||||
Row row = sheet.getRow(ROW_INDEX);
|
||||
Cell cell = row.getCell(CELL_INDEX);
|
||||
|
||||
cellStyleHandler.changeCellBackgroundColor(cell);
|
||||
|
||||
assertEquals(IndexedColors.LIGHT_BLUE.index, cell.getCellStyle().getFillForegroundColor());
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWorkbookCell_whenChangeCellBackgroundColorWithPattern() throws IOException {
|
||||
Workbook workbook = new XSSFWorkbook(fileLocation);
|
||||
Sheet sheet = workbook.getSheetAt(SHEET_INDEX);
|
||||
Row row = sheet.getRow(ROW_INDEX);
|
||||
Cell cell = row.getCell(CELL_INDEX + 1);
|
||||
|
||||
cellStyleHandler.changeCellBackgroundColorWithPattern(cell);
|
||||
|
||||
assertEquals(IndexedColors.LIGHT_BLUE.index, cell.getCellStyle().getFillForegroundColor());
|
||||
workbook.close();
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
BIN
apache-poi/src/test/resources/baeldung.xlsx
Normal file
BIN
apache-poi/src/test/resources/baeldung.xlsx
Normal file
Binary file not shown.
@ -47,7 +47,7 @@
|
||||
|
||||
<properties>
|
||||
<apache-shiro-core-version>1.5.3</apache-shiro-core-version>
|
||||
<log4j-version>1.2.17</log4j-version>
|
||||
<log4j.version>2.17.1</log4j.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
12
apache-shiro/src/test/resources/logback-test.xml
Normal file
12
apache-shiro/src/test/resources/logback-test.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="15 seconds" debug="false">
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>[%d{ISO8601}]-[%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
@ -1,9 +1,9 @@
|
||||
package com.baeldung.differences.rdd;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.spark.SparkConf;
|
||||
import org.apache.spark.api.java.JavaRDD;
|
||||
@ -12,9 +12,12 @@ import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class TransformationsUnitTest {
|
||||
|
||||
public static final String COMMA_DELIMITER = ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)";
|
||||
|
||||
private static JavaSparkContext sc;
|
||||
private static JavaRDD<String> tourists;
|
||||
|
||||
@ -25,6 +28,9 @@ public class TransformationsUnitTest {
|
||||
sc = new JavaSparkContext(conf);
|
||||
tourists = sc.textFile("data/Tourist.csv")
|
||||
.filter(line -> !line.startsWith("Region")); //filter header row
|
||||
|
||||
// delete previous output dir and files
|
||||
FileUtils.deleteQuietly(new File("data/output"));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -71,12 +71,6 @@
|
||||
<artifactId>derby</artifactId>
|
||||
<version>${derby.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- the JTA API -->
|
||||
<dependency>
|
||||
<groupId>javax.transaction</groupId>
|
||||
|
@ -10,9 +10,8 @@
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<artifactId>aws-lambda</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@ -63,7 +62,8 @@
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>${json-simple.version}</version>
|
||||
<exclusions>
|
||||
<!-- junit4 dependency is excluded as it should to be resolved from junit-vintage-engine included in parent-modules. -->
|
||||
<!-- junit4 dependency is excluded as it should to be resolved from junit-vintage-engine
|
||||
included in parent-modules. -->
|
||||
<exclusion>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@ -11,7 +11,6 @@
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@ -5,8 +5,8 @@
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>ShippingFunction</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>ShippingFunction</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -5,8 +5,8 @@
|
||||
<groupId>helloworld</groupId>
|
||||
<artifactId>ToDoFunction</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>ToDoFunction</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -111,7 +111,7 @@
|
||||
<feign-core.version>11.2</feign-core.version>
|
||||
<guice.version>5.0.1</guice.version>
|
||||
<system-stubs-junit4.version>1.2.0</system-stubs-junit4.version>
|
||||
<mockito-core.version>3.3.0</mockito-core.version>
|
||||
<mockito-core.version>4.1.0</mockito-core.version>
|
||||
<assertj-core.version>3.19.0</assertj-core.version>
|
||||
<junit-jupiter.version>5.8.1</junit-jupiter.version>
|
||||
</properties>
|
||||
|
14
aws/pom.xml
14
aws/pom.xml
@ -20,18 +20,6 @@
|
||||
<artifactId>aws-java-sdk</artifactId>
|
||||
<version>${aws-java-sdk.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>${mockito-core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj-core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-lambda-java-core</artifactId>
|
||||
@ -117,8 +105,6 @@
|
||||
<aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version>
|
||||
<gson.version>2.8.0</gson.version>
|
||||
<aws-java-sdk.version>1.11.290</aws-java-sdk.version>
|
||||
<mockito-core.version>2.21.0</mockito-core.version>
|
||||
<assertj-core.version>3.8.0</assertj-core.version>
|
||||
<dynamodblocal.version>1.11.86</dynamodblocal.version>
|
||||
<dynamodblocal.repository.url>https://s3-us-west-2.amazonaws.com/dynamodb-local/release</dynamodblocal.repository.url>
|
||||
<commons-codec-version>1.10.L001</commons-codec-version>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<dependency>
|
||||
<groupId>org.axonframework</groupId>
|
||||
<artifactId>axon-bom</artifactId>
|
||||
<version>4.5.0</version>
|
||||
<version>${axon.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@ -56,4 +56,8 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<axon.version>4.5.0</axon.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -36,12 +36,6 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- TEST -->
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj-core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
@ -119,7 +113,6 @@
|
||||
<httpclient.version>4.5.6</httpclient.version>
|
||||
<httpmime.version>4.5.6</httpmime.version>
|
||||
<httpcore.version>4.4.10</httpcore.version>
|
||||
<assertj-core.version>3.11.1</assertj-core.version>
|
||||
<maven-failsafe-plugin.version>3.0.0-M3</maven-failsafe-plugin.version>
|
||||
<process-exec-maven-plugin.version>0.7</process-exec-maven-plugin.version>
|
||||
<assembly.plugin.version>3.1.0</assembly.plugin.version>
|
||||
|
@ -25,12 +25,6 @@
|
||||
<artifactId>weld-se-core</artifactId>
|
||||
<version>${weld-se-core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj-core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
@ -53,7 +47,6 @@
|
||||
<cdi-api.version>2.0.SP1</cdi-api.version>
|
||||
<weld-se-core.version>3.0.5.Final</weld-se-core.version>
|
||||
<aspectjweaver.version>1.9.2</aspectjweaver.version>
|
||||
<assertj-core.version>3.10.0</assertj-core.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -10,9 +10,8 @@
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<artifactId>cloud-foundry-uaa</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -10,9 +10,8 @@
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<artifactId>cloud-foundry-uaa</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -4,14 +4,14 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cloud-foundry-uaa</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>cloud-foundry-uaa</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@ -12,7 +12,6 @@
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@ -40,7 +39,6 @@
|
||||
<properties>
|
||||
<maven.compiler.source.version>10</maven.compiler.source.version>
|
||||
<maven.compiler.target.version>10</maven.compiler.target.version>
|
||||
<commons-collections4.version>4.1</commons-collections4.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -9,3 +9,5 @@ This module contains articles about Java 11 core features
|
||||
- [New Features in Java 11](https://www.baeldung.com/java-11-new-features)
|
||||
- [Getting the Java Version at Runtime](https://www.baeldung.com/get-java-version-runtime)
|
||||
- [Invoking a SOAP Web Service in Java](https://www.baeldung.com/java-soap-web-service)
|
||||
- [Java HTTPS Client Certificate Authentication](https://www.baeldung.com/java-https-client-certificate-authentication)
|
||||
- [Call Methods at Runtime Using Java Reflection](https://www.baeldung.com/java-method-reflection)
|
||||
|
@ -12,7 +12,7 @@
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@ -21,35 +21,11 @@
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mock-server</groupId>
|
||||
<artifactId>mockserver-junit-jupiter</artifactId>
|
||||
<version>${mockserver.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
@ -60,18 +36,6 @@
|
||||
<artifactId>jakarta.xml.ws-api</artifactId>
|
||||
<version>${jakarta.ws-api.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.ws</groupId>
|
||||
<artifactId>jaxws-rt</artifactId>
|
||||
<version>${jaxws-rt.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.ws</groupId>
|
||||
<artifactId>jaxws-ri</artifactId>
|
||||
<version>${jaxws-ri.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -105,14 +69,9 @@
|
||||
<properties>
|
||||
<maven.compiler.source.version>11</maven.compiler.source.version>
|
||||
<maven.compiler.target.version>11</maven.compiler.target.version>
|
||||
<guava.version>29.0-jre</guava.version>
|
||||
<assertj.version>3.17.2</assertj.version>
|
||||
<mockserver.version>5.11.1</mockserver.version>
|
||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||
<jakarta.ws-api.version>3.0.0</jakarta.ws-api.version>
|
||||
<jaxws-rt.version>3.0.0</jaxws-rt.version>
|
||||
<jaxws-ri.version>2.3.1</jaxws-ri.version>
|
||||
<jaxws-maven-plugin.version>2.3.2</jaxws-maven-plugin.version>
|
||||
<jakarta.ws-api.version>3.0.1</jakarta.ws-api.version>
|
||||
<jaxws-maven-plugin.version>3.0.2</jaxws-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -0,0 +1,41 @@
|
||||
package com.baeldung.httpsclientauthentication;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
public class SSLScocketClient {
|
||||
|
||||
static void startClient(String host, int port) throws IOException {
|
||||
|
||||
SocketFactory factory = SSLSocketFactory.getDefault();
|
||||
|
||||
try (SSLSocket socket = (SSLSocket) factory.createSocket(host, port)) {
|
||||
socket.setEnabledCipherSuites(new String[] { "TLS_AES_128_GCM_SHA256" });
|
||||
socket.setEnabledProtocols(new String[] { "TLSv1.3" });
|
||||
InputStream is = new BufferedInputStream(socket.getInputStream());
|
||||
String message = "Hello World Message";
|
||||
System.out.println("sending message: " + message);
|
||||
OutputStream os = new BufferedOutputStream(socket.getOutputStream());
|
||||
os.write(message.getBytes());
|
||||
os.flush();
|
||||
byte[] data = new byte[2048];
|
||||
int len = is.read(data);
|
||||
if (len <= 0) {
|
||||
throw new IOException("no data received");
|
||||
}
|
||||
System.out.printf("client received %d bytes: %s%n", len, new String(data, 0, len));
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
startClient("localhost", 8443);
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.baeldung.httpsclientauthentication;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
import javax.net.ServerSocketFactory;
|
||||
import javax.net.ssl.SSLServerSocket;
|
||||
import javax.net.ssl.SSLServerSocketFactory;
|
||||
|
||||
public class SSLSocketEchoServer {
|
||||
|
||||
static void startServer(int port) throws IOException {
|
||||
|
||||
ServerSocketFactory factory = SSLServerSocketFactory.getDefault();
|
||||
|
||||
try (SSLServerSocket listener = (SSLServerSocket) factory.createServerSocket(port)) {
|
||||
listener.setNeedClientAuth(true);
|
||||
listener.setEnabledCipherSuites(new String[] { "TLS_AES_128_GCM_SHA256" });
|
||||
listener.setEnabledProtocols(new String[] { "TLSv1.3" });
|
||||
System.out.println("listening for messages...");
|
||||
try (Socket socket = listener.accept()) {
|
||||
InputStream is = new BufferedInputStream(socket.getInputStream());
|
||||
OutputStream os = new BufferedOutputStream(socket.getOutputStream());
|
||||
byte[] data = new byte[2048];
|
||||
int len = is.read(data);
|
||||
if (len <= 0) {
|
||||
throw new IOException("no data received");
|
||||
}
|
||||
String message = new String(data, 0, len);
|
||||
System.out.printf("server received %d bytes: %s%n", len, message);
|
||||
String response = message + " processed by server";
|
||||
os.write(response.getBytes(), 0, response.getBytes().length);
|
||||
os.flush();
|
||||
}
|
||||
System.out.println("message processed, exiting");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
startServer(8443);
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
|
||||
package com.baeldung.soap.ws.client.generated;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlSchemaType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlSchemaType;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,19 +1,19 @@
|
||||
|
||||
package com.baeldung.soap.ws.client.generated;
|
||||
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebParam;
|
||||
import javax.jws.WebResult;
|
||||
import javax.jws.WebService;
|
||||
import javax.jws.soap.SOAPBinding;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.ws.Action;
|
||||
import jakarta.jws.WebMethod;
|
||||
import jakarta.jws.WebParam;
|
||||
import jakarta.jws.WebResult;
|
||||
import jakarta.jws.WebService;
|
||||
import jakarta.jws.soap.SOAPBinding;
|
||||
import jakarta.xml.bind.annotation.XmlSeeAlso;
|
||||
import jakarta.xml.ws.Action;
|
||||
|
||||
|
||||
/**
|
||||
* This class was generated by the JAX-WS RI.
|
||||
* JAX-WS RI 2.3.2
|
||||
* Generated source version: 2.2
|
||||
* JAX-WS RI 3.0.2
|
||||
* Generated source version: 3.0
|
||||
*
|
||||
*/
|
||||
@WebService(name = "CountryService", targetNamespace = "http://server.ws.soap.baeldung.com/")
|
||||
|
@ -4,17 +4,17 @@ package com.baeldung.soap.ws.client.generated;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.Service;
|
||||
import javax.xml.ws.WebEndpoint;
|
||||
import javax.xml.ws.WebServiceClient;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import jakarta.xml.ws.Service;
|
||||
import jakarta.xml.ws.WebEndpoint;
|
||||
import jakarta.xml.ws.WebServiceClient;
|
||||
import jakarta.xml.ws.WebServiceException;
|
||||
import jakarta.xml.ws.WebServiceFeature;
|
||||
|
||||
|
||||
/**
|
||||
* This class was generated by the JAX-WS RI.
|
||||
* JAX-WS RI 2.3.2
|
||||
* Generated source version: 2.2
|
||||
* JAX-WS RI 3.0.2
|
||||
* Generated source version: 3.0
|
||||
*
|
||||
*/
|
||||
@WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "http://localhost:8888/ws/country?wsdl")
|
||||
@ -75,7 +75,7 @@ public class CountryServiceImplService
|
||||
/**
|
||||
*
|
||||
* @param features
|
||||
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
|
||||
* A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
|
||||
* @return
|
||||
* returns CountryService
|
||||
*/
|
||||
|
@ -1,15 +1,14 @@
|
||||
|
||||
package com.baeldung.soap.ws.client.generated;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import jakarta.xml.bind.annotation.XmlEnum;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for currency.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p>
|
||||
* <pre>
|
||||
* <simpleType name="currency">
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user