### Question:
NonFinalPluginExpiry { public static void verifyRetirementAge() { if (true) return; URLClassLoader cl = (URLClassLoader) NonFinalPluginExpiry.class.getClassLoader(); try (InputStream inputStream = cl.findResource("META-INF/MANIFEST.MF").openStream()) { verifyRetirementAge( LocalDate.now(), new Manifest(inputStream), System.getenv("ANDROID_DAILY_OVERRIDE")); } catch (IOException ignore) {} } private  NonFinalPluginExpiry(); static void verifyRetirementAge();  }### Answer:
@Test public void testFinalPlugin() { NonFinalPluginExpiry.verifyRetirementAge( TESTING_NOW, createManifest("2.2.0", INCEPTION_DATE_FOR_OLD_PLUGIN), null); }
@Test public void testExpiredNonFinalPlugin() { try { NonFinalPluginExpiry.verifyRetirementAge( TESTING_NOW, createManifest("2.2.0-rc4", INCEPTION_DATE_FOR_OLD_PLUGIN), null); throw new AssertionError("expected AndroidGradlePluginTooOldException"); } catch (NonFinalPluginExpiry.AndroidGradlePluginTooOldException e) { assertThat(e.getMessage()).contains("2.2.0-rc4"); } }
@Test public void testCurrentNonFinalPlugin() { NonFinalPluginExpiry.verifyRetirementAge( TESTING_NOW, createManifest("2.2.0-rc4", INCEPTION_DATE_FOR_NEW_PLUGIN), null); }
@Test public void unitTestEnvironmentTest() { NonFinalPluginExpiry.verifyRetirementAge(TESTING_NOW, new Manifest(), null); }
@Test public void testSettingOverride() { Manifest tooOld = createManifest("2.2.0-rc4", INCEPTION_DATE_FOR_OLD_PLUGIN); String override; try { NonFinalPluginExpiry.verifyRetirementAge(TESTING_NOW, tooOld, null); throw new AssertionError("expected AndroidGradlePluginTooOldException"); } catch (NonFinalPluginExpiry.AndroidGradlePluginTooOldException e) { String message = e.getMessage(); assertThat(message.indexOf('"')) .named("Message contains quoted string.") .isNotEqualTo(message.lastIndexOf('"')); override = message.substring(message.indexOf('"') + 1, message.lastIndexOf('"')); } NonFinalPluginExpiry.verifyRetirementAge(TESTING_NOW, tooOld, override); String override2; try { NonFinalPluginExpiry.verifyRetirementAge(TESTING_NOW.plusDays(1), tooOld, override); throw new AssertionError("expected AndroidGradlePluginTooOldException"); } catch (NonFinalPluginExpiry.AndroidGradlePluginTooOldException e) { String message = e.getMessage(); assertThat(message).contains("outdated"); assertThat(message.indexOf('"')) .named("Message contains quoted string.") .isNotEqualTo(message.lastIndexOf('"')); override2 = message.substring(message.indexOf('"') + 1, message.lastIndexOf('"')); } assertThat(override).isNotEqualTo(override2); NonFinalPluginExpiry.verifyRetirementAge(TESTING_NOW.plusDays(1), tooOld, override2); }
@Test public void testVersionSpecificOverride() { NonFinalPluginExpiry.verifyRetirementAge( TESTING_NOW, createManifest( Version.ANDROID_GRADLE_PLUGIN_VERSION, INCEPTION_DATE_FOR_OLD_PLUGIN), String.valueOf(Version.ANDROID_GRADLE_PLUGIN_VERSION.hashCode())); }
@Test public void testIncorrectVersionSpecificOverride() { try { NonFinalPluginExpiry.verifyRetirementAge( TESTING_NOW, createManifest("2.4.0-rc2", INCEPTION_DATE_FOR_OLD_PLUGIN), String.valueOf("2.4.0-rc3".hashCode())); } catch (NonFinalPluginExpiry.AndroidGradlePluginTooOldException e) { assertThat(e.getMessage()).contains("2.4.0-rc2"); } }