当前位置: 首页>>代码示例>>Java>>正文


Java OS.isFamilyWindows方法代码示例

本文整理汇总了Java中org.apache.commons.exec.OS.isFamilyWindows方法的典型用法代码示例。如果您正苦于以下问题:Java OS.isFamilyWindows方法的具体用法?Java OS.isFamilyWindows怎么用?Java OS.isFamilyWindows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.exec.OS的用法示例。


在下文中一共展示了OS.isFamilyWindows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeWSCommand

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
public void executeWSCommand() throws Throwable {
    if (OS.isFamilyWindows()) {
        throw new SkipException("Test not valid for Windows");
    }
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_WEBSTART).addWSArgument("-verbose").addVMArgument("-Dx.y.z=hello");
    final CommandLine commandLine = profile.getCommandLine();
    AssertJUnit.assertNotNull(commandLine);
    AssertJUnit.assertTrue(commandLine.toString().contains("-javaagent:"));
    AssertJUnit.assertTrue(commandLine.toString().contains("-verbose"));
    AssertJUnit.assertTrue(commandLine.toString().contains("-Dx.y.z=hello"));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    commandLine.copyOutputTo(baos);
    commandLine.executeAsync();
    new Wait("Waiting till the command is complete") {
        @Override public boolean until() {
            return !commandLine.isRunning();
        }
    };
    BufferedReader reader = new BufferedReader(new StringReader(new String(baos.toByteArray())));
    String line = reader.readLine();
    while (line != null && !line.contains("Web Start")) {
        line = reader.readLine();
    }
    AssertJUnit.assertTrue(line.contains("Web Start"));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:26,代码来源:JavaProfileTest.java

