Search in sources :

Example 1 with ServerManagerConnection

use of com.liferay.ide.server.remote.ServerManagerConnection in project liferay-ide by liferay.

the class LiferayServerCore method getRemoteConnection.

public static IServerManagerConnection getRemoteConnection(final IRemoteServer server) {
    IServerManagerConnection retval = null;
    if (connections == null) {
        connections = new HashMap<String, IServerManagerConnection>();
    }
    if (server != null) {
        IServerManagerConnection service = connections.get(server.getId());
        if (service == null) {
            service = new ServerManagerConnection();
            updateConnectionSettings(server, service);
            connections.put(server.getId(), service);
        } else {
            updateConnectionSettings(server, service);
        }
        retval = service;
    }
    return retval;
}
Also used : IServerManagerConnection(com.liferay.ide.server.remote.IServerManagerConnection) ServerManagerConnection(com.liferay.ide.server.remote.ServerManagerConnection) IServerManagerConnection(com.liferay.ide.server.remote.IServerManagerConnection)

Example 2 with ServerManagerConnection

use of com.liferay.ide.server.remote.ServerManagerConnection 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)

Aggregations

IServerManagerConnection (com.liferay.ide.server.remote.IServerManagerConnection)2 ServerManagerConnection (com.liferay.ide.server.remote.ServerManagerConnection)2 LaunchHelper (com.liferay.ide.core.util.LaunchHelper)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 IServer (org.eclipse.wst.server.core.IServer)1 Before (org.junit.Before)1