+ private static interface IFastTransformFactory {
+ public TmfTimestampTransformLinearFast create(double alpha, double beta);
+ }
+
+ private static final IFastTransformFactory fNewObject = (a, b) -> {
+ return new TmfTimestampTransformLinearFast(a, b);
+ };
+
+ private static final IFastTransformFactory fDeserialized = (a, b) -> {
+ TmfTimestampTransformLinearFast tt = new TmfTimestampTransformLinearFast(a, b);
+ /* Serialize the object */
+ String filePath = null;
+ try {
+ File temp = File.createTempFile("serialSyncAlgo", ".tmp");
+ filePath = temp.getAbsolutePath();
+ } catch (IOException e) {
+ fail("Could not create temporary file for serialization");
+ }
+ assertNotNull(filePath);
+
+ try (FileOutputStream fileOut = new FileOutputStream(filePath);
+ ObjectOutputStream out = new ObjectOutputStream(fileOut);) {
+ out.writeObject(tt);
+ } catch (IOException e) {
+ fail("Error serializing the synchronization algorithm " + e.getMessage());
+ }
+
+ TmfTimestampTransformLinearFast deserialTt = null;
+ /* De-Serialize the object */
+ try (FileInputStream fileIn = new FileInputStream(filePath);
+ ObjectInputStream in = new ObjectInputStream(fileIn);) {
+ deserialTt = (TmfTimestampTransformLinearFast) in.readObject();
+ } catch (IOException | ClassNotFoundException e) {
+ fail("Error de-serializing the synchronization algorithm " + e.getMessage());
+ }
+ return deserialTt;
+ };
+
+ private final IFastTransformFactory fTransformFactory;
+
+ /**
+ * Constructor
+ *
+ * @param name
+ * The name of this parameterized test
+ * @param factory
+ * Factory to create the timestamp transform
+ */
+ public TsTransformFastTest(String name, IFastTransformFactory factory) {
+ fTransformFactory = factory;
+ }
+
+ /**
+ * @return the test parameters
+ */
+ @Parameters(name = "Factory={0}")
+ public static Iterable<Object[]> parameters() {
+ return Arrays.asList(new Object[][] {
+ { "Object", fNewObject },
+ { "Deserialized", fDeserialized }
+ });
+ }
+