OpenLRBinaryEncoder implements PhysicalEncoder { public final LocationReference encodeData( final RawLocationReference rawLocRef) { return encodeData(rawLocRef, VERSIONS[VERSIONS.length - 1]); }  final Class<?> getDataClass(); final String getDataFormatIdentifier(); final int[] getSupportedVersions(); final LocationReference encodeData(
            final RawLocationReference rawLocRef); final LocationReference encodeData(
            final RawLocationReference rawLocRef, final int version);  }
@Test public final void testWhitepaperExample() { LocationReference ref = null; ref = BINARY_ENCODER.encodeData(lineLocRefWpExample); assertTrue(ref.isValid()); assertSame(ref.getVersion(), OpenLRBinaryConstants.BINARY_VERSION_3); Utils.checkBinData((ByteArray) ref.getLocationReferenceData(), DATA_WP_EXAMPLE, OpenLRBinaryConstants.BINARY_VERSION_3); }
@Test public final void testInvalidLocationEncoding() { LocationReference result = BINARY_ENCODER.encodeData(lineLocRefEmpty); assertFalse(result.isValid()); assertSame(result.getReturnCode(), MISSING_DATA); assertNotNull(result.toString()); assertNull(result.getLocationReferenceData()); }
@Test public final void testOffsetsNull() { LocationReference result = BINARY_ENCODER .encodeData(lineLocRefOffsetsNull); assertFalse(result.isValid()); assertSame(result.getReturnCode(), MISSING_DATA); }
@Test public final void testValidWithNoOffsets() { LocationReference ref = null; ref = BINARY_ENCODER.encodeData(lineLocRefValidOffset0); assertTrue(ref.isValid()); if (!"binary".equals(ref.getDataIdentifier())) { fail("Invalid data identifier"); } if (!checkDataClass(ref)) { fail("invalid data class"); } assertSame(ref.getVersion(), OpenLRBinaryConstants.LATEST_BINARY_VERSION); Utils.checkBinData((ByteArray) ref.getLocationReferenceData(), DATA_VALID_NO_OFFSETS_V3, OpenLRBinaryConstants.LATEST_BINARY_VERSION); }
@Test public final void testValidWithOffsets() { LocationReference ref = null; ref = BINARY_ENCODER.encodeData(lineLocRefValidWithOffset); assertTrue(ref.isValid()); if (!"binary".equals(ref.getDataIdentifier())) { fail("Invalid data identifier"); } if (!checkDataClass(ref)) { fail("invalid data class"); } assertSame(ref.getVersion(), OpenLRBinaryConstants.LATEST_BINARY_VERSION); Utils.checkBinData((ByteArray) ref.getLocationReferenceData(), DATA_VALID_WITH_OFFSETS_V3, OpenLRBinaryConstants.LATEST_BINARY_VERSION); }
@Test public final void testOffsetsTooLong() { LocationReference ref = null; ref = BINARY_ENCODER.encodeData(lineLocRefValidOffsetTooLong); assertFalse(ref.isValid()); assertSame(ref.getReturnCode(), INVALID_OFFSET); }