@Test
	public void testSaveToExistingNameCancel() throws Exception {
		ToolChest tc = tool.getProject().getLocalToolChest();
		// save tool to the tool chest
		tool.setToolName("MyTestTool");

		SwingUtilities.invokeLater(() -> tool.getToolServices().saveTool(tool));
		while (tc.getToolTemplate("MyTestTool") == null) {
			Thread.sleep(10);
		}
		waitForSwing();

		setText(toolNameField, "MyTestTool", false);

		runSwing(() -> {
			// force a change to the tool config
			try {
				tool.addPlugin(ByteViewerPlugin.class.getName());
				tool.setConfigChanged(true);
			}
			catch (PluginException e) {
				throw new AssertException();
			}
		});

		SwingUtilities.invokeLater(() -> {
			JButton saveButton = findButtonByText(saveDialog, "Save");
			saveButton.getActionListeners()[0].actionPerformed(null);
		});
		waitForSwing();

		final OptionDialog d = waitForDialogComponent(OptionDialog.class);
		assertNotNull(d);
		assertEquals("Overwrite Tool?", d.getTitle());
		pressButtonByText(d.getComponent(), "Cancel");

		while (d.isVisible()) {
			Thread.sleep(10);
		}
		waitForSwing();

		assertTrue(tool.hasConfigChanged());
	}
Tests for saving the tool config.
Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/framework/plugintool/dialog/SaveToolConfigDialogTest.java