@Test
	public void testCreateWorkspace() throws Exception {

		// get project (create it if it doesn't exist...)

		ToolManager tm = project.getToolManager();
		String userName = SystemUtilities.getUserName();

		tm.createWorkspace(userName);

		try {
			tm.createWorkspace(userName);
			Assert.fail("Should have gotten DuplicateNameException for " + userName);
		}
		catch (DuplicateNameException e) {
			// expected
		}

		tm.createWorkspace(userName + "(1)");
		tm.createWorkspace(userName + "(2)");

		// get list of workspaces...
		Workspace[] wspaces = tm.getWorkspaces();
		for (Workspace wspace : wspaces) {
			System.out.println("Found workspace " + wspace.getName());
		}

		// should have 4 workspaces now: the default workspace, the username,
		// username(1) and username(2)
		assertEquals(4, wspaces.length);
		assertEquals("Workspace", wspaces[0].getName());
		assertEquals(userName, wspaces[1].getName());
		assertEquals(userName + "(1)", wspaces[2].getName());
		assertEquals(userName + "(2)", wspaces[3].getName());

		// now delete one workspace
		tm.removeWorkspace(wspaces[2]); // 3rd workspace is username(1)

		wspaces = tm.getWorkspaces();
		assertEquals(3, wspaces.length);

		for (Workspace wspace : wspaces) {
			if (wspace.getName().equals(userName + "(1)")) {
				Assert.fail("Should have deleted workspace " + wspace.getName());
			}
		}

		try {
			// now rename workspace to an existing name
			wspaces[0].setName(userName);
			Assert.fail("DuplicateNameException expected");
		}
		catch (DuplicateNameException e) {
			// expected
		}

		wspaces[1].setName("WORKSPACE-1");
		assertEquals("WORKSPACE-1", wspaces[1].getName());

		// now add a launch a tool in the workspace
		setWorkspaceActive(wspaces[0]);

		final Workspace workspace = wspaces[0];
		runSwing(new Runnable() {
			@Override
			public void run() {
				workspace.createTool();
			}
		});

		PluginTool[] runningTools = wspaces[0].getTools();
		assertEquals(1, runningTools.length);

		setWorkspaceActive(wspaces[1]);

		runningTools = wspaces[0].getTools();

		project.save();

		runSwing(new Runnable() {
			@Override
			public void run() {
				project.close();
			}
		});

		// now restore it
		runSwing(new Runnable() {
			@Override
			public void run() {
				try {
					project = ProjectTestUtils.getProject(DIRECTORY_NAME, PROJECT_NAME);
				}
				catch (LockException exc) {
					exc.printStackTrace();
					Assert.fail();
				}
				catch (IOException exc) {
					exc.printStackTrace();
					Assert.fail();
				}
			}
		});

		tm = project.getToolManager();
		wspaces = tm.getWorkspaces();
		for (Workspace wspace : wspaces) {
			System.out.println("** Workspace " + wspace.getName());
		}

		assertEquals(3, wspaces.length);
		assertEquals("Workspace", wspaces[0].getName());
		assertEquals("WORKSPACE-1", wspaces[1].getName());
		assertEquals(userName + "(2)", wspaces[2].getName());

		assertEquals(wspaces[1], tm.getActiveWorkspace());

	}
Do the test.
@param args same args that are passed to RegressionTester.main()
Ghidra/Features/Base/src/test.slow/java/ghidra/framework/project/tool/CreateWorkspaceTest.java