示例2: getExecScriptFileOrNull

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
private File getExecScriptFileOrNull(String scriptNameBase) {
    String resource = null;
    if (OS.isFamilyWindows()) {
        resource = scriptNameBase + ".bat";
    } else if (OS.isFamilyUnix()) {
        resource = scriptNameBase + ".sh";
    }
    File resourceFile = getClasspathResourceFileOrNull(resource);
    // TODO use canExecute here (available since java 1.6)
    if (resourceFile != null && !resourceFile.canRead()) {
        logger.warn("The resource  " + resourceFile.getAbsolutePath() + " is not readable!");
        // it is not readable, do not try to execute it
        return null;
    }
    return resourceFile;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:ExecScriptTest.java

示例3: findExecutable

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
static String findExecutable( final String executable, final List<String> paths )
{
    File f = null;
    search: for ( final String path : paths )
    {
        f = new File( path, executable );
        if ( !OS.isFamilyWindows() && f.isFile() )
            break;
        else
            for ( final String extension : getExecutableExtensions() )
            {
                f = new File( path, executable + extension );
                if ( f.isFile() )
                    break search;
            }
    }

    if ( f == null || !f.exists() )
        return null;

    return f.getAbsolutePath();
}
 
开发者ID:mojohaus,项目名称:exec-maven-plugin,代码行数:23,代码来源:ExecMojo.java

示例4: searchForServerDirectory

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
/**
 * Search the operating system for an Appium server installation directory.
 *
 * @return A File representation to the Appium server installation
 * directory.
 */
private File searchForServerDirectory() {
    if (OS.isFamilyWindows()) {
        if (getArch().equals("32")) {
            return doesDirectoryExists(System.getenv("ProgramFiles")
                    + "/Appium");
        } else {
            // must be the x86_64
            return doesDirectoryExists(System.getenv("ProgramFiles")
                    + " (x86)/Appium");
        }
    } else if (OS.isFamilyMac()) {
        return doesDirectoryExists(APPIUM_SERVER_MAC_DEFAULT_DIRECTORY);
    }

    // server directrory was not found.
    throw new ServerDirectoryNotFoundException();
}
 
开发者ID:Genium-Framework,项目名称:Appium-Support,代码行数:24,代码来源:AppiumServer.java

示例5: init

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
private void init() throws MojoExecutionException {

        // Supply variables that are OS dependent
        if (OS.isFamilyWindows()) {
            if (command == null) {
                command = "taskkill";
            }
        } else if (OS.isFamilyUnix() || OS.isFamilyMac()) {
            if (command == null) {
                command = "kill";
            }
        } else {
            if (command == null) {
                throw new MojoExecutionException(
                        "Unknown OS - You must use the 'command' parameter");
            }
        }

    }
 
开发者ID:fuinorg,项目名称:event-store-maven-plugin,代码行数:20,代码来源:EventStoreStopMojo.java

示例6: testExecute

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
@Test
public void testExecute() throws MojoExecutionException, IOException {

    // PREPARE
    final EventStorePostStartMojo testee = new EventStorePostStartMojo();
    final File dir = new File("./src/test").getCanonicalFile();
    testee.setEventStoreDir(dir);
    if (OS.isFamilyWindows()) {
        testee.setPostStartCommand(dir + File.separator + "echotest.bat");
    } else {
        testee.setPostStartCommand(dir + File.separator + "echotest.sh");
    }

    // TEST
    testee.execute();

    // VERIFY
    assertThat(testee.getMessages()).contains("Hello world!");

}
 
开发者ID:fuinorg,项目名称:event-store-maven-plugin,代码行数:21,代码来源:EventStorePostStartMojoTest.java

示例7: checkGivenExecutableIsUsed

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
public void checkGivenExecutableIsUsed() throws Throwable {
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_APPLET);
    File f = findFile();
    profile.setAppletURL(f.getAbsolutePath());
    profile.setStartWindowTitle("Applet Viewer: SwingSet3Init.class");
    String actual = "";
    if (OS.isFamilyWindows()) {
        String path = System.getenv("Path");
        String[] split = path.split(";");
        File file = new File(split[0]);
        File[] listFiles = file.listFiles();
        if (listFiles != null) {
            for (File listFile : listFiles) {
                if (listFile.getName().contains(".exe")) {
                    profile.setJavaCommand(listFile.getAbsolutePath());
                    actual = listFile.getAbsolutePath();
                    break;
                }
            }
        }
    } else {
        actual = "ls";
        profile.setJavaCommand(actual);
    }
    CommandLine commandLine = profile.getCommandLine();
    AssertJUnit.assertTrue(commandLine.toString().contains(actual));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:28,代码来源:LaunchAppletTest.java

示例8: getProcessStatus

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
/**
 * get the status of the processname.
 *
 * @param processname
 *            the process name
 * @return the status of the process
 * @throws IOException
 *             throw IOException if occur error
 */
public static String getProcessStatus(String processname) throws IOException {
	if (isLinux() || OS.isFamilyMac()) {

		String line = "ps -ef";
		String r = run(line);
		StringBuilder sb = new StringBuilder();
		String[] ss = r.split("\n");
		if (ss != null && ss.length > 0) {
			for (String s : ss) {
				if (s.contains(processname)) {
					sb.append(s).append("\n");
				}
			}
		}

		return sb.toString();
	} else if (OS.isFamilyWindows()) {

		String cmd = "tasklist /nh /FI \"IMAGENAME eq " + processname + "\"";
		return run(cmd);

	} else {
		throw new IOException("not support");
	}

}
 
开发者ID:giiwa,项目名称:giiwa,代码行数:36,代码来源:Shell.java

示例9: getStartScriptName

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
public static String getStartScriptName() throws URISyntaxException {
		String base="Transkribus.";
		if (OS.isFamilyWindows()) {
			String exe = base+"exe";
			String cmd = "cmd /c start "+exe;
//			cmd += "& del "+getCurrentJar().getName(); // this cleans the old version in windows after the new version has started --> should work, as current JVM should exit sooner than new program has started! 
			return cmd;
		} else if (OS.isFamilyMac()) {
			return "./"+base+"command";
		} else {
			return "./"+base+"sh";
		}
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:14,代码来源:ProgramUpdaterDialog.java

示例10: getClasspathArg

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
private String getClasspathArg() {
    String classpath = System.getProperty("java.class.path");
    if (OS.isFamilyWindows()) {
        // On windows the ";" character is replaced by a space by the
        // command interpreter. Thus the classpath is split with the
        // ;-token. Therefore the classpath should be quoted with double
        // quotes
        classpath = "\"\"" + classpath + "\"\"";
    } else {
        // quote only once
        classpath = "\"" + classpath + "\"";
    }
    return classpath;

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:ExecScriptTest.java

示例11: createEnvWrapperFile

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
protected File createEnvWrapperFile( File envScript )
    throws IOException
{
    PrintWriter writer = null;
    File tmpFile = null;
    try
    {

        if ( OS.isFamilyWindows() )
        {
            tmpFile = File.createTempFile( "env", ".bat" );
            writer = new PrintWriter( tmpFile );
            writer.append( "@echo off" ).println();
            writer.append( "call \"" ).append( envScript.getCanonicalPath() ).append( "\"" ).println();
            writer.append( "echo " + EnvStreamConsumer.START_PARSING_INDICATOR ).println();
            writer.append( "set" ).println();
            writer.flush();
        }
        else
        {
            tmpFile = File.createTempFile( "env", ".sh" );
            // tmpFile.setExecutable( true );//java 6 only
            writer = new PrintWriter( tmpFile );
            writer.append( "#! /bin/sh" ).println();
            writer.append( ". " ).append( envScript.getCanonicalPath() ).println(); // works on all unix??
            writer.append( "echo " + EnvStreamConsumer.START_PARSING_INDICATOR ).println();
            writer.append( "env" ).println();
            writer.flush();
        }
    }
    finally
    {
        IOUtil.close( writer );
    }

    return tmpFile;

}
 
开发者ID:mojohaus,项目名称:exec-maven-plugin,代码行数:39,代码来源:ExecMojo.java

示例12: testGetExecutablePathPreferExecutableExtensionsOnWindows

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
public void testGetExecutablePathPreferExecutableExtensionsOnWindows()
		throws IOException
{
	// this test is for Windows
	if (!OS.isFamilyWindows()) {
		return;
	}
	final ExecMojo realMojo = new ExecMojo();
	
	final String tmp = System.getProperty("java.io.tmpdir");
	final File workdir = new File(tmp, "testGetExecutablePathPreferExecutableExtensionsOnWindows");
	workdir.mkdirs();
	
	final Map<String, String> enviro = new HashMap<String, String>();
	
	final File f = new File(workdir, "mycmd");
	final File fCmd = new File(workdir, "mycmd.cmd");
	f.createNewFile();
	fCmd.createNewFile();
	assertTrue( "file exists...", f.exists() );
	assertTrue( "file exists...", fCmd.exists() );
	
	realMojo.setExecutable( "mycmd" );
	
	final CommandLine cmd = realMojo.getExecutablePath( enviro, workdir );
	// cmdline argumets are: [/c, %path-to-temp%\mycmd.cmd], so check second argument
	assertTrue( "File should have cmd extension",
			cmd.getArguments()[1].endsWith( "mycmd.cmd" ) );
	
	f.delete();
	fCmd.delete();
	assertFalse( "file deleted...", f.exists() );
	assertFalse( "file deleted...", fCmd.exists() );
	
}
 
开发者ID:mojohaus,项目名称:exec-maven-plugin,代码行数:36,代码来源:ExecMojoTest.java

示例13: getCommandLineAsString

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
private String getCommandLineAsString( CommandLine commandline )
{
    // for the sake of the test comparisons, cut out the eventual
    // cmd /c *.bat conversion
    String result = commandline.getExecutable();
    boolean isCmd = false;
    if ( OS.isFamilyWindows() && result.equals( "cmd" ) )
    {
        result = "";
        isCmd = true;
    }
    String[] arguments = commandline.getArguments();
    for ( int i = 0; i < arguments.length; i++ )
    {
        String arg = arguments[i];
        if ( isCmd && i == 0 && "/c".equals( arg ) )
        {
            continue;
        }
        if ( isCmd && i == 1 && arg.endsWith( ".bat" ) )
        {
            arg = arg.substring( 0, arg.length() - ".bat".length() );
        }
        result += ( result.length() == 0 ? "" : " " ) + arg;
    }
    return result;
}
 
开发者ID:mojohaus,项目名称:exec-maven-plugin,代码行数:28,代码来源:ExecMojoTest.java

示例14: createEnvironmentMap

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
/**
 * Creates a map that obeys the casing rules of the current platform for key
 * lookup. E.g. on a Windows platform, the map keys will be
 * case-insensitive.
 * 
 * @return The map for storage of environment variables, never
 *         <code>null</code>.
 */
private Map createEnvironmentMap() {
    if (OS.isFamilyWindows()) {
        return new TreeMap(new Comparator() {
            public int compare(Object arg0, Object arg1) {
                String key0 = (String) arg0;
                String key1 = (String) arg1;
                return key0.compareToIgnoreCase(key1);
            }
        });
    } else {
        return new HashMap();
    }
}
 
开发者ID:deim0s,项目名称:XWBEx,代码行数:22,代码来源:DefaultProcessingEnvironment.java

示例15: AppiumServer

import org.apache.commons.exec.OS; //导入方法依赖的package包/类
/**
 * Constructs an Appium server instance. Searches automatically for an
 * installed Appium server on your machine using the default installation
 * location according to your operating system.
 *
 * The searched directories are: <br><ul><li>Windows OS: "C:/Program
 * Files/Appium" &amp; "C:/Program Files (x86)/Appium"</li> <li>Mac OS:
 * "/Applications/Appium.app/Contents/Resources" </li></ul>zz
 *
 * @param serverArguments The server arguments to be used when working with
 * the server.
 */
public AppiumServer(ServerArguments serverArguments) {
    this._serverArguments = serverArguments;

    // search for installed Appium server
    _absoluteServerDirectory = searchForServerDirectory();

    // make sure to get the node executable file path along with the appium.js path too.
    _nodeExecutableFilePath = new File(OS.isFamilyWindows()
            ? _absoluteServerDirectory + NODE_RELATIVE_PATH_WINDOWS
            : _absoluteServerDirectory + NODE_RELATIVE_PATH_MAC_OS);
    _appiumJavaScriptFilePath = new File(_absoluteServerDirectory
            + APPIUM_FILE_RELATIVE_PATH);
}
 
开发者ID:Genium-Framework,项目名称:Appium-Support,代码行数:26,代码来源:AppiumServer.java


注:本文中的org.apache.commons.exec.OS.isFamilyWindows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。