@Test public void testCustom() { try { IServer s = ServerCreationTestUtils.createMockServerWithRuntime(serverType, serverType); IServerWorkingCopy wc = s.createWorkingCopy(); wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_CUSTOM); wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY, "/home/user/test"); s = wc.save(true, null); String[] folders = getAdditions().getDeployLocationFolders(s); assertEquals(1, folders.length); assertTrue(folders[0].equals("/home/user/test")); } catch (CoreException ce) { fail("Unable to save changes to server"); } }
public void undo() { if (listener != null) combo.removeModifyListener(listener); wc.setAttribute(key, oldVal); if (combo != null && !combo.isDisposed()) combo.setText(oldVal); if (listener != null) combo.addModifyListener(listener); postOp(POST_UNDO); }
/** * Sets the attribute value in the underlying {@link IServer} * * @param attributeName * @param attributeValue * @throws CoreException */ private void configureServerAttribute(final String attributeName, boolean attributeValue) throws CoreException { final IServerWorkingCopy workingCopy = getServer().createWorkingCopy(); workingCopy.setAttribute(attributeName, attributeValue); // setServerRestartState(true); workingCopy.save(true, new NullProgressMonitor()); }
public IStatus redo() { if (listener != null) combo.removeModifyListener(listener); wc.setAttribute(key, newVal); if (combo != null && !combo.isDisposed()) combo.setText(newVal); if (listener != null) combo.addModifyListener(listener); postOp(POST_REDO); return Status.OK_STATUS; }
@Test public void testNoAdditionsRemovalsFromSettings() { // This test ensures that 'remote' servers are not handled by the standard listeners IServer s = ServerCreationTestUtils.createMockServerWithRuntime(serverType, serverType); try { IServerWorkingCopy wc = s.createWorkingCopy(); wc.setAttribute(IJBossToolingConstants.PROPERTY_ADD_DEPLOYMENT_SCANNERS, false); wc.setAttribute(IJBossToolingConstants.PROPERTY_REMOVE_DEPLOYMENT_SCANNERS, false); s = wc.save(true, null); } catch (CoreException ce) { fail("Could not set server mode to non-local"); } // Accepts will also check if the proper server type is here ServerExtendedProperties props = (ServerExtendedProperties) s.loadAdapter(ServerExtendedProperties.class, null); boolean usesManagement = props != null && props.getMultipleDeployFolderSupport() == ServerExtendedProperties.DEPLOYMENT_SCANNER_AS7_MANAGEMENT_SUPPORT; boolean usesJMX = props != null && props.getMultipleDeployFolderSupport() == ServerExtendedProperties.DEPLOYMENT_SCANNER_JMX_SUPPORT; boolean accepts = new LocalJBoss7DeploymentScannerAdditions().accepts(s); assertEquals(accepts, usesManagement); accepts = new JMXServerDeploymentScannerAdditions().accepts(s); assertEquals(accepts, usesJMX); Job j1 = new LocalJBoss7DeploymentScannerAdditions().getUpdateDeploymentScannerJob(s); assertNull(j1); Job j2 = new JMXServerDeploymentScannerAdditions().getUpdateDeploymentScannerJob(s); assertNull(j2); Job j3 = new LocalJBoss7DeploymentScannerAdditions().getRemoveDeploymentScannerJob(s); assertNull(j3); Job j4 = new JMXServerDeploymentScannerAdditions().getRemoveDeploymentScannerJob(s); assertNull(j4); }
@Test public void testMetadataWithCustomModule() { try { // Create the server IServer s = ServerCreationTestUtils.createMockServerWithRuntime(serverType, serverType); IServerWorkingCopy wc = s.createWorkingCopy(); wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_METADATA); s = wc.save(true, null); // Create the project projNum++; String projName = "Project" + projNum; IDataModel dm = CreateProjectOperationsUtility.getWebDataModel( projName, null, null, null, null, JavaEEFacetConstants.WEB_24, false); try { OperationTestCase.runAndVerify(dm); } catch (Exception e) { fail("Unable to create test web project: " + e.getMessage()); } IProject p = ResourceUtils.findProject(projName); assertTrue(p.exists()); IModule projMod = ServerUtil.getModule(p); // Set the custom setting. For now, just override output name wc = s.createWorkingCopy(); AbstractPublishingTest.setCustomDeployOverride(wc, projMod, "newName.war", null, null); s = wc.save(true, null); // verify no change vs standard metadata String[] folders = getAdditions().getDeployLocationFolders(s); assertEquals(1, folders.length); assertTrue(folders[0].contains("metadata")); // Change it to now make some other output folder wc = s.createWorkingCopy(); AbstractPublishingTest.setCustomDeployOverride( wc, projMod, "newName.war", "/home/user/deploy", null); s = wc.save(true, null); folders = getAdditions().getDeployLocationFolders(s); assertEquals(2, folders.length); assertTrue(folders[0].contains("metadata")); assertTrue(folders[1].equals("/home/user/deploy")); } catch (CoreException ce) { fail("Unable to save changes to server"); } }
public static void savePreferencesToServerWorkingCopy( IServerWorkingCopy wc, DeploymentPreferences prefs) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DeploymentPreferencesLoader.savePreferences(bos, prefs); String asXML = new String(bos.toByteArray()); wc.setAttribute(DeploymentPreferencesLoader.DEPLOYMENT_PREFERENCES_KEY, asXML); } catch (IOException ioe) { // Should never happen since this is a simple byte array output stream JBossServerCorePlugin.log( new Status( IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Could not save module deployment preferences to server " + wc.getOriginal().getName(), ioe)); //$NON-NLS-1$ } }
/** * Checks if this started server has already a configured proxy and returns the associated port if * it is still free, or associate a new port if the previous port is not avaiable anymore, or * create a new port if none existed before. * * @param startedServer * @return the proxy port * @throws CoreException */ private int getProxyPort(final IServer startedServer) throws CoreException { final IServer liveReloadServer = getServer(); @SuppressWarnings("unchecked") final Map<String, Integer> proxyPorts = liveReloadServer.getAttribute(PROXY_PORTS, new HashMap<String, Integer>()); final String startedServerId = startedServer.getId(); if (proxyPorts.containsKey(startedServerId)) { final int port = proxyPorts.get(startedServerId); if (!SocketUtil.isPortInUse(port)) { return port; } } final IServerWorkingCopy swc = getServer().createWorkingCopy(); final int port = SocketUtil.findUnusedPort(50000, 60000); proxyPorts.put(startedServerId, port); swc.setAttribute(PROXY_PORTS, proxyPorts); swc.saveAll(true, null); return port; }
@Test public void testRemoteGetsNoAdditionsInvalidMode() { // This test ensures that 'remote' servers are not handled by the standard listeners IServer s = ServerCreationTestUtils.createMockServerWithRuntime(serverType, serverType); try { IServerWorkingCopy wc = s.createWorkingCopy(); wc.setAttribute(IDeployableServer.SERVER_MODE, "mock5unknown"); s = wc.save(true, null); } catch (CoreException ce) { fail("Could not set server mode to non-local"); } boolean accepts = new LocalJBoss7DeploymentScannerAdditions().accepts(s); assertFalse(accepts); accepts = new JMXServerDeploymentScannerAdditions().accepts(s); assertFalse(accepts); Job j1 = new LocalJBoss7DeploymentScannerAdditions().getUpdateDeploymentScannerJob(s); assertNull(j1); Job j2 = new JMXServerDeploymentScannerAdditions().getUpdateDeploymentScannerJob(s); assertNull(j2); }
public void execute() { wc.setAttribute(key, newVal); postOp(POST_EXECUTE); }