Example usage for org.apache.commons.lang SystemUtils IS_OS_WINDOWS

List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.

Prototype

boolean IS_OS_WINDOWS

To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.

Click Source Link

Document

Is true if this is Windows.

The field will return false if OS_NAME is null.

Usage

From source file:org.goobi.export.ExportMetsIT.java

@AfterClass
public static void tearDown() throws Exception {
    SecurityTestUtils.cleanSecurityContext();
    MockDatabase.stopNode();//from w ww .  j  ava2  s .  c  o m
    MockDatabase.cleanDatabase();
    fileService.delete(URI.create(metadataDirectory));
    fileService.delete(Config.getUri(Parameters.DIR_USERS));
    FileLoader.deleteConfigProjectsFile();

    if (!SystemUtils.IS_OS_WINDOWS) {
        ExecutionPermission.setNoExecutePermission(scriptCreateDirUserHome);
    }
}

From source file:org.goobi.export.ExportMetsIT.java

@Test
public void exportMetsTest() throws Exception {
    if (SystemUtils.IS_OS_WINDOWS) {
        // This is a workaround for the problem that the startExport method
        // is calling
        // an external shell script for creating directories. This code only
        // does the work of that script.
        // TODO Find a better way for changing script selection
        // corresponding to OS
        fileService.createDirectory(Config.getUri(Parameters.DIR_USERS), userDirectory);
    }/*from   www .  j ava 2  s .  co m*/

    exportMets.startExport(process, exportUri);
    List<String> strings = Files
            .readAllLines(Paths.get(Config.getParameter(Parameters.DIR_USERS) + userDirectory + "/"
                    + serviceManager.getProcessService().getNormalizedTitle(process.getTitle()) + "_mets.xml"));

    Assert.assertTrue("Export of metadata was wrong",
            strings.get(1).contains("<mods:publisher>Test Publisher</mods:publisher>"));
    Assert.assertTrue("Export of person was wrong",
            strings.get(1).contains("<mods:title>Test Title</mods:title>"));
    Assert.assertTrue("Export of metadata group was wrong",
            strings.get(1).contains("<mods:namePart type=\"given\">FirstTestName</mods:namePart>"));

}

From source file:org.guvnor.ala.services.rest.tests.RestRuntimeProvisioningImplTest.java

@BeforeClass
public static void beforeClass() {
    Assume.assumeFalse(SystemUtils.IS_OS_WINDOWS);
}

From source file:org.guvnor.ala.wildfly.executor.tests.requirement.NotWindowsRequirement.java

@Override
public void check(RequiresNotWindows context) throws UnsatisfiedRequirementException {
    if (SystemUtils.IS_OS_WINDOWS) {
        throw new UnsatisfiedRequirementException("Don't run tests requiring docker on Windows.");
    }//from   w  w  w .  jav  a 2 s. co  m
}

From source file:org.jajuk.util.TestUtilSystem.java

/**
 * Test method for.//from ww w. j ava2 s .c  o  m
 *
 * @throws Exception the exception
 * {@link org.jajuk.util.UtilSystem#copy(java.net.URL, java.lang.String)}.
 */
public void testCopyURLString() throws Exception {
    FileUtils.writeStringToFile(file1, "this is some test data");
    UtilSystem.copy(file1.toURI().toURL(), file2.getAbsolutePath());
    // file is written into same directory as file1 here
    // TODO: currently the copy(URL) methods adds a newline at the end, should
    // we change that??
    assertEquals("this is some test data" + (SystemUtils.IS_OS_WINDOWS ? "\r" : "") + "\n",
            FileUtils.readFileToString(file2));
}

From source file:org.jajuk.util.TestUtilSystem.java

/**
 * Test method for {@link org.jajuk.util.UtilSystem#isUnderWindows()}.
 */
public void testIsUnderWindows() {
    assertEquals(SystemUtils.IS_OS_WINDOWS, UtilSystem.isUnderWindows());
}

From source file:org.jboss.pressgang.ccms.contentspec.client.commands.EditCommand.java

protected String getCommand(final String file) {
    if (getClientConfig().getEditorRequiresTerminal()) {
        if (SystemUtils.IS_OS_WINDOWS) {
            return "start \"\" \"" + getClientConfig().getEditorCommand() + "\" \"" + file + "\"";
        } else if (SystemUtils.IS_OS_LINUX) {
            return ClientUtilities.getLinuxTerminalCommand().replace("<COMMAND>",
                    getClientConfig().getEditorCommand() + " " + file);
        } else if (SystemUtils.IS_OS_MAC_OSX) {
            return "osascript -e 'tell app \"Terminal\" to do script \"" + getClientConfig().getEditorCommand()
                    + " " + file + "; exit\"'";
        } else {//from w  ww .ja v  a  2 s  . com
            printErrorAndShutdown(Constants.EXIT_FAILURE, "ERROR_UNABLE_TO_OPEN_EDITOR_IN_TERMINAL_MSG", false);
            return null;
        }
    } else {
        return getClientConfig().getEditorCommand() + " \"" + file + "\"";
    }
}

From source file:org.jboss.qa.jcontainer.util.executor.LoopProcessTest.java

@BeforeClass
public static void setUp() {
    Assume.assumeFalse(SystemUtils.IS_OS_WINDOWS); // TODO(tturek): Write batch script to test process interruption.

    commands = new ArrayList<>();
    commands.add("bash");
    commands.add("-c");
    commands.add(getFile("src", "test", "resources", "scriptLoop.sh").getAbsolutePath());
}

From source file:org.jboss.tools.openshift.internal.core.preferences.OCBinary.java

public static OCBinary getInstance() {
    if (SystemUtils.IS_OS_WINDOWS) {
        return WINDOWS;
    } else {// w  ww .  j  a va2  s .c  om
        return OTHER;
    }
}

From source file:org.jboss.tools.openshift.internal.ui.preferences.OpenShiftPreferencePage.java

private String findOCLocation() {
    String location = null;/*  w ww .j a  v a 2 s.c o  m*/
    if (SystemUtils.IS_OS_WINDOWS) {
        String[] paths = StringUtils.split(System.getenv("PATH"), ";");
        for (String path : paths) {
            Collection<File> files = FileUtils.listFiles(new File(path), new IOFileFilter() {

                @Override
                public boolean accept(File file) {
                    return ocBinary.getName().equals(file.getName());
                }

                @Override
                public boolean accept(File dir, String name) {
                    return ocBinary.getName().equals(name);
                }

            }, null);
            if (files.size() > 0) {
                location = files.iterator().next().toString();
                break;
            }
        }
    } else {
        String path = ThreadUtils.runWithTimeout(WHICH_CMD_TIMEOUT, new Callable<String>() {
            @Override
            public String call() throws Exception {
                Process process = null;
                try {
                    process = new ProcessBuilder("which", ocBinary.getName()).start();
                    process.waitFor();
                    if (process.exitValue() == WHICH_CMD_SUCCESS) {
                        return IOUtils.toString(process.getInputStream());
                    }
                    ;
                } catch (IOException e) {
                    OpenShiftUIActivator.getDefault().getLogger().logError("Could not run 'which' command", e);
                } finally {
                    if (process != null) {
                        process.destroy();
                    }
                }
                return null;
            }
        });

        if (!StringUtils.isEmpty(path)) {
            location = path;
        }
    }
    return StringUtils.trim(location);
}