@Test public void shouldThrowIfTooOldVersion() throws ClassNotFoundException { boolean passed = false; IndexAnalysisSettingsUpgrader upgrader = new IndexAnalysisSettingsUpgrader(); try { upgrader.upgrade(new byte[0], 1); } catch (IOException e) { assertTrue(e.getMessage().startsWith("Too old version")); passed = true; } assertTrue("should have thrown on too-old version", passed); }
public IndexAnalysisSettings3 upgrade(byte[] bytes, int objectVersion) throws ClassNotFoundException, IOException { switch (objectVersion) { case 1: throw new IOException("Too old version " + objectVersion); case 2: IndexAnalysisSettings old2 = IndexAnalysisSettings.deserialize(bytes); return convertFromV2(old2); case 3: return IndexAnalysisSettings3.deserialize(bytes); default: throw new IllegalArgumentException("Unknown version " + objectVersion); } }
IndexAnalysisSettingsUpgrader { public IndexAnalysisSettings3 upgrade(byte[] bytes, int objectVersion) throws ClassNotFoundException, IOException { switch (objectVersion) { case 1: throw new IOException("Too old version " + objectVersion); case 2: IndexAnalysisSettings old2 = IndexAnalysisSettings.deserialize(bytes); return convertFromV2(old2); case 3: return IndexAnalysisSettings3.deserialize(bytes); default: throw new IllegalArgumentException("Unknown version " + objectVersion); } } }
IndexAnalysisSettingsUpgrader { public IndexAnalysisSettings3 upgrade(byte[] bytes, int objectVersion) throws ClassNotFoundException, IOException { switch (objectVersion) { case 1: throw new IOException("Too old version " + objectVersion); case 2: IndexAnalysisSettings old2 = IndexAnalysisSettings.deserialize(bytes); return convertFromV2(old2); case 3: return IndexAnalysisSettings3.deserialize(bytes); default: throw new IllegalArgumentException("Unknown version " + objectVersion); } }  }
IndexAnalysisSettingsUpgrader { public IndexAnalysisSettings3 upgrade(byte[] bytes, int objectVersion) throws ClassNotFoundException, IOException { switch (objectVersion) { case 1: throw new IOException("Too old version " + objectVersion); case 2: IndexAnalysisSettings old2 = IndexAnalysisSettings.deserialize(bytes); return convertFromV2(old2); case 3: return IndexAnalysisSettings3.deserialize(bytes); default: throw new IllegalArgumentException("Unknown version " + objectVersion); } }  IndexAnalysisSettings3 upgrade(byte[] bytes, int objectVersion); }
IndexAnalysisSettingsUpgrader { public IndexAnalysisSettings3 upgrade(byte[] bytes, int objectVersion) throws ClassNotFoundException, IOException { switch (objectVersion) { case 1: throw new IOException("Too old version " + objectVersion); case 2: IndexAnalysisSettings old2 = IndexAnalysisSettings.deserialize(bytes); return convertFromV2(old2); case 3: return IndexAnalysisSettings3.deserialize(bytes); default: throw new IllegalArgumentException("Unknown version " + objectVersion); } }  IndexAnalysisSettings3 upgrade(byte[] bytes, int objectVersion);  }