java_gen: support testing classes without builders

Some classes, like OFInstructionBsnDisableSrcMacCheck, don't have any data
members and so have a single immutable instance and no builder. This change
fixes the unit tests to use the correct factory method.
diff --git a/java_gen/templates/unit_test.java b/java_gen/templates/unit_test.java
index ad2c3b8..cf01429 100644
--- a/java_gen/templates/unit_test.java
+++ b/java_gen/templates/unit_test.java
@@ -46,7 +46,8 @@
     //:: factory = java_model.model.factory_of(test.interface)
     //:: var_type = msg.interface.name
     //:: var_name = msg.interface.variable_name
-    //:: builder_method = factory.method_name(msg.interface)
+    //:: use_builder = len(msg.data_members) > 0
+    //:: factory_method = factory.method_name(msg.interface, builder=use_builder)
     //:: factory_impl = java_model.model.factory_of(test.interface).of_version(test.java_class.version).name
     ${factory.name if factory.name is not None else "OFFactory"} factory;
 
@@ -61,9 +62,13 @@
     //:: if "java" in test_data:
     @Test
     public void testWrite() {
-        ${var_type}.Builder builder = factory.${builder_method}();
+        //:: if use_builder:
+        ${var_type}.Builder builder = factory.${factory_method}();
         ${test_data["java"]};
         ${var_type} ${var_name} = builder.build();
+        //:: else:
+        ${var_type} ${var_name} = factory.${factory_method}();
+        //:: #endif
         ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
         ${var_name}.writeTo(bb);
         byte[] written = new byte[bb.readableBytes()];
@@ -74,9 +79,13 @@
 
     @Test
     public void testRead() throws Exception {
-        ${var_type}.Builder builder = factory.${builder_method}();
+        //:: if use_builder:
+        ${var_type}.Builder builder = factory.${factory_method}();
         ${test_data["java"]};
         ${var_type} ${var_name}Built = builder.build();
+        //:: else:
+        ${var_type} ${var_name}Built = factory.${factory_method}();
+        //:: #endif
 
         ChannelBuffer input = ChannelBuffers.copiedBuffer(${msg.constant_name}_SERIALIZED);