diff options
Diffstat (limited to 'jrt/tests')
-rw-r--r-- | jrt/tests/com/yahoo/jrt/AbortTest.java | 6 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/BackTargetTest.java | 18 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/CryptoUtils.java | 11 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/DetachTest.java | 8 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/EchoTest.java | 27 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/InvokeAsyncTest.java | 26 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/InvokeErrorTest.java | 63 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/InvokeSyncTest.java | 22 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/InvokeVoidTest.java | 6 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/LatencyTest.java | 3 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/MandatoryMethodsTest.java | 7 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/SimpleRequestAccessFilter.java | 9 | ||||
-rw-r--r-- | jrt/tests/com/yahoo/jrt/TimeoutTest.java | 8 |
13 files changed, 150 insertions, 64 deletions
diff --git a/jrt/tests/com/yahoo/jrt/AbortTest.java b/jrt/tests/com/yahoo/jrt/AbortTest.java index 2f31b3a52f6..df1f207458e 100644 --- a/jrt/tests/com/yahoo/jrt/AbortTest.java +++ b/jrt/tests/com/yahoo/jrt/AbortTest.java @@ -4,6 +4,8 @@ package com.yahoo.jrt; import org.junit.After; import org.junit.Before; +import java.time.Duration; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -44,7 +46,7 @@ public class AbortTest { Test.Waiter w = new Test.Waiter(); Request req = new Request("test"); req.parameters().add(new Int32Value(20)); - target.invokeAsync(req, 5.0, w); + target.invokeAsync(req, Duration.ofSeconds(5), w); req.abort(); barrier.breakIt(); w.waitDone(); @@ -54,7 +56,7 @@ public class AbortTest { Request req2 = new Request("test"); req2.parameters().add(new Int32Value(30)); - target.invokeSync(req2, 5.0); + target.invokeSync(req2, Duration.ofSeconds(5)); assertTrue(!req2.isError()); assertEquals(1, req2.returnValues().size()); assertEquals(30, req2.returnValues().get(0).asInt32()); diff --git a/jrt/tests/com/yahoo/jrt/BackTargetTest.java b/jrt/tests/com/yahoo/jrt/BackTargetTest.java index a55a6d7f474..5b9e7ccb157 100644 --- a/jrt/tests/com/yahoo/jrt/BackTargetTest.java +++ b/jrt/tests/com/yahoo/jrt/BackTargetTest.java @@ -4,6 +4,8 @@ package com.yahoo.jrt; import org.junit.After; import org.junit.Before; +import java.time.Duration; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -81,24 +83,24 @@ public class BackTargetTest { @org.junit.Test public void testBackTarget() { checkTargets(false, false); - target.invokeSync(new Request("sample_target"), 5.0); + target.invokeSync(new Request("sample_target"), Duration.ofSeconds(5)); checkTargets(true, false); - serverBackTarget.invokeSync(new Request("sample_target"), 5.0); + serverBackTarget.invokeSync(new Request("sample_target"), Duration.ofSeconds(5)); checkTargets(true, true); checkValues(0, 0); - target.invokeSync(new Request("inc"), 5.0); + target.invokeSync(new Request("inc"), Duration.ofSeconds(5)); checkValues(1, 0); - serverBackTarget.invokeSync(new Request("inc"), 5.0); + serverBackTarget.invokeSync(new Request("inc"), Duration.ofSeconds(5)); checkValues(1, 1); - clientBackTarget.invokeSync(new Request("inc"), 5.0); + clientBackTarget.invokeSync(new Request("inc"), Duration.ofSeconds(5)); checkValues(2, 1); - target.invokeSync(new Request("back_inc"), 5.0); + target.invokeSync(new Request("back_inc"), Duration.ofSeconds(5)); checkValues(2, 2); - serverBackTarget.invokeSync(new Request("back_inc"), 5.0); + serverBackTarget.invokeSync(new Request("back_inc"), Duration.ofSeconds(5)); checkValues(3, 2); - clientBackTarget.invokeSync(new Request("back_inc"), 5.0); + clientBackTarget.invokeSync(new Request("back_inc"), Duration.ofSeconds(5)); checkValues(3, 3); } diff --git a/jrt/tests/com/yahoo/jrt/CryptoUtils.java b/jrt/tests/com/yahoo/jrt/CryptoUtils.java index f1672f86e9b..cef138ffba1 100644 --- a/jrt/tests/com/yahoo/jrt/CryptoUtils.java +++ b/jrt/tests/com/yahoo/jrt/CryptoUtils.java @@ -4,15 +4,14 @@ package com.yahoo.jrt; import com.yahoo.security.KeyUtils; import com.yahoo.security.X509CertificateBuilder; import com.yahoo.security.tls.AuthorizationMode; +import com.yahoo.security.tls.AuthorizedPeers; import com.yahoo.security.tls.DefaultTlsContext; import com.yahoo.security.tls.HostnameVerification; import com.yahoo.security.tls.PeerAuthentication; +import com.yahoo.security.tls.PeerPolicy; +import com.yahoo.security.tls.RequiredPeerCredential; +import com.yahoo.security.tls.RequiredPeerCredential.Field; import com.yahoo.security.tls.TlsContext; -import com.yahoo.security.tls.policy.AuthorizedPeers; -import com.yahoo.security.tls.policy.PeerPolicy; -import com.yahoo.security.tls.policy.RequiredPeerCredential; -import com.yahoo.security.tls.policy.RequiredPeerCredential.Field; -import com.yahoo.security.tls.policy.Role; import javax.security.auth.x500.X500Principal; import java.security.KeyPair; @@ -42,8 +41,6 @@ class CryptoUtils { singleton( new PeerPolicy( "localhost-policy", - singleton( - new Role("localhost-role")), singletonList( RequiredPeerCredential.of(Field.CN, "localhost"))))); diff --git a/jrt/tests/com/yahoo/jrt/DetachTest.java b/jrt/tests/com/yahoo/jrt/DetachTest.java index 3c3356b53e2..4c3ee085913 100644 --- a/jrt/tests/com/yahoo/jrt/DetachTest.java +++ b/jrt/tests/com/yahoo/jrt/DetachTest.java @@ -4,6 +4,8 @@ package com.yahoo.jrt; import org.junit.After; import org.junit.Before; +import java.time.Duration; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -66,11 +68,11 @@ public class DetachTest { Test.Waiter w1 = new Test.Waiter(); Request req1 = new Request("d_inc"); req1.parameters().add(new Int32Value(50)); - target.invokeAsync(req1, 5.0, w1); + target.invokeAsync(req1, Duration.ofSeconds(5), w1); Request req2 = new Request("d_inc_r"); req2.parameters().add(new Int32Value(60)); - target.invokeSync(req2, 5.0); + target.invokeSync(req2, Duration.ofSeconds(5)); assertTrue(!req2.isError()); assertEquals(1, req2.returnValues().size()); @@ -123,7 +125,7 @@ public class DetachTest { Test.Waiter w = new Test.Waiter(); Request req3 = new Request("inc_b"); req3.parameters().add(new Int32Value(100)); - target.invokeAsync(req3, 5.0, w); + target.invokeAsync(req3, Duration.ofSeconds(5), w); Request blocked = (Request) receptor.get(); try { blocked.returnRequest(); diff --git a/jrt/tests/com/yahoo/jrt/EchoTest.java b/jrt/tests/com/yahoo/jrt/EchoTest.java index 26d4315fad6..11742fa42e2 100644 --- a/jrt/tests/com/yahoo/jrt/EchoTest.java +++ b/jrt/tests/com/yahoo/jrt/EchoTest.java @@ -2,6 +2,7 @@ package com.yahoo.jrt; +import com.yahoo.security.tls.ConnectionAuthContext; import org.junit.After; import org.junit.Before; import org.junit.runner.RunWith; @@ -10,12 +11,12 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; import java.security.cert.X509Certificate; +import java.time.Duration; import java.util.List; import static com.yahoo.jrt.CryptoUtils.createTestTlsContext; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @RunWith(Parameterized.class) @@ -28,19 +29,19 @@ public class EchoTest { Supervisor client; Target target; Values refValues; - SecurityContext securityContext; + ConnectionAuthContext connAuthCtx; private interface MetricsAssertions { void assertMetrics(TransportMetrics.Snapshot snapshot) throws AssertionError; } - private interface SecurityContextAssertion { - void assertSecurityContext(SecurityContext securityContext) throws AssertionError; + private interface ConnectionAuthContextAssertion { + void assertConnectionAuthContext(ConnectionAuthContext authContext) throws AssertionError; } @Parameter(value = 0) public CryptoEngine crypto; @Parameter(value = 1) public MetricsAssertions metricsAssertions; - @Parameter(value = 2) public SecurityContextAssertion securityContextAssertion; + @Parameter(value = 2) public ConnectionAuthContextAssertion connAuthCtxAssertion; @Parameters(name = "{0}") public static Object[] engines() { @@ -62,7 +63,7 @@ public class EchoTest { assertEquals(1, metrics.serverTlsConnectionsEstablished()); assertEquals(1, metrics.clientTlsConnectionsEstablished()); }, - (SecurityContextAssertion) context -> { + (ConnectionAuthContextAssertion) context -> { List<X509Certificate> chain = context.peerCertificateChain(); assertEquals(1, chain.size()); assertEquals(CryptoUtils.certificate, chain.get(0)); @@ -80,7 +81,7 @@ public class EchoTest { assertEquals(1, metrics.serverTlsConnectionsEstablished()); assertEquals(1, metrics.clientTlsConnectionsEstablished()); }, - (SecurityContextAssertion) context -> { + (ConnectionAuthContextAssertion) context -> { List<X509Certificate> chain = context.peerCertificateChain(); assertEquals(1, chain.size()); assertEquals(CryptoUtils.certificate, chain.get(0)); @@ -146,7 +147,7 @@ public class EchoTest { for (int i = 0; i < p.size(); i++) { r.add(p.get(i)); } - securityContext = req.target().getSecurityContext().orElse(null); + connAuthCtx = req.target().connectionAuthContext(); } @org.junit.Test @@ -156,7 +157,7 @@ public class EchoTest { for (int i = 0; i < refValues.size(); i++) { p.add(refValues.get(i)); } - target.invokeSync(req, 60.0); + target.invokeSync(req, Duration.ofSeconds(60)); assertTrue(req.checkReturnTypes("bBhHiIlLfFdDxXsS")); assertTrue(Test.equals(req.returnValues(), req.parameters())); assertTrue(Test.equals(req.returnValues(), refValues)); @@ -164,11 +165,9 @@ public class EchoTest { if (metricsAssertions != null) { metricsAssertions.assertMetrics(metrics.snapshot().changesSince(startSnapshot)); } - if (securityContextAssertion != null) { - assertNotNull(securityContext); - securityContextAssertion.assertSecurityContext(securityContext); - } else { - assertNull(securityContext); + if (connAuthCtxAssertion != null) { + assertNotNull(connAuthCtx); + connAuthCtxAssertion.assertConnectionAuthContext(connAuthCtx); } } } diff --git a/jrt/tests/com/yahoo/jrt/InvokeAsyncTest.java b/jrt/tests/com/yahoo/jrt/InvokeAsyncTest.java index 5e9f426bb17..e17b6c0cfdd 100644 --- a/jrt/tests/com/yahoo/jrt/InvokeAsyncTest.java +++ b/jrt/tests/com/yahoo/jrt/InvokeAsyncTest.java @@ -5,6 +5,8 @@ package com.yahoo.jrt; import org.junit.After; import org.junit.Before; +import java.time.Duration; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -16,6 +18,7 @@ public class InvokeAsyncTest { Supervisor client; Target target; Test.Barrier barrier; + SimpleRequestAccessFilter filter; @Before public void setUp() throws ListenFailedException { @@ -23,11 +26,13 @@ public class InvokeAsyncTest { client = new Supervisor(new Transport()); acceptor = server.listen(new Spec(0)); target = client.connect(new Spec("localhost", acceptor.port())); + filter = new SimpleRequestAccessFilter(); server.addMethod(new Method("concat", "ss", "s", this::rpc_concat) .methodDesc("Concatenate 2 strings") .paramDesc(0, "str1", "a string") .paramDesc(1, "str2", "another string") - .returnDesc(0, "ret", "str1 followed by str2")); + .returnDesc(0, "ret", "str1 followed by str2") + .requestAccessFilter(filter)); barrier = new Test.Barrier(); } @@ -54,7 +59,7 @@ public class InvokeAsyncTest { req.parameters().add(new StringValue("def")); Test.Waiter w = new Test.Waiter(); - target.invokeAsync(req, 5.0, w); + target.invokeAsync(req, Duration.ofSeconds(5), w); assertFalse(w.isDone()); barrier.breakIt(); w.waitDone(); @@ -65,4 +70,21 @@ public class InvokeAsyncTest { assertEquals("abcdef", req.returnValues().get(0).asString()); } + @org.junit.Test + public void testFilterIsInvoked() { + Request req = new Request("concat"); + req.parameters().add(new StringValue("abc")); + req.parameters().add(new StringValue("def")); + assertFalse(filter.invoked); + Test.Waiter w = new Test.Waiter(); + target.invokeAsync(req, Duration.ofSeconds(10), w); + assertFalse(w.isDone()); + barrier.breakIt(); + w.waitDone(); + assertTrue(w.isDone()); + assertFalse(req.isError()); + assertEquals("abcdef", req.returnValues().get(0).asString()); + assertTrue(filter.invoked); + } + } diff --git a/jrt/tests/com/yahoo/jrt/InvokeErrorTest.java b/jrt/tests/com/yahoo/jrt/InvokeErrorTest.java index a9a0b18b5a1..0b75fe713c2 100644 --- a/jrt/tests/com/yahoo/jrt/InvokeErrorTest.java +++ b/jrt/tests/com/yahoo/jrt/InvokeErrorTest.java @@ -5,17 +5,22 @@ package com.yahoo.jrt; import org.junit.After; import org.junit.Before; +import java.time.Duration; + import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class InvokeErrorTest { - final double timeout=60.0; + final Duration timeout = Duration.ofSeconds(60); Supervisor server; Acceptor acceptor; Supervisor client; Target target; Test.Barrier barrier; + SimpleRequestAccessFilter filter; + RpcTestMethod testMethod; @Before public void setUp() throws ListenFailedException { @@ -23,7 +28,9 @@ public class InvokeErrorTest { client = new Supervisor(new Transport()); acceptor = server.listen(new Spec(0)); target = client.connect(new Spec("localhost", acceptor.port())); - server.addMethod(new Method("test", "iib", "i", this::rpc_test)); + filter = new SimpleRequestAccessFilter(); + testMethod = new RpcTestMethod(); + server.addMethod(new Method("test", "iib", "i", testMethod).requestAccessFilter(filter)); server.addMethod(new Method("test_barrier", "iib", "i", this::rpc_test_barrier)); barrier = new Test.Barrier(); } @@ -36,22 +43,8 @@ public class InvokeErrorTest { server.transport().shutdown().join(); } - private void rpc_test(Request req) { - int value = req.parameters().get(0).asInt32(); - int error = req.parameters().get(1).asInt32(); - int extra = req.parameters().get(2).asInt8(); - - req.returnValues().add(new Int32Value(value)); - if (extra != 0) { - req.returnValues().add(new Int32Value(value)); - } - if (error != 0) { - req.setError(error, "Custom error"); - } - } - private void rpc_test_barrier(Request req) { - rpc_test(req); + testMethod.invoke(req); barrier.waitFor(); } @@ -157,4 +150,40 @@ public class InvokeErrorTest { assertEquals(ErrorCode.CONNECTION, req1.errorCode()); } + @org.junit.Test + public void testFilterFailsRequest() { + Request r = new Request("test"); + r.parameters().add(new Int32Value(42)); + r.parameters().add(new Int32Value(0)); + r.parameters().add(new Int8Value((byte)0)); + filter.allowed = false; + assertFalse(filter.invoked); + target.invokeSync(r, timeout); + assertTrue(r.isError()); + assertTrue(filter.invoked); + assertFalse(testMethod.invoked); + assertEquals(ErrorCode.PERMISSION_DENIED, r.errorCode()); + assertEquals("Permission denied", r.errorMessage()); + } + + private static class RpcTestMethod implements MethodHandler { + boolean invoked = false; + + @Override public void invoke(Request req) { invoked = true; rpc_test(req); } + + void rpc_test(Request req) { + int value = req.parameters().get(0).asInt32(); + int error = req.parameters().get(1).asInt32(); + int extra = req.parameters().get(2).asInt8(); + + req.returnValues().add(new Int32Value(value)); + if (extra != 0) { + req.returnValues().add(new Int32Value(value)); + } + if (error != 0) { + req.setError(error, "Custom error"); + } + } + } + } diff --git a/jrt/tests/com/yahoo/jrt/InvokeSyncTest.java b/jrt/tests/com/yahoo/jrt/InvokeSyncTest.java index ca7d0db129d..ff44017e1bc 100644 --- a/jrt/tests/com/yahoo/jrt/InvokeSyncTest.java +++ b/jrt/tests/com/yahoo/jrt/InvokeSyncTest.java @@ -10,8 +10,10 @@ import java.io.FileDescriptor; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; +import java.time.Duration; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -21,6 +23,7 @@ public class InvokeSyncTest { Acceptor acceptor; Supervisor client; Target target; + SimpleRequestAccessFilter filter; @Before public void setUp() throws ListenFailedException { @@ -28,11 +31,13 @@ public class InvokeSyncTest { client = new Supervisor(new Transport()); acceptor = server.listen(new Spec(0)); target = client.connect(new Spec("localhost", acceptor.port())); + filter = new SimpleRequestAccessFilter(); server.addMethod(new Method("concat", "ss", "s", this::rpc_concat) .methodDesc("Concatenate 2 strings") .paramDesc(0, "str1", "a string") .paramDesc(1, "str2", "another string") - .returnDesc(0, "ret", "str1 followed by str2")); + .returnDesc(0, "ret", "str1 followed by str2") + .requestAccessFilter(filter)); server.addMethod(new Method("alltypes", "bhilfds", "s", this::rpc_alltypes) .methodDesc("Method taking all types of params")); } @@ -63,7 +68,7 @@ public class InvokeSyncTest { req.parameters().add(new StringValue("abc")); req.parameters().add(new StringValue("def")); - target.invokeSync(req, 5.0); + target.invokeSync(req, Duration.ofSeconds(5)); assertTrue(!req.isError()); assertEquals(1, req.returnValues().size()); @@ -84,4 +89,17 @@ public class InvokeSyncTest { assertEquals(baos.toString(), "This was alltypes. The string param was: baz\n"); } + @org.junit.Test + public void testFilterIsInvoked() { + Request req = new Request("concat"); + req.parameters().add(new StringValue("abc")); + req.parameters().add(new StringValue("def")); + assertFalse(filter.invoked); + target.invokeSync(req, Duration.ofSeconds(10)); + assertFalse(req.isError()); + assertEquals("abcdef", req.returnValues().get(0).asString()); + assertTrue(filter.invoked); + } + + } diff --git a/jrt/tests/com/yahoo/jrt/InvokeVoidTest.java b/jrt/tests/com/yahoo/jrt/InvokeVoidTest.java index 8b674136fe2..64c3bc91371 100644 --- a/jrt/tests/com/yahoo/jrt/InvokeVoidTest.java +++ b/jrt/tests/com/yahoo/jrt/InvokeVoidTest.java @@ -5,6 +5,8 @@ package com.yahoo.jrt; import org.junit.After; import org.junit.Before; +import java.time.Duration; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -56,7 +58,7 @@ public class InvokeVoidTest { public void testInvokeVoid() { Request req = new Request("set"); req.parameters().add(new Int32Value(40)); - target.invokeSync(req, 5.0); + target.invokeSync(req, Duration.ofSeconds(5)); assertTrue(!req.isError()); assertEquals(0, req.returnValues().size()); @@ -64,7 +66,7 @@ public class InvokeVoidTest { target.invokeVoid(new Request("inc")); req = new Request("get"); - target.invokeSync(req, 5.0); + target.invokeSync(req, Duration.ofSeconds(5)); assertTrue(!req.isError()); assertEquals(42, req.returnValues().get(0).asInt32()); diff --git a/jrt/tests/com/yahoo/jrt/LatencyTest.java b/jrt/tests/com/yahoo/jrt/LatencyTest.java index 0df15ed400b..945833e51a8 100644 --- a/jrt/tests/com/yahoo/jrt/LatencyTest.java +++ b/jrt/tests/com/yahoo/jrt/LatencyTest.java @@ -2,6 +2,7 @@ package com.yahoo.jrt; +import java.time.Duration; import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; import java.util.logging.Logger; @@ -116,7 +117,7 @@ public class LatencyTest { } Request req = new Request("inc"); req.parameters().add(new Int32Value(value)); - target.invokeSync(req, 60.0); + target.invokeSync(req, Duration.ofSeconds(60)); long duration = System.nanoTime() - t; assertTrue(req.checkReturnTypes("i")); assertEquals(value + 1, req.returnValues().get(0).asInt32()); diff --git a/jrt/tests/com/yahoo/jrt/MandatoryMethodsTest.java b/jrt/tests/com/yahoo/jrt/MandatoryMethodsTest.java index 212447dd6da..c0ef9606b1f 100644 --- a/jrt/tests/com/yahoo/jrt/MandatoryMethodsTest.java +++ b/jrt/tests/com/yahoo/jrt/MandatoryMethodsTest.java @@ -5,6 +5,7 @@ package com.yahoo.jrt; import org.junit.After; import org.junit.Before; +import java.time.Duration; import java.util.HashSet; import static org.junit.Assert.assertEquals; @@ -38,7 +39,7 @@ public class MandatoryMethodsTest { @org.junit.Test public void testPing() { Request req = new Request("frt.rpc.ping"); - target.invokeSync(req, 5.0); + target.invokeSync(req, Duration.ofSeconds(5)); assertFalse(req.isError()); assertEquals(0, req.returnValues().size()); @@ -47,7 +48,7 @@ public class MandatoryMethodsTest { @org.junit.Test public void testGetMethodList() { Request req = new Request("frt.rpc.getMethodList"); - target.invokeSync(req, 5.0); + target.invokeSync(req, Duration.ofSeconds(5)); assertFalse(req.isError()); assertTrue(req.checkReturnTypes("SSS")); @@ -81,7 +82,7 @@ public class MandatoryMethodsTest { public void testGetMethodInfo() { Request req = new Request("frt.rpc.getMethodInfo"); req.parameters().add(new StringValue("frt.rpc.getMethodInfo")); - target.invokeSync(req, 5.0); + target.invokeSync(req, Duration.ofSeconds(5)); assertFalse(req.isError()); assertTrue(req.checkReturnTypes("sssSSSS")); diff --git a/jrt/tests/com/yahoo/jrt/SimpleRequestAccessFilter.java b/jrt/tests/com/yahoo/jrt/SimpleRequestAccessFilter.java new file mode 100644 index 00000000000..38d59720848 --- /dev/null +++ b/jrt/tests/com/yahoo/jrt/SimpleRequestAccessFilter.java @@ -0,0 +1,9 @@ +package com.yahoo.jrt;// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +/** + * @author bjorncs + */ +class SimpleRequestAccessFilter implements RequestAccessFilter { + volatile boolean invoked = false, allowed = true; + @Override public boolean allow(Request r) { invoked = true; return allowed; } +} diff --git a/jrt/tests/com/yahoo/jrt/TimeoutTest.java b/jrt/tests/com/yahoo/jrt/TimeoutTest.java index 0366020b221..1a802758e60 100644 --- a/jrt/tests/com/yahoo/jrt/TimeoutTest.java +++ b/jrt/tests/com/yahoo/jrt/TimeoutTest.java @@ -5,6 +5,8 @@ package com.yahoo.jrt; import org.junit.After; import org.junit.Before; +import java.time.Duration; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -52,11 +54,11 @@ public class TimeoutTest { req.parameters().add(new StringValue("abc")); req.parameters().add(new StringValue("def")); - target.invokeSync(req, 0.1); + target.invokeSync(req, Duration.ofMillis(100)); barrier.breakIt(); Request flush = new Request("frt.rpc.ping"); - target.invokeSync(flush, 5.0); + target.invokeSync(flush, Duration.ofSeconds(5)); assertTrue(!flush.isError()); assertTrue(req.isError()); @@ -72,7 +74,7 @@ public class TimeoutTest { req.parameters().add(new StringValue("def")); Test.Waiter w = new Test.Waiter(); - target.invokeAsync(req, 30.0, w); + target.invokeAsync(req, Duration.ofSeconds(30), w); try { Thread.sleep(2500); } catch (InterruptedException e) {} barrier.breakIt(); w.waitDone(); |