CmdLineBuilderFactory { public static CmdLineBuilder create(BpkRuntime runtime, TaskDescriptor taskDescriptor, File taskDir) throws TaskException { if (runtime instanceof JavaRuntime) { return new JVMCmdLineBuilder(taskDir, taskDescriptor, ((JavaRuntime) runtime)); } else if (runtime instanceof NativeRuntime) { return new NativeCmdLineBuilder(((NativeRuntime) runtime).getBinary(), taskDir, taskDescriptor); } else { String msg = String.format("Cannot create command line builder for unknown runtime: %s", runtime.getClass()); throw new TaskException(msg); } }  static CmdLineBuilder create(BpkRuntime runtime, TaskDescriptor taskDescriptor, File taskDir);  }
@Test public void testJVMCmdLineBuilderIsSelectedOnJVMRuntime() throws Exception { BpkRuntime runtime = new JavaRuntime(); TaskDescriptor taskDescriptor = null; File taskDir = null; assertEquals(JVMCmdLineBuilder.class, CmdLineBuilderFactory.create(runtime, taskDescriptor, taskDir).getClass()); }
@Test public void testNativeCmdLineBuilderIsSelectedOnNativeRuntime() throws Exception { BpkRuntime runtime = new NativeRuntime(); TaskDescriptor taskDescriptor = null; File taskDir = null; assertEquals(NativeCmdLineBuilder.class, CmdLineBuilderFactory.create(runtime, taskDescriptor, taskDir).getClass()); }