commit
8892ca4d0b
|
@ -0,0 +1,50 @@
|
|||
package com.baeldung.poi.excel.insert;
|
||||
|
||||
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 org.junit.jupiter.api.Assertions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class ExcelInsertRowUnitTest {
|
||||
private static final String FILE_NAME = "test.xlsx";
|
||||
private static final String NEW_FILE_NAME = "new_test.xlsx";
|
||||
private String fileLocation;
|
||||
|
||||
@Before
|
||||
public void setup() throws URISyntaxException {
|
||||
fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWorkbook_whenInsertRowBetween_thenRowCreated() throws IOException {
|
||||
int startRow = 2;
|
||||
int rowNumber = 1;
|
||||
Workbook workbook = new XSSFWorkbook(fileLocation);
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
int lastRow = sheet.getLastRowNum();
|
||||
if (lastRow < startRow) {
|
||||
sheet.createRow(startRow);
|
||||
}
|
||||
sheet.shiftRows(startRow, lastRow, rowNumber, true, true);
|
||||
sheet.createRow(startRow);
|
||||
FileOutputStream outputStream = new FileOutputStream(NEW_FILE_NAME);
|
||||
workbook.write(outputStream);
|
||||
File file = new File(NEW_FILE_NAME);
|
||||
|
||||
final int expectedRowResult = 5;
|
||||
Assertions.assertEquals(expectedRowResult, workbook.getSheetAt(0).getLastRowNum());
|
||||
|
||||
outputStream.close();
|
||||
file.delete();
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
}
|
6
pom.xml
6
pom.xml
|
@ -1350,8 +1350,8 @@
|
|||
<gib.skipTestsForUpstreamModules>true</gib.skipTestsForUpstreamModules>
|
||||
<gib.buildUpstream>false</gib.buildUpstream>
|
||||
<gib.failOnMissingGitDir>false</gib.failOnMissingGitDir>
|
||||
<gib.failOnError>false</gib.failOnError>
|
||||
<gib.enabled>false</gib.enabled>
|
||||
<gib.failOnError>false</gib.failOnError>
|
||||
<gib.disable>true</gib.disable>
|
||||
|
||||
<junit.version>4.12</junit.version>
|
||||
<hamcrest.version>2.2</hamcrest.version>
|
||||
|
@ -1391,7 +1391,7 @@
|
|||
<directory-maven-plugin.version>0.3.1</directory-maven-plugin.version>
|
||||
<maven-install-plugin.version>2.5.2</maven-install-plugin.version>
|
||||
<custom-pmd.version>0.0.1</custom-pmd.version>
|
||||
<gitflow-incremental-builder.version>3.8</gitflow-incremental-builder.version>
|
||||
<gitflow-incremental-builder.version>3.12.2</gitflow-incremental-builder.version>
|
||||
<maven-jxr-plugin.version>3.0.0</maven-jxr-plugin.version>
|
||||
<!-- <maven-pmd-plugin.version>3.9.0</maven-pmd-plugin.version> -->
|
||||
<maven-pmd-plugin.version>3.13.0</maven-pmd-plugin.version>
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
FROM alpine:edge
|
||||
MAINTAINER baeldung.com
|
||||
RUN apk add --no-cache openjdk8
|
||||
COPY files/UnlimitedJCEPolicyJDK8/* /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/
|
|
@ -1,6 +0,0 @@
|
|||
FROM alpine-java:base
|
||||
MAINTAINER baeldung.com
|
||||
RUN apk --no-cache add netcat-openbsd
|
||||
COPY files/config-client.jar /opt/spring-cloud/lib/
|
||||
COPY files/config-client-entrypoint.sh /opt/spring-cloud/bin/
|
||||
RUN chmod 755 /opt/spring-cloud/bin/config-client-entrypoint.sh
|
|
@ -1,9 +0,0 @@
|
|||
FROM alpine-java:base
|
||||
MAINTAINER baeldung.com
|
||||
COPY files/config-server.jar /opt/spring-cloud/lib/
|
||||
ENV SPRING_APPLICATION_JSON='{"spring": {"cloud": {"config": {"server": \
|
||||
{"git": {"uri": "/var/lib/spring-cloud/config-repo", "clone-on-start": true}}}}}}'
|
||||
ENTRYPOINT ["/usr/bin/java"]
|
||||
CMD ["-jar", "/opt/spring-cloud/lib/config-server.jar"]
|
||||
VOLUME /var/lib/spring-cloud/config-repo
|
||||
EXPOSE 8888
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
while ! nc -z config-server 8888 ; do
|
||||
echo "Waiting for upcoming Config Server"
|
||||
sleep 2
|
||||
done
|
||||
|
||||
java -jar /opt/spring-cloud/lib/config-client.jar
|
|
@ -1,41 +0,0 @@
|
|||
version: '2'
|
||||
services:
|
||||
config-server:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.server
|
||||
image: config-server:latest
|
||||
expose:
|
||||
- 8888
|
||||
networks:
|
||||
- spring-cloud-network
|
||||
volumes:
|
||||
- spring-cloud-config-repo:/var/lib/spring-cloud/config-repo
|
||||
logging:
|
||||
driver: json-file
|
||||
config-client:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.client
|
||||
image: config-client:latest
|
||||
entrypoint: /opt/spring-cloud/bin/config-client-entrypoint.sh
|
||||
environment:
|
||||
SPRING_APPLICATION_JSON: '{"spring": {"cloud": {"config": {"uri": "http://config-server:8888"}}}}'
|
||||
expose:
|
||||
- 8080
|
||||
ports:
|
||||
- 8080
|
||||
networks:
|
||||
- spring-cloud-network
|
||||
links:
|
||||
- config-server:config-server
|
||||
depends_on:
|
||||
- config-server
|
||||
logging:
|
||||
driver: json-file
|
||||
networks:
|
||||
spring-cloud-network:
|
||||
driver: bridge
|
||||
volumes:
|
||||
spring-cloud-config-repo:
|
||||
external: true
|
|
@ -1,43 +0,0 @@
|
|||
version: '2'
|
||||
services:
|
||||
config-server:
|
||||
container_name: config-server
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.server
|
||||
image: config-server:latest
|
||||
expose:
|
||||
- 8888
|
||||
networks:
|
||||
- spring-cloud-network
|
||||
volumes:
|
||||
- spring-cloud-config-repo:/var/lib/spring-cloud/config-repo
|
||||
logging:
|
||||
driver: json-file
|
||||
config-client:
|
||||
container_name: config-client
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.client
|
||||
image: config-client:latest
|
||||
entrypoint: /opt/spring-cloud/bin/config-client-entrypoint.sh
|
||||
environment:
|
||||
SPRING_APPLICATION_JSON: '{"spring": {"cloud": {"config": {"uri": "http://config-server:8888"}}}}'
|
||||
expose:
|
||||
- 8080
|
||||
ports:
|
||||
- 8080:8080
|
||||
networks:
|
||||
- spring-cloud-network
|
||||
links:
|
||||
- config-server:config-server
|
||||
depends_on:
|
||||
- config-server
|
||||
logging:
|
||||
driver: json-file
|
||||
networks:
|
||||
spring-cloud-network:
|
||||
driver: bridge
|
||||
volumes:
|
||||
spring-cloud-config-repo:
|
||||
external: true
|
|
@ -0,0 +1,23 @@
|
|||
version: '2'
|
||||
services:
|
||||
message-server:
|
||||
build:
|
||||
context: docker-message-server
|
||||
dockerfile: Dockerfile
|
||||
image: message-server:latest
|
||||
ports:
|
||||
- 18800-18888:8888
|
||||
networks:
|
||||
- spring-cloud-network
|
||||
product-server:
|
||||
build:
|
||||
context: docker-product-server
|
||||
dockerfile: Dockerfile
|
||||
image: product-server:latest
|
||||
ports:
|
||||
- 19900-19999:9999
|
||||
networks:
|
||||
- spring-cloud-network
|
||||
networks:
|
||||
spring-cloud-network:
|
||||
driver: bridge
|
|
@ -0,0 +1,25 @@
|
|||
version: '2'
|
||||
services:
|
||||
message-server:
|
||||
container_name: message-server
|
||||
build:
|
||||
context: docker-message-server
|
||||
dockerfile: Dockerfile
|
||||
image: message-server:latest
|
||||
ports:
|
||||
- 18888:8888
|
||||
networks:
|
||||
- spring-cloud-network
|
||||
product-server:
|
||||
container_name: product-server
|
||||
build:
|
||||
context: docker-product-server
|
||||
dockerfile: Dockerfile
|
||||
image: product-server:latest
|
||||
ports:
|
||||
- 19999:9999
|
||||
networks:
|
||||
- spring-cloud-network
|
||||
networks:
|
||||
spring-cloud-network:
|
||||
driver: bridge
|
|
@ -0,0 +1,4 @@
|
|||
FROM openjdk:8-jdk-alpine
|
||||
MAINTAINER baeldung.com
|
||||
COPY target/docker-message-server-1.0.0.jar message-server.jar
|
||||
ENTRYPOINT ["java","-jar","/message-server.jar"]
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>docker-message-server</artifactId>
|
||||
<name>docker-message-server</name>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.spring.cloud</groupId>
|
||||
<artifactId>spring-cloud-docker</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,12 @@
|
|||
package com.baeldung.spring.cloud.config.docker;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class DockerMessageController {
|
||||
@GetMapping("/messages")
|
||||
public String getMessage() {
|
||||
return "Hello from Docker!";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.baeldung.spring.cloud.config.docker;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DockerServer {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DockerServer.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
server.port=8888
|
||||
spring.security.user.name=root
|
||||
spring.security.user.password=docker!
|
|
@ -0,0 +1,4 @@
|
|||
FROM openjdk:8-jdk-alpine
|
||||
MAINTAINER baeldung.com
|
||||
COPY target/docker-product-server-1.0.0.jar product-server.jar
|
||||
ENTRYPOINT ["java","-jar","/product-server.jar"]
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>docker-product-server</artifactId>
|
||||
<name>docker-product-server</name>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.spring.cloud</groupId>
|
||||
<artifactId>spring-cloud-docker</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,12 @@
|
|||
package com.baeldung.spring.cloud.config.docker;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class DockerProductController {
|
||||
@GetMapping("/products")
|
||||
public String getMessage() {
|
||||
return "A brand new product";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.baeldung.spring.cloud.config.docker;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DockerServer {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DockerServer.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
server.port=9999
|
||||
spring.security.user.name=root
|
||||
spring.security.user.password=docker!
|
|
@ -0,0 +1,28 @@
|
|||
<?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"
|
||||
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>spring-cloud-docker</artifactId>
|
||||
<name>spring-cloud-docker</name>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.spring.cloud</groupId>
|
||||
<artifactId>spring-cloud</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>docker-message-server</module>
|
||||
<module>docker-product-server</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
Loading…
Reference in New Issue