Search in sources :

Example 1 with LaunchHelper

use of com.liferay.ide.core.util.LaunchHelper in project liferay-ide by liferay.

the class ServerManagerTests method startServer.

@Before
public void startServer() throws Exception {
    if (shouldSkipServerTests())
        return;
    final IServer server = getServer();
    assertEquals("Expected the port " + liferayServerStartPort + " is available", true, SocketUtil.isPortAvailable(liferayServerStartPort));
    assertEquals("Expected the port " + liferayServerAjpPort + " is available", true, SocketUtil.isPortAvailable(liferayServerAjpPort));
    changeServerXmlPort(BUNDLE_START_PORT, liferayServerStartPort);
    changeServerXmlPort(BUNDLE_AJP_PORT, liferayServerAjpPort);
    changeServerXmlPort(BUNDLE_SHUTDOWN_PORT, liferayServerShutdownPort);
    copyFileToServer(server, "deploy", "files", remoteIDEConnectorLPKGFileName);
    copyFileToServer(server, "", "files", portalSetupWizardFileName);
    final String exceFileName = Platform.getOS().contains("win") ? "catalina.bat" : "catalina.sh";
    final LaunchHelper launchHelper = new LaunchHelper();
    launchHelper.setLaunchSync(false);
    final IPath serverLocation = server.getRuntime().getLocation().append("bin");
    launchHelper.launch(getLaunchConfig(serverLocation, exceFileName, "run"), ILaunchManager.RUN_MODE, null);
    boolean stop = false;
    int i = 0;
    int statusCode = 0;
    while (!stop) {
        try {
            if (i > 1500) {
                stop = true;
            }
            URL pingUrl = new URL("http://localhost:" + liferayServerStartPort);
            URLConnection conn = pingUrl.openConnection();
            ((HttpURLConnection) conn).setInstanceFollowRedirects(false);
            statusCode = ((HttpURLConnection) conn).getResponseCode();
            if (!stop) {
                Thread.sleep(200);
            }
            stop = true;
        } catch (Exception e) {
            i++;
            Thread.sleep(200);
        }
    }
    service = new ServerManagerConnection();
    service.setHost("localhost");
    service.setHttpPort(liferayServerStartPort);
    service.setManagerContextPath("/server-manager-web");
    service.setUsername("test@liferay.com");
    service.setPassword("test");
    // Given the server 10 seconds to deploy remote IDE Connector plugin
    try {
        Thread.sleep(10000);
    } catch (Exception e) {
    }
    assertEquals(200, statusCode);
}
Also used : IServer(org.eclipse.wst.server.core.IServer) HttpURLConnection(java.net.HttpURLConnection) IPath(org.eclipse.core.runtime.IPath) LaunchHelper(com.liferay.ide.core.util.LaunchHelper) URL(java.net.URL) HttpURLConnection(java.net.HttpURLConnection) URLConnection(java.net.URLConnection) CoreException(org.eclipse.core.runtime.CoreException) IServerManagerConnection(com.liferay.ide.server.remote.IServerManagerConnection) ServerManagerConnection(com.liferay.ide.server.remote.ServerManagerConnection) Before(org.junit.Before)

Example 2 with LaunchHelper

use of com.liferay.ide.core.util.LaunchHelper in project liferay-ide by liferay.

the class ServerManagerTests method stopServer.

@After
public void stopServer() throws Exception {
    if (shouldSkipServerTests())
        return;
    IServer server = getServer();
    final String exceFileName = Platform.getOS().contains("win") ? "shutdown.bat" : "shutdown.sh";
    final LaunchHelper launchHelper = new LaunchHelper();
    launchHelper.setLaunchSync(false);
    final IPath serverLocation = server.getRuntime().getLocation().append("bin");
    launchHelper.launch(getLaunchConfig(serverLocation, exceFileName, "run"), ILaunchManager.RUN_MODE, null);
    boolean stop = false;
    int i = 0;
    while (!stop) {
        try {
            if (i > 15) {
                stop = true;
            }
            URL pingUrl = new URL("http://localhost:" + liferayServerStartPort);
            URLConnection conn = pingUrl.openConnection();
            ((HttpURLConnection) conn).setInstanceFollowRedirects(false);
            ((HttpURLConnection) conn).getResponseCode();
            if (!stop) {
                Thread.sleep(200);
            }
            i++;
        } catch (Exception e) {
            stop = true;
        }
    }
    changeServerXmlPort(liferayServerShutdownPort, BUNDLE_SHUTDOWN_PORT);
    changeServerXmlPort(liferayServerStartPort, BUNDLE_START_PORT);
    changeServerXmlPort(liferayServerAjpPort, BUNDLE_AJP_PORT);
}
Also used : IServer(org.eclipse.wst.server.core.IServer) HttpURLConnection(java.net.HttpURLConnection) IPath(org.eclipse.core.runtime.IPath) LaunchHelper(com.liferay.ide.core.util.LaunchHelper) URL(java.net.URL) HttpURLConnection(java.net.HttpURLConnection) URLConnection(java.net.URLConnection) CoreException(org.eclipse.core.runtime.CoreException) After(org.junit.After)

