List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS
boolean IS_OS_WINDOWS
To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.
Click Source Link
Is true
if this is Windows.
The field will return false
if OS_NAME
is null
.
From source file:org.codice.ddf.catalog.content.plugin.video.VideoThumbnailPluginTest.java
@BeforeClass public static void setUpClass() { Assume.assumeFalse("Skip unit tests on Windows. See DDF-3503.", SystemUtils.IS_OS_WINDOWS); }
From source file:org.dataconservancy.dcs.util.FilePathUtilTest.java
@Test public void testIllegalCharacterDetectedInPath() throws IOException { //This test doesn't run on windows if (!SystemUtils.IS_OS_WINDOWS) { final File testFile = tmpFolder.newFolder("testIllegalCharacterDetectedInPath:oops"); Assert.assertFalse(FilePathUtil.hasValidFilePath(testFile)); }/*from w ww. ja v a 2 s.com*/ }
From source file:org.eclipse.ice.developer.actions.LaunchNewICEHandler.java
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // Get the Launch Manager ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); if (manager != null) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject productProject = root.getProject("org.eclipse.ice.product"); if (productProject != null) { // Local Declarations ArrayList<String> currentPlugins = new ArrayList<String>(); ArrayList<String> notIncludedProjects = new ArrayList<String>(); String fileName = "", currentPluginsStr = "", key = "selected_workspace_plugins"; String vmArgs = "", vmArgsKey = "org.eclipse.jdt.launching.VM_ARGUMENTS"; String[] plugins;//from w w w.ja v a 2 s. c o m // Get the proper file name if (SystemUtils.IS_OS_WINDOWS) { fileName = "ice.product_WINDOWS.launch"; } else if (SystemUtils.IS_OS_MAC_OSX) { fileName = "ice.macosx_product.launch"; } else if (SystemUtils.IS_OS_LINUX) { fileName = "ice.product_linux.launch"; } else { throw new ExecutionException("Could not get the current OS. Cannot launch new version of ICE."); } // Get the Launch Configurations files IFile launchICE = productProject.getFile("modified_" + fileName); if (!launchICE.exists()) { IFile tempCopy = productProject.getFile(fileName); try { launchICE.create(tempCopy.getContents(), true, null); } catch (CoreException e1) { e1.printStackTrace(); logger.error("Could not create file withe name modified_" + fileName, e1); } } // Get the Launch Configuration from those files ILaunchConfiguration launchConfig = manager.getLaunchConfiguration(launchICE); try { currentPluginsStr = launchConfig.getAttribute(key, ""); vmArgs = launchConfig.getAttribute(vmArgsKey, ""); vmArgs = vmArgs.replace("org.eclipse.equinox.http.jetty.http.port=8081", "org.eclipse.equinox.http.jetty.http.port=8082"); // Put all workspace plugins in the launch config into a // list plugins = currentPluginsStr.split(","); for (String s : plugins) { currentPlugins.add(s.split("@")[0]); } // Get any project name that is not currently in the run // config List<String> pluginsToIgnore = Arrays.asList("org.eclipse.ice.aggregator", "reflectivity", "xsede", "ICEDocCleaner", "all", "default", "developerMenu", "dynamicUI", "fileFormats", "installation", "introToPTP", "itemDB", "moose-tutorial", "newItemGeneration", "org.eclipse.ice.examples.reflectivity", "org.eclipse.ice.installer", "org.eclipse.ice.parent", "org.eclipse.ice.product", "org.eclipse.ice.repository"); for (IProject p : root.getProjects()) { String name = p.getName(); if (!currentPlugins.contains(p.getName()) && !name.endsWith(".test") && !name.contains("Tutorial") && !name.contains("target.") && !name.contains("feature") && !pluginsToIgnore.contains(name)) { notIncludedProjects.add(p.getName()); } } // Display a list selection for the user to select which // plugins to add. ListSelectionDialog dialog = new ListSelectionDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell(), notIncludedProjects.toArray(), ArrayContentProvider.getInstance(), new LabelProvider(), "Select new plugins to include in the new ICE instance."); dialog.setTitle("Plugin Addition Selection"); // Open the dialog int ok = dialog.open(); if (ok == Window.OK) { // Get the results Object[] results = dialog.getResult(); for (Object s : results) { currentPluginsStr = s.toString() + "@default:true," + currentPluginsStr; } ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy(); // Set the launch configs list of plugins wc.setAttribute(key, currentPluginsStr); wc.setAttribute(vmArgsKey, vmArgs); // Save the configuration ILaunchConfiguration config = wc.doSave(); // Create and launch the Job. Job job = new WorkspaceJob("Launching New Instance of ICE") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { config.launch(ILaunchManager.RUN_MODE, monitor); return Status.OK_STATUS; } }; // Launch the job job.schedule(); } } catch (CoreException e) { e.printStackTrace(); logger.error("Could not create or launch new run configuration.", e); } } } return null; }
From source file:org.eclipse.smarthome.model.core.internal.folder.FolderObserverTest.java
/** * The following method creates a file in an existing directory. The file's extension is * in the configuration properties and there is a registered ModelParser for it. * addOrRefreshModel() method invocation is expected * * @throws Exception/*from w ww .jav a 2 s .c o m*/ */ @Test public void testCreation() throws Exception { String validExtension = "java"; configProps.put(EXISTING_SUBDIR_NAME, "txt,jpg," + validExtension); folderObserver.activate(context); File file = new File(EXISTING_SUBDIR_PATH, "NewlyCreatedMockFile." + validExtension); file.createNewFile(); /* * In some OS, like MacOS, creating an empty file is not related to sending an ENTRY_CREATE event. * So, it's necessary to put some initial content in that file. */ if (!SystemUtils.IS_OS_WINDOWS) { FileUtils.writeStringToFile(file, INITIAL_FILE_CONTENT); } waitForAssert(() -> assertThat(file.exists(), is(true))); waitForAssert(() -> assertThat(modelRepo.isAddOrRefreshModelMethodCalled, is(true)), DFL_TIMEOUT * 2, DFL_SLEEP_TIME); waitForAssert(() -> assertThat(modelRepo.isRemoveModelMethodCalled, is(false))); waitForAssert(() -> assertThat(modelRepo.calledFileName, is(file.getName()))); }
From source file:org.eclipse.smarthome.model.core.internal.folder.FolderObserverTest.java
/** * The following method creates a file in an existing directory. The file's extension is * in the configuration properties and there is a registered ModelParser for it. * Then the file's content is changed./*from w w w. j av a 2s .c o m*/ * addOrRefreshModel() method invocation is expected * * @throws Exception */ @Test public void testModification() throws Exception { String validExtension = "java"; configProps.put(EXISTING_SUBDIR_NAME, "txt,jpg," + validExtension); folderObserver.activate(context); File file = new File(EXISTING_SUBDIR_PATH, "MockFileForModification." + validExtension); file.createNewFile(); /* * In some OS, like MacOS, creating an empty file is not related to sending an ENTRY_CREATE event. So, it's * necessary to put some initial content in that file. */ if (!SystemUtils.IS_OS_WINDOWS) { FileUtils.writeStringToFile(file, INITIAL_FILE_CONTENT, true); } waitForAssert(() -> assertThat(file.exists(), is(true))); waitForAssert(() -> assertThat(modelRepo.isAddOrRefreshModelMethodCalled, is(true)), DFL_TIMEOUT * 2, DFL_SLEEP_TIME); modelRepo.clean(); String text = "Additional content"; FileUtils.writeStringToFile(file, text, true); waitForAssert(() -> assertThat(modelRepo.isAddOrRefreshModelMethodCalled, is(true)), DFL_TIMEOUT * 2, DFL_SLEEP_TIME); waitForAssert(() -> assertThat(modelRepo.calledFileName, is(file.getName()))); String finalFileContent; if (!SystemUtils.IS_OS_WINDOWS) { finalFileContent = INITIAL_FILE_CONTENT + text; } else { finalFileContent = text; } waitForAssert(() -> assertThat(modelRepo.fileContent, is(finalFileContent))); }
From source file:org.eclipse.smarthome.model.core.internal.folder.FolderObserverTest.java
@Test public void testException() throws Exception { ModelRepoDummy modelRepo = new ModelRepoDummy() { @Override/*w w w. j av a 2 s. c o m*/ public boolean addOrRefreshModel(String name, InputStream inputStream) { super.addOrRefreshModel(name, inputStream); throw new RuntimeException("intentional failure."); } }; folderObserver.setModelRepository(modelRepo); String validExtension = "java"; configProps.put(EXISTING_SUBDIR_NAME, "txt,jpg," + validExtension); folderObserver.activate(context); File mockFileWithValidExt = new File(EXISTING_SUBDIR_PATH, "MockFileForModification." + validExtension); mockFileWithValidExt.createNewFile(); if (!SystemUtils.IS_OS_WINDOWS) { FileUtils.writeStringToFile(mockFileWithValidExt, INITIAL_FILE_CONTENT); } waitForAssert(() -> assertThat(modelRepo.isAddOrRefreshModelMethodCalled, is(true)), DFL_TIMEOUT * 2, DFL_SLEEP_TIME); modelRepo.clean(); FileUtils.writeStringToFile(mockFileWithValidExt, "Additional content", true); waitForAssert(() -> assertThat(modelRepo.isAddOrRefreshModelMethodCalled, is(true)), DFL_TIMEOUT * 2, DFL_SLEEP_TIME); }
From source file:org.eclipse.smarthome.model.core.internal.folder.FolderObserverTest.java
/** * The following method creates a hidden file in an existing directory. The file's extension is * in the configuration properties and there is a registered ModelParser for it. * addOrRefreshModel() method invocation is NOT expected, the model should be ignored since the file is hidden * * @throws Exception/*from w w w .j a va2 s .c o m*/ */ @Test public void testHiddenFile() throws Exception { String validExtension = "java"; configProps.put(EXISTING_SUBDIR_NAME, "txt,jpg," + validExtension); folderObserver.activate(context); String filename = ".HiddenNewlyCreatedMockFile." + validExtension; if (!SystemUtils.IS_OS_WINDOWS) { /* * In some OS, like MacOS, creating an empty file is not related to sending an ENTRY_CREATE event. * So, it's necessary to put some initial content in that file. */ File file = new File(EXISTING_SUBDIR_PATH, filename); file.createNewFile(); FileUtils.writeStringToFile(file, INITIAL_FILE_CONTENT); } else { /* * In windows a hidden file cannot be created with a single api call. * The file must be created and afterwards it needs a filesystem property set for a file to be hidden. * But the initial creation already triggers the folder observer mechanism, * therefore the file is created in an unobserved directory, hidden and afterwards moved to the observed * directory */ UNWATCHED_DIRECTORY.mkdirs(); File file = new File(UNWATCHED_DIRECTORY, filename); file.createNewFile(); Files.setAttribute(file.toPath(), "dos:hidden", true); FileUtils.moveFileToDirectory(file, EXISTING_SUBDIR_PATH, false); FileUtils.deleteDirectory(UNWATCHED_DIRECTORY); } sleep(WAIT_EVENT_TO_BE_HANDLED); waitForAssert(() -> assertThat(modelRepo.isAddOrRefreshModelMethodCalled, is(false))); }
From source file:org.eclipse.wb.internal.css.dialogs.color.ColorDialog.java
@Override protected void addPages(Composite parent) { addPage(Messages.ColorDialog_namedPage, new NamedColorsComposite(parent, SWT.NONE, this)); addPage(Messages.ColorDialog_webPage, new WebSafeColorsComposite(parent, SWT.NONE, this)); if (SystemUtils.IS_OS_WINDOWS) { addPage(Messages.ColorDialog_systemPage, new SystemColorsComposite(parent, SWT.NONE, this)); }/* w w w .j av a 2 s. c om*/ }
From source file:org.eclipse.wb.internal.css.dialogs.color.ColorDialog.java
/** * @return the names of all colors on this page. *///from ww w. j av a 2 s . co m public static String[] getColorNames() { if (COLOR_NAMES == null) { List<String> colorNames = Lists.newArrayList(); for (String color : NamedColorsComposite.getColorNames()) { colorNames.add(color); } if (SystemUtils.IS_OS_WINDOWS) { for (String color : SystemColorsComposite.getColorNames()) { colorNames.add(color); } } COLOR_NAMES = colorNames.toArray(new String[colorNames.size()]); } return COLOR_NAMES; }
From source file:org.eclipse.wb.internal.css.dialogs.color.ColorDialog.java
/** * @return the {@link RGB} of given named color, may be <code>null</code>. *///w w w . j ava 2 s. co m public static RGB getRGB(String name) { RGB rgb; rgb = NamedColorsComposite.getRGB(name); if (rgb == null && SystemUtils.IS_OS_WINDOWS) { rgb = SystemColorsComposite.getRGB(name); } if (rgb == null && name.length() == 7) { name = StringUtils.removeStart(name, "#"); int r = Integer.parseInt(name.substring(0, 2), 16); int g = Integer.parseInt(name.substring(2, 4), 16); int b = Integer.parseInt(name.substring(4, 6), 16); rgb = new RGB(r, g, b); } if (rgb == null && name.length() == 4) { name = StringUtils.removeStart(name, "#"); int r0 = Integer.parseInt(name.substring(0, 1), 16); int g0 = Integer.parseInt(name.substring(1, 2), 16); int b0 = Integer.parseInt(name.substring(2, 3), 16); int r = (r0 << 4) + r0; int g = (g0 << 4) + g0; int b = (b0 << 4) + b0; rgb = new RGB(r, g, b); } return rgb; }