Skip to content

Commit

Permalink
Remove TestNG and replace with junit 5 (#514)
Browse files Browse the repository at this point in the history
Removed TestNG and replaced with JUnit 5
Upgraded Hamcrest to 2.2
  • Loading branch information
OwenLindsell authored Nov 5, 2019
1 parent 14c15e7 commit 7760578
Show file tree
Hide file tree
Showing 233 changed files with 1,876 additions and 1,869 deletions.
6 changes: 3 additions & 3 deletions components/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>

<dependency>
Expand All @@ -69,7 +69,7 @@

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<artifactId>hamcrest</artifactId>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,9 +15,9 @@
*/
package com.hotels.styx.api;

import org.junit.jupiter.api.Test;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscription;
import org.testng.annotations.Test;
import reactor.core.publisher.Flux;
import reactor.test.publisher.TestPublisher;

Expand All @@ -29,19 +29,20 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.testng.Assert.assertTrue;

public class ByteStreamAggregatorTest {

@Test(expectedExceptions = IllegalStateException.class)
@Test
public void allowsOnlyOneAggregation() {
Publisher<Buffer> upstream = Flux.just(new Buffer("x", UTF_8));
ByteStreamAggregator aggregator = new ByteStreamAggregator(upstream, 100);

aggregator.apply();
aggregator.apply();
assertThrows(IllegalStateException.class, () -> aggregator.apply());
}

@Test
Expand Down Expand Up @@ -102,15 +103,15 @@ public void aggregatesUpToNBytes() {
assertThat(b.delegate().refCnt(), is(0));
}

@Test(expectedExceptions = NullPointerException.class)
@Test
public void checkForNullSubscription() {
Publisher<Buffer> upstream = mock(Publisher.class);
ByteStreamAggregator aggregator = new ByteStreamAggregator(upstream, 100);

aggregator.onSubscribe(null);
assertThrows(NullPointerException.class, () -> aggregator.onSubscribe(null));
}

@Test(expectedExceptions = IllegalStateException.class)
@Test
public void allowsOnlyOneSubscription() {
Publisher<Buffer> upstream = mock(Publisher.class);
Subscription subscription1 = mock(Subscription.class);
Expand All @@ -119,12 +120,8 @@ public void allowsOnlyOneSubscription() {
ByteStreamAggregator aggregator = new ByteStreamAggregator(upstream, 100);
aggregator.onSubscribe(subscription1);

try {
aggregator.onSubscribe(subscription2);
} catch (IllegalStateException cause) {
verify(subscription2).cancel();
throw cause;
}
assertThrows(IllegalStateException.class, () -> aggregator.onSubscribe(subscription2));
verify(subscription2).cancel();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,8 @@
*/
package com.hotels.styx.api;

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;

Expand All @@ -28,15 +28,15 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.testng.AssertJUnit.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;


public class ByteStreamTest {
private Buffer buf1;
private Buffer buf2;
private Buffer buf3;

@BeforeMethod
@BeforeEach
public void setUp() {
buf1 = new Buffer("a", UTF_8);
buf2 = new Buffer("b", UTF_8);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,14 +15,14 @@
*/
package com.hotels.styx.api;

import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

import java.util.concurrent.CompletableFuture;

import static org.testng.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class EventualTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
*/
package com.hotels.styx.api;

import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;

import static com.hotels.styx.api.HttpHeader.header;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class HttpHeaderTest {
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void rejectsEmptyValuesList() {
header("name", new String[0]);
assertThrows(IllegalArgumentException.class, () -> header("name", new String[0]));
}

@Test
Expand Down Expand Up @@ -56,8 +57,8 @@ public void equalsBehavesCorrectly() {
assertThat(base.equals(different), is(false));
}

@Test(expectedExceptions = NullPointerException.class)
@Test
public void valuesCannotBeNull() {
header("name", "value1", null, "value2");
assertThrows(NullPointerException.class, () -> header("name", "value1", null, "value2"));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,8 +16,8 @@
package com.hotels.styx.api;

import com.hotels.styx.api.HttpHeaders.Builder;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.time.Instant;
import java.time.ZonedDateTime;
Expand All @@ -32,11 +32,12 @@
import static org.hamcrest.Matchers.emptyIterable;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.hamcrest.core.Is.is;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class HttpHeadersTest {
HttpHeaders headers;

@BeforeMethod
@BeforeEach
public void setUp() {
headers = new HttpHeaders.Builder()
.add("header1", "val1")
Expand Down Expand Up @@ -109,11 +110,11 @@ public void setsHeaders() {
assertThat(headers, contains(header("foo", "bar")));
}

@Test(expectedExceptions = NullPointerException.class)
@Test
public void doesNotAllowNullValue() {
new HttpHeaders.Builder()
assertThrows(NullPointerException.class, () -> new HttpHeaders.Builder()
.add("header1", (String) null)
.build();
.build());
}

@Test
Expand All @@ -125,11 +126,11 @@ public void removesNullValues() {
assertThat(headers, contains(header("header1", "val1"), header("header1", "val2")));
}

@Test(expectedExceptions = NullPointerException.class)
@Test
public void doesNotAllowNullName() {
new HttpHeaders.Builder()
assertThrows(NullPointerException.class, () -> new HttpHeaders.Builder()
.add(null, "value")
.build();
.build());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,7 @@
*/
package com.hotels.styx.api;

import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;

import static com.hotels.styx.api.HttpHeaderNames.CONNECTION;
import static com.hotels.styx.api.HttpHeaderNames.TRANSFER_ENCODING;
Expand Down
Loading

0 comments on commit 7760578

Please sign in to comment.