@Test
	public void testByteViewerPasteAsciiBytes() throws Exception {
		final DockingAction byteViewerPasteAction =
			getAction(byteViewerClipboardProvider, PASTE_ACTION_NAME);
		//
		// Test that we can paste characters from clipboard that contain some other special characters
		// that are not normal ascii text and only the normal ascii text will get pasted.
		// So, we have to perform the following steps to test the code:
		// 1) Put ill formed characters into clipboard
		// 2) Put the cursor on the byte viewer address for pasting.
		// 3) Paste the bytes
		// 4) Verify the bytes don't contain the non-ascii text.
		//

		final char[] droppedChars =
			new char[] { (char) 0x30, (char) 0x31, (char) 0xa0, (char) 0xc2, (char) 0x01,
				(char) 0x63, (char) 0x30, (char) 0xa0, (char) 0x35, (char) 0x65, (char) 0x20 };
//		final byte[] pastedBytes =
//			new byte[] { (byte) 0x30, (byte) 0x31, (byte) 0x63, (byte) 0x30, (byte) 0x35,
//				(byte) 0x65 };
		final byte[] resultBytes = new byte[] { (byte) 0x01, (byte) 0xc0, (byte) 0x5e };

		Clipboard systemClipboard = GClipboard.getSystemClipboard();
		Transferable transferable = new Transferable() {

			@Override
			public boolean isDataFlavorSupported(DataFlavor flavor) {
				if (flavor.equals(DataFlavor.stringFlavor)) {
					return true;
				}
				return false;
			}

			@Override
			public DataFlavor[] getTransferDataFlavors() {
				return new DataFlavor[] { DataFlavor.stringFlavor };
			}

			@Override
			public Object getTransferData(DataFlavor flavor)
					throws UnsupportedFlavorException, IOException {
				if (flavor.equals(DataFlavor.stringFlavor)) {
					return new String(droppedChars);
				}
				return null;
			}
		};
		// 1) Put ill formed characters into clipboard
		systemClipboard.setContents(transferable, (clipboard, contents) -> {
			// dummy listener so that we can be properly garbage collected
		});
		Transferable contents = systemClipboard.getContents(systemClipboard);
		assertNotNull(contents);
		assertTrue("Contents not copied into system clipboard", (contents != DUMMY_TRANSFERABLE));
		Object data = contents.getTransferData(DataFlavor.stringFlavor);
		assertEquals(new String(droppedChars), data);

		Address address = program.getAddressFactory().getAddress("01002cf0");
		AddressFieldLocation location = new AddressFieldLocation(program, address);
		// 2) Put the cursor on the byte viewer address for pasting.
		codeBrowserPlugin.goTo(location);

		// change the edit state of the byte viewer and make sure we can paste
		setByteViewerEditable(true);

		assertTrue(byteViewerPasteAction.isEnabled());

		// 3) Paste the bytes
		runSwing(() -> byteViewerPasteAction.actionPerformed(getActionContext(byteViewerWrapper)),
			false);

		OptionDialog d = waitForDialogComponent(OptionDialog.class);
		pressButton(d.getDefaultButton());

		waitForSwing();

		Memory memory = program.getMemory();
		byte[] memoryBytes = new byte[resultBytes.length];
		// 4) Verify the bytes don't contain the non-ascii text.
		memory.getBytes(address, memoryBytes, 0, resultBytes.length);
		assertTrue("The expected bytes were not pasted in the ByteViewer.",
			Arrays.equals(resultBytes, memoryBytes));
	}
Note: This test is sensitive to focus. So, don't click any windows while this test is running.
Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/clipboard/ClipboardPluginTest.java