X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotobuff%2Fmessages%2FAbstractMessagesTest.java;h=d3c5f97881b2d0fc40f4b7e03ff0833f887484b7;hb=4e696d9795fe7eef40369c05c340d137394126f3;hp=bef1f41b0acd8cdda0f5d954acdce48cd91feb3b;hpb=5679203b147817962534344db273e4f2109fd949;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java index bef1f41b0a..d3c5f97881 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java @@ -18,60 +18,50 @@ import java.io.FileOutputStream; * @author: syedbahm Date: 7/31/14 */ public abstract class AbstractMessagesTest { - public final String VERSION_COMPATIBILTY_TEST_DATA_PATH = "." - + File.separator + "src" + File.separator + "test" + File.separator - + "resources" + File.separator + "version-compatibility-serialized-data"; - private File file; - private File testDataFile; - - protected AbstractMessagesTest() { - init(); - } - - protected void init() { - file = new File(getTestFileName()); - testDataFile = - new File(VERSION_COMPATIBILTY_TEST_DATA_PATH + File.separator - + getTestFileName() + "Data"); - } - - - - abstract public void verifySerialization() throws Exception; - - - protected void writeToFile( - com.google.protobuf.GeneratedMessage.Builder builder) throws Exception { - - FileOutputStream output = new FileOutputStream(file); - builder.build().writeTo(output); - output.close(); - - } - - protected com.google.protobuf.GeneratedMessage readFromFile( - com.google.protobuf.Parser parser) throws Exception { - com.google.protobuf.GeneratedMessage message = - (com.google.protobuf.GeneratedMessage) parser - .parseFrom(new FileInputStream(file)); - - /*Note: we will delete only the test file -- comment below if you want to capture the - version-compatibility-serialized-data test data file.The file will be generated at root of the - sal-protocolbuffer-encoding - and you need to move it to test/resources/version-compatbility-serialized-data folder renaming the file to include suffix "Data" - */ - file.delete(); - return message; - } - - protected com.google.protobuf.GeneratedMessage readFromTestDataFile( - com.google.protobuf.Parser parser) throws Exception { - return (com.google.protobuf.GeneratedMessage) parser - .parseFrom(new FileInputStream(testDataFile)); - } - - - public abstract String getTestFileName(); - - + public final String VERSION_COMPATIBILTY_TEST_DATA_PATH = "." + File.separator + "src" + File.separator + "test" + + File.separator + "resources" + File.separator + "version-compatibility-serialized-data"; + private File file; + private File testDataFile; + + protected AbstractMessagesTest() { + init(); + } + + protected void init() { + file = new File(getTestFileName()); + testDataFile = new File(VERSION_COMPATIBILTY_TEST_DATA_PATH + File.separator + getTestFileName() + "Data"); + } + + abstract public void verifySerialization() throws Exception; + + protected void writeToFile(com.google.protobuf.GeneratedMessage.Builder builder) throws Exception { + + FileOutputStream output = new FileOutputStream(file); + builder.build().writeTo(output); + output.close(); + + } + + protected com.google.protobuf.GeneratedMessage readFromFile(com.google.protobuf.Parser parser) throws Exception { + com.google.protobuf.GeneratedMessage message = (com.google.protobuf.GeneratedMessage) parser + .parseFrom(new FileInputStream(file)); + + /* + * Note: we will delete only the test file -- comment below if you want + * to capture the version-compatibility-serialized-data test data + * file.The file will be generated at root of the + * sal-protocolbuffer-encoding and you need to move it to + * test/resources/version-compatbility-serialized-data folder renaming + * the file to include suffix "Data" + */ + file.delete(); + return message; + } + + protected com.google.protobuf.GeneratedMessage readFromTestDataFile(com.google.protobuf.Parser parser) + throws Exception { + return (com.google.protobuf.GeneratedMessage) parser.parseFrom(new FileInputStream(testDataFile)); + } + + public abstract String getTestFileName(); }