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]);
}
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]);
}
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);
}
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);
}
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)));
}
}
Aggregations