Build opt 9 08 2017 (#2397)
* pCollections * Reformat * Refactor metrics * Refactor hoverfly
This commit is contained in:
parent
69f3e1175a
commit
b5478f7e9a
@ -31,7 +31,7 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
import io.specto.hoverfly.junit.core.SimulationSource;
|
import io.specto.hoverfly.junit.core.SimulationSource;
|
||||||
import io.specto.hoverfly.junit.rule.HoverflyRule;
|
import io.specto.hoverfly.junit.rule.HoverflyRule;
|
||||||
|
|
||||||
public class HoverflyApiTest {
|
public class HoverflyApiIntegrationTest {
|
||||||
|
|
||||||
private static final SimulationSource source = dsl(
|
private static final SimulationSource source = dsl(
|
||||||
service("http://www.baeldung.com")
|
service("http://www.baeldung.com")
|
@ -1,7 +1,12 @@
|
|||||||
package com.baeldung.pcollections;
|
package com.baeldung.pcollections;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.pcollections.*;
|
import org.pcollections.HashPMap;
|
||||||
|
import org.pcollections.HashTreePMap;
|
||||||
|
import org.pcollections.HashTreePSet;
|
||||||
|
import org.pcollections.MapPSet;
|
||||||
|
import org.pcollections.PVector;
|
||||||
|
import org.pcollections.TreePVector;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -27,7 +32,7 @@ public class PCollectionsUnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenExistingHashMap_whenFrom_thenCreateHashPMap() {
|
public void givenExistingHashMap_whenFrom_thenCreateHashPMap() {
|
||||||
Map map = new HashMap();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("mkey1", "mval1");
|
map.put("mkey1", "mval1");
|
||||||
map.put("mkey2", "mval2");
|
map.put("mkey2", "mval2");
|
||||||
|
|
||||||
@ -41,7 +46,7 @@ public class PCollectionsUnitTest {
|
|||||||
HashPMap<String, String> pmap = HashTreePMap.empty();
|
HashPMap<String, String> pmap = HashTreePMap.empty();
|
||||||
HashPMap<String, String> pmap0 = pmap.plus("key1", "value1");
|
HashPMap<String, String> pmap0 = pmap.plus("key1", "value1");
|
||||||
|
|
||||||
Map map = new HashMap();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("key2", "val2");
|
map.put("key2", "val2");
|
||||||
map.put("key3", "val3");
|
map.put("key3", "val3");
|
||||||
|
|
||||||
@ -57,22 +62,24 @@ public class PCollectionsUnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenTreePVectorMethods_thenPerformOperations() {
|
public void whenTreePVectorMethods_thenPerformOperations() {
|
||||||
TreePVector pVector = TreePVector.empty();
|
TreePVector<String> pVector = TreePVector.empty();
|
||||||
|
|
||||||
|
TreePVector<String> pV1 = pVector.plus("e1");
|
||||||
|
TreePVector<String> pV2 = pV1.plusAll(Arrays.asList("e2", "e3", "e4"));
|
||||||
|
|
||||||
TreePVector pV1 = pVector.plus("e1");
|
|
||||||
TreePVector pV2 = pV1.plusAll(Arrays.asList("e2", "e3", "e4"));
|
|
||||||
assertEquals(1, pV1.size());
|
assertEquals(1, pV1.size());
|
||||||
assertEquals(4, pV2.size());
|
assertEquals(4, pV2.size());
|
||||||
|
|
||||||
TreePVector pV3 = pV2.minus("e1");
|
TreePVector<String> pV3 = pV2.minus("e1");
|
||||||
TreePVector pV4 = pV3.minusAll(Arrays.asList("e2", "e3", "e4"));
|
TreePVector<String> pV4 = pV3.minusAll(Arrays.asList("e2", "e3", "e4"));
|
||||||
|
|
||||||
assertEquals(pV3.size(), 3);
|
assertEquals(pV3.size(), 3);
|
||||||
assertEquals(pV4.size(), 0);
|
assertEquals(pV4.size(), 0);
|
||||||
|
|
||||||
TreePVector pSub = pV2.subList(0, 2);
|
TreePVector<String> pSub = pV2.subList(0, 2);
|
||||||
assertTrue(pSub.contains("e1") && pSub.contains("e2"));
|
assertTrue(pSub.contains("e1") && pSub.contains("e2"));
|
||||||
|
|
||||||
TreePVector pVW = (TreePVector) pV2.with(0, "e10");
|
PVector<String> pVW = pV2.with(0, "e10");
|
||||||
assertEquals(pVW.get(0), "e10");
|
assertEquals(pVW.get(0), "e10");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +27,6 @@ import static org.hamcrest.CoreMatchers.containsString;
|
|||||||
import static org.hamcrest.CoreMatchers.not;
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author aiet
|
|
||||||
*/
|
|
||||||
public class AtlasObserverLiveTest {
|
public class AtlasObserverLiveTest {
|
||||||
|
|
||||||
private final String atlasUri = "http://localhost:7101/api/v1";
|
private final String atlasUri = "http://localhost:7101/api/v1";
|
||||||
|
@ -22,10 +22,7 @@ import static org.hamcrest.Matchers.*;
|
|||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
public class MetricAnnotationManualTest extends MetricTestBase {
|
||||||
* @author aiet
|
|
||||||
*/
|
|
||||||
public class MetricAnnotationTest extends MetricTestBase {
|
|
||||||
|
|
||||||
@Monitor(name = "integerCounter", type = DataSourceType.COUNTER, description = "Total number of update operations.")
|
@Monitor(name = "integerCounter", type = DataSourceType.COUNTER, description = "Total number of update operations.")
|
||||||
private final AtomicInteger updateCount = new AtomicInteger(0);
|
private final AtomicInteger updateCount = new AtomicInteger(0);
|
@ -13,14 +13,16 @@ import java.util.List;
|
|||||||
|
|
||||||
import static com.netflix.servo.annotations.DataSourceType.GAUGE;
|
import static com.netflix.servo.annotations.DataSourceType.GAUGE;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||||
|
import static org.hamcrest.Matchers.hasItem;
|
||||||
|
import static org.hamcrest.Matchers.hasProperty;
|
||||||
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
/**
|
public class MetricObserverManualTest extends MetricTestBase {
|
||||||
* @author aiet
|
|
||||||
*/
|
|
||||||
public class MetricObserverTest extends MetricTestBase {
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenMetrics_whenRegister_thenMonitored() throws InterruptedException {
|
public void givenMetrics_whenRegister_thenMonitored() throws InterruptedException {
|
@ -1,20 +1,23 @@
|
|||||||
package com.baeldung.metrics.servo;
|
package com.baeldung.metrics.servo;
|
||||||
|
|
||||||
import com.netflix.servo.Metric;
|
import com.netflix.servo.Metric;
|
||||||
import com.netflix.servo.publish.*;
|
import com.netflix.servo.publish.BasicMetricFilter;
|
||||||
|
import com.netflix.servo.publish.JvmMetricPoller;
|
||||||
|
import com.netflix.servo.publish.MemoryMetricObserver;
|
||||||
|
import com.netflix.servo.publish.PollRunnable;
|
||||||
|
import com.netflix.servo.publish.PollScheduler;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||||
|
import static org.hamcrest.Matchers.hasItems;
|
||||||
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
/**
|
public class MetricPollerManualTest {
|
||||||
* @author aiet
|
|
||||||
*/
|
|
||||||
public class MetricPollerTest {
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenJvmPoller_whenMonitor_thenDataCollected() throws Exception {
|
public void givenJvmPoller_whenMonitor_thenDataCollected() throws Exception {
|
@ -1,14 +1,16 @@
|
|||||||
package com.baeldung.metrics.servo;
|
package com.baeldung.metrics.servo;
|
||||||
|
|
||||||
import com.netflix.servo.publish.*;
|
import com.netflix.servo.publish.BasicMetricFilter;
|
||||||
|
import com.netflix.servo.publish.MemoryMetricObserver;
|
||||||
|
import com.netflix.servo.publish.MetricFilter;
|
||||||
|
import com.netflix.servo.publish.MonitorRegistryMetricPoller;
|
||||||
|
import com.netflix.servo.publish.PollRunnable;
|
||||||
|
import com.netflix.servo.publish.PollScheduler;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author aiet
|
|
||||||
*/
|
|
||||||
abstract class MetricTestBase {
|
abstract class MetricTestBase {
|
||||||
|
|
||||||
MemoryMetricObserver observer;
|
MemoryMetricObserver observer;
|
||||||
|
@ -1,6 +1,21 @@
|
|||||||
package com.baeldung.metrics.servo;
|
package com.baeldung.metrics.servo;
|
||||||
|
|
||||||
import com.netflix.servo.monitor.*;
|
import com.netflix.servo.monitor.BasicCounter;
|
||||||
|
import com.netflix.servo.monitor.BasicGauge;
|
||||||
|
import com.netflix.servo.monitor.BasicInformational;
|
||||||
|
import com.netflix.servo.monitor.BasicTimer;
|
||||||
|
import com.netflix.servo.monitor.BucketConfig;
|
||||||
|
import com.netflix.servo.monitor.BucketTimer;
|
||||||
|
import com.netflix.servo.monitor.Counter;
|
||||||
|
import com.netflix.servo.monitor.Gauge;
|
||||||
|
import com.netflix.servo.monitor.MaxGauge;
|
||||||
|
import com.netflix.servo.monitor.Monitor;
|
||||||
|
import com.netflix.servo.monitor.MonitorConfig;
|
||||||
|
import com.netflix.servo.monitor.Monitors;
|
||||||
|
import com.netflix.servo.monitor.PeakRateCounter;
|
||||||
|
import com.netflix.servo.monitor.StatsTimer;
|
||||||
|
import com.netflix.servo.monitor.StepCounter;
|
||||||
|
import com.netflix.servo.monitor.Stopwatch;
|
||||||
import com.netflix.servo.stats.StatsConfig;
|
import com.netflix.servo.stats.StatsConfig;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -9,13 +24,12 @@ import java.util.Map;
|
|||||||
|
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static java.util.stream.Collectors.toMap;
|
import static java.util.stream.Collectors.toMap;
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
import static org.hamcrest.Matchers.hasEntry;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
/**
|
|
||||||
* Unit test for simple App.
|
|
||||||
*/
|
|
||||||
public class MetricTypeTest {
|
public class MetricTypeTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user