You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by bl...@apache.org on 2016/05/14 23:44:02 UTC
[29/43] avro git commit: AVRO-1828: Add EditorConfig file and cleanup
of whitespace violations
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolGenericMeta.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolGenericMeta.java b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolGenericMeta.java
index 5bc46f6..ed24444 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolGenericMeta.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolGenericMeta.java
@@ -26,7 +26,7 @@ import org.apache.avro.ipc.generic.GenericRequestor;
import org.junit.Before;
public class TestProtocolGenericMeta extends TestProtocolGeneric {
-
+
@Before @Override
public void testStartServer() throws Exception {
if (server != null) return;
@@ -35,7 +35,7 @@ public class TestProtocolGenericMeta extends TestProtocolGeneric {
responder.addRPCPlugin(new RPCMetaTestPlugin("key2"));
server = new SocketServer(responder, new InetSocketAddress(0));
server.start();
-
+
client = new SocketTransceiver(new InetSocketAddress(server.getPort()));
requestor = new GenericRequestor(PROTOCOL, client);
requestor.addRPCPlugin(new RPCMetaTestPlugin("key1"));
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttp.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttp.java b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttp.java
index dc460c5..c162c09 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttp.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttp.java
@@ -42,12 +42,12 @@ public class TestProtocolHttp extends TestProtocolSpecific {
public Server createServer(Responder testResponder) throws Exception {
return new HttpServer(testResponder, 0);
}
-
+
@Override
public Transceiver createTransceiver() throws Exception{
return new HttpTransceiver(new URL("http://127.0.0.1:"+server.getPort()+"/"));
}
-
+
protected int getExpectedHandshakeCount() {
return REPEATING;
}
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttps.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttps.java b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttps.java
index 1c87955..f770dae 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttps.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttps.java
@@ -57,12 +57,12 @@ public class TestProtocolHttps extends TestProtocolSpecific {
connector.setNeedClientAuth(false);
return new HttpServer(testResponder, connector);
}
-
+
@Override
public Transceiver createTransceiver() throws Exception{
return new HttpTransceiver(new URL("https://localhost:"+server.getPort()+"/"));
}
-
+
protected int getExpectedHandshakeCount() {
return REPEATING;
}
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolNetty.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolNetty.java b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolNetty.java
index ed73e78..07ba143 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolNetty.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolNetty.java
@@ -34,12 +34,12 @@ public class TestProtocolNetty extends TestProtocolSpecific {
public Server createServer(Responder testResponder) throws Exception {
return new NettyServer(responder, new InetSocketAddress(0));
}
-
+
@Override
public Transceiver createTransceiver() throws Exception{
return new NettyTransceiver(new InetSocketAddress(server.getPort()), 2000L);
}
-
+
@Override
protected int getExpectedHandshakeCount() {
return REPEATING;
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflect.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflect.java b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflect.java
index 7567c6e..4c8b478 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflect.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflect.java
@@ -54,7 +54,7 @@ public class TestProtocolReflect {
byte[] echoBytes(byte[] data);
void error() throws SimpleException;
}
-
+
private static boolean throwUndeclaredError;
public static class TestImpl implements Simple {
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflectMeta.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflectMeta.java b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflectMeta.java
index c6394cd..91a54b7 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflectMeta.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflectMeta.java
@@ -36,7 +36,7 @@ public class TestProtocolReflectMeta extends TestProtocolReflect {
rresp.addRPCPlugin(new RPCMetaTestPlugin("key2"));
server = new SocketServer(rresp, new InetSocketAddress(0));
server.start();
-
+
client = new SocketTransceiver(new InetSocketAddress(server.getPort()));
ReflectRequestor requestor = new ReflectRequestor(Simple.class, client);
requestor.addRPCPlugin(new RPCMetaTestPlugin("key1"));
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecific.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecific.java b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecific.java
index f660f28..08b569a 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecific.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecific.java
@@ -95,23 +95,23 @@ public class TestProtocolSpecific {
responder = new SpecificResponder(Simple.class, new TestImpl());
server = createServer(responder);
server.start();
-
+
client = createTransceiver();
SpecificRequestor req = new SpecificRequestor(Simple.class, client);
addRpcPlugins(req);
proxy = SpecificRequestor.getClient(Simple.class, (SpecificRequestor)req);
-
+
monitor = new HandshakeMonitor();
responder.addRPCPlugin(monitor);
}
-
+
public void addRpcPlugins(Requestor requestor){}
-
+
public Server createServer(Responder testResponder) throws Exception{
return server = new SocketServer(testResponder,
- new InetSocketAddress(0));
+ new InetSocketAddress(0));
}
-
+
public Transceiver createTransceiver() throws Exception{
return new SocketTransceiver(new InetSocketAddress(server.getPort()));
}
@@ -218,14 +218,14 @@ public class TestProtocolSpecific {
try { Thread.sleep(100); } catch (InterruptedException e) {}
assertEquals(2, ackCount);
}
-
+
@Test
public void testRepeatedAccess() throws Exception {
for (int x = 0; x < 1000; x++) {
proxy.hello("hi!");
}
}
-
+
@Test(expected = Exception.class)
public void testConnectionRefusedOneWay() throws IOException {
Transceiver client = new HttpTransceiver(new URL("http://localhost:4444"));
@@ -277,12 +277,12 @@ public class TestProtocolSpecific {
server.close();
server = null;
}
-
+
public class HandshakeMonitor extends RPCPlugin{
-
+
private int handshakes;
private HashSet<String> seenProtocols = new HashSet<String>();
-
+
@Override
public void serverConnecting(RPCContext context) {
handshakes++;
@@ -299,7 +299,7 @@ public class TestProtocolSpecific {
seenProtocols.add(clientProtocol);
}
}
-
+
public void assertHandshake(){
int expected = getExpectedHandshakeCount();
if(expected != REPEATING){
@@ -307,7 +307,7 @@ public class TestProtocolSpecific {
}
}
}
-
+
protected int getExpectedHandshakeCount() {
return 3;
}
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecificMeta.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecificMeta.java b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecificMeta.java
index a2dd575..d38362e 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecificMeta.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecificMeta.java
@@ -28,19 +28,19 @@ import org.apache.avro.ipc.Transceiver;
public class TestProtocolSpecificMeta extends TestProtocolSpecific {
-
+
@Override
public Server createServer(Responder testResponder) throws Exception {
responder.addRPCPlugin(new RPCMetaTestPlugin("key1"));
responder.addRPCPlugin(new RPCMetaTestPlugin("key2"));
return new SocketServer(responder, new InetSocketAddress(0));
}
-
+
@Override
public Transceiver createTransceiver() throws Exception {
return new SocketTransceiver(new InetSocketAddress(server.getPort()));
}
-
+
public void addRpcPlugins(Requestor req){
req.addRPCPlugin(new RPCMetaTestPlugin("key1"));
req.addRPCPlugin(new RPCMetaTestPlugin("key2"));
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java b/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java
index b19b138..468a21b 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java
@@ -172,16 +172,16 @@ public class TestSchema {
check("{\"type\":\"map\", \"values\":\"long\"}", "{\"a\":1}", map);
checkParseError("{\"type\":\"map\"}"); // values required
}
-
+
@Test
public void testUnionMap() throws Exception {
String unionMapSchema = "{\"name\":\"foo\", \"type\":\"record\"," +
- " \"fields\":[ {\"name\":\"mymap\", \"type\":" +
- " [{\"type\":\"map\", \"values\":" +
- " [\"int\",\"long\",\"float\",\"string\"]}," +
- " \"null\"]" +
- " }]" +
- " }";
+ " \"fields\":[ {\"name\":\"mymap\", \"type\":" +
+ " [{\"type\":\"map\", \"values\":" +
+ " [\"int\",\"long\",\"float\",\"string\"]}," +
+ " \"null\"]" +
+ " }]" +
+ " }";
check(unionMapSchema, true);
}
@@ -305,10 +305,10 @@ public class TestSchema {
// reasonable amount of time
for (Schema s1 : recs) {
Schema s2 = Schema.parse(s1.toString());
- assertEquals(s1.hashCode(), s2.hashCode());
+ assertEquals(s1.hashCode(), s2.hashCode());
assertEquals(s1, s2);
}
- }
+ }
}
@Test
@@ -370,15 +370,15 @@ public class TestSchema {
String namedTypes = ", {\"type\":\"record\",\"name\":\"Foo\",\"fields\":[]}," +
" {\"type\":\"fixed\",\"name\":\"Bar\",\"size\": 1}," +
" {\"type\":\"enum\",\"name\":\"Baz\",\"symbols\": [\"X\"]}";
-
+
String namedTypes2 = ", {\"type\":\"record\",\"name\":\"Foo2\",\"fields\":[]}," +
" {\"type\":\"fixed\",\"name\":\"Bar2\",\"size\": 1}," +
" {\"type\":\"enum\",\"name\":\"Baz2\",\"symbols\": [\"X\"]}";
-
+
check(partial + namedTypes + "]", false);
- check(partial + namedTypes + namedTypes2 + "]", false);
+ check(partial + namedTypes + namedTypes2 + "]", false);
checkParseError(partial + namedTypes + namedTypes + "]");
-
+
// fail with two branches of the same unnamed type
checkUnionError(new Schema[] {Schema.create(Type.INT), Schema.create(Type.INT)});
checkUnionError(new Schema[] {Schema.create(Type.LONG), Schema.create(Type.LONG)});
@@ -387,14 +387,14 @@ public class TestSchema {
checkUnionError(new Schema[] {Schema.create(Type.BOOLEAN), Schema.create(Type.BOOLEAN)});
checkUnionError(new Schema[] {Schema.create(Type.BYTES), Schema.create(Type.BYTES)});
checkUnionError(new Schema[] {Schema.create(Type.STRING), Schema.create(Type.STRING)});
- checkUnionError(new Schema[] {Schema.createArray(Schema.create(Type.INT)),
+ checkUnionError(new Schema[] {Schema.createArray(Schema.create(Type.INT)),
Schema.createArray(Schema.create(Type.INT))});
- checkUnionError(new Schema[] {Schema.createMap(Schema.create(Type.INT)),
+ checkUnionError(new Schema[] {Schema.createMap(Schema.create(Type.INT)),
Schema.createMap(Schema.create(Type.INT))});
-
+
List<String> symbols = new ArrayList<String>();
symbols.add("NOTHING");
-
+
// succeed with two branches of the same named type, if different names
Schema u;
u = buildUnion(new Schema[] {
@@ -408,12 +408,12 @@ public class TestSchema {
Schema.parse
("{\"type\":\"enum\",\"name\":\"y.A\",\"symbols\":[\"Y\"]}")});
check(u.toString(), false);
-
+
u = buildUnion(new Schema[] {
Schema.parse("{\"type\":\"fixed\",\"name\":\"x.A\",\"size\":4}"),
Schema.parse("{\"type\":\"fixed\",\"name\":\"y.A\",\"size\":8}")});
check(u.toString(), false);
-
+
// fail with two branches of the same named type, but same names
checkUnionError(new Schema[] {Schema.createRecord("Foo", null, "org.test", false),
Schema.createRecord("Foo", null, "org.test", false)});
@@ -421,19 +421,19 @@ public class TestSchema {
Schema.createEnum("Bar", null, "org.test", symbols)});
checkUnionError(new Schema[] {Schema.createFixed("Baz", null, "org.test", 2),
Schema.createFixed("Baz", null, "org.test", 1)});
-
+
Schema union = buildUnion(new Schema[] {Schema.create(Type.INT)});
// fail if creating a union of a union
checkUnionError(new Schema[] {union});
}
-
+
@Test
public void testComplexProp() throws Exception {
String json = "{\"type\":\"null\", \"foo\": [0]}";
Schema s = Schema.parse(json);
assertEquals(null, s.getProp("foo"));
}
-
+
@Test public void testPropOrdering() throws Exception {
String json = "{\"type\":\"int\",\"z\":\"c\",\"yy\":\"b\",\"x\":\"a\"}";
Schema s = Schema.parse(json);
@@ -600,7 +600,7 @@ public class TestSchema {
// check field doc is parsed correctly
Schema schema = Schema.parse(schemaStr);
assertEquals("test", schema.getField("f").doc());
-
+
// check print/read cycle preserves field doc
schema = Schema.parse(schema.toString());
assertEquals("test", schema.getField("f").doc());
@@ -669,7 +669,7 @@ public class TestSchema {
Schema induced = GenericData.get().induce(datum);
assertEquals("Induced schema does not match.", schema, induced);
}
-
+
assertTrue("Datum does not validate against schema "+datum,
GenericData.get().validate(schema, datum));
@@ -709,14 +709,14 @@ public class TestSchema {
assertEquals(s1, s2);
assertFalse(s0.equals(s2));
}
-
+
public static void checkBinary(Schema schema, Object datum,
DatumWriter<Object> writer,
DatumReader<Object> reader)
throws IOException {
checkBinary(schema, datum, writer, reader, null);
}
-
+
public static Object checkBinary(Schema schema, Object datum,
DatumWriter<Object> writer,
DatumReader<Object> reader,
@@ -730,11 +730,11 @@ public class TestSchema {
byte[] data = out.toByteArray();
reader.setSchema(schema);
-
+
Object decoded =
reader.read(reuse, DecoderFactory.get().binaryDecoder(
data, null));
-
+
assertEquals("Decoded data does not match.", datum, decoded);
return decoded;
}
@@ -814,7 +814,7 @@ public class TestSchema {
reader.setSchema(schema);
Object decoded = reader.read(null, DecoderFactory.get()
.jsonDecoder(schema, new ByteArrayInputStream(data)));
-
+
assertEquals("Decoded data does not match.", datum, decoded);
}
@@ -909,12 +909,12 @@ public class TestSchema {
public void testRecordWithPrimitiveName() {
Schema.parse("{\"type\":\"record\", \"name\":\"string\", \"fields\": []}");
}
-
+
@Test(expected=AvroTypeException.class)
public void testEnumWithPrimitiveName() {
Schema.parse("{\"type\":\"enum\", \"name\":\"null\", \"symbols\": [\"A\"]}");
}
-
+
private static Schema enumSchema() {
return Schema.parse("{ \"type\": \"enum\", \"name\": \"e\", "
+ "\"symbols\": [\"a\", \"b\"]}");
@@ -926,7 +926,7 @@ public class TestSchema {
s.addProp("p1", "1");
s.addProp("p1", "2");
}
-
+
@Test(expected=AvroRuntimeException.class)
public void testImmutability2() {
Schema s = enumSchema();
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java b/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
index 34a3601..7710be8 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
@@ -119,7 +119,7 @@ public class TestSpecificCompiler {
assertTrue(protocol.contains("java.lang.CharSequence goto$(java.lang.CharSequence break$)"));
assertTrue(protocol.contains("public interface default$"));
assertTrue(protocol.contains("throws org.apache.avro.AvroRemoteException, finally$"));
-
+
assertCompilesWithJavaCompiler(c);
}
@@ -144,7 +144,7 @@ public class TestSpecificCompiler {
assertTrue(contents.contains("public java.lang.CharSequence package$;"));
assertTrue(contents.contains("class volatile$ extends"));
assertTrue(contents.contains("volatile$ short$;"));
-
+
assertCompilesWithJavaCompiler(c);
}
@@ -159,7 +159,7 @@ public class TestSpecificCompiler {
String contents = c.iterator().next().contents;
assertTrue(contents.contains("new$"));
-
+
assertCompilesWithJavaCompiler(c);
}
@@ -203,10 +203,10 @@ public class TestSpecificCompiler {
assertTrue(o.contents.contains("/** Very Inner Enum */"));
}
}
-
+
assertEquals(3, count);
}
-
+
@Test
public void testProtocolWithDocs() throws IOException {
Protocol protocol = TestProtocolParsing.getSimpleProtocol();
@@ -222,7 +222,7 @@ public class TestSpecificCompiler {
}
assertEquals("Missed generated protocol!", 1, count);
}
-
+
@Test
public void testNeedCompile() throws IOException, InterruptedException {
String schema = "" +
@@ -233,8 +233,8 @@ public class TestSpecificCompiler {
FileWriter fw = new FileWriter(inputFile);
fw.write(schema);
fw.close();
-
- File outputDir = new File(System.getProperty("test.dir", "target/test") +
+
+ File outputDir = new File(System.getProperty("test.dir", "target/test") +
System.getProperty("file.separator") + "test_need_compile");
File outputFile = new File(outputDir, "Foo.java");
outputFile.delete();
@@ -249,14 +249,14 @@ public class TestSpecificCompiler {
Thread.sleep(1000); //granularity of JVM doesn't seem to go below 1 sec
SpecificCompiler.compileSchema(inputFile, outputDir);
assertEquals(lastModified, outputFile.lastModified());
-
+
fw = new FileWriter(inputFile);
fw.write(schema);
fw.close();
SpecificCompiler.compileSchema(inputFile, outputDir);
assertTrue(lastModified != outputFile.lastModified());
}
-
+
/**
* Creates a record with the given name, error status, and fields.
* @param name the name of the schema.
@@ -264,51 +264,51 @@ public class TestSpecificCompiler {
* @param fields the field(s) to add to the schema.
* @return the schema.
*/
- private Schema createRecord(String name,
+ private Schema createRecord(String name,
boolean isError, Field... fields) {
Schema record = Schema.createRecord(name, null, null, isError);
record.setFields(Arrays.asList(fields));
return record;
}
-
+
@Test
public void generateGetMethod() {
Field height = new Field("height", Schema.create(Type.INT), null, null);
Field Height = new Field("Height", Schema.create(Type.INT), null, null);
- Field height_and_width =
+ Field height_and_width =
new Field("height_and_width", Schema.create(Type.STRING), null, null);
- Field message =
+ Field message =
new Field("message", Schema.create(Type.STRING), null, null);
- Field Message =
+ Field Message =
new Field("Message", Schema.create(Type.STRING), null, null);
- Field cause =
+ Field cause =
new Field("cause", Schema.create(Type.STRING), null, null);
- Field clasz =
+ Field clasz =
new Field("class", Schema.create(Type.STRING), null, null);
- Field schema =
+ Field schema =
new Field("schema", Schema.create(Type.STRING), null, null);
- Field Schema$ =
+ Field Schema$ =
new Field("Schema", Schema.create(Type.STRING), null, null);
-
+
assertEquals("getHeight", SpecificCompiler.generateGetMethod(
createRecord("test", false, height), height));
-
+
assertEquals("getHeightAndWidth", SpecificCompiler.generateGetMethod(
createRecord("test", false, height_and_width), height_and_width));
-
+
assertEquals("getMessage", SpecificCompiler.generateGetMethod(
createRecord("test", false, message), message));
message = new Field("message", Schema.create(Type.STRING), null, null);
assertEquals("getMessage$", SpecificCompiler.generateGetMethod(
createRecord("test", true, message), message));
-
+
assertEquals("getCause", SpecificCompiler.generateGetMethod(
createRecord("test", false, cause), cause));
cause = new Field("cause", Schema.create(Type.STRING), null, null);
assertEquals("getCause$", SpecificCompiler.generateGetMethod(
createRecord("test", true, cause), cause));
-
+
assertEquals("getClass$", SpecificCompiler.generateGetMethod(
createRecord("test", false, clasz), clasz));
clasz = new Field("class", Schema.create(Type.STRING), null, null);
@@ -325,42 +325,42 @@ public class TestSpecificCompiler {
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("getHeight", SpecificCompiler.generateGetMethod(
createRecord("test", false, Height), Height));
-
+
height = new Field("height", Schema.create(Type.INT), null, null);
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("getHeight$0", SpecificCompiler.generateGetMethod(
createRecord("test", false, height, Height), height));
-
+
height = new Field("height", Schema.create(Type.INT), null, null);
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("getHeight$1", SpecificCompiler.generateGetMethod(
createRecord("test", false, height, Height), Height));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("getMessage$", SpecificCompiler.generateGetMethod(
createRecord("test", true, Message), Message));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("getMessage$0", SpecificCompiler.generateGetMethod(
createRecord("test", true, message, Message), message));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("getMessage$1", SpecificCompiler.generateGetMethod(
createRecord("test", true, message, Message), Message));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("getSchema$", SpecificCompiler.generateGetMethod(
createRecord("test", false, Schema$), Schema$));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("getSchema$0", SpecificCompiler.generateGetMethod(
createRecord("test", false, schema, Schema$), schema));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("getSchema$1", SpecificCompiler.generateGetMethod(
@@ -371,40 +371,40 @@ public class TestSpecificCompiler {
public void generateSetMethod() {
Field height = new Field("height", Schema.create(Type.INT), null, null);
Field Height = new Field("Height", Schema.create(Type.INT), null, null);
- Field height_and_width =
+ Field height_and_width =
new Field("height_and_width", Schema.create(Type.STRING), null, null);
- Field message =
+ Field message =
new Field("message", Schema.create(Type.STRING), null, null);
- Field Message =
+ Field Message =
new Field("Message", Schema.create(Type.STRING), null, null);
- Field cause =
+ Field cause =
new Field("cause", Schema.create(Type.STRING), null, null);
- Field clasz =
+ Field clasz =
new Field("class", Schema.create(Type.STRING), null, null);
- Field schema =
+ Field schema =
new Field("schema", Schema.create(Type.STRING), null, null);
- Field Schema$ =
+ Field Schema$ =
new Field("Schema", Schema.create(Type.STRING), null, null);
-
+
assertEquals("setHeight", SpecificCompiler.generateSetMethod(
createRecord("test", false, height), height));
-
+
assertEquals("setHeightAndWidth", SpecificCompiler.generateSetMethod(
createRecord("test", false, height_and_width), height_and_width));
-
+
assertEquals("setMessage", SpecificCompiler.generateSetMethod(
createRecord("test", false, message), message));
message = new Field("message", Schema.create(Type.STRING), null, null);
assertEquals("setMessage$", SpecificCompiler.generateSetMethod(
createRecord("test", true, message), message));
-
+
assertEquals("setCause", SpecificCompiler.generateSetMethod(
createRecord("test", false, cause), cause));
cause = new Field("cause", Schema.create(Type.STRING), null, null);
assertEquals("setCause$", SpecificCompiler.generateSetMethod(
createRecord("test", true, cause), cause));
-
+
assertEquals("setClass$", SpecificCompiler.generateSetMethod(
createRecord("test", false, clasz), clasz));
clasz = new Field("class", Schema.create(Type.STRING), null, null);
@@ -421,86 +421,86 @@ public class TestSpecificCompiler {
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("setHeight", SpecificCompiler.generateSetMethod(
createRecord("test", false, Height), Height));
-
+
height = new Field("height", Schema.create(Type.INT), null, null);
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("setHeight$0", SpecificCompiler.generateSetMethod(
createRecord("test", false, height, Height), height));
-
+
height = new Field("height", Schema.create(Type.INT), null, null);
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("setHeight$1", SpecificCompiler.generateSetMethod(
createRecord("test", false, height, Height), Height));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("setMessage$", SpecificCompiler.generateSetMethod(
createRecord("test", true, Message), Message));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("setMessage$0", SpecificCompiler.generateSetMethod(
createRecord("test", true, message, Message), message));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("setMessage$1", SpecificCompiler.generateSetMethod(
createRecord("test", true, message, Message), Message));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("setSchema$", SpecificCompiler.generateSetMethod(
createRecord("test", false, Schema$), Schema$));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("setSchema$0", SpecificCompiler.generateSetMethod(
createRecord("test", false, schema, Schema$), schema));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("setSchema$1", SpecificCompiler.generateSetMethod(
createRecord("test", false, schema, Schema$), Schema$));
}
-
+
@Test
public void generateHasMethod() {
Field height = new Field("height", Schema.create(Type.INT), null, null);
Field Height = new Field("Height", Schema.create(Type.INT), null, null);
- Field height_and_width =
+ Field height_and_width =
new Field("height_and_width", Schema.create(Type.STRING), null, null);
- Field message =
+ Field message =
new Field("message", Schema.create(Type.STRING), null, null);
- Field Message =
+ Field Message =
new Field("Message", Schema.create(Type.STRING), null, null);
- Field cause =
+ Field cause =
new Field("cause", Schema.create(Type.STRING), null, null);
- Field clasz =
+ Field clasz =
new Field("class", Schema.create(Type.STRING), null, null);
- Field schema =
+ Field schema =
new Field("schema", Schema.create(Type.STRING), null, null);
- Field Schema$ =
+ Field Schema$ =
new Field("Schema", Schema.create(Type.STRING), null, null);
-
+
assertEquals("hasHeight", SpecificCompiler.generateHasMethod(
createRecord("test", false, height), height));
-
+
assertEquals("hasHeightAndWidth", SpecificCompiler.generateHasMethod(
createRecord("test", false, height_and_width), height_and_width));
-
+
assertEquals("hasMessage", SpecificCompiler.generateHasMethod(
createRecord("test", false, message), message));
message = new Field("message", Schema.create(Type.STRING), null, null);
assertEquals("hasMessage$", SpecificCompiler.generateHasMethod(
createRecord("test", true, message), message));
-
+
assertEquals("hasCause", SpecificCompiler.generateHasMethod(
createRecord("test", false, cause), cause));
cause = new Field("cause", Schema.create(Type.STRING), null, null);
assertEquals("hasCause$", SpecificCompiler.generateHasMethod(
createRecord("test", true, cause), cause));
-
+
assertEquals("hasClass$", SpecificCompiler.generateHasMethod(
createRecord("test", false, clasz), clasz));
clasz = new Field("class", Schema.create(Type.STRING), null, null);
@@ -517,86 +517,86 @@ public class TestSpecificCompiler {
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("hasHeight", SpecificCompiler.generateHasMethod(
createRecord("test", false, Height), Height));
-
+
height = new Field("height", Schema.create(Type.INT), null, null);
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("hasHeight$0", SpecificCompiler.generateHasMethod(
createRecord("test", false, height, Height), height));
-
+
height = new Field("height", Schema.create(Type.INT), null, null);
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("hasHeight$1", SpecificCompiler.generateHasMethod(
createRecord("test", false, height, Height), Height));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("hasMessage$", SpecificCompiler.generateHasMethod(
createRecord("test", true, Message), Message));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("hasMessage$0", SpecificCompiler.generateHasMethod(
createRecord("test", true, message, Message), message));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("hasMessage$1", SpecificCompiler.generateHasMethod(
createRecord("test", true, message, Message), Message));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("hasSchema$", SpecificCompiler.generateHasMethod(
createRecord("test", false, Schema$), Schema$));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("hasSchema$0", SpecificCompiler.generateHasMethod(
createRecord("test", false, schema, Schema$), schema));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("hasSchema$1", SpecificCompiler.generateHasMethod(
createRecord("test", false, schema, Schema$), Schema$));
}
-
+
@Test
public void generateClearMethod() {
Field height = new Field("height", Schema.create(Type.INT), null, null);
Field Height = new Field("Height", Schema.create(Type.INT), null, null);
- Field height_and_width =
+ Field height_and_width =
new Field("height_and_width", Schema.create(Type.STRING), null, null);
- Field message =
+ Field message =
new Field("message", Schema.create(Type.STRING), null, null);
- Field Message =
+ Field Message =
new Field("Message", Schema.create(Type.STRING), null, null);
- Field cause =
+ Field cause =
new Field("cause", Schema.create(Type.STRING), null, null);
- Field clasz =
+ Field clasz =
new Field("class", Schema.create(Type.STRING), null, null);
- Field schema =
+ Field schema =
new Field("schema", Schema.create(Type.STRING), null, null);
- Field Schema$ =
+ Field Schema$ =
new Field("Schema", Schema.create(Type.STRING), null, null);
-
+
assertEquals("clearHeight", SpecificCompiler.generateClearMethod(
createRecord("test", false, height), height));
-
+
assertEquals("clearHeightAndWidth", SpecificCompiler.generateClearMethod(
createRecord("test", false, height_and_width), height_and_width));
-
+
assertEquals("clearMessage", SpecificCompiler.generateClearMethod(
createRecord("test", false, message), message));
message = new Field("message", Schema.create(Type.STRING), null, null);
assertEquals("clearMessage$", SpecificCompiler.generateClearMethod(
createRecord("test", true, message), message));
-
+
assertEquals("clearCause", SpecificCompiler.generateClearMethod(
createRecord("test", false, cause), cause));
cause = new Field("cause", Schema.create(Type.STRING), null, null);
assertEquals("clearCause$", SpecificCompiler.generateClearMethod(
createRecord("test", true, cause), cause));
-
+
assertEquals("clearClass$", SpecificCompiler.generateClearMethod(
createRecord("test", false, clasz), clasz));
clasz = new Field("class", Schema.create(Type.STRING), null, null);
@@ -613,42 +613,42 @@ public class TestSpecificCompiler {
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("clearHeight", SpecificCompiler.generateClearMethod(
createRecord("test", false, Height), Height));
-
+
height = new Field("height", Schema.create(Type.INT), null, null);
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("clearHeight$0", SpecificCompiler.generateClearMethod(
createRecord("test", false, height, Height), height));
-
+
height = new Field("height", Schema.create(Type.INT), null, null);
Height = new Field("Height", Schema.create(Type.INT), null, null);
assertEquals("clearHeight$1", SpecificCompiler.generateClearMethod(
createRecord("test", false, height, Height), Height));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("clearMessage$", SpecificCompiler.generateClearMethod(
createRecord("test", true, Message), Message));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("clearMessage$0", SpecificCompiler.generateClearMethod(
createRecord("test", true, message, Message), message));
-
+
message = new Field("message", Schema.create(Type.STRING), null, null);
Message = new Field("Message", Schema.create(Type.STRING), null, null);
assertEquals("clearMessage$1", SpecificCompiler.generateClearMethod(
createRecord("test", true, message, Message), Message));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("clearSchema$", SpecificCompiler.generateClearMethod(
createRecord("test", false, Schema$), Schema$));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("clearSchema$0", SpecificCompiler.generateClearMethod(
createRecord("test", false, schema, Schema$), schema));
-
+
schema = new Field("schema", Schema.create(Type.STRING), null, null);
Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
assertEquals("clearSchema$1", SpecificCompiler.generateClearMethod(
@@ -694,7 +694,7 @@ public class TestSpecificCompiler {
* that the generated code is valid.
*/
public static void
- assertCompiles(Schema schema, boolean useJavaCompiler)
+ assertCompiles(Schema schema, boolean useJavaCompiler)
throws IOException {
Collection<OutputFile> outputs = new SpecificCompiler(schema).compile();
assertTrue(null != outputs);
@@ -702,7 +702,7 @@ public class TestSpecificCompiler {
assertCompilesWithJavaCompiler(outputs);
}
}
-
+
/**
* Checks that a protocol passes through the SpecificCompiler,
* and, optionally, uses the system's Java compiler to check
@@ -716,9 +716,9 @@ public class TestSpecificCompiler {
assertCompilesWithJavaCompiler(outputs);
}
}
-
+
/** Uses the system's java compiler to actually compile the generated code. */
- static void assertCompilesWithJavaCompiler(Collection<OutputFile> outputs)
+ static void assertCompilesWithJavaCompiler(Collection<OutputFile> outputs)
throws IOException {
if (outputs.isEmpty()) {
return; // Nothing to compile!
@@ -730,10 +730,10 @@ public class TestSpecificCompiler {
}
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fileManager =
+ StandardJavaFileManager fileManager =
compiler.getStandardFileManager(null, null, null);
-
- CompilationTask cTask = compiler.getTask(null, fileManager, null, null,
+
+ CompilationTask cTask = compiler.getTask(null, fileManager, null, null,
null,
fileManager.getJavaFileObjects(
javaFiles.toArray(new File[javaFiles.size()])));
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java b/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java
index 0cf36f5..3829391 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java
@@ -49,37 +49,37 @@ public class TestDeepCopy {
interopBuilder.setBytesField(ByteBuffer.wrap(new byte[] { 1, 2, 3, 4 }));
interopBuilder.setDoubleField(3.14d);
interopBuilder.setEnumField(Kind.B);
- interopBuilder.setFixedField(new MD5(new byte[] {
+ interopBuilder.setFixedField(new MD5(new byte[] {
4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1 }));
interopBuilder.setFloatField(6.022f);
interopBuilder.setIntField(32);
interopBuilder.setLongField(64L);
-
- Map<java.lang.String,org.apache.avro.Foo> map =
+
+ Map<java.lang.String,org.apache.avro.Foo> map =
new HashMap<java.lang.String,org.apache.avro.Foo>(1);
map.put("foo", Foo.newBuilder().setLabel("bar").build());
interopBuilder.setMapField(map);
-
+
interopBuilder.setNullField(null);
-
+
Node.Builder rootBuilder = Node.newBuilder().setLabel("/");
Node.Builder homeBuilder = Node.newBuilder().setLabel("home");
homeBuilder.setChildren(new ArrayList<Node>(0));
rootBuilder.setChildren(Arrays.asList(new Node[] { homeBuilder.build() }));
interopBuilder.setRecordField(rootBuilder.build());
-
+
interopBuilder.setStringField("Hello");
interopBuilder.setUnionField(Arrays.asList(new ByteBuffer[] {
ByteBuffer.wrap(new byte[] { 1, 2 }) }));
-
+
Interop interop = interopBuilder.build();
-
+
// Verify that deepCopy works for all fields:
for (Field field : Interop.SCHEMA$.getFields()) {
// Original field and deep copy should be equivalent:
if (interop.get(field.pos()) instanceof ByteBuffer) {
assertTrue(Arrays.equals(((ByteBuffer)interop.get(field.pos())).array(),
- ((ByteBuffer)GenericData.get().deepCopy(field.schema(),
+ ((ByteBuffer)GenericData.get().deepCopy(field.schema(),
interop.get(field.pos()))).array()));
}
else {
@@ -87,7 +87,7 @@ public class TestDeepCopy {
SpecificData.get().deepCopy(
field.schema(), interop.get(field.pos())));
}
-
+
// Original field and deep copy should be different instances:
if ((field.schema().getType() != Type.ENUM)
&& (field.schema().getType() != Type.NULL)
@@ -98,7 +98,7 @@ public class TestDeepCopy {
&& (field.schema().getType() != Type.DOUBLE)
&& (field.schema().getType() != Type.STRING)) {
assertFalse("Field " + field.name() + " is same instance in deep copy",
- interop.get(field.pos()) ==
+ interop.get(field.pos()) ==
GenericData.get().deepCopy(
field.schema(), interop.get(field.pos())));
}
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/io/Perf.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/io/Perf.java b/lang/java/ipc/src/test/java/org/apache/avro/io/Perf.java
index 762a215..1f8a892 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/io/Perf.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/io/Perf.java
@@ -52,7 +52,7 @@ import org.apache.avro.util.Utf8;
public class Perf {
private static final int COUNT = 250000; // needs to be a multiple of 4
private static final int CYCLES = 800;
-
+
/**
* Use a fixed value seed for random number generation
* to allow for better cross-run comparisons.
@@ -62,7 +62,7 @@ public class Perf {
protected static Random newRandom() {
return new Random(SEED);
}
-
+
private static class TestDescriptor {
Class<? extends Test> test;
String param;
@@ -75,7 +75,7 @@ public class Perf {
typeList.add(this);
}
}
-
+
private static final List<TestDescriptor> BASIC = new ArrayList<TestDescriptor>();
private static final List<TestDescriptor> RECORD = new ArrayList<TestDescriptor>();
private static final List<TestDescriptor> GENERIC = new ArrayList<TestDescriptor>();
@@ -132,7 +132,7 @@ public class Perf {
new TestDescriptor(ReflectNestedLargeFloatArrayTest.class, "-REFnlf").add(REFLECT);
new TestDescriptor(ReflectNestedLargeFloatArrayBlockedTest.class, "-REFnlfb").add(REFLECT);
}
-
+
private static void usage() {
StringBuilder usage = new StringBuilder("Usage: Perf { -nowrite | -noread | ");
StringBuilder details = new StringBuilder();
@@ -154,7 +154,7 @@ public class Perf {
System.out.println(usage.toString());
System.out.print(details.toString());
}
-
+
public static void main(String[] args) throws Exception {
List<Test> tests = new ArrayList<Test>();
boolean writeTests = true;
@@ -192,7 +192,7 @@ public class Perf {
}
System.out.println("Executing tests: \n" + tests + "\n readTests:" +
readTests + "\n writeTests:" + writeTests + "\n cycles=" + CYCLES);
-
+
for (int k = 0; k < tests.size(); k++) {
Test t = tests.get(k);
try {
@@ -210,7 +210,7 @@ public class Perf {
throw e;
}
}
-
+
printHeader();
for (int k = 0; k < tests.size(); k++) {
@@ -248,25 +248,25 @@ public class Perf {
t.reset();
}
}
-
+
private static final void printHeader() {
String header = String.format(
"%60s time M entries/sec M bytes/sec bytes/cycle",
"test name");
System.out.println(header.toString());
}
-
+
private static final void printResult(long s, Test t, String name) {
s /= 1000;
double entries = (t.cycles * (double) t.count);
double bytes = t.cycles * (double) t.encodedSize;
StringBuilder result = new StringBuilder();
result.append(String.format("%42s: %6d ms ", name, (s/1000)));
- result.append(String.format("%10.3f %11.3f %11d",
+ result.append(String.format("%10.3f %11.3f %11d",
(entries / s), (bytes/ s), t.encodedSize));
System.out.println(result.toString());
}
-
+
private abstract static class Test {
/**
@@ -280,7 +280,7 @@ public class Perf {
protected boolean isWriteTest = true;
static DecoderFactory decoder_factory = new DecoderFactory();
static EncoderFactory encoder_factory = new EncoderFactory();
-
+
public Test(String name, int cycles, int count) {
this.name = name;
this.cycles = cycles;
@@ -291,33 +291,33 @@ public class Perf {
* Reads data from a Decoder and returns the time taken in nanoseconds.
*/
abstract long readTest() throws IOException;
-
+
/**
* Writes data to an Encoder and returns the time taken in nanoseconds.
*/
abstract long writeTest() throws IOException;
-
+
final boolean isWriteTest() {
return isWriteTest;
}
-
+
final boolean isReadTest() {
return isReadTest;
}
-
+
/** initializes data for read and write tests **/
abstract void init() throws IOException;
/** clears generated data arrays and other large objects created during initialization **/
abstract void reset();
-
+
@Override
public String toString() {
return this.getClass().getSimpleName();
}
-
+
}
-
+
/** the basic test writes a simple schema directly to an encoder or
* reads from an array. It does not use GenericDatumReader or any
* higher level constructs, just manual serialization.
@@ -340,7 +340,7 @@ public class Perf {
readInternal(d);
return (System.nanoTime() - t);
}
-
+
@Override
public final long writeTest() throws IOException {
long t = System.nanoTime();
@@ -349,11 +349,11 @@ public class Perf {
e.flush();
return (System.nanoTime() - t);
}
-
+
protected Decoder getDecoder() throws IOException {
return newDecoder();
}
-
+
private Encoder getEncoder() throws IOException {
return newEncoder(getOutputStream());
}
@@ -361,7 +361,7 @@ public class Perf {
protected Decoder newDecoder() {
return decoder_factory.binaryDecoder(data, null);
}
-
+
protected Encoder newEncoder(ByteArrayOutputStream out) throws IOException {
Encoder e = encoder_factory.binaryEncoder(out, null);
// Encoder e = encoder_factory.directBinaryEncoder(out, null);
@@ -373,7 +373,7 @@ public class Perf {
private ByteArrayOutputStream getOutputStream() {
return new ByteArrayOutputStream((int)(encodedSize > 0 ? encodedSize : count));
}
-
+
@Override
void init() throws IOException {
genSourceData();
@@ -390,7 +390,7 @@ public class Perf {
abstract void readInternal(Decoder d) throws IOException;
abstract void writeInternal(Encoder e) throws IOException;
}
-
+
static class IntTest extends BasicTest {
protected int[] sourceData = null;
public IntTest() throws IOException {
@@ -412,7 +412,7 @@ public class Perf {
sourceData[i+3] = r.nextInt(150000000); // most in 4, some in 5
}
}
-
+
@Override
void readInternal(Decoder d) throws IOException {
for (int i = 0; i < count/4; i++) {
@@ -432,7 +432,7 @@ public class Perf {
e.writeInt(sourceData[i+3]);
}
}
-
+
@Override
void reset() {
sourceData = null;
@@ -466,30 +466,30 @@ public class Perf {
}
}
}
-
+
// this tests reading Longs that are sometimes very large
static class LongTest extends BasicTest {
private long[] sourceData = null;
public LongTest() throws IOException {
super("Long", "{ \"type\": \"long\"} ");
}
-
+
@Override
void genSourceData() {
Random r = newRandom();
sourceData = new long[count];
for (int i = 0; i < sourceData.length; i+=4) {
- sourceData[i] = r.nextLong() % 0x7FL; // half fit in 1, half in 2
+ sourceData[i] = r.nextLong() % 0x7FL; // half fit in 1, half in 2
sourceData[i+1] = r.nextLong() % 0x1FFFFFL; // half fit in <=3, half in 4
sourceData[i+2] = r.nextLong() % 0x3FFFFFFFFL; // half in <=5, half in 6
- sourceData[i+3] = r.nextLong() % 0x1FFFFFFFFFFFFL; // half in <=8, half in 9
+ sourceData[i+3] = r.nextLong() % 0x1FFFFFFFFFFFFL; // half in <=8, half in 9
}
// last 16, make full size
for (int i = sourceData.length - 16; i < sourceData.length; i ++) {
sourceData[i] = r.nextLong();
}
}
-
+
@Override
void readInternal(Decoder d) throws IOException {
for (int i = 0; i < count/4; i++) {
@@ -509,14 +509,14 @@ public class Perf {
e.writeLong(sourceData[i+3]);
}
}
-
+
@Override
void reset() {
sourceData = null;
data = null;
}
}
-
+
static class FloatTest extends BasicTest {
float[] sourceData = null;
public FloatTest() throws IOException {
@@ -531,10 +531,10 @@ public class Perf {
Random r = newRandom();
sourceData = new float[count];
for (int i = 0; i < sourceData.length;) {
- sourceData[i++] = r.nextFloat();
+ sourceData[i++] = r.nextFloat();
}
}
-
+
@Override
void readInternal(Decoder d) throws IOException {
for (int i = 0; i < count; i+=4) {
@@ -554,7 +554,7 @@ public class Perf {
e.writeFloat(sourceData[i+3]);
}
}
-
+
@Override
void reset() {
sourceData = null;
@@ -567,16 +567,16 @@ public class Perf {
public DoubleTest() throws IOException {
super("Double", "{ \"type\": \"double\"} ");
}
-
+
@Override
void genSourceData() {
Random r = newRandom();
sourceData = new double[count];
for (int i = 0; i < sourceData.length;) {
- sourceData[i++] = r.nextDouble();
+ sourceData[i++] = r.nextDouble();
}
}
-
+
@Override
void readInternal(Decoder d) throws IOException {
for (int i = 0; i < count; i+=4) {
@@ -596,29 +596,29 @@ public class Perf {
e.writeDouble(sourceData[i+3]);
}
}
-
+
@Override
void reset() {
sourceData = null;
data = null;
}
}
-
+
static class BoolTest extends BasicTest {
boolean[] sourceData = null;
public BoolTest() throws IOException {
super("Boolean", "{ \"type\": \"boolean\"} ");
}
-
+
@Override
void genSourceData() {
Random r = newRandom();
sourceData = new boolean[count];
for (int i = 0; i < sourceData.length;) {
- sourceData[i++] = r.nextBoolean();
+ sourceData[i++] = r.nextBoolean();
}
}
-
+
@Override
void readInternal(Decoder d) throws IOException {
for (int i = 0; i < count/4; i++) {
@@ -638,20 +638,20 @@ public class Perf {
e.writeBoolean(sourceData[i+3]);
}
}
-
+
@Override
void reset() {
sourceData = null;
data = null;
}
}
-
+
static class BytesTest extends BasicTest {
byte[][] sourceData = null;
public BytesTest() throws IOException {
super("Bytes", "{ \"type\": \"bytes\"} ", 5);
}
-
+
@Override
void genSourceData() {
Random r = newRandom();
@@ -659,10 +659,10 @@ public class Perf {
for (int i = 0; i < sourceData.length;) {
byte[] data = new byte[r.nextInt(70)];
r.nextBytes(data);
- sourceData[i++] = data;
+ sourceData[i++] = data;
}
}
-
+
@Override
void readInternal(Decoder d) throws IOException {
ByteBuffer bb = ByteBuffer.allocate(70);
@@ -683,14 +683,14 @@ public class Perf {
e.writeBytes(sourceData[i+3]);
}
}
-
+
@Override
void reset() {
sourceData = null;
data = null;
}
}
-
+
private static String randomString(Random r) {
char[] data = new char[r.nextInt(70)];
for (int j = 0; j < data.length; j++) {
@@ -704,7 +704,7 @@ public class Perf {
public StringTest() throws IOException {
super("String", "{ \"type\": \"string\"} ", 5);
}
-
+
@Override
void genSourceData() {
Random r = newRandom();
@@ -712,7 +712,7 @@ public class Perf {
for (int i = 0; i < sourceData.length;)
sourceData[i++] = randomString(r);
}
-
+
@Override
void readInternal(Decoder d) throws IOException {
Utf8 utf = new Utf8();
@@ -733,14 +733,14 @@ public class Perf {
e.writeString(sourceData[i+3]);
}
}
-
+
@Override
void reset() {
sourceData = null;
data = null;
}
}
-
+
static class ArrayTest extends FloatTest {
public ArrayTest() throws IOException {
super("Array",
@@ -757,7 +757,7 @@ public class Perf {
" }" +
" }]}}");
}
-
+
@Override
void readInternal(Decoder d) throws IOException {
d.readArrayStart();
@@ -791,7 +791,7 @@ public class Perf {
e.writeArrayEnd();
}
}
-
+
static class MapTest extends FloatTest {
public MapTest() throws IOException {
super("Map", "{ \"type\": \"map\", \"values\": " +
@@ -802,7 +802,7 @@ public class Perf {
" {\"name\":\"f4\", \"type\":\"float\"}]" +
" }} ");
}
-
+
@Override
void readInternal(Decoder d) throws IOException {
Utf8 key = new Utf8();
@@ -834,8 +834,8 @@ public class Perf {
e.writeMapEnd();
}
}
-
- private static final String RECORD_SCHEMA =
+
+ private static final String RECORD_SCHEMA =
"{ \"type\": \"record\", \"name\": \"R\", \"fields\": [\n"
+ "{ \"name\": \"f1\", \"type\": \"double\" },\n"
+ "{ \"name\": \"f2\", \"type\": \"double\" },\n"
@@ -844,7 +844,7 @@ public class Perf {
+ "{ \"name\": \"f5\", \"type\": \"int\" },\n"
+ "{ \"name\": \"f6\", \"type\": \"int\" }\n"
+ "] }";
-
+
private static final String NESTED_RECORD_SCHEMA =
"{ \"type\": \"record\", \"name\": \"R\", \"fields\": [\n"
+ "{ \"name\": \"f1\", \"type\": \n" +
@@ -857,7 +857,7 @@ public class Perf {
+ "{ \"name\": \"f5\", \"type\": \"int\" },\n"
+ "{ \"name\": \"f6\", \"type\": \"int\" }\n"
+ "] }";
-
+
private static class Rec {
double f1;
double f2;
@@ -866,7 +866,7 @@ public class Perf {
int f5;
int f6;
Rec() {
-
+
}
Rec(Random r) {
f1 = r.nextDouble();
@@ -891,7 +891,7 @@ public class Perf {
Random r = newRandom();
sourceData = new Rec[count];
for (int i = 0; i < sourceData.length; i++) {
- sourceData[i] = new Rec(r);
+ sourceData[i] = new Rec(r);
}
}
@Override
@@ -923,7 +923,7 @@ public class Perf {
data = null;
}
}
-
+
static class ValidatingRecord extends RecordTest {
ValidatingRecord() throws IOException {
super("ValidatingRecord");
@@ -934,10 +934,10 @@ public class Perf {
}
@Override
protected Encoder newEncoder(ByteArrayOutputStream out) throws IOException {
- return encoder_factory.validatingEncoder(schema, super.newEncoder(out));
+ return encoder_factory.validatingEncoder(schema, super.newEncoder(out));
}
}
-
+
static class ResolvingRecord extends RecordTest {
public ResolvingRecord() throws IOException {
super("ResolvingRecord");
@@ -962,7 +962,7 @@ public class Perf {
+ "{ \"name\": \"f8\", \"type\": \"string\","
+ "\"default\": \"undefined\" }\n"
+ "] }";
-
+
private static final String RECORD_SCHEMA_WITH_OUT_OF_ORDER =
"{ \"type\": \"record\", \"name\": \"R\", \"fields\": [\n"
+ "{ \"name\": \"f1\", \"type\": \"double\" },\n"
@@ -1025,7 +1025,7 @@ public class Perf {
}
}
}
-
+
/**
* Tests the performance of resolving a change in field order.
*/
@@ -1063,7 +1063,7 @@ public class Perf {
}
}
}
-
+
/**
* Tests the performance of resolving a type promotion.
*/
@@ -1101,7 +1101,7 @@ public class Perf {
}
}
}
-
+
static class GenericTest extends BasicTest {
GenericRecord[] sourceData = null;
protected final GenericDatumReader<Object> reader;
@@ -1133,7 +1133,7 @@ public class Perf {
rec.put(3, r.nextInt());
rec.put(4, r.nextInt());
rec.put(5, r.nextInt());
- sourceData[i] = rec;
+ sourceData[i] = rec;
}
}
@Override
@@ -1156,14 +1156,14 @@ public class Perf {
data = null;
}
}
-
- private static final String GENERIC_STRINGS =
+
+ private static final String GENERIC_STRINGS =
"{ \"type\": \"record\", \"name\": \"R\", \"fields\": [\n"
+ "{ \"name\": \"f1\", \"type\": \"string\" },\n"
+ "{ \"name\": \"f2\", \"type\": \"string\" },\n"
+ "{ \"name\": \"f3\", \"type\": \"string\" }\n"
+ "] }";
-
+
static class GenericStrings extends GenericTest {
public GenericStrings() throws IOException {
super("GenericStrings", GENERIC_STRINGS);
@@ -1177,7 +1177,7 @@ public class Perf {
rec.put(0, randomString(r));
rec.put(1, randomString(r));
rec.put(2, randomString(r));
- sourceData[i] = rec;
+ sourceData[i] = rec;
}
}
}
@@ -1210,11 +1210,11 @@ public class Perf {
rec.put(3, r.nextInt());
rec.put(4, r.nextInt());
rec.put(5, r.nextInt());
- sourceData[i] = rec;
+ sourceData[i] = rec;
}
return sourceData;
}
-
+
static class GenericNestedFake extends BasicTest {
//reads and writes generic data, but not using
//GenericDatumReader or GenericDatumWriter
@@ -1267,7 +1267,7 @@ public class Perf {
data = null;
sourceData = null;
}
-
+
}
private static abstract class GenericResolving extends GenericTest {
@@ -1312,7 +1312,7 @@ public class Perf {
return new Schema.Parser().parse(RECORD_SCHEMA_WITH_PROMOTION);
}
}
-
+
static class GenericOneTimeDecoderUse extends GenericTest {
public GenericOneTimeDecoderUse() throws IOException {
super("GenericOneTimeDecoderUse_");
@@ -1487,7 +1487,7 @@ public class Perf {
return new Rec(r);
}
}
-
+
static class ReflectFloatTest extends ReflectTest<float[]> {
ReflectFloatTest() throws IOException {
super("ReflectFloat", new float[0], COUNT);
@@ -1531,7 +1531,7 @@ public class Perf {
return populateDoubleArray(r);
}
}
-
+
static class ReflectIntArrayTest extends ReflectTest<int[]> {
ReflectIntArrayTest() throws IOException {
super("ReflectIntArray", new int[0], 12);
@@ -1542,7 +1542,7 @@ public class Perf {
return populateIntArray(r);
}
}
-
+
static class ReflectLongArrayTest extends ReflectTest<long[]> {
ReflectLongArrayTest() throws IOException {
super("ReflectLongArray", new long[0], 24);
@@ -1571,7 +1571,7 @@ public class Perf {
Foo() {
}
-
+
Foo(Random r) {
bar = new Vals[smallArraySize(r)];
for (int i = 0; i < bar.length; i++) {
@@ -1588,7 +1588,7 @@ public class Perf {
Vals(){
}
-
+
Vals(Random r) {
this.f1 = r.nextFloat();
this.f2 = r.nextFloat();
@@ -1601,7 +1601,7 @@ public class Perf {
static public class FloatFoo {
float[] floatBar;
-
+
FloatFoo() {
}
@@ -1624,7 +1624,7 @@ public class Perf {
int size = large ? largeArraySize(r) : smallArraySize(r);
return populateFloatArray(r, size);
}
-
+
static float[] populateFloatArray(Random r, int size) {
float[] result = new float[size];
for (int i = 0; i < result.length; i++) {
@@ -1632,11 +1632,11 @@ public class Perf {
}
return result;
}
-
+
static double[] populateDoubleArray(Random r) {
return populateDoubleArray(r, smallArraySize(r));
}
-
+
static double[] populateDoubleArray(Random r, int size) {
double[] result = new double[size];
for (int i = 0; i < result.length; i++) {
@@ -1653,7 +1653,7 @@ public class Perf {
}
return result;
}
-
+
static long[] populateLongArray(Random r) {
int size = smallArraySize(r);
long[] result = new long[size];
@@ -1662,7 +1662,7 @@ public class Perf {
}
return result;
}
-
+
static class ReflectNestedFloatArrayTest extends ReflectTest<FloatFoo> {
public ReflectNestedFloatArrayTest() throws IOException {
super("ReflectNestedFloatArray", new FloatFoo(new Random(), false), 10);
@@ -1686,7 +1686,7 @@ public class Perf {
}
}
-
+
static class ReflectNestedLargeFloatArrayBlockedTest extends ReflectTest<FloatFoo> {
public ReflectNestedLargeFloatArrayBlockedTest() throws IOException {
super("ReflectNestedLargeFloatArrayBlocked", new FloatFoo(new Random(), true),
@@ -1697,7 +1697,7 @@ public class Perf {
protected FloatFoo createDatum(Random r) {
return new FloatFoo(r, true);
}
-
+
@Override
protected Encoder newEncoder(ByteArrayOutputStream out) throws IOException {
return new EncoderFactory().configureBlockSize(254).blockingBinaryEncoder(out, null);
@@ -1722,7 +1722,7 @@ public class Perf {
Rec1() {
}
-
+
Rec1(Random r) {
d1 = r.nextDouble();
d11 = r.nextDouble();
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestLocalTransceiver.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestLocalTransceiver.java b/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestLocalTransceiver.java
index 09f7078..47ee403 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestLocalTransceiver.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestLocalTransceiver.java
@@ -59,7 +59,7 @@ public class TestLocalTransceiver {
"m").getRequest());
params.put("x", new Utf8("hello"));
GenericRequestor r = new GenericRequestor(protocol, t);
-
+
for(int x = 0; x < 5; x++)
assertEquals(new Utf8("there"), r.request("m", params));
}
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java b/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java
index a39de4c..14981c3 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java
@@ -49,31 +49,31 @@ public class TestNettyServer {
public static class MailImpl implements Mail {
private CountDownLatch allMessages = new CountDownLatch(5);
-
+
// in this simple example just return details of the message
public String send(Message message) {
- return "Sent message to ["+ message.getTo().toString() +
- "] from [" + message.getFrom().toString() + "] with body [" +
+ return "Sent message to ["+ message.getTo().toString() +
+ "] from [" + message.getFrom().toString() + "] with body [" +
message.getBody().toString() + "]";
}
-
+
public void fireandforget(Message message) {
allMessages.countDown();
}
-
+
private void awaitMessages() throws InterruptedException {
allMessages.await(2, TimeUnit.SECONDS);
}
-
+
private void assertAllMessagesReceived() {
assertEquals(0, allMessages.getCount());
}
public void reset() {
- allMessages = new CountDownLatch(5);
+ allMessages = new CountDownLatch(5);
}
}
-
+
@BeforeClass
public static void initializeConnections()throws Exception {
// start server
@@ -82,23 +82,23 @@ public class TestNettyServer {
Responder responder = new SpecificResponder(Mail.class, mailService);
server = initializeServer(responder);
server.start();
-
+
int serverPort = server.getPort();
System.out.println("server port : " + serverPort);
transceiver = initializeTransceiver(serverPort);
proxy = SpecificRequestor.getClient(Mail.class, transceiver);
}
-
+
protected static Server initializeServer(Responder responder) {
return new NettyServer(responder, new InetSocketAddress(0));
}
-
+
protected static Transceiver initializeTransceiver(int serverPort) throws IOException {
return new NettyTransceiver(new InetSocketAddress(
serverPort), CONNECT_TIMEOUT_MILLIS);
}
-
+
@AfterClass
public static void tearDownConnections() throws Exception{
transceiver.close();
@@ -117,7 +117,7 @@ public class TestNettyServer {
"Sent message to [wife] from [husband] with body [I love you!]",
result.toString());
}
-
+
@Test
public void testOneway() throws Exception {
for (int x = 0; x < 5; x++) {
@@ -126,7 +126,7 @@ public class TestNettyServer {
mailService.awaitMessages();
mailService.assertAllMessagesReceived();
}
-
+
@Test
public void testMixtureOfRequests() throws Exception {
mailService.reset();
http://git-wip-us.apache.org/repos/asf/avro/blob/ade55151/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerConcurrentExecution.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerConcurrentExecution.java b/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerConcurrentExecution.java
index 6d3fd1e..8859998 100644
--- a/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerConcurrentExecution.java
+++ b/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerConcurrentExecution.java
@@ -37,31 +37,31 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Verifies that RPCs executed by different client threads using the same
+ * Verifies that RPCs executed by different client threads using the same
* NettyTransceiver will execute concurrently. The test follows these steps:
- * 1. Execute the {@link #org.apache.avro.test.Simple.add(int, int)} RPC to
+ * 1. Execute the {@link #org.apache.avro.test.Simple.add(int, int)} RPC to
* complete the Avro IPC handshake.
* 2a. In a background thread, wait for the waitLatch.
- * 3a. In the main thread, invoke
- * {@link #org.apache.avro.test.Simple.hello(String)} with the argument
- * "wait". This causes the ClientImpl running on the server to count down
- * the wait latch, which will unblock the background thread and allow it to
- * proceed. After counting down the latch, this call blocks, waiting for
+ * 3a. In the main thread, invoke
+ * {@link #org.apache.avro.test.Simple.hello(String)} with the argument
+ * "wait". This causes the ClientImpl running on the server to count down
+ * the wait latch, which will unblock the background thread and allow it to
+ * proceed. After counting down the latch, this call blocks, waiting for
* {@link #org.apache.avro.test.Simple.ack()} to be invoked.
- * 2b. The background thread wakes up because the waitLatch has been counted
+ * 2b. The background thread wakes up because the waitLatch has been counted
* down. Now we know that some thread is executing inside hello(String).
- * Next, execute {@link #org.apache.avro.test.Simple.ack()} in the
- * background thread, which will allow the thread executing hello(String)
+ * Next, execute {@link #org.apache.avro.test.Simple.ack()} in the
+ * background thread, which will allow the thread executing hello(String)
* to return.
- * 3b. The thread executing hello(String) on the server unblocks (since ack()
+ * 3b. The thread executing hello(String) on the server unblocks (since ack()
* has been called), allowing hello(String) to return.
- * 4. If control returns to the main thread, we know that two RPCs
+ * 4. If control returns to the main thread, we know that two RPCs
* (hello(String) and ack()) were executing concurrently.
*/
public class TestNettyServerConcurrentExecution {
private Server server;
private Transceiver transceiver;
-
+
@After
public void cleanUpAfter() throws Exception {
try {
@@ -79,41 +79,41 @@ public class TestNettyServerConcurrentExecution {
e.printStackTrace();
}
}
-
+
@Test(timeout=30000)
public void test() throws Exception {
final CountDownLatch waitLatch = new CountDownLatch(1);
server = new NettyServer(
- new SpecificResponder(Simple.class, new SimpleImpl(waitLatch)),
- new InetSocketAddress(0),
+ new SpecificResponder(Simple.class, new SimpleImpl(waitLatch)),
+ new InetSocketAddress(0),
new NioServerSocketChannelFactory
- (Executors.newCachedThreadPool(), Executors.newCachedThreadPool()),
+ (Executors.newCachedThreadPool(), Executors.newCachedThreadPool()),
new ExecutionHandler(Executors.newCachedThreadPool()));
server.start();
-
+
transceiver = new NettyTransceiver(new InetSocketAddress(
server.getPort()), TestNettyServer.CONNECT_TIMEOUT_MILLIS);
-
+
// 1. Create the RPC proxy, and establish the handshake:
- final Simple.Callback simpleClient =
+ final Simple.Callback simpleClient =
SpecificRequestor.getClient(Simple.Callback.class, transceiver);
SpecificRequestor.getRemote(simpleClient); // force handshake
-
+
/*
* 2a. In a background thread, wait for the Client.hello("wait") call to be
* received by the server, then:
- * 2b. Execute the Client.ack() RPC, which will unblock the
+ * 2b. Execute the Client.ack() RPC, which will unblock the
* Client.hello("wait") call, allowing it to return to the main thread.
*/
new Thread() {
@Override
public void run() {
- setName(TestNettyServerConcurrentExecution.class.getSimpleName() +
+ setName(TestNettyServerConcurrentExecution.class.getSimpleName() +
"Ack Thread");
try {
// Step 2a:
waitLatch.await();
-
+
// Step 2b:
simpleClient.ack();
} catch (InterruptedException e) {
@@ -121,27 +121,27 @@ public class TestNettyServerConcurrentExecution {
}
}
}.start();
-
+
/*
* 3. Execute the Client.hello("wait") RPC, which will block until the
* Client.ack() call has completed in the background thread.
*/
String response = simpleClient.hello("wait");
-
+
// 4. If control reaches here, both RPCs have executed concurrently
- Assert.assertEquals("wait", response);
+ Assert.assertEquals("wait", response);
}
/**
* Implementation of the Simple interface for use with this unit test.
- * If {@link #hello(String)} is called with "wait" as its argument,
- * {@link #waitLatch} will be counted down, and {@link #hello(String)} will
+ * If {@link #hello(String)} is called with "wait" as its argument,
+ * {@link #waitLatch} will be counted down, and {@link #hello(String)} will
* block until {@link #ack()} has been invoked.
*/
private static class SimpleImpl implements Simple {
private final CountDownLatch waitLatch;
private final CountDownLatch ackLatch = new CountDownLatch(1);
-
+
/**
* Creates a SimpleImpl that uses the given CountDownLatch.
* @param waitLatch the CountDownLatch to use in {@link #hello(String)}.
@@ -149,20 +149,20 @@ public class TestNettyServerConcurrentExecution {
public SimpleImpl(final CountDownLatch waitLatch) {
this.waitLatch = waitLatch;
}
-
+
@Override
public int add(int arg1, int arg2) throws AvroRemoteException {
// Step 1:
return arg1 + arg2;
}
-
+
@Override
public String hello(String greeting) throws AvroRemoteException {
if (greeting.equals("wait")) {
try {
// Step 3a:
waitLatch.countDown();
-
+
// Step 3b:
ackLatch.await();
} catch (InterruptedException e) {
@@ -172,15 +172,15 @@ public class TestNettyServerConcurrentExecution {
}
return greeting;
}
-
+
@Override
public void ack() {
// Step 2b:
ackLatch.countDown();
}
-
+
// All RPCs below this line are irrelevant to this test:
-
+
@Override
public TestRecord echo(TestRecord record) throws AvroRemoteException {
return record;