Example 3 with LaunchHelper

use of com.liferay.ide.core.util.LaunchHelper in project liferay-ide by liferay.

the class MavenProjectRemoteServerPublisher method _execMavenLaunch.

private boolean _execMavenLaunch(IProject project, String goal, IMavenProjectFacade facade, IProgressMonitor monitor) throws CoreException {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(_launchConfigurationTypeId);
    IPath basedirLocation = project.getLocation();
    String newName = launchManager.generateLaunchConfigurationName(basedirLocation.lastSegment());
    ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(null, newName);
    workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Dmaven.multiModuleProjectDirectory");
    workingCopy.setAttribute(_attrPomDir, basedirLocation.toString());
    workingCopy.setAttribute(_attrGoals, goal);
    workingCopy.setAttribute(_attrUpdateSnapshots, Boolean.TRUE);
    workingCopy.setAttribute(_attrWorkspaceResolution, Boolean.TRUE);
    workingCopy.setAttribute(_attrSkipTests, Boolean.TRUE);
    if (facade != null) {
        ResolverConfiguration configuration = facade.getResolverConfiguration();
        String selectedProfiles = configuration.getSelectedProfiles();
        if ((selectedProfiles != null) && (selectedProfiles.length() > 0)) {
            workingCopy.setAttribute(_attrProfiles, selectedProfiles);
        }
        new LaunchHelper().launch(workingCopy, "run", monitor);
        return true;
    } else {
        return false;
    }
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) IPath(org.eclipse.core.runtime.IPath) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) LaunchHelper(com.liferay.ide.core.util.LaunchHelper) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 4 with LaunchHelper

use of com.liferay.ide.core.util.LaunchHelper in project liferay-ide by liferay.

the class MavenProjectBuilder method _execMavenLaunch.

private boolean _execMavenLaunch(IProject project, String goal, IMavenProjectFacade facade, IProgressMonitor monitor) throws CoreException {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(_launchConfigurationTypeId);
    IPath basedirLocation = project.getLocation();
    String newName = launchManager.generateLaunchConfigurationName(basedirLocation.lastSegment());
    ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(null, newName);
    workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Dmaven.multiModuleProjectDirectory");
    workingCopy.setAttribute(_attrPomDir, basedirLocation.toString());
    workingCopy.setAttribute(_attrGoals, goal);
    // workingCopy.setAttribute( ATTR_UPDATE_SNAPSHOTS, Boolean.TRUE );
    workingCopy.setAttribute(_attrWorkspaceResolution, Boolean.TRUE);
    workingCopy.setAttribute(_attrSkipTests, Boolean.TRUE);
    if (facade != null) {
        ResolverConfiguration configuration = facade.getResolverConfiguration();
        String selectedProfiles = configuration.getSelectedProfiles();
        if ((selectedProfiles != null) && (selectedProfiles.length() > 0)) {
            workingCopy.setAttribute(_attrProfiles, selectedProfiles);
        }
        new LaunchHelper().launch(workingCopy, "run", monitor);
        return true;
    } else {
        return false;
    }
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) IPath(org.eclipse.core.runtime.IPath) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) LaunchHelper(com.liferay.ide.core.util.LaunchHelper) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Aggregations

LaunchHelper (com.liferay.ide.core.util.LaunchHelper)4 IPath (org.eclipse.core.runtime.IPath)4 HttpURLConnection (java.net.HttpURLConnection)2 URL (java.net.URL)2 URLConnection (java.net.URLConnection)2 CoreException (org.eclipse.core.runtime.CoreException)2 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)2 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)2 ILaunchManager (org.eclipse.debug.core.ILaunchManager)2 ResolverConfiguration (org.eclipse.m2e.core.project.ResolverConfiguration)2 IServer (org.eclipse.wst.server.core.IServer)2 IServerManagerConnection (com.liferay.ide.server.remote.IServerManagerConnection)1 ServerManagerConnection (com.liferay.ide.server.remote.ServerManagerConnection)1 After (org.junit.After)1 Before (org.junit.Before)1