Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,39 @@
<properties>
<protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>

<junit.version>4.13.2</junit.version>
<junit-bom.version>5.14.4</junit-bom.version>
<slf4j.version>2.0.18</slf4j.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.ratis</groupId>
<artifactId>ratis-thirdparty-misc</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand All @@ -20,20 +20,17 @@
import org.apache.ratis.thirdparty.demo.common.SslClientConfig;
import org.apache.ratis.thirdparty.demo.common.SslServerConfig;
import org.apache.ratis.thirdparty.demo.common.TestUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Optional;

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

public class GrpcSslTest {
private final static Logger LOG = LoggerFactory.getLogger(GrpcSslTest.class);


@Test
public void testSslClientServer() throws InterruptedException, IOException {
final int port = TestUtils.randomPort();
Expand All @@ -55,7 +52,7 @@ public void testSslClientServer() throws InterruptedException, IOException {
String user = "testuser";
String response = client.greet(user);
LOG.info("Greet result: {}", response);
Assert.assertEquals("Hello " + user, response);
assertEquals("Hello " + user, response);
} finally {
client.shutdown();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand All @@ -18,22 +18,20 @@
package org.apache.ratis.thirdparty.demo.grpc;

import org.apache.ratis.thirdparty.demo.common.TestUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

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

/**
* Unit test for demo gRPC client/server with ratis thirdparty.
*/
@RunWith(JUnit4.class)
public class GrpcTest {

private final static Logger LOG = LoggerFactory.getLogger(GrpcTest.class);

@Test
public void testClientServer() throws IOException, InterruptedException {
final int port = TestUtils.randomPort();
Expand All @@ -46,7 +44,7 @@ public void testClientServer() throws IOException, InterruptedException {
String user = "testuser";
String response = client.greet(user);
LOG.info("Greet result: {}", response);
Assert.assertEquals("Hello " + user, response);
assertEquals("Hello " + user, response);
} finally {
client.shutdown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import org.apache.ratis.thirdparty.demo.common.TestUtils;
import org.apache.ratis.thirdparty.io.netty.buffer.ByteBuf;
import org.apache.ratis.thirdparty.io.netty.handler.ssl.SslContext;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -32,6 +31,8 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

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

/**
* Unit test for demo netty client/server with ratis thirdparty.
*/
Expand Down Expand Up @@ -70,7 +71,7 @@ static void testNetty(int port, SslServerConfig serverSslConf, SslClientConfig c
final CompletableFuture<String> future = replyFutures.get(i);
final String reply = future.get(3, TimeUnit.SECONDS);
LOG.info(reply);
Assert.assertEquals(NettyServer.toReply(words[i]), reply);
assertEquals(NettyServer.toReply(words[i]), reply);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand All @@ -18,15 +18,13 @@
package org.apache.ratis.thirdparty.demo.proto;

import org.apache.ratis.thirdparty.com.google.protobuf.util.JsonFormat;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.Test;

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

/**
* Unit test for ensure that protobuf-java-util is properly shaded as ratis thirdparty.
*/
@RunWith(JUnit4.class)
public class ProtoUtilTest {

@Test
Expand All @@ -36,7 +34,7 @@ public void testJsonFormatPrinter() throws Exception {
final String expected = "{\n" +
" \"name\": \"ratis\"\n" +
"}";
Assert.assertEquals(expected, actual);
assertEquals(expected, actual);
}

}
6 changes: 2 additions & 4 deletions test/src/test/resources/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# log4j configuration used during build and unit tests

# log4j configuration used in unit tests

log4j.rootLogger=INFO,stdout
log4j.threshold=ALL
Expand All @@ -18,6 +19,3 @@ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c{2} (%F:%M(%L)) - %m%n

log4j.logger.org.apache.hadoop.util.NativeCodeLoader=ERROR

# for debugging low level Ozone operations, uncomment this line
# log4j.logger.org.apache.hadoop.ozone=DEBUG