Fixes to in ports masked
Conflicts:
test_data/of13/oxm_bsn_in_ports_masked_128.data
diff --git a/java_gen/templates/unit_test.java b/java_gen/templates/unit_test.java
index 47dcc24..7fb52bb 100644
--- a/java_gen/templates/unit_test.java
+++ b/java_gen/templates/unit_test.java
@@ -28,6 +28,7 @@
//:: from loxi_ir import *
//:: import itertools
//:: import of_g
+//:: import java_gen.java_model as java_model
//:: include('_copyright.java')
//:: include('_autogen.java')
@@ -40,22 +41,25 @@
import static org.junit.Assert.*;
public class ${test.name} {
+ //:: factory = java_model.model.factory_of(test.interface)
//:: var_type = msg.interface.name
//:: var_name = msg.interface.variable_name
- OFFactory factory;
+ //:: builder_method = factory.method_name(msg.interface)
+ //:: 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;
final static byte[] ${msg.constant_name}_SERIALIZED =
new byte[] { ${", ".join("%s0x%x" % (("" if ord(c)<128 else "(byte) "), ord(c)) for c in test_data["binary"] ) } };
@Before
public void setup() {
- factory = OFFactories.getFactory(OFVersion.${version.constant_version});
+ factory = ${factory_impl + ".INSTANCE" if factory_impl is not None else "OFFactories.getFactory(OFVersion." + version.constant_version + ")"};
}
//:: if "java" in test_data:
@Test
public void testWrite() {
- ${var_type}.Builder builder = factory.build${var_type[2:]}();
+ ${var_type}.Builder builder = factory.${builder_method}();
${test_data["java"]};
${var_type} ${var_name} = builder.build();
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
@@ -68,7 +72,7 @@
@Test
public void testRead() throws Exception {
- ${var_type}.Builder builder = factory.build${var_type[2:]}();
+ ${var_type}.Builder builder = factory.${builder_method}();
${test_data["java"]};
${var_type} ${var_name}Built = builder.build();