commit
07dd57469b
|
@ -0,0 +1,40 @@
|
||||||
|
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.baeldung.groovy</groupId>
|
||||||
|
<artifactId>determine-datatype</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.gmaven</groupId>
|
||||||
|
<artifactId>groovy-maven-plugin</artifactId>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
|
<artifactId>groovy-all</artifactId>
|
||||||
|
<version>2.0.6</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.junit/junit5-engine -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit</groupId>
|
||||||
|
<artifactId>junit5-engine</artifactId>
|
||||||
|
<version>5.0.0-ALPHA</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.baeldung.groovy.determine.datatype
|
||||||
|
|
||||||
|
class Person {
|
||||||
|
|
||||||
|
private int ageAsInt
|
||||||
|
private Double ageAsDouble
|
||||||
|
private String ageAsString
|
||||||
|
|
||||||
|
Person() {}
|
||||||
|
Person(int ageAsInt) { this.ageAsInt = ageAsInt}
|
||||||
|
Person(Double ageAsDouble) { this.ageAsDouble = ageAsDouble}
|
||||||
|
Person(String ageAsString) { this.ageAsString = ageAsString}
|
||||||
|
}
|
||||||
|
class Student extends Person {}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.baeldung.groovy.determine.datatype;
|
||||||
|
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class PersonTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenWhenParameterTypeIsInteger_thenReturnTrue() {
|
||||||
|
Person personObj = new Person(10)
|
||||||
|
Assert.assertTrue(personObj.ageAsInt instanceof Integer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenWhenParameterTypeIsDouble_thenReturnTrue() {
|
||||||
|
Person personObj = new Person(10.0)
|
||||||
|
Assert.assertTrue((personObj.ageAsDouble).getClass() == Double)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenWhenParameterTypeIsString_thenReturnTrue() {
|
||||||
|
Person personObj = new Person("10 years")
|
||||||
|
Assert.assertTrue(personObj.ageAsString.class == String)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenClassName_WhenParameterIsInteger_thenReturnTrue() {
|
||||||
|
Assert.assertTrue(Person.class.getDeclaredField('ageAsInt').type == int.class)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenWhenObjectIsInstanceOfType_thenReturnTrue() {
|
||||||
|
Person personObj = new Person()
|
||||||
|
Assert.assertTrue(personObj instanceof Person)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenWhenInstanceIsOfSubtype_thenReturnTrue() {
|
||||||
|
Student studentObj = new Student()
|
||||||
|
Assert.assertTrue(studentObj in Person)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenGroovyList_WhenFindClassName_thenReturnTrue() {
|
||||||
|
def ageList = ['ageAsString','ageAsDouble', 10]
|
||||||
|
Assert.assertTrue(ageList.class == ArrayList)
|
||||||
|
Assert.assertTrue(ageList.getClass() == ArrayList)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenGrooyMap_WhenFindClassName_thenReturnTrue() {
|
||||||
|
def ageMap = [ageAsString: '10 years', ageAsDouble: 10.0]
|
||||||
|
Assert.assertFalse(ageMap.class == LinkedHashMap)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,17 +0,0 @@
|
||||||
## Core Java Arrays (Part 2)
|
|
||||||
|
|
||||||
This module contains articles about Java arrays
|
|
||||||
|
|
||||||
## Relevant Articles
|
|
||||||
|
|
||||||
- [Extending an Array’s Length](https://www.baeldung.com/java-array-add-element-at-the-end)
|
|
||||||
- [Looping Diagonally Through a 2d Java Array](https://www.baeldung.com/java-loop-diagonal-array)
|
|
||||||
- [Converting Between Stream and Array in Java](https://www.baeldung.com/java-stream-to-array)
|
|
||||||
- [Convert a Float to a Byte Array in Java](https://www.baeldung.com/java-convert-float-to-byte-array)
|
|
||||||
- [Array Operations in Java](https://www.baeldung.com/java-common-array-operations)
|
|
||||||
- [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection)
|
|
||||||
- [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element)
|
|
||||||
- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element)
|
|
||||||
- [Adding an Element to a Java Array vs an ArrayList](https://www.baeldung.com/java-add-element-to-array-vs-list)
|
|
||||||
- [Arrays.sort vs Arrays.parallelSort](https://www.baeldung.com/java-arrays-sort-vs-parallelsort)
|
|
||||||
- [[<-- Prev]](/core-java-modules/core-java-arrays)
|
|
|
@ -1,3 +0,0 @@
|
||||||
### Relevant Articles:
|
|
||||||
|
|
||||||
- [Arrays.deepEquals](https://www.baeldung.com/java-arrays-deepequals)
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?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>core-java-arrays-3</artifactId>
|
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
|
||||||
<name>core-java-arrays-3</name>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>parent-java</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
<relativePath>../../parent-java</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.assertj</groupId>
|
|
||||||
<artifactId>assertj-core</artifactId>
|
|
||||||
<version>${assertj.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<assertj.version>3.14.0</assertj.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
## Core Java Arrays - Conversions
|
||||||
|
|
||||||
|
This module contains articles about arrays conversion in Java
|
||||||
|
|
||||||
|
## Relevant Articles
|
||||||
|
- [Convert a Float to a Byte Array in Java](https://www.baeldung.com/java-convert-float-to-byte-array)
|
||||||
|
- [Converting Between Stream and Array in Java](https://www.baeldung.com/java-stream-to-array)
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?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">
|
||||||
|
<parent>
|
||||||
|
<artifactId>core-java-modules</artifactId>
|
||||||
|
<groupId>com.baeldung.core-java-modules</groupId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>core-java-arrays-convert</artifactId>
|
||||||
|
<name>core-java-arrays-convert</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<guava.version>28.2-jre</guava.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -0,0 +1,7 @@
|
||||||
|
## Core Java Arrays - Guides
|
||||||
|
|
||||||
|
This module contains complete guides about arrays in Java
|
||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
- [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide)
|
||||||
|
- [Guide to the java.util.Arrays Class](https://www.baeldung.com/java-util-arrays)
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?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">
|
||||||
|
<parent>
|
||||||
|
<artifactId>core-java-modules</artifactId>
|
||||||
|
<groupId>com.baeldung.core-java-modules</groupId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>core-java-arrays-guides</artifactId>
|
||||||
|
<name>core-java-arrays-guides</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-core</artifactId>
|
||||||
|
<version>${jmh.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
|
<version>${jmh.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<jmh.version>1.19</jmh.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -0,0 +1,7 @@
|
||||||
|
## Core Java Arrays - Multidimensional
|
||||||
|
|
||||||
|
This module contains articles about multidimensional arrays in Java
|
||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
- [Multi-Dimensional Arrays In Java](https://www.baeldung.com/java-jagged-arrays)
|
||||||
|
- [Looping Diagonally Through a 2d Java Array](https://www.baeldung.com/java-loop-diagonal-array)
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?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">
|
||||||
|
<parent>
|
||||||
|
<artifactId>core-java-modules</artifactId>
|
||||||
|
<groupId>com.baeldung.core-java-modules</groupId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>core-java-arrays-multidimensional</artifactId>
|
||||||
|
<name>core-java-arrays-multidimensional</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
</project>
|
|
@ -0,0 +1,9 @@
|
||||||
|
## Core Java Arrays - Advanced Operations
|
||||||
|
|
||||||
|
This module contains articles about advanced operations on arrays in Java. They assume some background knowledge with arrays in Java.
|
||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
- [How to Copy an Array in Java](https://www.baeldung.com/java-array-copy)
|
||||||
|
- [Arrays.deepEquals](https://www.baeldung.com/java-arrays-deepequals)
|
||||||
|
- [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average)
|
||||||
|
- [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection)
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?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">
|
||||||
|
<parent>
|
||||||
|
<artifactId>core-java-modules</artifactId>
|
||||||
|
<groupId>com.baeldung.core-java-modules</groupId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>core-java-arrays-operations-advanced</artifactId>
|
||||||
|
<name>core-java-arrays-operations-advanced</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons-lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${assertj-core.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<commons-lang3.version>3.9</commons-lang3.version>
|
||||||
|
|
||||||
|
<assertj-core.version>3.10.0</assertj-core.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.baeldung.array.operations;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class ArraysIntersectionOperations {
|
||||||
|
|
||||||
|
public static Integer[] intersectionSimple(final Integer[] a, final Integer[] b) {
|
||||||
|
return Stream.of(a)
|
||||||
|
.filter(Arrays.asList(b)::contains)
|
||||||
|
.toArray(Integer[]::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer[] intersectionSet(final Integer[] a, final Integer[] b) {
|
||||||
|
return Stream.of(a)
|
||||||
|
.filter(Arrays.asList(b)::contains)
|
||||||
|
.distinct()
|
||||||
|
.toArray(Integer[]::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer[] intersectionMultiSet(final Integer[] a, final Integer[] b) {
|
||||||
|
return Stream.of(a)
|
||||||
|
.filter(new LinkedList<>(Arrays.asList(b))::remove)
|
||||||
|
.toArray(Integer[]::new);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package com.baeldung.array.operations;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static com.baeldung.array.operations.ArrayOperations.*;
|
import static com.baeldung.array.operations.ArraysIntersectionOperations.*;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
class IntersectionUnitTest {
|
class IntersectionUnitTest {
|
|
@ -0,0 +1,12 @@
|
||||||
|
## Core Java Arrays - Basic Operations
|
||||||
|
|
||||||
|
This module contains articles about Java array fundamentals. They assume no previous background knowledge on working with arrays.
|
||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
- [Initializing Arrays in Java](https://www.baeldung.com/java-initialize-array)
|
||||||
|
- [Array Operations in Java](https://www.baeldung.com/java-common-array-operations)
|
||||||
|
- [Adding an Element to a Java Array vs an ArrayList](https://www.baeldung.com/java-add-element-to-array-vs-list)
|
||||||
|
- [Check if a Java Array Contains a Value](https://www.baeldung.com/java-array-contains-value)
|
||||||
|
- [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element)
|
||||||
|
- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element)
|
||||||
|
- [Extending an Array’s Length](https://www.baeldung.com/java-array-add-element-at-the-end)
|
|
@ -1,54 +1,19 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>core-java-modules</artifactId>
|
||||||
|
<groupId>com.baeldung.core-java-modules</groupId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>core-java-arrays-2</artifactId>
|
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<artifactId>core-java-arrays-operations-basic</artifactId>
|
||||||
<name>core-java-arrays-2</name>
|
<name>core-java-arrays-operations-basic</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>parent-java</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
<relativePath>../../parent-java</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
<version>${commons-lang3.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
|
||||||
<artifactId>jmh-core</artifactId>
|
|
||||||
<version>${jmh.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
|
||||||
<version>${jmh.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- test scoped -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.assertj</groupId>
|
|
||||||
<artifactId>assertj-core</artifactId>
|
|
||||||
<version>${assertj-core.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>core-java-arrays-2</finalName>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
@ -74,13 +39,40 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<dependencies>
|
||||||
<jmh.version>1.19</jmh.version>
|
<dependency>
|
||||||
<!-- util -->
|
<groupId>org.apache.commons</groupId>
|
||||||
<commons-lang3.version>3.9</commons-lang3.version>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<!-- testing -->
|
<version>${commons-lang3.version}</version>
|
||||||
<assertj-core.version>3.10.0</assertj-core.version>
|
</dependency>
|
||||||
<shade.plugin.version>3.2.0</shade.plugin.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
|
<!-- Benchmarking -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-core</artifactId>
|
||||||
|
<version>${jmh.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
|
<version>${jmh.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${assertj-core.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<shade.plugin.version>3.2.0</shade.plugin.version>
|
||||||
|
|
||||||
|
<commons-lang3.version>3.9</commons-lang3.version>
|
||||||
|
|
||||||
|
<jmh.version>1.19</jmh.version>
|
||||||
|
|
||||||
|
<assertj-core.version>3.10.0</assertj-core.version>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
|
@ -9,7 +9,7 @@ public class ArrayBenchmarkRunner {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
Options options = new OptionsBuilder()
|
Options options = new OptionsBuilder()
|
||||||
.include(SearchArrayUnitTest.class.getSimpleName()).threads(1)
|
.include(SearchArrayBenchmark.class.getSimpleName()).threads(1)
|
||||||
.forks(1).shouldFailOnError(true).shouldDoGC(true)
|
.forks(1).shouldFailOnError(true).shouldDoGC(true)
|
||||||
.jvmArgs("-server").build();
|
.jvmArgs("-server").build();
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
@BenchmarkMode(Mode.AverageTime)
|
@BenchmarkMode(Mode.AverageTime)
|
||||||
@Warmup(iterations = 5)
|
@Warmup(iterations = 5)
|
||||||
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
||||||
public class SearchArrayUnitTest {
|
public class SearchArrayBenchmark {
|
||||||
|
|
||||||
@State(Scope.Benchmark)
|
@State(Scope.Benchmark)
|
||||||
public static class SearchData {
|
public static class SearchData {
|
|
@ -0,0 +1,9 @@
|
||||||
|
## Core Java Arrays - Sorting
|
||||||
|
|
||||||
|
This module contains articles about sorting arrays in Java
|
||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
- [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays)
|
||||||
|
- [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array)
|
||||||
|
- [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array)
|
||||||
|
- [Arrays.sort vs Arrays.parallelSort](https://www.baeldung.com/java-arrays-sort-vs-parallelsort)
|
|
@ -0,0 +1,87 @@
|
||||||
|
<?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">
|
||||||
|
<parent>
|
||||||
|
<artifactId>core-java-modules</artifactId>
|
||||||
|
<groupId>com.baeldung.core-java-modules</groupId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>core-java-arrays-sorting</artifactId>
|
||||||
|
<name>core-java-arrays-sorting</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>${shade.plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<finalName>benchmarks</finalName>
|
||||||
|
<transformers>
|
||||||
|
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
|
<mainClass>org.openjdk.jmh.Main</mainClass>
|
||||||
|
</transformer>
|
||||||
|
</transformers>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- Utilities -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons-lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Benchmarking -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-core</artifactId>
|
||||||
|
<version>${jmh.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
|
<version>${jmh.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Testing -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${assertj-core.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<shade.plugin.version>3.2.0</shade.plugin.version>
|
||||||
|
|
||||||
|
<commons-lang3.version>3.9</commons-lang3.version>
|
||||||
|
<guava.version>28.2-jre</guava.version>
|
||||||
|
|
||||||
|
<jmh.version>1.19</jmh.version>
|
||||||
|
|
||||||
|
<assertj-core.version>3.10.0</assertj-core.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -1,7 +1,5 @@
|
||||||
package com.baeldung.array;
|
package com.baeldung.array;
|
||||||
|
|
||||||
import com.baeldung.arraycopy.model.Employee;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
public class SortedArrayChecker {
|
public class SortedArrayChecker {
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.baeldung.sort;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Employee implements Serializable {
|
||||||
|
private static final long serialVersionUID = -2454619097207585825L;
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private int age;
|
||||||
|
|
||||||
|
public Employee() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Employee(int id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Employee(int id, String name, int age) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAge() {
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAge(int age) {
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package com.baeldung.array;
|
package com.baeldung.array;
|
||||||
|
|
||||||
import com.baeldung.arraycopy.model.Employee;
|
import com.baeldung.sort.Employee;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.baeldung.sort;
|
package com.baeldung.sort;
|
||||||
|
|
||||||
import com.baeldung.arraycopy.model.Employee;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -86,5 +85,4 @@ public class ArraySortUnitTest {
|
||||||
|
|
||||||
assertArrayEquals(new Employee[]{david, john, mary}, employees);
|
assertArrayEquals(new Employee[]{david, john, mary}, employees);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
## Core Java Arrays
|
|
||||||
|
|
||||||
This module contains articles about Java arrays
|
|
||||||
|
|
||||||
### Relevant Articles:
|
|
||||||
- [How to Copy an Array in Java](https://www.baeldung.com/java-array-copy)
|
|
||||||
- [Check if a Java Array Contains a Value](https://www.baeldung.com/java-array-contains-value)
|
|
||||||
- [Initializing Arrays in Java](https://www.baeldung.com/java-initialize-array)
|
|
||||||
- [Guide to the java.util.Arrays Class](https://www.baeldung.com/java-util-arrays)
|
|
||||||
- [Multi-Dimensional Arrays In Java](https://www.baeldung.com/java-jagged-arrays)
|
|
||||||
- [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average)
|
|
||||||
- [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide)
|
|
||||||
- [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array)
|
|
||||||
- [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays)
|
|
||||||
- [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array)
|
|
||||||
- [[More -->]](/core-java-modules/core-java-arrays-2)
|
|
|
@ -1,180 +0,0 @@
|
||||||
<?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>core-java-arrays</artifactId>
|
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
|
||||||
<name>core-java-arrays</name>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>parent-java</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
<relativePath>../../parent-java</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
<version>${commons-lang3.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- test scoped -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.assertj</groupId>
|
|
||||||
<artifactId>assertj-core</artifactId>
|
|
||||||
<version>${assertj-core.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
|
||||||
<artifactId>jmh-core</artifactId>
|
|
||||||
<version>${jmh-core.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
|
||||||
<version>${jmh-generator-annprocess.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>core-java-arrays</finalName>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>copy-dependencies</id>
|
|
||||||
<phase>prepare-package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-dependencies</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
|
||||||
<version>${exec-maven-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<executable>java</executable>
|
|
||||||
<mainClass>com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed</mainClass>
|
|
||||||
<arguments>
|
|
||||||
<argument>-Xmx300m</argument>
|
|
||||||
<argument>-XX:+UseParallelGC</argument>
|
|
||||||
<argument>-classpath</argument>
|
|
||||||
<classpath />
|
|
||||||
<argument>com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed</argument>
|
|
||||||
</arguments>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>${maven-javadoc-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<source>${source.version}</source>
|
|
||||||
<target>${target.version}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>integration</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>integration-test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>test</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*ManualTest.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
<includes>
|
|
||||||
<include>**/*IntegrationTest.java</include>
|
|
||||||
<include>**/*IntTest.java</include>
|
|
||||||
</includes>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<systemPropertyVariables>
|
|
||||||
<test.mime>json</test.mime>
|
|
||||||
</systemPropertyVariables>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
|
||||||
<version>${exec-maven-plugin.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>run-benchmarks</id>
|
|
||||||
<!-- <phase>integration-test</phase> -->
|
|
||||||
<phase>none</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>exec</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<classpathScope>test</classpathScope>
|
|
||||||
<executable>java</executable>
|
|
||||||
<arguments>
|
|
||||||
<argument>-classpath</argument>
|
|
||||||
<classpath />
|
|
||||||
<argument>org.openjdk.jmh.Main</argument>
|
|
||||||
<argument>.*</argument>
|
|
||||||
</arguments>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<!-- util -->
|
|
||||||
<commons-lang3.version>3.9</commons-lang3.version>
|
|
||||||
|
|
||||||
<jmh-core.version>1.19</jmh-core.version>
|
|
||||||
<jmh-generator-annprocess.version>1.19</jmh-generator-annprocess.version>
|
|
||||||
|
|
||||||
<!-- testing -->
|
|
||||||
<assertj-core.version>3.10.0</assertj-core.version>
|
|
||||||
|
|
||||||
<!-- maven and spring plugins -->
|
|
||||||
<maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version>
|
|
||||||
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
|
|
||||||
<source.version>1.8</source.version>
|
|
||||||
<target.version>1.8</target.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -9,7 +9,7 @@ This module contains articles about string operations.
|
||||||
- [String toLowerCase and toUpperCase Methods in Java](https://www.baeldung.com/java-string-convert-case)
|
- [String toLowerCase and toUpperCase Methods in Java](https://www.baeldung.com/java-string-convert-case)
|
||||||
- [Java String equalsIgnoreCase()](https://www.baeldung.com/java-string-equalsignorecase)
|
- [Java String equalsIgnoreCase()](https://www.baeldung.com/java-string-equalsignorecase)
|
||||||
- [Case-Insensitive String Matching in Java](https://www.baeldung.com/java-case-insensitive-string-matching)
|
- [Case-Insensitive String Matching in Java](https://www.baeldung.com/java-case-insensitive-string-matching)
|
||||||
- [L-Trim and R-Trim in Java](https://www.baeldung.com/l-trim-and-r-trim-in-java)
|
|
||||||
- [L-Trim and R-Trim Alternatives in Java](https://www.baeldung.com/java-trim-alternatives)
|
- [L-Trim and R-Trim Alternatives in Java](https://www.baeldung.com/java-trim-alternatives)
|
||||||
- [Java Convert PDF to Base64](https://www.baeldung.com/java-convert-pdf-to-base64)
|
- [Java Convert PDF to Base64](https://www.baeldung.com/java-convert-pdf-to-base64)
|
||||||
|
- [Encode a String to UTF-8 in Java](https://www.baeldung.com/java-string-encode-utf-8)
|
||||||
- More articles: [[<-- prev]](../core-java-string-operations)
|
- More articles: [[<-- prev]](../core-java-string-operations)
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.baeldung.encodetoutf8;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.StringUtils;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class StringEncodeUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenGermanAsciiString_whenComparing_thenCompareNotEquals() {
|
||||||
|
String germanString = "Entwickeln Sie mit Vergnügen";
|
||||||
|
byte[] germanBytes = germanString.getBytes();
|
||||||
|
|
||||||
|
String asciiEncodedString = new String(germanBytes, StandardCharsets.US_ASCII);
|
||||||
|
|
||||||
|
assertNotEquals(germanString, asciiEncodedString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenUsAsciiString_whenComparing_thenCompareNotEquals() {
|
||||||
|
String englishString = "Develop with pleasure";
|
||||||
|
byte[] englishBytes = englishString.getBytes();
|
||||||
|
|
||||||
|
String asciiEncondedEnglishString = new String(englishBytes, StandardCharsets.US_ASCII);
|
||||||
|
|
||||||
|
assertEquals(englishString, asciiEncondedEnglishString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ApacheCommonsCodecEncode
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void givenSomeUnencodedString_whenApacheCommonsCodecEncode_thenCompareEquals() {
|
||||||
|
String rawString = "Entwickeln Sie mit Vergnügen";
|
||||||
|
byte[] bytes = StringUtils.getBytesUtf8(rawString);
|
||||||
|
|
||||||
|
String utf8EncodedString = StringUtils.newStringUtf8(bytes);
|
||||||
|
|
||||||
|
assertEquals(rawString, utf8EncodedString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CoreJavaEncode
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void givenSomeUnencodedString_whenCoreJavaEncode_thenCompareEquals() {
|
||||||
|
String rawString = "Entwickeln Sie mit Vergnügen";
|
||||||
|
byte[] bytes = rawString.getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
String utf8EncodedString = new String(bytes, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
assertEquals(rawString, utf8EncodedString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Java7StandardCharsetsEncode
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void givenSomeUnencodedString_whenJava7StandardCharsetsEncode_thenCompareEquals() {
|
||||||
|
String rawString = "Entwickeln Sie mit Vergnügen";
|
||||||
|
ByteBuffer buffer = StandardCharsets.UTF_8.encode(rawString);
|
||||||
|
|
||||||
|
String utf8EncodedString = StandardCharsets.UTF_8.decode(buffer)
|
||||||
|
.toString();
|
||||||
|
|
||||||
|
assertEquals(rawString, utf8EncodedString);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.baeldung.objectclass;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Borrower extends User {
|
||||||
|
|
||||||
|
private double totalLoanAmount;
|
||||||
|
|
||||||
|
public double requestLoan(double amount) {
|
||||||
|
totalLoanAmount = amount;
|
||||||
|
return totalLoanAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double increaseLoan(double increaseBy) {
|
||||||
|
return totalLoanAmount + increaseBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double payLoan(double amount) {
|
||||||
|
return totalLoanAmount - amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.baeldung.objectclass;
|
||||||
|
|
||||||
|
public class Lender extends User {
|
||||||
|
|
||||||
|
private double totalInvestmentAmount;
|
||||||
|
|
||||||
|
public double invest(double amount) {
|
||||||
|
totalInvestmentAmount = amount;
|
||||||
|
return totalInvestmentAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double increaseInvestment(double increaseBy) {
|
||||||
|
return totalInvestmentAmount + increaseBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double collectDividends() {
|
||||||
|
return totalInvestmentAmount * 0.07;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.baeldung.objectclass;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.baeldung.objectclass;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class CreditAppUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenLender_whenInstanceOf_thenReturnTrue() {
|
||||||
|
User lender = new Lender();
|
||||||
|
assertTrue(lender instanceof Lender);
|
||||||
|
assertTrue(lender instanceof User);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenUser_whenInstanceOfLender_thenDowncast() {
|
||||||
|
User user = new Lender();
|
||||||
|
Lender lender = null;
|
||||||
|
|
||||||
|
if(user instanceof Lender) {
|
||||||
|
lender = (Lender) user;
|
||||||
|
}
|
||||||
|
|
||||||
|
assertNotNull(lender);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenUser_whenIsInstanceOfLender_thenDowncast() {
|
||||||
|
User user = new Lender();
|
||||||
|
Lender lender = null;
|
||||||
|
|
||||||
|
if(Lender.class.isInstance(user)) {
|
||||||
|
lender = (Lender) user;
|
||||||
|
}
|
||||||
|
|
||||||
|
assertNotNull(lender);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenBorrower_whenLoanAmountIsDouble_thenRequestLoan() {
|
||||||
|
Borrower borrower = new Borrower();
|
||||||
|
double amount = 100.0;
|
||||||
|
|
||||||
|
//if(amount instanceof Double) // Compilation error, no autoboxing
|
||||||
|
if(Double.class.isInstance(amount)) {
|
||||||
|
borrower.requestLoan(amount);
|
||||||
|
}
|
||||||
|
assertEquals(100, borrower.getTotalLoanAmount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenBorrower_whenLoanAmountIsNotString_thenRequestLoan() {
|
||||||
|
Borrower borrower = new Borrower();
|
||||||
|
Double amount = 100.0;
|
||||||
|
|
||||||
|
//if(amount instanceof String) // Compilation error, incompatible operands
|
||||||
|
if(!String.class.isInstance(amount)) {
|
||||||
|
borrower.requestLoan(amount);
|
||||||
|
}
|
||||||
|
assertEquals(100, borrower.getTotalLoanAmount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenLender_whenGetClass_thenEqualsLenderType() {
|
||||||
|
User lender = new Lender();
|
||||||
|
assertEquals(Lender.class, lender.getClass());
|
||||||
|
assertNotEquals(User.class, lender.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -31,9 +31,13 @@
|
||||||
<!-- <module>core-java-9-streams</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
|
<!-- <module>core-java-9-streams</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
|
||||||
|
|
||||||
<module>core-java-annotations</module>
|
<module>core-java-annotations</module>
|
||||||
<module>core-java-arrays</module>
|
|
||||||
<module>core-java-arrays-2</module>
|
<module>core-java-arrays-sorting</module>
|
||||||
<module>core-java-arrays-3</module>
|
<module>core-java-arrays-guides</module>
|
||||||
|
<module>core-java-arrays-multidimensional</module>
|
||||||
|
<module>core-java-arrays-convert</module>
|
||||||
|
<module>core-java-arrays-operations-basic</module>
|
||||||
|
<module>core-java-arrays-operations-advanced</module>
|
||||||
|
|
||||||
<module>core-java-collections</module>
|
<module>core-java-collections</module>
|
||||||
<module>core-java-collections-2</module>
|
<module>core-java-collections-2</module>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
This module contains articles about Kotlin core features.
|
This module contains articles about Kotlin core features.
|
||||||
|
|
||||||
### Relevant articles:
|
### Relevant articles:
|
||||||
- [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin/tutorial)
|
- [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin-intro)
|
||||||
- [Kotlin Java Interoperability](https://www.baeldung.com/kotlin-java-interoperability)
|
- [Kotlin Java Interoperability](https://www.baeldung.com/kotlin-java-interoperability)
|
||||||
- [Get a Random Number in Kotlin](https://www.baeldung.com/kotlin-random-number)
|
- [Get a Random Number in Kotlin](https://www.baeldung.com/kotlin-random-number)
|
||||||
- [Create a Java and Kotlin Project with Maven](https://www.baeldung.com/kotlin-maven-java-project)
|
- [Create a Java and Kotlin Project with Maven](https://www.baeldung.com/kotlin-maven-java-project)
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
/.idea
|
||||||
|
/.gradle
|
||||||
|
/build
|
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'java-library'
|
||||||
|
id 'application'
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'application'
|
||||||
|
mainClassName = 'employee.EmployeeApp'
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
println 'This is executed during configuration phase'
|
||||||
|
|
||||||
|
task configured {
|
||||||
|
println 'The project is configured'
|
||||||
|
}
|
||||||
|
|
||||||
|
task wrapper(type: Wrapper){
|
||||||
|
gradleVersion = '5.3.1'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
|
||||||
|
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
|
||||||
|
testImplementation('junit:junit:4.13')
|
||||||
|
testRuntime('junit:junit:4.13')
|
||||||
|
}
|
||||||
|
test {
|
||||||
|
useJUnit()
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package employee;
|
||||||
|
|
||||||
|
public class Employee {
|
||||||
|
|
||||||
|
String name;
|
||||||
|
String emailAddress;
|
||||||
|
int yearOfBirth;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package employee;
|
||||||
|
|
||||||
|
public class EmployeeApp {
|
||||||
|
|
||||||
|
public static void main(String[] args){
|
||||||
|
|
||||||
|
Employee employee = new Employee();
|
||||||
|
employee.name = "John";
|
||||||
|
employee.emailAddress = "john@baeldung.com";
|
||||||
|
employee.yearOfBirth = 1978;
|
||||||
|
System.out.println("Name: " + employee.name);
|
||||||
|
System.out.println("Email Address: " + employee.emailAddress);
|
||||||
|
System.out.println("Year Of Birth:" + employee.yearOfBirth);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package employee;
|
||||||
|
|
||||||
|
import employee.Employee;
|
||||||
|
import org.junit.*;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
public class EmployeeAppTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testData(){
|
||||||
|
|
||||||
|
Employee testEmp = this.getEmployeeTest();
|
||||||
|
|
||||||
|
assertEquals(testEmp.name, "John");
|
||||||
|
assertEquals(testEmp.emailAddress, "john@baeldung.com");
|
||||||
|
assertEquals(testEmp.yearOfBirth, 1978);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Employee getEmployeeTest(){
|
||||||
|
|
||||||
|
Employee employee = new Employee();
|
||||||
|
employee.name = "John";
|
||||||
|
employee.emailAddress = "john@baeldung.com";
|
||||||
|
employee.yearOfBirth = 1978;
|
||||||
|
|
||||||
|
return employee;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
rootProject.name = 'gradletutorial'
|
rootProject.name = 'gradletutorial'
|
||||||
|
|
||||||
|
|
||||||
include 'greeting-library'
|
include 'greeting-library'
|
||||||
include 'greeting-library-java'
|
include 'greeting-library-java'
|
||||||
include 'greeter'
|
include 'greeter'
|
||||||
include 'gradletaskdemo'
|
include 'gradletaskdemo'
|
||||||
include 'junit5'
|
include 'junit5'
|
||||||
|
include 'gradle-employee-app'
|
||||||
|
|
||||||
println 'This will be executed during the initialization phase.'
|
println 'This will be executed during the initialization phase.'
|
||||||
|
|
|
@ -13,3 +13,4 @@ This module contains articles a Google Guava
|
||||||
- [Bloom Filter in Java using Guava](https://www.baeldung.com/guava-bloom-filter)
|
- [Bloom Filter in Java using Guava](https://www.baeldung.com/guava-bloom-filter)
|
||||||
- [Quick Guide to the Guava RateLimiter](https://www.baeldung.com/guava-rate-limiter)
|
- [Quick Guide to the Guava RateLimiter](https://www.baeldung.com/guava-rate-limiter)
|
||||||
- [Introduction to Guava Throwables](https://www.baeldung.com/guava-throwables)
|
- [Introduction to Guava Throwables](https://www.baeldung.com/guava-throwables)
|
||||||
|
- [Guava Cache](https://www.baeldung.com/guava-cache)
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-boot-1</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-1</relativePath>
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
## Java Collections Cookbooks and Examples
|
|
||||||
|
|
||||||
This module contains articles about Map data structures in Java.
|
|
||||||
|
|
||||||
### Relevant Articles:
|
|
||||||
|
|
||||||
- More articles: [[<-- prev>]](/../java-collections-maps)
|
|
||||||
- More articles: [[<-- prev>]](/../java-collections-maps-2)
|
|
|
@ -242,6 +242,29 @@
|
||||||
</lifecycleMappingMetadata>
|
</lifecycleMappingMetadata>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<!-- jax-ws maven plugin-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>jaxws-maven-plugin</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>wsimport-from-jdk</id>
|
||||||
|
<goals>
|
||||||
|
<goal>wsimport</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<wsdlDirectory>src/main/resources</wsdlDirectory>
|
||||||
|
<wsdlFiles>
|
||||||
|
<wsdlFile>country.wsdl</wsdlFile>
|
||||||
|
</wsdlFiles>
|
||||||
|
<keep>true</keep>
|
||||||
|
<packageName>com.baeldung.soap.ws.client.generated</packageName>
|
||||||
|
<sourceDestDir>src/main/java</sourceDestDir>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Java class for country complex type.
|
||||||
|
*
|
||||||
|
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType name="country">
|
||||||
|
* <complexContent>
|
||||||
|
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||||
|
* <sequence>
|
||||||
|
* <element name="capital" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||||
|
* <element name="currency" type="{http://server.ws.soap.baeldung.com/}currency" minOccurs="0"/>
|
||||||
|
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||||
|
* <element name="population" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||||
|
* </sequence>
|
||||||
|
* </restriction>
|
||||||
|
* </complexContent>
|
||||||
|
* </complexType>
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "country", propOrder = { "capital", "currency", "name", "population" })
|
||||||
|
public class Country {
|
||||||
|
|
||||||
|
protected String capital;
|
||||||
|
@XmlSchemaType(name = "string")
|
||||||
|
protected Currency currency;
|
||||||
|
protected String name;
|
||||||
|
protected int population;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the capital property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getCapital() {
|
||||||
|
return capital;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the capital property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setCapital(String value) {
|
||||||
|
this.capital = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the currency property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link Currency }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public Currency getCurrency() {
|
||||||
|
return currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the currency property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link Currency }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setCurrency(Currency value) {
|
||||||
|
this.currency = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the name property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the name property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setName(String value) {
|
||||||
|
this.name = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the population property.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public int getPopulation() {
|
||||||
|
return population;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the population property.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setPopulation(int value) {
|
||||||
|
this.population = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class was generated by the JAX-WS RI.
|
||||||
|
* JAX-WS RI 2.3.2
|
||||||
|
* Generated source version: 2.2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@WebService(name = "CountryService", targetNamespace = "http://server.ws.soap.baeldung.com/")
|
||||||
|
@SOAPBinding(style = SOAPBinding.Style.RPC)
|
||||||
|
@XmlSeeAlso({ ObjectFactory.class })
|
||||||
|
public interface CountryService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param arg0
|
||||||
|
* @return
|
||||||
|
* returns com.baeldung.soap.ws.client.generated.Country
|
||||||
|
*/
|
||||||
|
@WebMethod
|
||||||
|
@WebResult(partName = "return")
|
||||||
|
@Action(input = "http://server.ws.soap.baeldung.com/CountryService/findByNameRequest", output = "http://server.ws.soap.baeldung.com/CountryService/findByNameResponse")
|
||||||
|
public Country findByName(@WebParam(name = "arg0", partName = "arg0") String arg0);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class was generated by the JAX-WS RI.
|
||||||
|
* JAX-WS RI 2.3.2
|
||||||
|
* Generated source version: 2.2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "file:src/main/resources/country.wsdl")
|
||||||
|
public class CountryServiceImplService extends Service {
|
||||||
|
|
||||||
|
private final static URL COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION;
|
||||||
|
private final static WebServiceException COUNTRYSERVICEIMPLSERVICE_EXCEPTION;
|
||||||
|
private final static QName COUNTRYSERVICEIMPLSERVICE_QNAME = new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplService");
|
||||||
|
|
||||||
|
static {
|
||||||
|
URL url = null;
|
||||||
|
WebServiceException e = null;
|
||||||
|
try {
|
||||||
|
url = new URL("file:src/main/resources/country.wsdl");
|
||||||
|
} catch (MalformedURLException ex) {
|
||||||
|
e = new WebServiceException(ex);
|
||||||
|
}
|
||||||
|
COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION = url;
|
||||||
|
COUNTRYSERVICEIMPLSERVICE_EXCEPTION = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CountryServiceImplService() {
|
||||||
|
super(__getWsdlLocation(), COUNTRYSERVICEIMPLSERVICE_QNAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CountryServiceImplService(WebServiceFeature... features) {
|
||||||
|
super(__getWsdlLocation(), COUNTRYSERVICEIMPLSERVICE_QNAME, features);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CountryServiceImplService(URL wsdlLocation) {
|
||||||
|
super(wsdlLocation, COUNTRYSERVICEIMPLSERVICE_QNAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CountryServiceImplService(URL wsdlLocation, WebServiceFeature... features) {
|
||||||
|
super(wsdlLocation, COUNTRYSERVICEIMPLSERVICE_QNAME, features);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CountryServiceImplService(URL wsdlLocation, QName serviceName) {
|
||||||
|
super(wsdlLocation, serviceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CountryServiceImplService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
|
||||||
|
super(wsdlLocation, serviceName, features);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* returns CountryService
|
||||||
|
*/
|
||||||
|
@WebEndpoint(name = "CountryServiceImplPort")
|
||||||
|
public CountryService getCountryServiceImplPort() {
|
||||||
|
return super.getPort(new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplPort"), CountryService.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
* @return
|
||||||
|
* returns CountryService
|
||||||
|
*/
|
||||||
|
@WebEndpoint(name = "CountryServiceImplPort")
|
||||||
|
public CountryService getCountryServiceImplPort(WebServiceFeature... features) {
|
||||||
|
return super.getPort(new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplPort"), CountryService.class, features);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static URL __getWsdlLocation() {
|
||||||
|
if (COUNTRYSERVICEIMPLSERVICE_EXCEPTION != null) {
|
||||||
|
throw COUNTRYSERVICEIMPLSERVICE_EXCEPTION;
|
||||||
|
}
|
||||||
|
return COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
package com.baeldung.soap.ws.client.generated;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlEnum;
|
||||||
|
import javax.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">
|
||||||
|
* <enumeration value="EUR"/>
|
||||||
|
* <enumeration value="INR"/>
|
||||||
|
* <enumeration value="USD"/>
|
||||||
|
* </restriction>
|
||||||
|
* </simpleType>
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlType(name = "currency")
|
||||||
|
@XmlEnum
|
||||||
|
public enum Currency {
|
||||||
|
|
||||||
|
EUR, INR, USD;
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return name();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Currency fromValue(String v) {
|
||||||
|
return valueOf(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
package com.baeldung.soap.ws.client.generated;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This object contains factory methods for each
|
||||||
|
* Java content interface and Java element interface
|
||||||
|
* generated in the com.baeldung.soap.ws.client.generated package.
|
||||||
|
* <p>An ObjectFactory allows you to programatically
|
||||||
|
* construct new instances of the Java representation
|
||||||
|
* for XML content. The Java representation of XML
|
||||||
|
* content can consist of schema derived interfaces
|
||||||
|
* and classes representing the binding of schema
|
||||||
|
* type definitions, element declarations and model
|
||||||
|
* groups. Factory methods for each of these are
|
||||||
|
* provided in this class.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlRegistry
|
||||||
|
public class ObjectFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.soap.ws.client.generated
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ObjectFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of {@link Country }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public Country createCountry() {
|
||||||
|
return new Country();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
@javax.xml.bind.annotation.XmlSchema(namespace = "http://server.ws.soap.baeldung.com/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
|
||||||
|
package com.baeldung.soap.ws.client.generated;
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.baeldung.soap.ws.server;
|
||||||
|
|
||||||
|
public class Country {
|
||||||
|
protected String name;
|
||||||
|
protected int population;
|
||||||
|
protected String capital;
|
||||||
|
protected Currency currency;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPopulation() {
|
||||||
|
return population;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPopulation(int population) {
|
||||||
|
this.population = population;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCapital() {
|
||||||
|
return capital;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCapital(String capital) {
|
||||||
|
this.capital = capital;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Currency getCurrency() {
|
||||||
|
return currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrency(Currency currency) {
|
||||||
|
this.currency = currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.baeldung.soap.ws.server;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class CountryRepository {
|
||||||
|
|
||||||
|
private static final Map<String, Country> countries = new HashMap<>();
|
||||||
|
|
||||||
|
{
|
||||||
|
initData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static void initData() {
|
||||||
|
Country usa = new Country();
|
||||||
|
usa.setName("USA");
|
||||||
|
usa.setCapital("Washington D.C.");
|
||||||
|
usa.setCurrency(Currency.USD);
|
||||||
|
usa.setPopulation(323947000);
|
||||||
|
|
||||||
|
countries.put(usa.getName(), usa);
|
||||||
|
|
||||||
|
Country india = new Country();
|
||||||
|
india.setName("India");
|
||||||
|
india.setCapital("New Delhi");
|
||||||
|
india.setCurrency(Currency.INR);
|
||||||
|
india.setPopulation(1295210000);
|
||||||
|
|
||||||
|
countries.put(india.getName(), india);
|
||||||
|
|
||||||
|
Country france = new Country();
|
||||||
|
france.setName("France");
|
||||||
|
france.setCapital("Paris");
|
||||||
|
france.setCurrency(Currency.EUR);
|
||||||
|
france.setPopulation(66710000);
|
||||||
|
|
||||||
|
countries.put(france.getName(), france);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Country findCountry(String name) {
|
||||||
|
return countries.get(name);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.baeldung.soap.ws.server;
|
||||||
|
|
||||||
|
import javax.jws.WebMethod;
|
||||||
|
import javax.jws.WebService;
|
||||||
|
import javax.jws.soap.SOAPBinding;
|
||||||
|
import javax.jws.soap.SOAPBinding.Style;
|
||||||
|
|
||||||
|
@WebService
|
||||||
|
@SOAPBinding(style=Style.RPC)
|
||||||
|
public interface CountryService {
|
||||||
|
|
||||||
|
@WebMethod
|
||||||
|
Country findByName(String name);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.baeldung.soap.ws.server;
|
||||||
|
|
||||||
|
import javax.jws.WebService;
|
||||||
|
|
||||||
|
@WebService(endpointInterface = "com.baeldung.soap.ws.server.CountryService")
|
||||||
|
public class CountryServiceImpl implements CountryService {
|
||||||
|
|
||||||
|
private CountryRepository countryRepository = new CountryRepository();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Country findByName(String name) {
|
||||||
|
return countryRepository.findCountry(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.baeldung.soap.ws.server;
|
||||||
|
|
||||||
|
import javax.xml.ws.Endpoint;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
public class CountryServicePublisher {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(CountryServicePublisher.class);
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Endpoint endpoint = Endpoint.create(new CountryServiceImpl());
|
||||||
|
endpoint.publish("http://localhost:8888/ws/country");
|
||||||
|
|
||||||
|
logger.info("Country web service ready to consume requests!");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.baeldung.soap.ws.server;
|
||||||
|
|
||||||
|
public enum Currency {
|
||||||
|
|
||||||
|
EUR, INR, USD;
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return name();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Currency fromValue(String v) {
|
||||||
|
return valueOf(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. --><!-- Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. -->
|
||||||
|
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy"
|
||||||
|
xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||||
|
xmlns:tns="http://server.ws.soap.baeldung.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"
|
||||||
|
targetNamespace="http://server.ws.soap.baeldung.com/" name="CountryServiceImplService">
|
||||||
|
<types>
|
||||||
|
<xsd:schema>
|
||||||
|
<xsd:import namespace="http://server.ws.soap.baeldung.com/" schemaLocation="http://localhost:8888/ws/country?xsd=1"></xsd:import>
|
||||||
|
</xsd:schema>
|
||||||
|
</types>
|
||||||
|
<message name="findByName">
|
||||||
|
<part name="arg0" type="xsd:string"></part>
|
||||||
|
</message>
|
||||||
|
<message name="findByNameResponse">
|
||||||
|
<part name="return" type="tns:country"></part>
|
||||||
|
</message>
|
||||||
|
<portType name="CountryService">
|
||||||
|
<operation name="findByName">
|
||||||
|
<input wsam:Action="http://server.ws.soap.baeldung.com/CountryService/findByNameRequest" message="tns:findByName"></input>
|
||||||
|
<output wsam:Action="http://server.ws.soap.baeldung.com/CountryService/findByNameResponse" message="tns:findByNameResponse"></output>
|
||||||
|
</operation>
|
||||||
|
</portType>
|
||||||
|
<binding name="CountryServiceImplPortBinding" type="tns:CountryService">
|
||||||
|
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"></soap:binding>
|
||||||
|
<operation name="findByName">
|
||||||
|
<soap:operation soapAction=""></soap:operation>
|
||||||
|
<input>
|
||||||
|
<soap:body use="literal" namespace="http://server.ws.soap.baeldung.com/"></soap:body>
|
||||||
|
</input>
|
||||||
|
<output>
|
||||||
|
<soap:body use="literal" namespace="http://server.ws.soap.baeldung.com/"></soap:body>
|
||||||
|
</output>
|
||||||
|
</operation>
|
||||||
|
</binding>
|
||||||
|
<service name="CountryServiceImplService">
|
||||||
|
<port name="CountryServiceImplPort" binding="tns:CountryServiceImplPortBinding">
|
||||||
|
<soap:address location="http://localhost:8888/ws/country"></soap:address>
|
||||||
|
</port>
|
||||||
|
</service>
|
||||||
|
</definitions>
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. -->
|
||||||
|
<xs:schema xmlns:tns="http://server.ws.soap.baeldung.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="1.0"
|
||||||
|
targetNamespace="http://server.ws.soap.baeldung.com/">
|
||||||
|
|
||||||
|
<xs:complexType name="country">
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="capital" type="xs:string" minOccurs="0"></xs:element>
|
||||||
|
<xs:element name="currency" type="tns:currency" minOccurs="0"></xs:element>
|
||||||
|
<xs:element name="name" type="xs:string" minOccurs="0"></xs:element>
|
||||||
|
<xs:element name="population" type="xs:int"></xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<xs:simpleType name="currency">
|
||||||
|
<xs:restriction base="xs:string">
|
||||||
|
<xs:enumeration value="EUR"></xs:enumeration>
|
||||||
|
<xs:enumeration value="INR"></xs:enumeration>
|
||||||
|
<xs:enumeration value="USD"></xs:enumeration>
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
</xs:schema>
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.baeldung.soap.ws.client;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.baeldung.soap.ws.client.generated.CountryService;
|
||||||
|
import com.baeldung.soap.ws.client.generated.CountryServiceImplService;
|
||||||
|
import com.baeldung.soap.ws.client.generated.Currency;
|
||||||
|
|
||||||
|
//Ensure that com.baeldung.soap.ws.server.CountryServicePublisher is running before executing this test
|
||||||
|
public class CountryClientLiveTest {
|
||||||
|
|
||||||
|
private static CountryService countryService;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setup() {
|
||||||
|
CountryServiceImplService service = new CountryServiceImplService();
|
||||||
|
countryService = service.getCountryServiceImplPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenCountryService_whenCountryIndia_thenCapitalIsNewDelhi() {
|
||||||
|
assertEquals("New Delhi", countryService.findByName("India").getCapital());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenCountryService_whenCountryFrance_thenPopulationCorrect() {
|
||||||
|
assertEquals(66710000, countryService.findByName("France").getPopulation());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenCountryService_whenCountryUSA_thenCurrencyUSD() {
|
||||||
|
assertEquals(Currency.USD, countryService.findByName("USA").getCurrency());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -9,10 +9,10 @@
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-boot-1</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-1</relativePath>
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-boot-1</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-1</relativePath>
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -31,6 +31,11 @@
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
<artifactId>jjwt</artifactId>
|
<artifactId>jjwt</artifactId>
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-boot-1</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-1</relativePath>
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
FROM ubuntu
|
||||||
|
ENTRYPOINT ["/bin/bash", "-c", "echo hello"]
|
|
@ -0,0 +1,19 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: kaniko
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: kaniko
|
||||||
|
image: gcr.io/kaniko-project/executor:latest
|
||||||
|
args: ["--dockerfile=/workspace/dockerfile",
|
||||||
|
"--context=dir://workspace",
|
||||||
|
"--no-push"]
|
||||||
|
volumeMounts:
|
||||||
|
- name: dockerfile-storage
|
||||||
|
mountPath: /workspace
|
||||||
|
restartPolicy: Never
|
||||||
|
volumes:
|
||||||
|
- name: dockerfile-storage
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: dockerfile-claim
|
|
@ -0,0 +1,11 @@
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: dockerfile-claim
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 8Gi
|
||||||
|
storageClassName: local-storage
|
|
@ -0,0 +1,14 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolume
|
||||||
|
metadata:
|
||||||
|
name: dockerfile
|
||||||
|
labels:
|
||||||
|
type: local
|
||||||
|
spec:
|
||||||
|
capacity:
|
||||||
|
storage: 10Gi
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
storageClassName: local-storage
|
||||||
|
hostPath:
|
||||||
|
path: /home/docker/kaniko # Path to the local mount directory that was setup
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue