Java 类org.eclipse.debug.core.ILaunch 实例源码

项目:dsp4e    文件:DSPDebugTarget.java   
public DSPDebugTarget(ILaunch launch, Process process, InputStream in, OutputStream out,
        Map<String, Object> launchArguments) throws CoreException {
    super(null);
    this.launch = launch;
    this.process = process;

    DebugLauncher<IDebugProtocolServer> debugProtocolLauncher = DebugLauncher.createLauncher(this,
            IDebugProtocolServer.class, in, out, true, new PrintWriter(System.out));

    debugProtocolFuture = debugProtocolLauncher.startListening();
    debugProtocolServer = debugProtocolLauncher.getRemoteProxy();

    complete(debugProtocolServer.initialize(new InitializeRequestArguments().setClientID("lsp4e")
            .setAdapterID((String) launchArguments.get("type")).setPathFormat("path")));

    Object object = launchArguments.get("program");
    targetName = Objects.toString(object, "Debug Adapter Target");

    complete(debugProtocolServer.launch(Either.forLeft(launchArguments)));
    complete(debugProtocolServer.configurationDone());
    IBreakpointManager breakpointManager = getBreakpointManager();
    breakpointManager.addBreakpointListener(this);
    breakpointManager.addBreakpointManagerListener(this);
    breakpointManagerEnablementChanged(breakpointManager.isEnabled());
}
项目:egradle    文件:EGradleJunitLaunchDelegate.java   
@Override
protected void appendAdditionalLaunchParameters(LaunchParameterValues launchParameterValues) {
    ILaunch launch = launchParameterValues.getLaunch();
    if (launch==null){
        throw new IllegalStateException("launch missing");
    }
    String projectName;
    try {
        ILaunchConfiguration configuration = launch.getLaunchConfiguration();

        projectName = configuration.getAttribute(PROPERTY_PROJECTNAME, (String)null);

        String configuredTasksValue= configuration.getAttribute(PROPERTY_TASKS, "");
        String tasksToExecute = variableReplacement.replace(configuredTasksValue, JUNIT_PREFERENCES.getDefaultTestTaskType().getTestTasks());

        launchParameterValues.setPostJob(new ImportGradleJunitResultsJob("Import gradle junit results",projectName,true));
        launchParameterValues.setOverriddenTasks(tasksToExecute);
    } catch (CoreException e) {
        JunitUtil.logError("Was not able to add additional launch parameters", e);
    }
}
项目:eclemma    文件:SessionManagerTest.java   
@Test
public void testRemoveSessionsFor1() {
  ILaunch launch0 = new Launch(null, null, null);
  ILaunch launch1 = new Launch(null, null, null);
  ICoverageSession s0 = new DummySession();
  ICoverageSession s1 = new DummySession();
  manager.addSession(s0, false, launch0);
  manager.addSession(s1, true, launch1);
  listener.clear();

  manager.removeSessionsFor(launch1);

  assertEquals(Arrays.asList(s0), manager.getSessions());
  assertSame(s0, manager.getActiveSession());
  reflistener.sessionRemoved(s1);
  reflistener.sessionActivated(s0);
  assertEquals(reflistener, listener);
}
项目:eclemma    文件:SessionManagerTest.java   
@Test
public void testRemoveSessionsFor2() {
  ILaunch launch0 = new Launch(null, null, null);
  ILaunch launch1 = new Launch(null, null, null);
  ILaunch launch2 = new Launch(null, null, null);
  ICoverageSession s0 = new DummySession();
  ICoverageSession s1 = new DummySession();
  manager.addSession(s0, false, launch0);
  manager.addSession(s1, true, launch1);
  listener.clear();

  manager.removeSessionsFor(launch2);

  assertEquals(Arrays.asList(s0, s1), manager.getSessions());
  assertSame(s1, manager.getActiveSession());
  assertEquals(reflistener, listener);
}
项目:eclemma    文件:SessionManagerTest.java   
@Test
public void testRemoveSessionsFor3() {
  ILaunch launch0 = new Launch(null, null, null);
  ILaunch launch1 = new Launch(null, null, null);
  ICoverageSession s0 = new DummySession();
  ICoverageSession s1 = new DummySession();
  ICoverageSession s2 = new DummySession();
  manager.addSession(s0, true, launch0);
  manager.addSession(s1, true, launch1);
  manager.addSession(s2, true, launch1);
  listener.clear();

  manager.removeSessionsFor(launch1);

  assertEquals(Arrays.asList(s0), manager.getSessions());
  assertSame(s0, manager.getActiveSession());
  reflistener.sessionRemoved(s1);
  reflistener.sessionRemoved(s2);
  reflistener.sessionActivated(s0);
  assertEquals(reflistener, listener);
}
项目:eclemma    文件:LaunchLabelProvider.java   
public static String getLaunchText(ILaunch launch) {
  // new launch configuration
  final ILaunchConfiguration config = launch.getLaunchConfiguration();
  if (config == null) {
    return UIMessages.DumpExecutionDataUnknownLaunch_value;
  }
  StringBuilder sb = new StringBuilder(config.getName());
  sb.append(" ["); //$NON-NLS-1$
  try {
    sb.append(config.getType().getName());
  } catch (CoreException e) {
    EclEmmaUIPlugin.log(e);
  }
  sb.append("]"); //$NON-NLS-1$
  return sb.toString();
}
项目:eclemma    文件:SessionManager.java   
public void addSession(ICoverageSession session, boolean activate,
    ILaunch launch) {
  synchronized (lock) {
    if (session == null) {
      throw new IllegalArgumentException();
    }
    if (!sessions.contains(session)) {
      sessions.add(session);
      if (launch != null) {
        List<ICoverageSession> l = launchmap.get(launch);
        if (l == null) {
          l = new ArrayList<ICoverageSession>();
          launchmap.put(launch, l);
        }
        l.add(session);
      }
      fireSessionAdded(session);
    }
    if (activate) {
      activeSession = session;
      fireSessionActivated(session);
    }
  }
}
项目:eclemma    文件:CoverageTools.java   
/**
 * Determines all current coverage launches which are running.
 *
 * @return list of running coverage launches
 */
public static List<ICoverageLaunch> getRunningCoverageLaunches() {
  final List<ICoverageLaunch> result = new ArrayList<ICoverageLaunch>();
  for (final ILaunch launch : DebugPlugin.getDefault().getLaunchManager()
      .getLaunches()) {
    if (launch instanceof ICoverageLaunch && !launch.isTerminated()) {
      result.add((ICoverageLaunch) launch);
    }
  }
  return result;
}
项目:google-cloud-eclipse    文件:DataflowPipelineLaunchDelegateTest.java   
@Test
public void testLaunchWithProjectThatDoesNotExistThrowsIllegalArgumentException()
    throws CoreException {
  ILaunchConfiguration configuration = mockILaunchConfiguration();
  when(project.exists()).thenReturn(false);

  String mode = "run";
  ILaunch launch = mock(ILaunch.class);

  try {
    dataflowDelegate.launch(configuration, mode, launch, monitor);
    fail();
  } catch (IllegalArgumentException ex) {
    assertTrue(
        ex.getMessage().contains("Project with name Test-project,Name must exist to launch."));
  }
}
项目:google-cloud-eclipse    文件:FlexMavenPackagedProjectStagingDelegate.java   
/**
 * Waits until {@code launch} terminates or {@code monitor} is canceled. if the monitor is
 * canceled, attempts to terminate the launch before returning.
 *
 * @return true if the launch terminated normally; false otherwise
 */
@VisibleForTesting
static boolean waitUntilLaunchTerminates(ILaunch launch, IProgressMonitor monitor)
    throws InterruptedException, DebugException {
  while (!launch.isTerminated() && !monitor.isCanceled()) {
    Thread.sleep(100 /*ms*/);
  }

  if (monitor.isCanceled()) {
    launch.terminate();
    return false;
  }
  for (IProcess process : launch.getProcesses()) {
    if (process.getExitValue() != 0) {
      return false;
    }
  }
  return true;
}
项目:google-cloud-eclipse    文件:FlexMavenPackagedProjectStagingDelegate.java   
@Override
protected IPath getDeployArtifact(IPath safeWorkingDirectory, IProgressMonitor monitor)
    throws CoreException {
  SubMonitor subMonitor = SubMonitor.convert(monitor, 100);

  try {
    ILaunchConfiguration config = createMavenPackagingLaunchConfiguration(project);
    ILaunch launch = config.launch("run", subMonitor.newChild(10));
    if (!waitUntilLaunchTerminates(launch, subMonitor.newChild(90))) {
      throw new OperationCanceledException();
    }
    return getFinalArtifactPath(project);
  } catch (InterruptedException ex) {
    throw new OperationCanceledException();
  }
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegate.java   
@VisibleForTesting
void checkConflictingLaunches(ILaunchConfigurationType launchConfigType, String mode,
    DefaultRunConfiguration runConfig, ILaunch[] launches) throws CoreException {

  for (ILaunch launch : launches) {
    if (launch.isTerminated()
        || launch.getLaunchConfiguration() == null
        || launch.getLaunchConfiguration().getType() != launchConfigType) {
      continue;
    }
    IServer otherServer = ServerUtil.getServer(launch.getLaunchConfiguration());
    DefaultRunConfiguration otherRunConfig =
        generateServerRunConfiguration(launch.getLaunchConfiguration(), otherServer, mode);
    IStatus conflicts = checkConflicts(runConfig, otherRunConfig,
        new MultiStatus(Activator.PLUGIN_ID, 0,
            Messages.getString("conflicts.with.running.server", otherServer.getName()), //$NON-NLS-1$
            null));
    if (!conflicts.isOK()) {
      throw new CoreException(StatusUtil.filter(conflicts));
    }
  }
}
项目:google-cloud-eclipse    文件:FlexMavenPackagedProjectStagingDelegateTest.java   
@Test
public void testWaitUntilLaunchTerminates_atLeastOneNonZeroExit()
    throws DebugException, InterruptedException {
  IProcess process = mock(IProcess.class);
  when(process.getExitValue()).thenReturn(0);
  IProcess nonZeroExitProcess = mock(IProcess.class);
  when(nonZeroExitProcess.getExitValue()).thenReturn(1);

  ILaunch launch = mock(ILaunch.class);
  when(launch.isTerminated()).thenReturn(true);
  when(launch.getProcesses()).thenReturn(new IProcess[] {process, nonZeroExitProcess});

  boolean normalExit = FlexMavenPackagedProjectStagingDelegate.waitUntilLaunchTerminates(
      launch, new NullProgressMonitor());
  assertFalse(normalExit);
}
项目:EclipsePlugins    文件:AntLauncher.java   
@Override
public void launchesTerminated(ILaunch[] launches) {
    boolean found = false;
    for (int i = 0; i < launches.length; i++) {
        if (launches[i].equals(launch)) {
            found = true;
            break;
        }
    }
    if (!found || notified) {
        return;
    }
    notified = true;
    if (success) {
        succeededCallback.run();
    }
    DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
}
项目:cft    文件:ApplicationDebugLauncher.java   
public static ILaunch getLaunch(String launchId) {
    if (launchId == null) {
        return null;
    }
    ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
    for (ILaunch launch : launches) {
        ILaunchConfiguration config = launch.getLaunchConfiguration();
        try {
            // Fix for NPE: Bug 518204
            if (config != null && launchId.equals(
                    config.getAttribute(CloudFoundryDebugDelegate.CLOUD_DEBUG_APP_LAUNCH_ID, (String) null))) {
                return launch;
            }
        }
        catch (CoreException e) {
            CloudFoundryPlugin.logWarning(e.getMessage());
        }
    }
    return null;
}
项目:coordination    文件:CoordinatedModelExecutionContext.java   
private ILaunch createAndLaunchConfiguration(ExecutionMode executionMode,
        IProgressMonitor monitor, URI launchURI) {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    String launchPathName = launchURI.toPlatformString(true);
    String tmpProjectName = launchPathName.substring(1, launchPathName.length());
    String projectName = tmpProjectName.substring(0, tmpProjectName.indexOf('/'));
    IProject launchProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    IFile launchFile = launchProject.getFile(launchPathName.replaceFirst("/"+projectName+"/", ""));
    ILaunchConfiguration launch = manager.getLaunchConfiguration(launchFile);
    try {
        ILaunch startedLaunch = launch.launch(ILaunchManager.DEBUG_MODE, monitor);
        return startedLaunch;
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return null;
}
项目:gerrit-tools    文件:BranchOperationUI.java   
private ILaunchConfiguration getRunningLaunchConfiguration() {
    Set<IProject> projects = new HashSet<IProject>(
            Arrays.asList(ProjectUtil.getProjects(repository)));

    ILaunchManager launchManager = DebugPlugin.getDefault()
            .getLaunchManager();
    ILaunch[] launches = launchManager.getLaunches();
    for (ILaunch launch : launches) {
        if (launch.isTerminated())
            continue;
        ISourceLocator locator = launch.getSourceLocator();
        if (locator instanceof ISourceLookupDirector) {
            ISourceLookupDirector director = (ISourceLookupDirector) locator;
            ISourceContainer[] containers = director.getSourceContainers();
            if (isAnyProjectInSourceContainers(containers, projects))
                return launch.getLaunchConfiguration();
        }
    }
    return null;
}
项目:testability-explorer    文件:TestabilityCompilationParticipant.java   
@Override
public void buildFinished(IJavaProject project) {
  super.buildFinished(project);
  ILaunchConfiguration launchConfiguration =
      configurationHelper.getLaunchConfiguration(project.getElementName());
  if (launchConfiguration != null) {
    try {
      ILaunchConfigurationWorkingCopy workingCopy = launchConfiguration.getWorkingCopy();
      workingCopy.setAttribute(
          TestabilityConstants.CONFIGURATION_ATTR_RUNNING_IN_COMPILATION_MODE, true);
      ILaunch launch = workingCopy.launch(TestabilityConstants.TESTABILITY_MODE, null);
    } catch (CoreException e) {
      logger.logException(e);
    }
  }
}
项目:gwt-eclipse-plugin    文件:WebAppDebugModel.java   
/**
 * Given a {@link ILaunch} of a terminated launch, find the associated launch configuration in the
 * model, and mark it as terminated. Fires an event to all listeners on the
 * {@link WebAppDebugModel}.
 *
 * This method does nothing if no such launch configuration can be found.
 */
public void launchTerminated(ILaunch launch) {
  LaunchConfiguration launchConfiguration = null;
  synchronized (privateInstanceLock) {
    for (LaunchConfiguration lc : launchConfigurations) {
      if (lc.getLaunch() == launch) {
        launchConfiguration = lc;
        break;
      }
    }
  }

  if (launchConfiguration != null) {
    launchConfiguration.setTerminated();
  }
}
项目:gwt-eclipse-plugin    文件:GwtWtpPlugin.java   
private void onAfterCodeServerStarted(DebugEvent event) {
  if (!(event.getSource() instanceof IProcess)) {
    return;
  }

  IProcess runtimeProcess = (IProcess) event.getSource();
  final ILaunch launch = runtimeProcess.getLaunch();
  IProcess[] processes = launch.getProcesses();
  final IProcess process = processes[0];

  // Look for the links in the sdm console output
  consoleStreamListenerCodeServer = new IStreamListener() {
    @Override
    public void streamAppended(String text, IStreamMonitor monitor) {
      displayCodeServerUrlInDevMode(launch, text);
    }
  };

  // Listen to Console output
  streamMonitorCodeServer = process.getStreamsProxy().getOutputStreamMonitor();
  streamMonitorCodeServer.addListener(consoleStreamListenerCodeServer);
}
项目:gwt-eclipse-plugin    文件:GwtWtpPlugin.java   
private void displayCodeServerUrlInDevMode(final ILaunch launch, String text) {
  if (!text.contains("http")) {
    return;
  }

  // Extract URL http://localhost:9876/
  String url = text.replaceAll(".*(http.*).*?", "$1").trim();
  if (url.matches(".*/")) {
    url = url.substring(0, url.length() - 1);
    launchUrls.add(url);
  }

  // Dev Mode View, add url
  LaunchConfiguration lc = WebAppDebugModel.getInstance().addOrReturnExistingLaunchConfiguration(launch, "", null);
  lc.setLaunchUrls(launchUrls);
}
项目:gwt-eclipse-plugin    文件:SwtBotLaunchManagerActions.java   
public static void terminateAllLaunchConfigs(SWTBot bot) {
  SwtBotUtils.print("Terminating Launches");

  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  ILaunch[] launches = manager.getLaunches();
  if (launches == null || launches.length == 0) {
    SwtBotUtils.print("No Launches to terminate");
  }

  for (ILaunch launch : launches) {
    if (!launch.isTerminated()) {
      try {
        launch.terminate();
      } catch (DebugException e) {
        SwtBotUtils.printError("Could not terminate launch." + e.getMessage());
      }
    }
  }

  SwtBotWorkbenchActions.waitForIdle(bot);

  SwtBotUtils.print("Terminated Launches");
}
项目:egradle    文件:EGradleRuntimeProcess.java   
public static EGradleRuntimeProcess create(ILaunch launch, Process process, String name,
        Map<String, String> attributes) {
    // workaround, because attribute must be set before constructor call
    // DEFINE EGRADLE AS PROCESS TYPE - so console line tracker is able to track
            attributes.put(IProcess.ATTR_PROCESS_TYPE, "EGradleRuntimeProcess");
    return new EGradleRuntimeProcess(launch, process, name, attributes);
}
项目:gemfirexd-oss    文件:DerbyServerUtils.java   
public void startDerbyServer( IProject proj) throws CoreException {
    String args = CommonNames.START_DERBY_SERVER;
    String vmargs="";
    DerbyProperties dprop=new DerbyProperties(proj);
    //Starts the server as a Java app
    args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();

    //Set Derby System Home from the Derby Properties
    if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
        vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
    }
    String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.START_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";
    ILaunch launch = DerbyUtils.launch(proj, procName ,     
    CommonNames.DERBY_SERVER_CLASS, args, vmargs, CommonNames.START_DERBY_SERVER);
    IProcess ip=launch.getProcesses()[0];
    //set a name to be seen in the Console list
    ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);

    // saves the mapping between (server) process and project
    //servers.put(launch.getProcesses()[0], proj);
    servers.put(ip, proj);
    // register a listener to listen, when this process is finished
    DebugPlugin.getDefault().addDebugEventListener(listener);
    //Add resource listener
    IWorkspace workspace = ResourcesPlugin.getWorkspace();

    workspace.addResourceChangeListener(rlistener);
    setRunning(proj, Boolean.TRUE);
    Shell shell = new Shell();
    MessageDialog.openInformation(
        shell,
        CommonNames.PLUGIN_NAME,
        Messages.D_NS_ATTEMPT_STARTED+dprop.getPort()+".");

}
项目:gemfirexd-oss    文件:DerbyServerUtils.java   
public void stopDerbyServer( IProject proj) throws CoreException, ClassNotFoundException, SQLException {
    String args = CommonNames.SHUTDOWN_DERBY_SERVER;
    String vmargs="";
    DerbyProperties dprop=new DerbyProperties(proj);
    args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();

    //  Set Derby System Home from the Derby Properties
    if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
        vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
    }
    String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.SHUTDOWN_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";

    // starts the server as a Java app
    ILaunch launch = DerbyUtils.launch(proj, procName,
    CommonNames.DERBY_SERVER_CLASS, args, vmargs,CommonNames.SHUTDOWN_DERBY_SERVER);
    IProcess ip=launch.getProcesses()[0];

    //set a name to be seen in the Console list
    ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);

    //update the objectState
    setRunning(proj, Boolean.FALSE);
    if(proj.isOpen()){
        Shell shell = new Shell();
        MessageDialog.openInformation(
        shell,
        CommonNames.PLUGIN_NAME,
        Messages.D_NS_ATTEMPT_STOPPED+dprop.getPort()+"." );
    }
}
项目:gemfirexd-oss    文件:DerbyUtils.java   
public static void runIJ(IFile currentScript, IProject currentProject) throws CoreException {   

        String launchType="";
        String args="";

        //the above some times throws wrong 'create=true|false' errors
        String vmargs="";
        DerbyProperties dprop=new DerbyProperties(currentProject);
        if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
            vmargs+=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
        }

        if(currentScript!=null){
            launchType=CommonNames.SQL_SCRIPT;

            //Preferable to use the full String with quotes to take care of spaces 
            //in file names
            args="\""+currentScript.getLocation().toOSString()+"\"";
        }else{
            launchType=CommonNames.IJ;
            args="";    
        }

        ILaunch launch=launch(currentProject,launchType,CommonNames.IJ_CLASS,args, vmargs, CommonNames.IJ);
        IProcess ip=launch.getProcesses()[0];
        String procName="["+currentProject.getName()+"] - "+CommonNames.IJ+" "+args;
        ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
    }
项目:gemfirexd-oss    文件:DerbyUtils.java   
public static void runSysInfo(IProject currentProject) throws CoreException {   
    String args="";
    ILaunch launch=launch(currentProject,CommonNames.SYSINFO,CommonNames.SYSINFO_CLASS,args, null, CommonNames.SYSINFO);
    IProcess ip=launch.getProcesses()[0];
    String procName="["+currentProject.getName()+"] - "+CommonNames.SYSINFO;
    ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
}
项目:eclemma    文件:SessionManager.java   
public void removeSessionsFor(ILaunch launch) {
  synchronized (lock) {
    final List<ICoverageSession> sessionsToRemove = launchmap.get(launch);
    if (sessionsToRemove != null) {
      removeSessions(sessionsToRemove);
    }
  }
}
项目:eclemma    文件:EclEmmaCorePlugin.java   
public void handleDebugEvents(DebugEvent[] events) {
  for (final DebugEvent e : events) {
    if (e.getSource() instanceof IProcess
        && e.getKind() == DebugEvent.TERMINATE) {
      final IProcess proc = (IProcess) e.getSource();
      final ILaunch launch = proc.getLaunch();
      if (launch instanceof CoverageLaunch) {
        final CoverageLaunch coverageLaunch = (CoverageLaunch) launch;
        coverageLaunch.getAgentServer().stop();
        checkExecutionData(coverageLaunch);
      }
    }
  }
}
项目:google-cloud-eclipse    文件:DataflowPipelineLaunchDelegateTest.java   
@Test
public void testLaunchWithLaunchConfigurationWithIncompleteArgsThrowsIllegalArgumentException()
    throws CoreException {
  ILaunchConfiguration configuration = mockILaunchConfiguration();
  Map<String, String> incompleteRequiredArguments = ImmutableMap.of();
  when(
      configuration.getAttribute(
          PipelineConfigurationAttr.ALL_ARGUMENT_VALUES.toString(),
          ImmutableMap.<String, String>of())).thenReturn(incompleteRequiredArguments);

  Set<PipelineOptionsProperty> properties =
      ImmutableSet.of(requiredProperty("foo"), requiredProperty("bar-baz"));
  when(
      pipelineOptionsHierarchy.getRequiredOptionsByType(
          "com.google.cloud.dataflow.sdk.options.BlockingDataflowPipelineOptions"))
      .thenReturn(
          ImmutableMap.of(
              new PipelineOptionsType(
                  "MyOptions", Collections.<PipelineOptionsType>emptySet(), properties),
              properties));

  String mode = "run";
  ILaunch launch = mock(ILaunch.class);

  try {
    dataflowDelegate.launch(configuration, mode, launch, monitor);
    fail();
  } catch (IllegalArgumentException ex) {
    assertTrue(ex.getMessage().contains("Dataflow Pipeline Configuration is not valid"));
  }
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegateTest.java   
@Test
public void testLaunch_noNullPointerExceptionWhenLaunchHasNoConfiguration() throws CoreException {
  ILaunch launch = mock(ILaunch.class);
  ILaunch[] launches = new ILaunch[] {launch};
  when(launch.getLaunchConfiguration()).thenReturn(null);

  new LocalAppEngineServerLaunchConfigurationDelegate().checkConflictingLaunches(null,
      ILaunchManager.RUN_MODE, mock(DefaultRunConfiguration.class), launches);
}
项目:google-cloud-eclipse    文件:LaunchHelperTest.java   
@Test(expected = CoreException.class)
public void failsIfAlreadyLaunched() throws CoreException {
  IModule module1 = appEngineStandardProject1.getModule();

  serverToReturn = mock(IServer.class);
  ILaunch launch = mock(ILaunch.class);
  when(serverToReturn.getServerState()).thenReturn(IServer.STATE_STARTED);
  when(serverToReturn.getLaunch()).thenReturn(launch);
  when(launch.getLaunchMode()).thenReturn(ILaunchManager.DEBUG_MODE);
  handler.launch(new IModule[] {module1}, ILaunchManager.DEBUG_MODE);
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegate.java   
@Override
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
  IServer server = ServerUtil.getServer(configuration);
  DefaultRunConfiguration runConfig = generateServerRunConfiguration(configuration, server, mode);
  ILaunch[] launches = getLaunchManager().getLaunches();
  checkConflictingLaunches(configuration.getType(), mode, runConfig, launches);
  return super.getLaunch(configuration, mode);
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegate.java   
private void setupDebugTarget(DefaultRunConfiguration devServerRunConfiguration, ILaunch launch,
    int debugPort, IProgressMonitor monitor) throws CoreException {
  if (debugPort <= 0 || debugPort > 65535) {
    throw new IllegalArgumentException("Debug port is set to " + debugPort //$NON-NLS-1$
        + ", should be between 1-65535"); //$NON-NLS-1$
  }
  List<String> jvmFlags = new ArrayList<>();
  if (devServerRunConfiguration.getJvmFlags() != null) {
    jvmFlags.addAll(devServerRunConfiguration.getJvmFlags());
  }
  jvmFlags.add("-Xdebug"); //$NON-NLS-1$
  jvmFlags.add("-Xrunjdwp:transport=dt_socket,server=n,suspend=y,quiet=y,address=" + debugPort); //$NON-NLS-1$
  devServerRunConfiguration.setJvmFlags(jvmFlags);

  // The 4.7 listen connector supports a connectionLimit
  IVMConnector connector =
      JavaRuntime.getVMConnector(IJavaLaunchConfigurationConstants.ID_SOCKET_LISTEN_VM_CONNECTOR);
  if (connector == null || !connector.getArgumentOrder().contains("connectionLimit")) { //$NON-NLS-1$
    // Attempt to retrieve our socketListenerMultipleConnector
    connector = JavaRuntime.getVMConnector(
        "com.google.cloud.tools.eclipse.jdt.launching.socketListenerMultipleConnector"); //$NON-NLS-1$
  }
  if (connector == null) {
    abort("Cannot find Socket Listening connector", null, 0); //$NON-NLS-1$
    return; // keep JDT null analysis happy
  }

  // Set JVM debugger connection parameters
  @SuppressWarnings("deprecation")
  int timeout = JavaRuntime.getPreferences().getInt(JavaRuntime.PREF_CONNECT_TIMEOUT);
  Map<String, String> connectionParameters = new HashMap<>();
  connectionParameters.put("hostname", DEBUGGER_HOST); //$NON-NLS-1$
  connectionParameters.put("port", Integer.toString(debugPort)); //$NON-NLS-1$
  connectionParameters.put("timeout", Integer.toString(timeout)); //$NON-NLS-1$
  connectionParameters.put("connectionLimit", "0"); //$NON-NLS-1$ //$NON-NLS-2$
  connector.connect(connectionParameters, monitor, launch);
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegate.java   
@Override
public void launchesTerminated(ILaunch[] launches) {
  for (ILaunch terminated : launches) {
    if (terminated == launch) {
      if (server.getServerState() == IServer.STATE_STARTED) {
        logger.fine("Launch terminated; stopping server"); //$NON-NLS-1$
        server.stop(false);
      }
      return;
    }
  }
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegate.java   
@Override
public void launchesRemoved(ILaunch[] launches) {
  for (ILaunch removed : launches) {
    if (removed == launch) {
      getLaunchManager().removeLaunchListener(launchesListener);
      removeConsole();
    }
  }
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegate.java   
private CloudSdkDebugTarget(ILaunch launch, LocalAppEngineServerBehaviour serverBehaviour,
    IOConsole console) {
  super(null);
  this.launch = launch;
  this.serverBehaviour = serverBehaviour;
  server = serverBehaviour.getServer();
  this.console = console;
}
项目:google-cloud-eclipse    文件:DevAppServerProcessFactory.java   
@Override
public IProcess newProcess(ILaunch launch,
                           Process process,
                           String label,
                           Map<String, String> attributes) {
  return new DevAppServerRuntimeProcess(launch, process, label, attributes);
}
项目:google-cloud-eclipse    文件:FlexMavenPackagedProjectStagingDelegateTest.java   
@Test
public void testWaitUntilLaunchTerminates_cancaledMonitor()
    throws DebugException, InterruptedException {
  IProgressMonitor monitor = new NullProgressMonitor();
  monitor.setCanceled(true);
  assertTrue(monitor.isCanceled());

  ILaunch launch = mock(ILaunch.class);
  assertFalse(launch.isTerminated());

  boolean normalExit = FlexMavenPackagedProjectStagingDelegate.waitUntilLaunchTerminates(
      launch, monitor);
  assertFalse(normalExit);
  verify(launch).terminate();
}