Build optimization (#2253)

This commit is contained in:
Grzegorz Piwowarek 2017-07-12 19:28:47 +02:00 committed by GitHub
parent e5abeb4fd9
commit 84956990b6
19 changed files with 178 additions and 170 deletions

View File

@ -3,7 +3,6 @@ package com.baeldung.awaitility;
import org.awaitility.Awaitility;
import org.awaitility.Duration;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.concurrent.Callable;

View File

@ -1,6 +1,10 @@
package com.baeldung.cglib.proxy;
import com.baeldung.cglib.mixin.*;
import com.baeldung.cglib.mixin.Class1;
import com.baeldung.cglib.mixin.Class2;
import com.baeldung.cglib.mixin.Interface1;
import com.baeldung.cglib.mixin.Interface2;
import com.baeldung.cglib.mixin.MixinInterface;
import net.sf.cglib.proxy.Mixin;
import org.junit.Test;

View File

@ -2,16 +2,12 @@ package com.baeldung.commons.collections;
import org.apache.commons.collections4.BidiMap;
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
import org.apache.commons.collections4.bidimap.DualLinkedHashBidiMap;
import org.apache.commons.collections4.bidimap.DualTreeBidiMap;
import org.apache.commons.collections4.bidimap.TreeBidiMap;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* Created by smatt on 03/07/2017.
*/
public class BidiMapUnitTest {
@Test

View File

@ -3,14 +3,17 @@ package com.baeldung.commons.collections;
import com.baeldung.commons.collectionutil.Address;
import com.baeldung.commons.collectionutil.Customer;
import org.apache.commons.collections4.Closure;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.collections4.Transformer;
import org.junit.Before;
import org.junit.Test;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -70,7 +73,7 @@ public class CollectionUtilsGuideTest {
boolean isModified = CollectionUtils.filter(linkedList1, new Predicate<Customer>() {
public boolean evaluate(Customer customer) {
return Arrays.asList("Daniel","Kyle").contains(customer.getName());
return Arrays.asList("Daniel", "Kyle").contains(customer.getName());
}
});

View File

@ -16,16 +16,18 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.collection.IsMapContaining.hasEntry;
import static org.hamcrest.collection.IsMapWithSize.aMapWithSize;
import static org.hamcrest.collection.IsMapWithSize.anEmptyMap;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class MapUtilsTest {
private String[][] color2DArray = new String[][] {
private String[][] color2DArray = new String[][]{
{"RED", "#FF0000"},
{"GREEN", "#00FF00"},
{"BLUE", "#0000FF"}
};
private String[] color1DArray = new String[] {
private String[] color1DArray = new String[]{
"RED", "#FF0000",
"GREEN", "#00FF00",
"BLUE", "#0000FF"

View File

@ -11,9 +11,6 @@ import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* Created by smatt on 21/06/2017.
*/
public class SetUtilsUnitTest {
@Test(expected = IllegalArgumentException.class)
@ -27,33 +24,33 @@ public class SetUtilsUnitTest {
@Test
public void givenTwoSets_whenDifference_thenSetView() {
Set<Integer> a = new HashSet<>(Arrays.asList(1,2,5));
Set<Integer> b = new HashSet<>(Arrays.asList(1,2));
Set<Integer> a = new HashSet<>(Arrays.asList(1, 2, 5));
Set<Integer> b = new HashSet<>(Arrays.asList(1, 2));
SetUtils.SetView<Integer> result = SetUtils.difference(a, b);
assertTrue(result.size() == 1 && result.contains(5));
}
@Test
public void givenTwoSets_whenUnion_thenUnionResult() {
Set<Integer> a = new HashSet<>(Arrays.asList(1,2,5));
Set<Integer> b = new HashSet<>(Arrays.asList(1,2));
Set<Integer> expected = new HashSet<>(Arrays.asList(1,2,5));
Set<Integer> a = new HashSet<>(Arrays.asList(1, 2, 5));
Set<Integer> b = new HashSet<>(Arrays.asList(1, 2));
Set<Integer> expected = new HashSet<>(Arrays.asList(1, 2, 5));
SetUtils.SetView<Integer> union = SetUtils.union(a, b);
assertTrue(SetUtils.isEqualSet(expected, union));
}
@Test
public void givenTwoSets_whenIntersection_thenIntersectionResult() {
Set<Integer> a = new HashSet<>(Arrays.asList(1,2,5));
Set<Integer> b = new HashSet<>(Arrays.asList(1,2));
Set<Integer> expected = new HashSet<>(Arrays.asList(1,2));
Set<Integer> a = new HashSet<>(Arrays.asList(1, 2, 5));
Set<Integer> b = new HashSet<>(Arrays.asList(1, 2));
Set<Integer> expected = new HashSet<>(Arrays.asList(1, 2));
SetUtils.SetView<Integer> intersect = SetUtils.intersection(a, b);
assertTrue(SetUtils.isEqualSet(expected, intersect));
}
@Test
public void givenSet_whenTransformedSet_thenTransformedResult() {
Set<Integer> a = SetUtils.transformedSet(new HashSet<>(), (e) -> e * 2 );
Set<Integer> a = SetUtils.transformedSet(new HashSet<>(), (e) -> e * 2);
a.add(2);
assertEquals(a.toArray()[0], 4);
@ -65,19 +62,19 @@ public class SetUtilsUnitTest {
@Test
public void givenTwoSet_whenDisjunction_thenDisjunctionSet() {
Set<Integer> a = new HashSet<>(Arrays.asList(1,2,5));
Set<Integer> b = new HashSet<>(Arrays.asList(1,2,3));
Set<Integer> a = new HashSet<>(Arrays.asList(1, 2, 5));
Set<Integer> b = new HashSet<>(Arrays.asList(1, 2, 3));
SetUtils.SetView<Integer> result = SetUtils.disjunction(a, b);
assertTrue(result.toSet().contains(5) && result.toSet().contains(3));
}
@Test
public void givenSet_when_OrderedSet_thenMaintainElementOrder() {
Set<Integer> set = new HashSet<>(Arrays.asList(10,1,5));
Set<Integer> set = new HashSet<>(Arrays.asList(10, 1, 5));
System.out.println("unordered set: " + set);
Set<Integer> orderedSet = SetUtils.orderedSet(new HashSet<>());
orderedSet.addAll(Arrays.asList(10,1,5));
orderedSet.addAll(Arrays.asList(10, 1, 5));
System.out.println("ordered set = " + orderedSet);
}
}

View File

@ -1,10 +1,5 @@
package com.baeldung.commons.collections.orderedmap;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.collections4.OrderedMap;
import org.apache.commons.collections4.OrderedMapIterator;
import org.apache.commons.collections4.map.LinkedMap;
@ -12,6 +7,11 @@ import org.apache.commons.collections4.map.ListOrderedMap;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
public class OrderedMapUnitTest {
private String[] names = {"Emily", "Mathew", "Rose", "John", "Anna"};

View File

@ -1,5 +1,15 @@
package com.baeldung.commons.dbutils;
import org.apache.commons.dbutils.AsyncQueryRunner;
import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.MapListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
@ -9,16 +19,9 @@ import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.apache.commons.dbutils.AsyncQueryRunner;
import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.MapListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class DbUtilsUnitTest {

View File

@ -2,9 +2,10 @@ package com.baeldung.commons.lang3;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class StringUtilsUnitTest {
@Test

View File

@ -6,7 +6,7 @@ import java.util.List;
import static org.junit.Assert.assertEquals;
public class HikariCPUnitTest {
public class HikariCPIntegrationTest {
@Test
public void givenConnection_thenFetchDbData() {

View File

@ -8,7 +8,9 @@ import org.jasypt.util.text.BasicTextEncryptor;
import org.junit.Ignore;
import org.junit.Test;
import static junit.framework.Assert.*;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotSame;
import static junit.framework.Assert.assertTrue;
import static junit.framework.TestCase.assertEquals;
public class JasyptUnitTest {
@ -30,7 +32,7 @@ public class JasyptUnitTest {
}
@Test
public void givenTextPassword_whenOneWayEncryption_thenCompareEncryptedPasswordsShouldBeSame(){
public void givenTextPassword_whenOneWayEncryption_thenCompareEncryptedPasswordsShouldBeSame() {
String password = "secret-pass";
BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor();
String encryptedPassword = passwordEncryptor.encryptPassword(password);
@ -43,7 +45,7 @@ public class JasyptUnitTest {
}
@Test
public void givenTextPassword_whenOneWayEncryption_thenCompareEncryptedPasswordsShouldNotBeSame(){
public void givenTextPassword_whenOneWayEncryption_thenCompareEncryptedPasswordsShouldNotBeSame() {
String password = "secret-pass";
BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor();
String encryptedPassword = passwordEncryptor.encryptPassword(password);
@ -56,7 +58,6 @@ public class JasyptUnitTest {
}
@Test
@Ignore("should have installed local_policy.jar")
public void givenTextPrivateData_whenDecrypt_thenCompareToEncryptedWithCustomAlgorithm() {
@ -77,7 +78,7 @@ public class JasyptUnitTest {
@Test
@Ignore("should have installed local_policy.jar")
public void givenTextPrivateData_whenDecryptOnHighPerformance_thenDecrypt(){
public void givenTextPrivateData_whenDecryptOnHighPerformance_thenDecrypt() {
//given
String privateData = "secret-data";
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();

View File

@ -8,7 +8,6 @@ import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.Iterator;
import java.util.List;
import static org.junit.Assert.assertEquals;

View File

@ -8,7 +8,11 @@ import au.com.dius.pact.consumer.dsl.PactDslWithProvider;
import au.com.dius.pact.model.RequestResponsePact;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.http.*;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;

View File

@ -1,6 +1,8 @@
package com.baeldung.vaadin;
import static org.junit.Assert.assertEquals;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.vaadin.server.DefaultUIProvider;
import com.vaadin.server.VaadinServlet;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
@ -15,9 +17,7 @@ import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.vaadin.server.DefaultUIProvider;
import com.vaadin.server.VaadinServlet;
import static org.junit.Assert.assertEquals;
public class VaadinUITests {
@ -26,15 +26,15 @@ public class VaadinUITests {
private Server server;
@Before
public void setUp() throws Exception{
public void setUp() throws Exception {
startJettyServer();
driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_45,true);
driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_45, true);
driver.get("http://localhost:8080");
Thread.sleep(10000);
}
@Test
public void whenPageLoadedThenShouldSeeURL(){
public void whenPageLoadedThenShouldSeeURL() {
String url = driver.getCurrentUrl();
assertEquals("http://localhost:8080/", url);
}
@ -70,12 +70,12 @@ public class VaadinUITests {
}
@After
public void cleanUp() throws Exception{
public void cleanUp() throws Exception {
driver.close();
server.stop();
}
public void startJettyServer() throws Exception{
public void startJettyServer() throws Exception {
int maxThreads = 100;
int minThreads = 10;

View File

@ -5,8 +5,8 @@ import java.io.IOException;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonUtil {
public static byte[] toJson(Object object) throws IOException {
class JsonUtil {
static byte[] toJson(Object object) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper.writeValueAsBytes(object);

View File

@ -5,7 +5,6 @@
<artifactId>spring-mvc-java</artifactId>
<version>0.1-SNAPSHOT</version>
<name>spring-mvc-java</name>
<packaging>war</packaging>
<parent>
<groupId>com.baeldung</groupId>