|
18 | 18 |
|
19 | 19 | import static com.netflix.hollow.core.HollowConstants.VERSION_LATEST;
|
20 | 20 | import static com.netflix.hollow.core.HollowConstants.VERSION_NONE;
|
| 21 | +import static com.netflix.hollow.core.HollowStateEngine.HEADER_TAG_PRODUCER_TO_VERSION; |
21 | 22 | import static com.netflix.hollow.core.HollowStateEngine.HEADER_TAG_SCHEMA_HASH;
|
22 | 23 | import static java.util.Collections.emptyList;
|
23 | 24 | import static org.junit.Assert.assertEquals;
|
|
46 | 47 | import com.netflix.hollow.test.consumer.TestHollowConsumer;
|
47 | 48 | import java.io.ByteArrayInputStream;
|
48 | 49 | import java.io.ByteArrayOutputStream;
|
| 50 | +import java.io.IOException; |
49 | 51 | import java.util.HashMap;
|
50 | 52 | import java.util.Map;
|
51 | 53 | import java.util.Optional;
|
|
55 | 57 | import java.util.logging.LogManager;
|
56 | 58 | import java.util.logging.LogRecord;
|
57 | 59 | import java.util.logging.Logger;
|
| 60 | + |
| 61 | +import org.junit.Assert; |
58 | 62 | import org.junit.Before;
|
59 | 63 | import org.junit.Rule;
|
60 | 64 | import org.junit.Test;
|
@@ -98,6 +102,26 @@ public void testUpdateTo_noVersions() throws Throwable {
|
98 | 102 | assertTrue("Should still have no types", readStateEngine.getAllTypes().isEmpty());
|
99 | 103 | }
|
100 | 104 |
|
| 105 | + @Test |
| 106 | + public void testUpdateTo_updateToLatestButBlobOnDifferentVersion() throws Throwable { |
| 107 | + long updateToVersion = 1234; |
| 108 | + long blobToVersion = 1235; //this needs to be different from updateToVersion |
| 109 | + HollowWriteStateEngine writeStateEngine = new HollowWriteStateEngine(); |
| 110 | + writeStateEngine.addHeaderTag(HEADER_TAG_PRODUCER_TO_VERSION, String.valueOf(blobToVersion)); |
| 111 | + ByteArrayOutputStream os = new ByteArrayOutputStream(); |
| 112 | + new HollowBlobWriter(writeStateEngine).writeSnapshot(os); |
| 113 | + ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); |
| 114 | + HollowConsumer.Blob blob = mock(HollowConsumer.Blob.class); |
| 115 | + when(blob.isSnapshot()) |
| 116 | + .thenReturn(true); |
| 117 | + when(blob.getInputStream()) |
| 118 | + .thenReturn(is); |
| 119 | + when(retriever.retrieveSnapshotBlob(anyLong())) |
| 120 | + .thenReturn(blob); |
| 121 | + subject.updateTo(updateToVersion); |
| 122 | + Assert.assertEquals(subject.getCurrentVersionId(), blobToVersion); |
| 123 | + } |
| 124 | + |
101 | 125 | @Rule
|
102 | 126 | public ExpectedException expectedException = ExpectedException.none();
|
103 | 127 |
|
|
0 commit comments