Search in sources :

Example 26 with IServer

use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.

the class ServerCustomSettingTests method testVMArgsWithCustomMemoryArgs.

@Test
public void testVMArgsWithCustomMemoryArgs() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final NullProgressMonitor npm = new NullProgressMonitor();
    if (runtime == null) {
        setupRuntime();
    }
    assertNotNull(runtime);
    final IServerWorkingCopy serverWC = createServerForRuntime("testvmargs", runtime);
    ILiferayTomcatServerWC wc = (ILiferayTomcatServerWC) serverWC.loadAdapter(ILiferayTomcatServerWC.class, npm);
    wc.setMemoryArgs("-Xmx2048m");
    final IServer newServer = serverWC.save(true, npm);
    final LiferayTomcatServerBehavior behavior = (LiferayTomcatServerBehavior) newServer.loadAdapter(LiferayTomcatServerBehavior.class, npm);
    assertEquals("-Xmx2048m", behavior.getRuntimeVMArguments()[6]);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ILiferayTomcatServerWC(com.liferay.ide.server.tomcat.core.ILiferayTomcatServerWC) IServer(org.eclipse.wst.server.core.IServer) LiferayTomcatServerBehavior(com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) Test(org.junit.Test)

Example 27 with IServer

use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.

the class ServerCustomSettingTests method testVMArgsWithDefaultUseDefaultPortalSettings.

@Test
public void testVMArgsWithDefaultUseDefaultPortalSettings() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final NullProgressMonitor npm = new NullProgressMonitor();
    if (runtime == null) {
        setupRuntime();
    }
    assertNotNull(runtime);
    final IServerWorkingCopy serverWC = createServerForRuntime("testvmargs", runtime);
    final IServer newServer = serverWC.save(true, npm);
    final LiferayTomcatServerBehavior behavior = (LiferayTomcatServerBehavior) newServer.loadAdapter(LiferayTomcatServerBehavior.class, npm);
    assertEquals("-Xmx1024m", behavior.getRuntimeVMArguments()[6]);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) LiferayTomcatServerBehavior(com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) Test(org.junit.Test)

Example 28 with IServer

use of org.eclipse.wst.server.core.IServer 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 29 with IServer

use of org.eclipse.wst.server.core.IServer 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 30 with IServer

use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.

the class InitConfigureProjectPage method importProject.

protected void importProject() throws CoreException {
    String layout = dataModel.getLayout().content();
    IPath location = PathBridge.create(dataModel.getSdkLocation().content());
    if (_isAlreadyImported(location)) {
        Stream.of(CoreUtil.getAllProjects()).forEach(this::_checkProjectType);
        dataModel.setImportFinished(true);
        return;
    }
    try {
        IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
        progressService.run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
                try {
                    String newPath = "";
                    _backup(monitor);
                    _clearExistingProjects(location, monitor);
                    _deleteEclipseConfigFiles(location.toFile());
                    if (_isMavenProject(location.toPortableString())) {
                        ILiferayProjectImporter importer = LiferayCore.getImporter("maven");
                        List<IProject> projects = importer.importProjects(location.toPortableString(), monitor);
                        for (IProject project : projects) {
                            _checkProjectType(project);
                        }
                    } else {
                        if (layout.equals("Upgrade to Liferay Workspace")) {
                            _createLiferayWorkspace(location, monitor);
                            _removeIvyPrivateSetting(location.append("plugins-sdk"));
                            newPath = _renameProjectFolder(location);
                            IPath sdkLocation = new Path(newPath).append("plugins-sdk");
                            _deleteSDKLegacyProjects(sdkLocation);
                            ILiferayProjectImporter importer = LiferayCore.getImporter("gradle");
                            importer.importProjects(newPath, monitor);
                            if (dataModel.getDownloadBundle().content()) {
                                _createInitBundle(monitor);
                            }
                            _importSDKProject(sdkLocation, monitor);
                            dataModel.setConvertLiferayWorkspace(true);
                        } else {
                            _deleteEclipseConfigFiles(location.toFile());
                            _copyNewSDK(location, monitor);
                            _removeIvyPrivateSetting(location);
                            _deleteSDKLegacyProjects(location);
                            String serverName = dataModel.getLiferay70ServerName().content();
                            IServer server = ServerUtil.getServer(serverName);
                            newPath = _renameProjectFolder(location);
                            SDK sdk = SDKUtil.createSDKFromLocation(new Path(newPath));
                            sdk.addOrUpdateServerProperties(ServerUtil.getLiferayRuntime(server).getLiferayHome());
                            SDKUtil.openAsProject(sdk, monitor);
                            _importSDKProject(sdk.getLocation(), monitor);
                        }
                    }
                    dataModel.setImportFinished(true);
                } catch (Exception e) {
                    ProjectUI.logError(e);
                    throw new InvocationTargetException(e, e.getMessage());
                }
            }
        });
    } catch (Exception e) {
        ProjectUI.logError(e);
        throw new CoreException(StatusBridge.create(Status.createErrorStatus(e.getMessage(), e)));
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IServer(org.eclipse.wst.server.core.IServer) IPath(org.eclipse.core.runtime.IPath) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) BladeCLIException(com.liferay.ide.project.core.modules.BladeCLIException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) JDOMException(org.jdom.JDOMException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ILiferayProjectImporter(com.liferay.ide.core.ILiferayProjectImporter) CoreException(org.eclipse.core.runtime.CoreException) IProgressService(org.eclipse.ui.progress.IProgressService) ArrayList(java.util.ArrayList) List(java.util.List) SDK(com.liferay.ide.sdk.core.SDK)

Aggregations

IServer (org.eclipse.wst.server.core.IServer)183 CoreException (org.eclipse.core.runtime.CoreException)39 IModule (org.eclipse.wst.server.core.IModule)32 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)30 Test (org.junit.Test)30 IProject (org.eclipse.core.resources.IProject)25 IStatus (org.eclipse.core.runtime.IStatus)25 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)23 ArrayList (java.util.ArrayList)20 File (java.io.File)17 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 Status (org.eclipse.core.runtime.Status)12 Iterator (java.util.Iterator)11 IPath (org.eclipse.core.runtime.IPath)11 IServerType (org.eclipse.wst.server.core.IServerType)11 CDKServer (org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)11 IOException (java.io.IOException)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 Server (org.eclipse.wst.server.core.internal.Server)10 IFolder (org.eclipse.core.resources.IFolder)8