Merge branch 'master' into BAEL-1423-jctools
This commit is contained in:
commit
0bb4359ac3
@ -26,14 +26,6 @@
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>animal-sniffer-maven-plugin</artifactId>
|
||||
|
@ -19,32 +19,11 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.auto.service</groupId>
|
||||
<artifactId>auto-service</artifactId>
|
||||
<version>${auto-service.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
@ -25,15 +25,6 @@
|
||||
<mainClass>com.baeldung.cxf.introduction.Server</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${surefire.version}</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -27,15 +27,6 @@
|
||||
<mainClass>com.baeldung.cxf.jaxrs.implementation.RestfulServer</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${surefire.version}</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -52,15 +52,6 @@
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${surefire.version}</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@ -102,24 +93,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${surefire.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>none</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
@ -32,17 +32,4 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -29,18 +29,4 @@
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
|
@ -1,56 +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/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<artifactId>bootique-parent</artifactId>
|
||||
<groupId>io.bootique.parent</groupId>
|
||||
<version>0.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.bootique</groupId>
|
||||
<artifactId>bootique</artifactId>
|
||||
<name>bootique</name>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<url>http://maven.apache.org</url>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.bootique</groupId>
|
||||
<artifactId>bootique-test</artifactId>
|
||||
<version>0.23</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.bootique.bom</groupId>
|
||||
<artifactId>bootique-bom</artifactId>
|
||||
<version>0.23</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<properties>
|
||||
<main.class>com.baeldung.bootique.App</main.class>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -45,14 +45,6 @@
|
||||
<defaultGoal>spring-boot:run</defaultGoal>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
@ -71,7 +63,6 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
<camel.version>2.19.1</camel.version>
|
||||
<spring-boot-starter.version>1.5.4.RELEASE</spring-boot-starter.version>
|
||||
</properties>
|
||||
|
@ -65,24 +65,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<forkCount>3</forkCount>
|
||||
<reuseForks>true</reuseForks>
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||
<exclude>**/*ManualTest.java</exclude>
|
||||
<exclude>**/JdbcTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -78,10 +78,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.19.1</version>
|
||||
|
@ -75,13 +75,6 @@
|
||||
<target>1.9</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
@ -232,17 +232,6 @@
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
@ -256,7 +245,6 @@
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
@ -238,31 +238,6 @@
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||
<exclude>**/*ManualTest.java</exclude>
|
||||
</excludes>
|
||||
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
|
BIN
core-java/externalizable.txt
Normal file
BIN
core-java/externalizable.txt
Normal file
Binary file not shown.
@ -247,17 +247,6 @@
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
@ -0,0 +1,92 @@
|
||||
package com.baeldung.keystore;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.UnrecoverableEntryException;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* Created by adi on 3/7/18.
|
||||
*/
|
||||
public class JavaKeyStore {
|
||||
|
||||
private KeyStore keyStore;
|
||||
|
||||
private String keyStoreName;
|
||||
private String keyStoreType;
|
||||
private String keyStorePassword;
|
||||
|
||||
JavaKeyStore(String keyStoreType, String keyStorePassword, String keyStoreName) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
|
||||
this.keyStoreName = keyStoreName;
|
||||
this.keyStoreType = keyStoreType;
|
||||
this.keyStorePassword = keyStorePassword;
|
||||
}
|
||||
|
||||
void createEmptyKeyStore() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
|
||||
if(keyStoreType ==null || keyStoreType.isEmpty()){
|
||||
keyStoreType = KeyStore.getDefaultType();
|
||||
}
|
||||
keyStore = KeyStore.getInstance(keyStoreType);
|
||||
//load
|
||||
char[] pwdArray = keyStorePassword.toCharArray();
|
||||
keyStore.load(null, pwdArray);
|
||||
|
||||
// Save the keyStore
|
||||
FileOutputStream fos = new FileOutputStream(keyStoreName);
|
||||
keyStore.store(fos, pwdArray);
|
||||
fos.close();
|
||||
}
|
||||
|
||||
void loadKeyStore() throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException {
|
||||
char[] pwdArray = keyStorePassword.toCharArray();
|
||||
keyStore.load(new FileInputStream(keyStoreName), pwdArray);
|
||||
}
|
||||
|
||||
void setEntry(String alias, KeyStore.SecretKeyEntry secretKeyEntry, KeyStore.ProtectionParameter protectionParameter) throws KeyStoreException {
|
||||
keyStore.setEntry(alias, secretKeyEntry, protectionParameter);
|
||||
}
|
||||
|
||||
KeyStore.Entry getEntry(String alias) throws UnrecoverableEntryException, NoSuchAlgorithmException, KeyStoreException {
|
||||
KeyStore.ProtectionParameter protParam = new KeyStore.PasswordProtection(keyStorePassword.toCharArray());
|
||||
return keyStore.getEntry(alias, protParam);
|
||||
}
|
||||
|
||||
void setKeyEntry(String alias, PrivateKey privateKey, String keyPassword, Certificate[] certificateChain) throws KeyStoreException {
|
||||
keyStore.setKeyEntry(alias, privateKey, keyPassword.toCharArray(), certificateChain);
|
||||
}
|
||||
|
||||
void setCertificateEntry(String alias, Certificate certificate) throws KeyStoreException {
|
||||
keyStore.setCertificateEntry(alias, certificate);
|
||||
}
|
||||
|
||||
Certificate getCertificate(String alias) throws KeyStoreException {
|
||||
return keyStore.getCertificate(alias);
|
||||
}
|
||||
|
||||
void deleteEntry(String alias) throws KeyStoreException {
|
||||
keyStore.deleteEntry(alias);
|
||||
}
|
||||
|
||||
void deleteKeyStore() throws KeyStoreException, IOException {
|
||||
Enumeration<String> aliases = keyStore.aliases();
|
||||
while (aliases.hasMoreElements()) {
|
||||
String alias = aliases.nextElement();
|
||||
keyStore.deleteEntry(alias);
|
||||
}
|
||||
keyStore = null;
|
||||
Files.delete(Paths.get(keyStoreName));
|
||||
}
|
||||
|
||||
KeyStore getKeyStore() {
|
||||
return this.keyStore;
|
||||
}
|
||||
}
|
@ -0,0 +1,205 @@
|
||||
package com.baeldung.keystore;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import sun.security.x509.AlgorithmId;
|
||||
import sun.security.x509.CertificateAlgorithmId;
|
||||
import sun.security.x509.CertificateSerialNumber;
|
||||
import sun.security.x509.CertificateValidity;
|
||||
import sun.security.x509.CertificateVersion;
|
||||
import sun.security.x509.CertificateX509Key;
|
||||
import sun.security.x509.X500Name;
|
||||
import sun.security.x509.X509CertImpl;
|
||||
import sun.security.x509.X509CertInfo;
|
||||
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.KeyPair;
|
||||
import java.security.KeyPairGenerator;
|
||||
import java.security.KeyStore;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.SignatureException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by adi on 4/14/18.
|
||||
*/
|
||||
public class JavaKeyStoreTest {
|
||||
|
||||
private JavaKeyStore keyStore;
|
||||
|
||||
private static final String KEYSTORE_PWD = "abc123";
|
||||
private static final String KEYSTORE_NAME = "myKeyStore";
|
||||
private static final String KEY_STORE_TYPE = "JCEKS";
|
||||
|
||||
private static final String MY_SECRET_ENTRY = "mySecretEntry";
|
||||
private static final String DN_NAME = "CN=test, OU=test, O=test, L=test, ST=test, C=CY";
|
||||
private static final String SHA1WITHRSA = "SHA1withRSA";
|
||||
private static final String MY_PRIVATE_KEY = "myPrivateKey";
|
||||
private static final String MY_CERTIFICATE = "myCertificate";
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
//using java cryptography extension keyStore instead of Keystore.getDefaultType
|
||||
keyStore = new JavaKeyStore(KEY_STORE_TYPE, KEYSTORE_PWD, KEYSTORE_NAME);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (keyStore.getKeyStore() != null) {
|
||||
keyStore.deleteKeyStore();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenNoKeyStore_whenCreateEmptyKeyStore_thenGetKeyStoreNotNull() throws Exception {
|
||||
keyStore.createEmptyKeyStore();
|
||||
KeyStore result = keyStore.getKeyStore();
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenEmptyKeystore_whenLoadKeyStore_thenKeyStoreLoadedAndSizeZero() throws Exception {
|
||||
keyStore.createEmptyKeyStore();
|
||||
keyStore.loadKeyStore();
|
||||
KeyStore result = keyStore.getKeyStore();
|
||||
Assert.assertNotNull(result);
|
||||
Assert.assertTrue(result.size() == 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenLoadedKeyStore_whenSetEntry_thenSizeIsOneAndGetKeyNotNull() throws Exception {
|
||||
keyStore.createEmptyKeyStore();
|
||||
keyStore.loadKeyStore();
|
||||
|
||||
KeyGenerator keygen = KeyGenerator.getInstance("HmacSHA256");
|
||||
SecretKey secretKey = keygen.generateKey();
|
||||
//ideally, password should be different for every key
|
||||
KeyStore.ProtectionParameter protParam = new KeyStore.PasswordProtection(KEYSTORE_PWD.toCharArray());
|
||||
KeyStore.SecretKeyEntry secretKeyEntry = new KeyStore.SecretKeyEntry(secretKey);
|
||||
keyStore.setEntry(MY_SECRET_ENTRY, secretKeyEntry, protParam);
|
||||
|
||||
KeyStore result = keyStore.getKeyStore();
|
||||
Assert.assertTrue(result.size() == 1);
|
||||
KeyStore.Entry entry = keyStore.getEntry(MY_SECRET_ENTRY);
|
||||
Assert.assertTrue(entry != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenLoadedKeyStore_whenSetKeyEntry_thenSizeIsOneAndGetEntryNotNull() throws Exception {
|
||||
keyStore.createEmptyKeyStore();
|
||||
keyStore.loadKeyStore();
|
||||
|
||||
// Generate the key pair
|
||||
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
|
||||
keyPairGenerator.initialize(1024);
|
||||
KeyPair keyPair = keyPairGenerator.generateKeyPair();
|
||||
|
||||
// Generate a self signed certificate
|
||||
X509Certificate certificate = generateSelfSignedCertificate(keyPair);
|
||||
|
||||
X509Certificate[] certificateChain = new X509Certificate[1];
|
||||
certificateChain[0] = certificate;
|
||||
keyStore.setKeyEntry(MY_PRIVATE_KEY, keyPair.getPrivate(), KEYSTORE_PWD, certificateChain);
|
||||
|
||||
KeyStore result = keyStore.getKeyStore();
|
||||
Assert.assertTrue(result.size() == 1);
|
||||
KeyStore.Entry entry = keyStore.getEntry(MY_PRIVATE_KEY);
|
||||
Assert.assertTrue(entry != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenLoadedKeyStore_whenSetCertificateEntry_thenSizeIsOneAndGetCertificateEntryNotNull() throws Exception {
|
||||
keyStore.createEmptyKeyStore();
|
||||
keyStore.loadKeyStore();
|
||||
|
||||
// Generate the key pair
|
||||
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
|
||||
keyPairGenerator.initialize(1024);
|
||||
KeyPair keyPair = keyPairGenerator.generateKeyPair();
|
||||
|
||||
// Generate a self signed certificate
|
||||
X509Certificate certificate = generateSelfSignedCertificate(keyPair);
|
||||
|
||||
keyStore.setCertificateEntry(MY_CERTIFICATE, certificate);
|
||||
|
||||
KeyStore result = this.keyStore.getKeyStore();
|
||||
Assert.assertTrue(result.size() == 1);
|
||||
java.security.cert.Certificate resultCertificate = keyStore.getCertificate(MY_CERTIFICATE);
|
||||
Assert.assertNotNull(resultCertificate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenLoadedKeyStoreWithOneEntry_whenDeleteEntry_thenKeyStoreSizeIsZero() throws Exception {
|
||||
keyStore.createEmptyKeyStore();
|
||||
keyStore.loadKeyStore();
|
||||
|
||||
KeyGenerator keygen = KeyGenerator.getInstance("HmacSHA256");
|
||||
SecretKey secretKey = keygen.generateKey();
|
||||
//ideally, password should be different for every key
|
||||
KeyStore.ProtectionParameter protParam = new KeyStore.PasswordProtection(KEYSTORE_PWD.toCharArray());
|
||||
KeyStore.SecretKeyEntry secretKeyEntry = new KeyStore.SecretKeyEntry(secretKey);
|
||||
keyStore.setEntry(MY_SECRET_ENTRY, secretKeyEntry, protParam);
|
||||
|
||||
keyStore.deleteEntry(MY_SECRET_ENTRY);
|
||||
|
||||
KeyStore result = this.keyStore.getKeyStore();
|
||||
Assert.assertTrue(result.size() == 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenLoadedKeystore_whenDeleteKeyStore_thenKeyStoreIsNull() throws Exception {
|
||||
keyStore.createEmptyKeyStore();
|
||||
keyStore.loadKeyStore();
|
||||
|
||||
keyStore.deleteKeyStore();
|
||||
|
||||
KeyStore result = this.keyStore.getKeyStore();
|
||||
Assert.assertTrue(result == null);
|
||||
}
|
||||
|
||||
private X509Certificate generateSelfSignedCertificate(KeyPair keyPair) throws CertificateException, IOException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
|
||||
X509CertInfo certInfo = new X509CertInfo();
|
||||
// Serial number and version
|
||||
certInfo.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber(new BigInteger(64, new SecureRandom())));
|
||||
certInfo.set(X509CertInfo.VERSION, new CertificateVersion(CertificateVersion.V3));
|
||||
|
||||
// Subject & Issuer
|
||||
X500Name owner = new X500Name(DN_NAME);
|
||||
certInfo.set(X509CertInfo.SUBJECT, owner);
|
||||
certInfo.set(X509CertInfo.ISSUER, owner);
|
||||
|
||||
// Key and algorithm
|
||||
certInfo.set(X509CertInfo.KEY, new CertificateX509Key(keyPair.getPublic()));
|
||||
AlgorithmId algorithm = new AlgorithmId(AlgorithmId.sha1WithRSAEncryption_oid);
|
||||
certInfo.set(X509CertInfo.ALGORITHM_ID, new CertificateAlgorithmId(algorithm));
|
||||
|
||||
// Validity
|
||||
Date validFrom = new Date();
|
||||
Date validTo = new Date(validFrom.getTime() + 50L * 365L * 24L * 60L * 60L * 1000L); //50 years
|
||||
CertificateValidity validity = new CertificateValidity(validFrom, validTo);
|
||||
certInfo.set(X509CertInfo.VALIDITY, validity);
|
||||
|
||||
// Create certificate and sign it
|
||||
X509CertImpl cert = new X509CertImpl(certInfo);
|
||||
cert.sign(keyPair.getPrivate(), SHA1WITHRSA);
|
||||
|
||||
// Since the SHA1withRSA provider may have a different algorithm ID to what we think it should be,
|
||||
// we need to reset the algorithm ID, and resign the certificate
|
||||
AlgorithmId actualAlgorithm = (AlgorithmId) cert.get(X509CertImpl.SIG_ALG);
|
||||
certInfo.set(CertificateAlgorithmId.NAME + "." + CertificateAlgorithmId.ALGORITHM, actualAlgorithm);
|
||||
X509CertImpl newCert = new X509CertImpl(certInfo);
|
||||
newCert.sign(keyPair.getPrivate(), SHA1WITHRSA);
|
||||
|
||||
return newCert;
|
||||
}
|
||||
}
|
BIN
core-java/yofile.txt
Normal file
BIN
core-java/yofile.txt
Normal file
Binary file not shown.
BIN
core-java/yofile2.txt
Normal file
BIN
core-java/yofile2.txt
Normal file
Binary file not shown.
1
core-kotlin/.gitignore
vendored
Normal file
1
core-kotlin/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/bin/
|
@ -23,3 +23,4 @@
|
||||
- [Kotlin Dependency Injection with Kodein](http://www.baeldung.com/kotlin-kodein-dependency-injection)
|
||||
- [Regular Expressions in Kotlin](http://www.baeldung.com/kotlin-regular-expressions)
|
||||
- [Objects in Kotlin](http://www.baeldung.com/kotlin-objects)
|
||||
- [Reading from a File in Kotlin](http://www.baeldung.com/kotlin-read-file)
|
||||
|
@ -21,6 +21,11 @@
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math3</artifactId>
|
||||
<version>${commons-math3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
@ -33,12 +38,6 @@
|
||||
<version>${junit.platform.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
@ -46,7 +45,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>${kotlin-stdlib.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -160,10 +159,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.19.1</version>
|
||||
@ -194,14 +189,16 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<kotlin-maven-plugin.version>1.1.2</kotlin-maven-plugin.version>
|
||||
<kotlin-test-junit.version>1.1.2</kotlin-test-junit.version>
|
||||
<kotlin-stdlib.version>1.1.2</kotlin-stdlib.version>
|
||||
<kotlin-reflect.version>1.1.2</kotlin-reflect.version>
|
||||
<kotlin-maven-plugin.version>1.2.31</kotlin-maven-plugin.version>
|
||||
<kotlin-test-junit.version>1.2.31</kotlin-test-junit.version>
|
||||
<kotlin-stdlib.version>1.2.31</kotlin-stdlib.version>
|
||||
<kotlin-reflect.version>1.2.31</kotlin-reflect.version>
|
||||
<kotlinx.version>0.15</kotlinx.version>
|
||||
<mockito-kotlin.version>1.5.0</mockito-kotlin.version>
|
||||
<kodein.version>4.1.0</kodein.version>
|
||||
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
|
||||
<junit.jupiter.version>5.0.0</junit.jupiter.version>
|
||||
<junit.platform.version>1.0.0</junit.platform.version>
|
||||
<junit.vintage.version>4.12.0</junit.vintage.version>
|
||||
|
@ -0,0 +1,39 @@
|
||||
package com.baeldung.filter
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertIterableEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class ChunkedTest {
|
||||
|
||||
@Test
|
||||
fun givenDNAFragmentString_whenChunking_thenProduceListOfChunks() {
|
||||
val dnaFragment = "ATTCGCGGCCGCCAA"
|
||||
|
||||
val fragments = dnaFragment.chunked(3)
|
||||
|
||||
assertIterableEquals(listOf("ATT", "CGC", "GGC", "CGC", "CAA"), fragments)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenDNAString_whenChunkingWithTransformer_thenProduceTransformedList() {
|
||||
val codonTable = mapOf("ATT" to "Isoleucine", "CAA" to "Glutamine", "CGC" to "Arginine", "GGC" to "Glycine")
|
||||
val dnaFragment = "ATTCGCGGCCGCCAA"
|
||||
|
||||
val proteins = dnaFragment.chunked(3) { codon ->
|
||||
codonTable[codon.toString()] ?: error("Unknown codon")
|
||||
}
|
||||
|
||||
assertIterableEquals(listOf("Isoleucine", "Arginine", "Glycine", "Arginine", "Glutamine"), proteins)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenListOfValues_whenChunking_thenProduceListOfArrays() {
|
||||
val whole = listOf(1, 4, 7, 4753, 2, 34, 62, 76, 5868, 0)
|
||||
val chunks = whole.chunked(6)
|
||||
|
||||
val expected = listOf(listOf(1, 4, 7, 4753, 2, 34), listOf(62, 76, 5868, 0))
|
||||
|
||||
assertIterableEquals(expected, chunks)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.baeldung.filter
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertIterableEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class DistinctTest {
|
||||
data class SmallClass(val key: String, val num: Int)
|
||||
|
||||
@Test
|
||||
fun whenApplyingDistinct_thenReturnListOfNoDuplicateValues() {
|
||||
val array = arrayOf(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 5, 6, 7, 8, 9)
|
||||
val result = array.distinct()
|
||||
val expected = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||
|
||||
assertIterableEquals(expected, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenArrayOfClassObjects_whenApplyingDistinctOnClassProperty_thenReturnListDistinctOnThatValue() {
|
||||
|
||||
val original = arrayOf(
|
||||
SmallClass("key1", 1),
|
||||
SmallClass("key2", 2),
|
||||
SmallClass("key3", 3),
|
||||
SmallClass("key4", 3),
|
||||
SmallClass("er", 9),
|
||||
SmallClass("er", 10),
|
||||
SmallClass("er", 11))
|
||||
|
||||
val actual = original.distinctBy { it.key }
|
||||
|
||||
val expected = listOf(
|
||||
SmallClass("key1", 1),
|
||||
SmallClass("key2", 2),
|
||||
SmallClass("key3", 3),
|
||||
SmallClass("key4", 3),
|
||||
SmallClass("er", 9))
|
||||
|
||||
|
||||
assertIterableEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenArrayOfClassObjects_whenApplyingComplicatedSelector_thenReturnFirstElementToMatchEachSelectorValue() {
|
||||
val array = arrayOf(
|
||||
SmallClass("key1", 1),
|
||||
SmallClass("key2", 2),
|
||||
SmallClass("key3", 3),
|
||||
SmallClass("key4", 3),
|
||||
SmallClass("er", 9),
|
||||
SmallClass("er", 10),
|
||||
SmallClass("er", 11),
|
||||
SmallClass("er", 11),
|
||||
SmallClass("er", 91),
|
||||
SmallClass("blob", 22),
|
||||
SmallClass("dob", 27),
|
||||
SmallClass("high", 201_434_314))
|
||||
|
||||
val actual = array.distinctBy { Math.floor(it.num / 10.0) }
|
||||
|
||||
val expected = listOf(
|
||||
SmallClass("key1", 1),
|
||||
SmallClass("er", 10),
|
||||
SmallClass("er", 91),
|
||||
SmallClass("blob", 22),
|
||||
SmallClass("high", 201_434_314))
|
||||
|
||||
assertIterableEquals(expected, actual)
|
||||
}
|
||||
|
||||
}
|
53
core-kotlin/src/test/kotlin/com/baeldung/filter/DropTest.kt
Normal file
53
core-kotlin/src/test/kotlin/com/baeldung/filter/DropTest.kt
Normal file
@ -0,0 +1,53 @@
|
||||
package com.baeldung.filter
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertIterableEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class DropTest {
|
||||
|
||||
@Test
|
||||
fun whenDroppingFirstTwoItemsOfArray_thenTwoLess() {
|
||||
val array = arrayOf(1, 2, 3, 4)
|
||||
val result = array.drop(2)
|
||||
val expected = listOf(3, 4)
|
||||
|
||||
assertIterableEquals(expected, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenDroppingMoreItemsOfArray_thenEmptyList() {
|
||||
val array = arrayOf(1, 2, 3, 4)
|
||||
val result = array.drop(5)
|
||||
val expected = listOf<Int>()
|
||||
|
||||
assertIterableEquals(expected, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenArray_whenDroppingLastElement_thenReturnListWithoutLastElement() {
|
||||
val array = arrayOf("1", "2", "3", "4")
|
||||
val result = array.dropLast(1)
|
||||
val expected = listOf("1", "2", "3")
|
||||
|
||||
assertIterableEquals(expected, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenArrayOfFloats_whenDroppingLastUntilPredicateIsFalse_thenReturnSubsetListOfFloats() {
|
||||
val array = arrayOf(1f, 1f, 1f, 1f, 1f, 2f, 1f, 1f, 1f)
|
||||
val result = array.dropLastWhile { it == 1f }
|
||||
val expected = listOf(1f, 1f, 1f, 1f, 1f, 2f)
|
||||
|
||||
assertIterableEquals(expected, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenList_whenDroppingMoreThanAvailable_thenThrowException() {
|
||||
val list = listOf('a', 'e', 'i', 'o', 'u')
|
||||
val result = list.drop(6)
|
||||
val expected: List<String> = listOf()
|
||||
|
||||
assertIterableEquals(expected, result)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.baeldung.filter
|
||||
|
||||
import org.apache.commons.math3.primes.Primes
|
||||
import org.junit.jupiter.api.Assertions.assertIterableEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
internal class FilterTest {
|
||||
|
||||
@Test
|
||||
fun givenAscendingValueMap_whenFilteringOnValue_ThenReturnSubsetOfMap() {
|
||||
val originalMap = mapOf("key1" to 1, "key2" to 2, "key3" to 3)
|
||||
val filteredMap = originalMap.filter { it.value < 2 }
|
||||
val expectedMap = mapOf("key1" to 1)
|
||||
|
||||
assertTrue { expectedMap == filteredMap }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenSeveralCollections_whenFilteringToAccumulativeList_thenListContainsAllContents() {
|
||||
val array1 = arrayOf(90, 92, 93, 94, 92, 95, 93)
|
||||
val array2 = sequenceOf(51, 31, 83, 674_506_111, 256_203_161, 15_485_863)
|
||||
val list1 = listOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||
val primes = mutableListOf<Int>()
|
||||
|
||||
val expected = listOf(2, 3, 5, 7, 31, 83, 15_485_863, 256_203_161, 674_506_111)
|
||||
|
||||
val primeCheck = { num: Int -> Primes.isPrime(num) }
|
||||
|
||||
array1.filterTo(primes, primeCheck)
|
||||
list1.filterTo(primes, primeCheck)
|
||||
array2.filterTo(primes, primeCheck)
|
||||
|
||||
primes.sort()
|
||||
|
||||
assertIterableEquals(expected, primes)
|
||||
}
|
||||
|
||||
}
|
44
core-kotlin/src/test/kotlin/com/baeldung/filter/SliceTest.kt
Normal file
44
core-kotlin/src/test/kotlin/com/baeldung/filter/SliceTest.kt
Normal file
@ -0,0 +1,44 @@
|
||||
package com.baeldung.filter
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertIterableEquals
|
||||
import org.junit.jupiter.api.Assertions.assertThrows
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class SliceTest {
|
||||
|
||||
@Test
|
||||
fun whenSlicingAnArrayWithDotRange_ThenListEqualsTheSlice() {
|
||||
val original = arrayOf(1, 2, 3, 2, 1)
|
||||
val actual = original.slice(1..3)
|
||||
val expected = listOf(2, 3, 2)
|
||||
|
||||
assertIterableEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenSlicingAnArrayWithDownToRange_thenListMadeUpOfReverseSlice() {
|
||||
val original = arrayOf(1, 2, 3, 2, 1)
|
||||
val actual = original.slice(3 downTo 0)
|
||||
val expected = listOf(2, 3, 2, 1)
|
||||
|
||||
assertIterableEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenSlicingBeyondTheRangeOfTheArray_thenContainManyNulls() {
|
||||
val original = arrayOf(12, 3, 34, 4)
|
||||
val actual = original.slice(3..8)
|
||||
val expected = listOf(4, null, null, null, null, null)
|
||||
|
||||
assertIterableEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenSlicingBeyondRangeOfArrayWithStep_thenOutOfBoundsException() {
|
||||
assertThrows(ArrayIndexOutOfBoundsException::class.java) {
|
||||
val original = arrayOf(12, 3, 34, 4)
|
||||
original.slice(3..8 step 2)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
38
core-kotlin/src/test/kotlin/com/baeldung/filter/TakeTest.kt
Normal file
38
core-kotlin/src/test/kotlin/com/baeldung/filter/TakeTest.kt
Normal file
@ -0,0 +1,38 @@
|
||||
package com.baeldung.filter
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertIterableEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class TakeTest {
|
||||
|
||||
@Test
|
||||
fun `given array of alternating types, when predicating on 'is String', then produce list of array up until predicate is false`() {
|
||||
val originalArray = arrayOf("val1", 2, "val3", 4, "val5", 6)
|
||||
val actualList = originalArray.takeWhile { it is String }
|
||||
val expectedList = listOf("val1")
|
||||
|
||||
assertIterableEquals(expectedList, actualList)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given array of alternating types, when taking 4 items, then produce list of first 4 items`() {
|
||||
val originalArray = arrayOf("val1", 2, "val3", 4, "val5", 6)
|
||||
val actualList = originalArray.take(4)
|
||||
val expectedList = listOf("val1", 2, "val3", 4)
|
||||
|
||||
println(originalArray.drop(4))
|
||||
println(actualList)
|
||||
|
||||
assertIterableEquals(expectedList, actualList)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when taking more items than available, then return all elements`() {
|
||||
val originalArray = arrayOf(1, 2)
|
||||
val actual = originalArray.take(10)
|
||||
val expected = listOf(1, 2)
|
||||
|
||||
assertIterableEquals(expected, actual)
|
||||
}
|
||||
|
||||
}
|
@ -60,28 +60,5 @@
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>4.3.6.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<forkCount>3</forkCount>
|
||||
<reuseForks>true</reuseForks>
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||
<exclude>**/*ManualTest.java</exclude>
|
||||
<exclude>**/JdbcTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
@ -47,27 +47,4 @@
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${surefire.version}</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
@ -80,14 +80,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
@ -95,10 +87,6 @@
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -57,20 +57,6 @@
|
||||
<url>http://repo.opengeo.org</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<inherited>true</inherited>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<geotools.version>15.2</geotools.version>
|
||||
<geotools-swing.version>15.2</geotools-swing.version>
|
||||
|
@ -40,19 +40,6 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<log4j2.version>2.8.2</log4j2.version>
|
||||
<org.hamcrest.version>1.3</org.hamcrest.version>
|
||||
|
@ -29,17 +29,6 @@
|
||||
|
||||
<build>
|
||||
<finalName>deep-jsf</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -44,14 +44,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.19.1</version>
|
||||
|
@ -41,16 +41,6 @@
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
|
@ -28,19 +28,5 @@
|
||||
<artifactId>janino</artifactId>
|
||||
<version>3.0.7</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -30,15 +30,5 @@
|
||||
<directory>src/test/resources/</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -17,17 +17,4 @@
|
||||
<version>1.2.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -55,14 +55,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
|
@ -12,14 +12,6 @@
|
||||
</parent>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
|
@ -36,14 +36,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
|
@ -67,33 +67,5 @@
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<forkCount>3</forkCount>
|
||||
<reuseForks>true</reuseForks>
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
@ -36,22 +36,7 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
<joda-time.version>2.9.9</joda-time.version>
|
||||
<hirondelle-date4j.version>1.5.1</hirondelle-date4j.version>
|
||||
|
@ -6,7 +6,11 @@
|
||||
<packaging>war</packaging>
|
||||
<name>JavaEEAnnotationsSample</name>
|
||||
<description>JavaEEAnnotationsSample</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
@ -31,15 +35,6 @@
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
|
@ -19,7 +19,6 @@
|
||||
<hibernate.version>5.2.5.Final</hibernate.version>
|
||||
<mysql.version>6.0.5</mysql.version>
|
||||
<commons-io.version>2.5</commons-io.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
|
@ -99,7 +99,6 @@
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<junit.platform.version>1.0.0</junit.platform.version>
|
||||
<junit.jupiter.version>5.0.0</junit.jupiter.version>
|
||||
<maven-surefire-plugin.version>2.20</maven-surefire-plugin.version>
|
||||
<jsonb-api.version>1.0</jsonb-api.version>
|
||||
<johnzon.version>1.1.3</johnzon.version>
|
||||
<geronimo-json_1.1_spec.version>1.0</geronimo-json_1.1_spec.version>
|
||||
|
@ -89,15 +89,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Reladomo -->
|
||||
<plugin>
|
||||
|
@ -791,7 +791,6 @@
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- /Neuroph -->
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
@ -838,7 +837,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -35,14 +35,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
|
@ -71,24 +71,7 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<forkCount>3</forkCount>
|
||||
<reuseForks>true</reuseForks>
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||
<exclude>**/*ManualTest.java</exclude>
|
||||
<exclude>**/JdbcTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
|
@ -31,15 +31,6 @@
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
|
@ -20,15 +20,6 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
2
patterns/facade/README.md
Normal file
2
patterns/facade/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
### Relevant Articles:
|
||||
- [Facade Design Pattern in Java](http://www.baeldung.com/java-facade-pattern)
|
@ -20,15 +20,6 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
@ -22,15 +22,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
|
@ -23,16 +23,6 @@
|
||||
<build>
|
||||
<finalName>baeldung-liquibase-demo</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.liquibase</groupId>
|
||||
<artifactId>liquibase-maven-plugin</artifactId>
|
||||
|
@ -149,32 +149,6 @@
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
|
1
pom.xml
1
pom.xml
@ -64,6 +64,7 @@
|
||||
<module>core-java</module>
|
||||
<module>core-java-io</module>
|
||||
<module>core-java-8</module>
|
||||
<!--<module>core-kotlin</module>-->
|
||||
<module>core-groovy</module>
|
||||
<module>core-java-concurrency</module>
|
||||
|
||||
|
@ -14,6 +14,12 @@
|
||||
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>resteasy-tutorial</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
<finalName>RestEasyTutorial</finalName>
|
||||
<plugins>
|
||||
@ -73,66 +79,5 @@
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>live</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>**/*IntegrationTest.java</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>**/*LiveTest.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<test.mime>json</test.mime>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.cargo</groupId>
|
||||
<artifactId>cargo-maven2-plugin</artifactId>
|
||||
<version>${cargo-maven2-plugin.version}</version>
|
||||
<configuration>
|
||||
<wait>false</wait>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>start-server</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>start</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>stop-server</id>
|
||||
<phase>post-integration-test</phase>
|
||||
<goals>
|
||||
<goal>stop</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
@ -39,8 +39,8 @@ public class Car {
|
||||
// ...
|
||||
}
|
||||
|
||||
public void сhangeOilWithIsNull(String oil) {
|
||||
Assert.isNull(oil, "oil must be null");
|
||||
public void replaceBattery(CarBattery carBattery) {
|
||||
Assert.isNull(carBattery.getCharge(), "to replace battery the charge must be null");
|
||||
// ...
|
||||
}
|
||||
|
||||
@ -99,7 +99,9 @@ public class Car {
|
||||
car.fuel();
|
||||
|
||||
car.сhangeOil("oil");
|
||||
car.сhangeOilWithIsNull(null);
|
||||
|
||||
CarBattery carBattery = new CarBattery();
|
||||
car.replaceBattery(carBattery);
|
||||
|
||||
car.сhangeEngine(new ToyotaEngine());
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.baeldung.assertions;
|
||||
|
||||
public class CarBattery {
|
||||
private String charge;
|
||||
|
||||
public String getCharge() {
|
||||
return charge;
|
||||
}
|
||||
|
||||
public void setCharge(String charge) {
|
||||
this.charge = charge;
|
||||
}
|
||||
}
|
@ -86,15 +86,6 @@
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>integration</id>
|
||||
|
@ -71,11 +71,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
|
@ -69,24 +69,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
|
@ -61,13 +61,8 @@
|
||||
<properties>
|
||||
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
@ -85,16 +80,6 @@
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -34,25 +34,4 @@
|
||||
<version>1.3.0.RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -54,15 +54,4 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
|
@ -29,25 +29,4 @@
|
||||
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
|
||||
<spring-boot-maven-plugin.version>1.4.2.RELEASE</spring-boot-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -43,24 +43,6 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
|
||||
<spring-cloud-starter-eureka.version>1.2.3.RELEASE</spring-cloud-starter-eureka.version>
|
||||
|
@ -53,24 +53,6 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
|
||||
<spring-cloud-starter-eureka.version>1.2.3.RELEASE</spring-cloud-starter-eureka.version>
|
||||
|
@ -38,24 +38,6 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
|
||||
<spring-cloud-starter-eureka.version>1.2.3.RELEASE</spring-cloud-starter-eureka.version>
|
||||
|
@ -75,25 +75,4 @@
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -67,24 +67,6 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-starter-feign.version>1.2.3.RELEASE</spring-cloud-starter-feign.version>
|
||||
<spring-cloud-starter-hystrix.version>1.2.3.RELEASE</spring-cloud-starter-hystrix.version>
|
||||
|
@ -28,25 +28,4 @@
|
||||
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
|
||||
<spring-boot-maven-plugin.version>1.4.2.RELEASE</spring-boot-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -57,24 +57,6 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
|
||||
<spring-cloud-starter-hystrix.version>1.2.3.RELEASE</spring-cloud-starter-hystrix.version>
|
||||
|
@ -25,24 +25,6 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
|
||||
</properties>
|
||||
|
@ -47,25 +47,4 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -42,24 +42,6 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
|
||||
<spring-cloud-starter-eureka.version>1.2.3.RELEASE</spring-cloud-starter-eureka.version>
|
||||
|
@ -42,25 +42,6 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
|
||||
<spring-cloud-starter-eureka.version>1.2.3.RELEASE</spring-cloud-starter-eureka.version>
|
||||
|
@ -27,26 +27,6 @@
|
||||
<commons-config.version>1.10</commons-config.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<modules>
|
||||
<module>zuul-server</module>
|
||||
<module>eureka-server</module>
|
||||
|
@ -41,21 +41,4 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -42,24 +42,6 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
|
||||
<spring-cloud-starter-eureka.version>1.2.3.RELEASE</spring-cloud-starter-eureka.version>
|
||||
|
@ -43,24 +43,6 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
|
||||
<spring-cloud-starter-eureka.version>1.2.3.RELEASE</spring-cloud-starter-eureka.version>
|
||||
|
@ -28,26 +28,6 @@
|
||||
<rxjava.version>1.2.10</rxjava.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<modules>
|
||||
<module>zuul-server</module>
|
||||
<module>eureka-server</module>
|
||||
|
@ -46,21 +46,4 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -7,11 +7,13 @@
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Spring MVC simple Maven Webapp</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
@ -164,11 +166,6 @@
|
||||
<outputDirectory>${deploy-path}</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven.compiler.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
|
@ -154,14 +154,6 @@
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.tomcat.maven</groupId>
|
||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||
|
@ -120,15 +120,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
|
@ -41,14 +41,6 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.baeldung.easymock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IUserService {
|
||||
public boolean addUser(User user);
|
||||
public List<User> findByFirstName(String firstName);
|
||||
public List<User> findByLastName(String lastName);
|
||||
public List<User> findByAge(double age);
|
||||
public List<User> findByEmail(String email);
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package com.baeldung.easymock;
|
||||
|
||||
public class User {
|
||||
private long id;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private double age;
|
||||
private String email;
|
||||
|
||||
public User() {
|
||||
super();
|
||||
}
|
||||
|
||||
public User(String firstName, String lastName) {
|
||||
super();
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
public double getAge() {
|
||||
return age;
|
||||
}
|
||||
public void setAge(double age) {
|
||||
this.age = age;
|
||||
}
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(age);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
result = prime * result + ((email == null) ? 0 : email.hashCode());
|
||||
result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
|
||||
result = prime * result + (int) (id ^ (id >>> 32));
|
||||
result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
User other = (User) obj;
|
||||
if (Double.doubleToLongBits(age) != Double.doubleToLongBits(other.age)) {
|
||||
return false;
|
||||
}
|
||||
if (email == null) {
|
||||
if (other.email != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!email.equals(other.email)) {
|
||||
return false;
|
||||
}
|
||||
if (firstName == null) {
|
||||
if (other.firstName != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!firstName.equals(other.firstName)) {
|
||||
return false;
|
||||
}
|
||||
if (id != other.id) {
|
||||
return false;
|
||||
}
|
||||
if (lastName == null) {
|
||||
if (other.lastName != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!lastName.equals(other.lastName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,220 @@
|
||||
package com.baeldung.easymock;
|
||||
|
||||
import static org.easymock.EasyMock.and;
|
||||
import static org.easymock.EasyMock.anyString;
|
||||
import static org.easymock.EasyMock.contains;
|
||||
import static org.easymock.EasyMock.endsWith;
|
||||
import static org.easymock.EasyMock.eq;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.geq;
|
||||
import static org.easymock.EasyMock.gt;
|
||||
import static org.easymock.EasyMock.isA;
|
||||
import static org.easymock.EasyMock.isNull;
|
||||
import static org.easymock.EasyMock.lt;
|
||||
import static org.easymock.EasyMock.matches;
|
||||
import static org.easymock.EasyMock.mock;
|
||||
import static org.easymock.EasyMock.not;
|
||||
import static org.easymock.EasyMock.notNull;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.same;
|
||||
import static org.easymock.EasyMock.startsWith;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.easymock.IArgumentMatcher;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ArgumentMatchersUnitTest {
|
||||
|
||||
private IUserService userService = mock(IUserService.class);
|
||||
|
||||
//====================== equals
|
||||
@Test
|
||||
public void givenUserService_whenAddNewUser_thenOK() {
|
||||
expect(userService.addUser(eq(new User()))).andReturn(true);
|
||||
replay(userService);
|
||||
|
||||
boolean result = userService.addUser(new User());
|
||||
verify(userService);
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
//================ same
|
||||
@Test
|
||||
public void givenUserService_whenAddSpecificUser_thenOK() {
|
||||
User user = new User();
|
||||
|
||||
expect(userService.addUser(same(user))).andReturn(true);
|
||||
replay(userService);
|
||||
|
||||
boolean result = userService.addUser(user);
|
||||
verify(userService);
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
//============= anyX
|
||||
@Test
|
||||
public void givenUserService_whenSearchForUserByFirstName_thenFound() {
|
||||
expect(userService.findByFirstName(anyString())).andReturn(Collections.emptyList());
|
||||
replay(userService);
|
||||
|
||||
List<User> result = userService.findByFirstName("joe");
|
||||
verify(userService);
|
||||
assertEquals(0,result.size());
|
||||
}
|
||||
|
||||
//================= isA
|
||||
@Test
|
||||
public void givenUserService_whenAddUser_thenOK() {
|
||||
expect(userService.addUser(isA(User.class))).andReturn(true);
|
||||
replay(userService);
|
||||
|
||||
boolean result = userService.addUser(new User());
|
||||
verify(userService);
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
//=================== null, not null
|
||||
@Test
|
||||
public void givenUserService_whenAddNull_thenFail() {
|
||||
expect(userService.addUser(isNull())).andReturn(false);
|
||||
replay(userService);
|
||||
|
||||
boolean result = userService.addUser(null);
|
||||
verify(userService);
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenUserService_whenAddNotNull_thenOK() {
|
||||
expect(userService.addUser(notNull())).andReturn(true);
|
||||
replay(userService);
|
||||
|
||||
boolean result = userService.addUser(new User());
|
||||
verify(userService);
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
// number less,great
|
||||
@Test
|
||||
public void givenUserService_whenSearchForUserByAgeLessThan_thenFound() {
|
||||
expect(userService.findByAge(lt(100.0))).andReturn(Collections.emptyList());
|
||||
replay(userService);
|
||||
|
||||
List<User> result = userService.findByAge(20);
|
||||
verify(userService);
|
||||
assertEquals(0,result.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenUserService_whenSearchForUserByAgeGreaterThan_thenFound() {
|
||||
expect(userService.findByAge(geq(10.0))).andReturn(Collections.emptyList());
|
||||
replay(userService);
|
||||
|
||||
List<User> result = userService.findByAge(20);
|
||||
verify(userService);
|
||||
assertEquals(0,result.size());
|
||||
}
|
||||
|
||||
//=============== string
|
||||
//=============== start
|
||||
@Test
|
||||
public void givenUserService_whenSearchForUserByEmailStartsWith_thenFound() {
|
||||
expect(userService.findByEmail(startsWith("test"))).andReturn(Collections.emptyList());
|
||||
replay(userService);
|
||||
|
||||
List<User> result = userService.findByEmail("test@example.com");
|
||||
verify(userService);
|
||||
assertEquals(0,result.size());
|
||||
}
|
||||
|
||||
//==================end
|
||||
@Test
|
||||
public void givenUserService_whenSearchForUserByEmailEndsWith_thenFound() {
|
||||
expect(userService.findByEmail(endsWith(".com"))).andReturn(Collections.emptyList());
|
||||
replay(userService);
|
||||
|
||||
List<User> result = userService.findByEmail("test@example.com");
|
||||
verify(userService);
|
||||
assertEquals(0,result.size());
|
||||
}
|
||||
|
||||
//=================contain
|
||||
@Test
|
||||
public void givenUserService_whenSearchForUserByEmailContains_thenFound() {
|
||||
expect(userService.findByEmail(contains("@"))).andReturn(Collections.emptyList());
|
||||
replay(userService);
|
||||
|
||||
List<User> result = userService.findByEmail("test@example.com");
|
||||
verify(userService);
|
||||
assertEquals(0,result.size());
|
||||
}
|
||||
|
||||
//==================matches
|
||||
@Test
|
||||
public void givenUserService_whenSearchForUserByEmailMatches_thenFound() {
|
||||
expect(userService.findByEmail(matches(".+\\@.+\\..+"))).andReturn(Collections.emptyList());
|
||||
replay(userService);
|
||||
|
||||
List<User> result = userService.findByEmail("test@example.com");
|
||||
verify(userService);
|
||||
assertEquals(0,result.size());
|
||||
}
|
||||
|
||||
//================== combine and, or, not
|
||||
@Test
|
||||
public void givenUserService_whenSearchForUserByAgeRange_thenFound() {
|
||||
expect(userService.findByAge(and(gt(10.0),lt(100.0)))).andReturn(Collections.emptyList());
|
||||
replay(userService);
|
||||
|
||||
List<User> result = userService.findByAge(20);
|
||||
verify(userService);
|
||||
assertEquals(0,result.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenUserService_whenSearchForUserByEmailNotEndsWith_thenFound() {
|
||||
expect(userService.findByEmail(not(endsWith(".com")))).andReturn(Collections.emptyList());
|
||||
replay(userService);
|
||||
|
||||
List<User> result = userService.findByEmail("test@example.org");
|
||||
verify(userService);
|
||||
assertEquals(0,result.size());
|
||||
}
|
||||
|
||||
//================ custom matcher
|
||||
|
||||
@Test
|
||||
public void givenUserService_whenSearchForUserByLastName_thenFound() {
|
||||
expect(userService.findByLastName(charCount(3))).andReturn(Collections.emptyList());
|
||||
replay(userService);
|
||||
|
||||
List<User> result = userService.findByLastName("doe");
|
||||
verify(userService);
|
||||
assertEquals(0,result.size());
|
||||
}
|
||||
|
||||
public static String charCount(int value){
|
||||
EasyMock.reportMatcher(new IArgumentMatcher() {
|
||||
@Override
|
||||
public boolean matches(Object argument) {
|
||||
return argument instanceof String
|
||||
&& ((String) argument).length() == value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendTo(StringBuffer buffer) {
|
||||
buffer.append("charCount(\"" + value + "\")");
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,12 @@
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>mockserver</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
<mock-sever-netty-version>3.10.8</mock-sever-netty-version>
|
||||
<apche-http-version>4.4.1</apche-http-version>
|
||||
@ -35,20 +41,5 @@
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>${apche-http-version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.20</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/**LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
</project>
|
21
vavr/pom.xml
21
vavr/pom.xml
@ -66,27 +66,6 @@
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<forkCount>3</forkCount>
|
||||
<reuseForks>true</reuseForks>
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||
<exclude>**/*ManualTest.java</exclude>
|
||||
<exclude>**/JdbcTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<vavr.version>0.9.1</vavr.version>
|
||||
|
@ -116,15 +116,6 @@
|
||||
<finalName>vraptor</finalName>
|
||||
<outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.tomcat.maven</groupId>
|
||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||
|
10
xml/pom.xml
10
xml/pom.xml
@ -156,16 +156,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>${java-version}</source>
|
||||
<target>${java-version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
Loading…
x
Reference in New Issue
Block a user