@Test
	public void testInstallingNewExtension_SameName_SaveVersion() throws Exception {

		// install extension Foo with Ghidra version
		File buildFolder = createTempDirectory(BUILD_FOLDER_NAME);
		String appVersion = Application.getApplicationVersion();
		File extensionFolder =
			doCreateExternalExtensionInFolder(buildFolder, TEST_EXT_NAME, appVersion);
		assertTrue(ExtensionInstaller.install(extensionFolder));

		Set<ExtensionDetails> extensions = ExtensionUtils.getInstalledExtensions();
		assertEquals(extensions.size(), 1);
		ExtensionDetails installedExtension = extensions.iterator().next();

		// create another extension Foo v2
		File buildFolder2 = createTempDirectory("TestExtensionParentDir2");
		String newVersion = appVersion;
		File extensionFolder2 =
			doCreateExternalExtensionInFolder(buildFolder2, TEST_EXT_NAME, newVersion);

		AtomicBoolean didInstall = new AtomicBoolean();
		runSwingLater(() -> {
			didInstall.set(ExtensionInstaller.install(extensionFolder2));
		});

		DialogComponentProvider confirmDialog = waitForDialogComponent("Duplicate Extension");
		pressButtonByText(confirmDialog, "Remove Existing");

		waitForSwing();
		assertFalse(didInstall.get());
		checkMarkForUninstall(installedExtension);

		// run again after choosing to replace the installed extension
		ExtensionUtils.initializeExtensions(); // removed marked extensions
		checkCleanInstall();

		runSwingLater(() -> {
			didInstall.set(ExtensionInstaller.install(extensionFolder2));
		});

		waitFor(didInstall);
		assertExtensionInstalled(TEST_EXT_NAME, newVersion);
		assertEquals(1, ExtensionUtils.getInstalledExtensions().size());
	}
Tests for the {@link ExtensionInstaller} class.
Ghidra/Framework/Project/src/test/java/ghidra/framework/project/extensions/ExtensionInstallerTest.java