@Test(expectedExceptions = IllegalArgumentException.class) public void testHostPrefixEmpty() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestVirtualHost.class, "getPrefix", String.class, String.class); processor.apply(Invocation.create(method, ImmutableList.<Object> of("1", ""))); }
@Test public void testBuildOneQuery() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestQueryReplace.class, "oneQuery", String.class); String query = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot"))) .getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/robot"); }
@Test public void testBuildTwoHeader() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestHeader.class, "twoHeader", String.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot"))).getHeaders(); assertEquals(headers.size(), 2); assertEquals(headers.get("slash"), ImmutableList.of("/robot")); assertEquals(headers.get("hyphen"), ImmutableList.of("-robot")); }
@Test public void testBuildOneClassQuery() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestClassQuery.class, "oneQuery", String.class); String query = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot"))) .getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/robot"); }
@Test public void testBuildTwoQuerysOutOfOrder() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestQueryReplace.class, "twoQuerysOutOfOrder", String.class, String.class); String query = processor .apply(Invocation.create(method, ImmutableList.<Object> of("robot", "eggs"))).getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/eggs/robot"); }
@Test public void testBuildOneHeader() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestHeader.class, "oneHeader", String.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot"))).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("x-amz-copy-source"), ImmutableList.of("/robot")); }
@Test public void testBuildTwoQuery() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestQueryReplace.class, "twoQuery", String.class); String query = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot"))) .getEndpoint().getQuery(); assertEquals(query, "slash=/robot&hyphen=-robot"); }
@Test public void testOneIntHeader() throws SecurityException, NoSuchMethodException, ExecutionException { Invokable<?, ?> method = method(TestHeaders.class, "oneIntHeader", int.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of(1))).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("header"), ImmutableList.of("1")); }
@Test public void testBuildTwoHeadersOutOfOrder() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestHeader.class, "twoHeadersOutOfOrder", String.class, String.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot", "eggs"))).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("x-amz-copy-source"), ImmutableList.of("/eggs/robot")); }
@Test public void testBuildTwoQuerys() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestQueryReplace.class, "twoQuerys", String.class, String.class); String query = processor .apply(Invocation.create(method, ImmutableList.<Object> of("robot", "eggs"))).getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/robot/eggs"); }
@Test public void testTwoDifferentHeaders() throws SecurityException, NoSuchMethodException, ExecutionException { Invokable<?, ?> method = method(TestHeaders.class, "twoDifferentHeaders", String.class, String.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot", "egg"))).getHeaders(); assertEquals(headers.size(), 2); assertEquals(headers.get("header1"), ImmutableList.of("robot")); assertEquals(headers.get("header2"), ImmutableList.of("egg")); }
@Test public void testTwoSameHeaders() throws SecurityException, NoSuchMethodException, ExecutionException { Invokable<?, ?> method = method(TestHeaders.class, "twoSameHeaders", String.class, String.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot", "egg"))).getHeaders(); assertEquals(headers.size(), 2); Collection<String> values = headers.get("header"); assert values.contains("robot"); assert values.contains("egg"); }
@Test public void testBuildOneClassHeader() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestClassHeader.class, "oneHeader", String.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot"))).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("x-amz-copy-source"), ImmutableList.of("/robot")); }
@Test public void testBuildTwoHeaders() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestHeader.class, "twoHeaders", String.class, String.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot", "eggs"))).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("x-amz-copy-source"), ImmutableList.of("/robot/eggs")); }
@Test public void testOneHeader() throws SecurityException, NoSuchMethodException, ExecutionException { Invokable<?, ?> method = method(TestHeaders.class, "oneHeader", String.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot"))).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("header"), ImmutableList.of("robot")); }
public void testWrapWith() throws SecurityException, NoSuchMethodException, IOException { Invokable<?, ?> method = method(TestPut.class, "testWrapWith", String.class); GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of("bar"))); assertPayloadEquals(request, "{\"foo\":\"bar\"}", "application/json", false); }
@Test public void testBuildOneClassHeader() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestClassHeader.class, "oneHeader", String.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot"))).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("x-amz-copy-source"), ImmutableList.of("/robot")); }
@Test public void testBuildOneHeader() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestHeader.class, "oneHeader", String.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot"))).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("x-amz-copy-source"), ImmutableList.of("/robot")); }
@Test public void testBuildOneClassQuery() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestClassQuery.class, "oneQuery", String.class); String query = processor.apply(Invocation.create(method, ImmutableList.<Object> of("robot"))) .getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/robot"); }
@Test public void testOneIntHeader() throws SecurityException, NoSuchMethodException, ExecutionException { Invokable<?, ?> method = method(TestHeaders.class, "oneIntHeader", int.class); Multimap<String, String> headers = processor.apply(Invocation.create(method, ImmutableList.<Object> of(1))).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("header"), ImmutableList.of("1")); }