Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 301264 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-2 / +3 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Functional TPTP tests.
3
Bundle-Name: Functional TPTP tests.
4
Bundle-SymbolicName: org.eclipse.hyades.use.cases; singleton:=true
4
Bundle-SymbolicName: org.eclipse.hyades.use.cases; singleton:=true
5
Bundle-Version: 4.0.0
5
Bundle-Version: 4.0.100
6
Bundle-ClassPath: tptp-platform-tests.jar
6
Bundle-ClassPath: tptp-platform-tests.jar
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Require-Bundle: org.apache.xerces,
8
Require-Bundle: org.apache.xerces,
Lines 19-25 Link Here
19
 org.eclipse.hyades.test.ui,
19
 org.eclipse.hyades.test.ui,
20
 org.eclipse.ui.views,
20
 org.eclipse.ui.views,
21
 org.eclipse.ui.views.properties.tabbed,
21
 org.eclipse.ui.views.properties.tabbed,
22
 org.eclipse.core.resources
22
 org.eclipse.core.resources,
23
 org.eclipse.tptp.platform.iac.administrator
23
Bundle-ActivationPolicy: lazy
24
Bundle-ActivationPolicy: lazy
24
Export-Package: org.eclipse.hyades.use.cases.auto.common,
25
Export-Package: org.eclipse.hyades.use.cases.auto.common,
25
 org.eclipse.hyades.use.cases.auto.profiling.logging,
26
 org.eclipse.hyades.use.cases.auto.profiling.logging,
(-)src/org/eclipse/hyades/use/cases/junit/iac/administrator/internal/test/AdminUtilTest.java (+90 lines)
Added Link Here
1
/**********************************************************************
2
 Copyright (c) 2007, 2010 IBM Corporation and others.
3
 All rights reserved. This program and the accompanying materials
4
 are made available under the terms of the Eclipse Public License v1.0
5
 which accompanies this distribution, and is available at
6
 http://www.eclipse.org/legal/epl-v10.html
7
 $Id: ConfigGenerator.java,
8
 
9
 Contributors:
10
     IBM - initial implementation
11
 **********************************************************************/
12
13
package org.eclipse.hyades.use.cases.junit.iac.administrator.internal.test;
14
15
import java.io.File;
16
17
import junit.framework.TestCase;
18
19
import org.eclipse.tptp.platform.iac.administrator.internal.common.AdminUtil;
20
21
/**
22
 * Note: Test case moved from platform/org.eclipse.tptp.platform.iac.administrator/
23
 * org.eclipse.tptp.platform.iac.administrator.internal.test as part of bug 302579. 
24
 *
25
 */
26
27
public class AdminUtilTest extends TestCase {
28
29
	public void testGetIACPlugins() {		
30
		boolean found;
31
		File[] plugins = AdminUtil.getIACPlugins();
32
		assertTrue(plugins.length > 0);
33
		
34
		
35
		String[] expectedPlugins = {"org.apache.commons_logging","org.eclipse.hyades.execution","org.eclipse.hyades.logging.core","org.eclipse.hyades.probekit","org.eclipse.hyades.test.core","org.eclipse.hyades.test.tools.core","org.eclipse.tptp.platform.collection.framework","org.eclipse.tptp.platform.logging.events","org.eclipse.tptp.platform.models","org.eclipse.tptp.platform.models.hierarchy"};
36
		
37
		for(int i=0; i < plugins.length; i++)
38
		{
39
			/* Plugin name with version */
40
			String pluginName = plugins[i].getName();
41
			
42
			assertEquals(-1, pluginName.indexOf('\\'));
43
			assertEquals(-1, pluginName.indexOf('/'));
44
			assertTrue(pluginName.indexOf('_') >= 0);
45
			
46
			/* Plugin name without version */
47
			pluginName = pluginName.substring(0, pluginName.lastIndexOf('_'));
48
			
49
			found = false;
50
			/* Find the plugin in our list of expected plugins */
51
			for (int k=0; k < expectedPlugins.length; k++)
52
			{
53
				if(pluginName.equals(expectedPlugins[k]))
54
				{
55
					found = true;
56
					expectedPlugins[k] = "";
57
					break;
58
				}
59
			}
60
			assertTrue("Couldn't find " + pluginName + " in our list of expected plugins", found);
61
		}
62
		
63
		/* Make sure everything in our expected plugins list has been found */
64
		for (int i=0; i < expectedPlugins.length; i++)
65
		{
66
			assertTrue("Didn't find plugin " + expectedPlugins[i] + " in our list of actual plugins", expectedPlugins[i].equals(""));
67
		}
68
	}
69
	
70
	public void testGetIACBinFolder()
71
	{
72
		assertNotNull(AdminUtil.getIACBinFolder());
73
	}
74
	
75
	public void testGetIACHome()
76
	{
77
		assertNotNull(AdminUtil.getIACHome());
78
	}
79
	
80
	public void testGetPluginsFolder()
81
	{
82
		assertNotNull(AdminUtil.getPluginsFolder());
83
	}
84
	
85
	public void testGetJvmtiNativePath()
86
	{
87
		assertNotNull(AdminUtil.getJvmtiNativePath());
88
	}
89
90
}
(-)src/org/eclipse/hyades/use/cases/junit/iac/administrator/internal/test/AutoStartStopTest.java (+79 lines)
Added Link Here
1
/**********************************************************************
2
 Copyright (c) 2007, 2010 IBM Corporation and others.
3
 All rights reserved. This program and the accompanying materials
4
 are made available under the terms of the Eclipse Public License v1.0
5
 which accompanies this distribution, and is available at
6
 http://www.eclipse.org/legal/epl-v10.html
7
 $Id: ConfigGenerator.java,
8
 
9
 Contributors:
10
     IBM - initial implementation
11
 **********************************************************************/
12
13
package org.eclipse.hyades.use.cases.junit.iac.administrator.internal.test;
14
15
import junit.framework.TestCase;
16
17
import org.eclipse.tptp.platform.iac.administrator.internal.startstop.AutoStartStop;
18
19
/**
20
 * Note: Test case moved from platform/org.eclipse.tptp.platform.iac.administrator/
21
 * org.eclipse.tptp.platform.iac.administrator.internal.test as part of bug 302579. 
22
 *
23
 */
24
25
public class AutoStartStopTest extends TestCase  {
26
	
27
	/**
28
	 * Make sure Agent Controller isn't running
29
	 */
30
	public void setUp()
31
	{
32
		assertEquals(0, AutoStartStop.stopIAC());
33
		assertFalse(AutoStartStop.isIACRunning());
34
	}
35
	
36
	/**
37
	 * Test just start
38
	 */
39
	public void testStart()
40
	{
41
		assertEquals(0, AutoStartStop.startIAC());
42
		assertTrue(AutoStartStop.isIACRunning());
43
	}
44
	
45
	/**
46
	 * Test both start and stop
47
	 */
48
	public void testAutoStartStop()
49
	{
50
		assertEquals(0, AutoStartStop.startIAC());
51
		assertTrue(AutoStartStop.isIACRunning());
52
		assertEquals(0, AutoStartStop.stopIAC());
53
		assertFalse(AutoStartStop.isIACRunning());
54
	}
55
	
56
	/**
57
	 * Test restart
58
	 */
59
	public void testRestart()
60
	{
61
		assertEquals(0, AutoStartStop.restartIAC());
62
		assertTrue(AutoStartStop.isIACRunning());
63
	}
64
	
65
	/**
66
	 * Load test start/stop
67
	 */
68
	public void testMultipleCalls()
69
	{
70
		/* Call start/stop multiple times */
71
		for (int i=0; i < 5; i++)
72
		{
73
			assertEquals(0, AutoStartStop.startIAC());
74
			assertTrue(AutoStartStop.isIACRunning());
75
			assertEquals(0, AutoStartStop.stopIAC());
76
			assertFalse(AutoStartStop.isIACRunning());
77
		}
78
	}
79
}
(-)src/org/eclipse/hyades/use/cases/junit/iac/administrator/internal/test/ConfigGeneratorTest.java (+171 lines)
Added Link Here
1
/**********************************************************************
2
 Copyright (c) 2007, 2010 IBM Corporation and others.
3
 All rights reserved. This program and the accompanying materials
4
 are made available under the terms of the Eclipse Public License v1.0
5
 which accompanies this distribution, and is available at
6
 http://www.eclipse.org/legal/epl-v10.html
7
 $Id: ConfigGeneratorTest.java,v 1.5 2008/11/13 20:02:14 jkubasta Exp $
8
 
9
 Contributors:
10
     IBM - initial implementation
11
 **********************************************************************/
12
13
package org.eclipse.hyades.use.cases.junit.iac.administrator.internal.test;
14
15
import java.io.File;
16
17
import junit.framework.TestCase;
18
19
import org.eclipse.tptp.platform.iac.administrator.internal.common.AdminUtil;
20
import org.eclipse.tptp.platform.iac.administrator.internal.common.CommonConstants;
21
import org.eclipse.tptp.platform.iac.administrator.internal.config.ConfigGenerator;
22
import org.w3c.dom.Document;
23
24
/**
25
 * Note that this has to be run as a JUnit plug-in test
26
 * 
27
 * Note: Test case moved from platform/org.eclipse.tptp.platform.iac.administrator/
28
 * org.eclipse.tptp.platform.iac.administrator.internal.test as part of bug 302579.
29
 * 
30
 * @author Navid Mehregani
31
 *
32
 */
33
public class ConfigGeneratorTest extends TestCase {
34
	
35
	/* These values need to change to match location for the machine being tested */ 
36
	public static String acHome = "C:\\Documents and Settings\\Administrator\\workspace_iac_poc\\org.eclipse.tptp.platform.ac.win_ia32\\agent_controller";
37
	public static String javaExecutable = "C:\\java\\ibm_jdk1.5\\jre\\bin\\java.exe";	
38
	public static String pluginsFolder = "D:\\TPTP_Drivers\\TPTP-4.4.0-200702211545\\eclipse\\plugins";
39
	
40
	/* Absolute path to the serviceconfig.xml file of Agent Controller */ 
41
	private String configLocation = acHome + CommonConstants.FILE_SEPARATOR + "config" + CommonConstants.FILE_SEPARATOR + "serviceconfig.xml";
42
	
43
	/* All the AC Plugins */
44
	private File[] plugins = null;
45
	
46
	/* Config file */
47
	private File configFile = new File(configLocation);
48
	
49
	protected void setUp() throws Exception 
50
	{
51
		/* Delete the config file before starting */
52
		configFile.delete(); 
53
		
54
		/* Get the AC plugins */
55
		plugins = AdminUtil.getIACPlugins();
56
	}
57
	
58
	public void testAllowAllWithNoSecurity() {
59
		ConfigGenerator configGenerator = new ConfigGenerator();
60
		configGenerator.allowAllWithNoSecurity(acHome, javaExecutable, pluginsFolder, plugins);
61
		
62
		Document document = AdminUtil.parseFile(configLocation, false);
63
		
64
		/* Check java executable */
65
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value"));
66
		
67
		/* Check AC home */
68
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value"));
69
		
70
		/* Check accessibility */
71
		assertEquals("ALL", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
72
		
73
		/* Check security */
74
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0));
75
	}
76
77
	public void testSetUpLocallyWithNoSecurity() {
78
		ConfigGenerator configGenerator = new ConfigGenerator();
79
		configGenerator.setUpLocallyWithNoSecurity(acHome, javaExecutable, pluginsFolder, plugins); 
80
		
81
		Document document = AdminUtil.parseFile(configLocation, false);
82
		
83
		/* Check java executable */
84
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value"));
85
		
86
		/* Check AC home */
87
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value"));
88
		
89
		/* Check accessibility */
90
		assertEquals("LOCAL", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
91
		
92
		/* Check security */
93
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0));
94
	}
95
96
	public void testCustomAccessWithNoSecurity() {
97
		ConfigGenerator configGenerator = new ConfigGenerator();
98
		
99
		/* Check with Null passed in for hosts */
100
		configGenerator.customAccessWithNoSecurity(null, acHome, javaExecutable, pluginsFolder, plugins);
101
		Document document = AdminUtil.parseFile(configLocation, false);			
102
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
103
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value")); /* Check AC home */
104
		assertEquals("localhost", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0)); /* Check accessibility */
105
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
106
		
107
		/* Check with empty string passed in for hosts */
108
		configGenerator.customAccessWithNoSecurity("", acHome, javaExecutable, pluginsFolder, plugins);
109
		document = AdminUtil.parseFile(configLocation, false);		
110
		assertEquals("localhost", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
111
		
112
		/* Check with specific machines passed in for hosts */ 
113
		configGenerator.customAccessWithNoSecurity("host1, host2, host3", acHome, javaExecutable, pluginsFolder, plugins);
114
		document = AdminUtil.parseFile(configLocation, false);		
115
		assertEquals("host1", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
116
		assertEquals("host2", AdminUtil.getAttributeOfElement(document, "Allow", "host", 1));
117
		assertEquals("host3", AdminUtil.getAttributeOfElement(document, "Allow", "host", 2));
118
	}
119
120
	public void testAllowAllWithSecurity() {
121
		ConfigGenerator configGenerator = new ConfigGenerator();
122
		
123
		/* Check with Null passed in for users */
124
		configGenerator.allowAllWithSecurity(null, null, acHome, javaExecutable, pluginsFolder, plugins); 
125
		Document document = AdminUtil.parseFile(configLocation, false);			
126
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
127
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value")); /* Check AC home */
128
		assertEquals("ALL", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0)); /* Check accessibility */
129
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
130
		assertEquals("ANY", AdminUtil.getElementValue(document, "UserDefinition", 0));
131
		
132
		/* Check with empty string passed in for users */
133
		configGenerator.allowAllWithSecurity("", "", acHome, javaExecutable, pluginsFolder, plugins); 
134
		document = AdminUtil.parseFile(configLocation, false);			
135
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
136
		assertEquals("ANY", AdminUtil.getElementValue(document, "UserDefinition", 0));
137
		
138
		/* Check with specific users passed in for users */
139
		configGenerator.allowAllWithSecurity("CUSTOM", "user1,user2,user3", acHome, javaExecutable, pluginsFolder, plugins); 
140
		document = AdminUtil.parseFile(configLocation, false);
141
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
142
		assertEquals("user1,user2,user3", AdminUtil.getElementValue(document, "UserDefinition", 0));
143
	}
144
145
	public void testSetUpLocallyWithSecurity() {
146
		ConfigGenerator configGenerator = new ConfigGenerator();
147
		configGenerator.setUpLocallyWithSecurity("ANY", "user1, user2, user3", acHome, javaExecutable, pluginsFolder, plugins); 
148
		
149
		Document document = AdminUtil.parseFile(configLocation, false);			
150
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
151
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value")); /* Check AC home */
152
		assertEquals("LOCAL", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0)); /* Check accessibility */
153
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
154
		assertEquals("user1,user2,user3", AdminUtil.getElementValue(document, "UserDefinition", 0));
155
	}
156
157
	public void testCustomAccessWithSecurity() {
158
		ConfigGenerator configGenerator = new ConfigGenerator();
159
		configGenerator.customAccessWithSecurity("host1, host2, host3","CUSTOM", "user1,user2,user3", acHome, javaExecutable, pluginsFolder, plugins);
160
		
161
		Document document = AdminUtil.parseFile(configLocation, false);			
162
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
163
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value")); /* Check AC home */
164
		assertEquals("host1", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0)); /* Check accessibility */
165
		assertEquals("host2", AdminUtil.getAttributeOfElement(document, "Allow", "host", 1)); /* Check accessibility */
166
		assertEquals("host3", AdminUtil.getAttributeOfElement(document, "Allow", "host", 2)); /* Check accessibility */
167
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
168
		assertEquals("user1,user2,user3", AdminUtil.getElementValue(document, "UserDefinition", 0));
169
	}
170
171
}
(-)META-INF/MANIFEST.MF (-2 / +1 lines)
Lines 14-21 Link Here
14
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
14
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
15
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
15
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
16
 org.eclipse.tptp.platform.agentcontroller;bundle-version="[4.1.0,5.0.0)",
16
 org.eclipse.tptp.platform.agentcontroller;bundle-version="[4.1.0,5.0.0)",
17
 org.eclipse.jdt.launching;bundle-version="[3.2.0,4.0.0)",
17
 org.eclipse.jdt.launching;bundle-version="[3.2.0,4.0.0)"
18
 org.junit;bundle-version="[3.8.2,4.0.0)"
19
Eclipse-LazyStart: true
18
Eclipse-LazyStart: true
20
Bundle-ActivationPolicy: lazy
19
Bundle-ActivationPolicy: lazy
21
Bundle-RequiredExecutionEnvironment: J2SE-1.4
20
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)src/org/eclipse/tptp/platform/iac/administrator/internal/test/AdminUtilTest.java (-84 lines)
Removed Link Here
1
/**********************************************************************
2
 Copyright (c) 2007, 2010 IBM Corporation and others.
3
 All rights reserved. This program and the accompanying materials
4
 are made available under the terms of the Eclipse Public License v1.0
5
 which accompanies this distribution, and is available at
6
 http://www.eclipse.org/legal/epl-v10.html
7
 $Id: ConfigGenerator.java,
8
 
9
 Contributors:
10
     IBM - initial implementation
11
 **********************************************************************/
12
13
package org.eclipse.tptp.platform.iac.administrator.internal.test;
14
15
import java.io.File;
16
17
import junit.framework.TestCase;
18
19
import org.eclipse.tptp.platform.iac.administrator.internal.common.AdminUtil;
20
21
public class AdminUtilTest extends TestCase {
22
23
	public void testGetIACPlugins() {		
24
		boolean found;
25
		File[] plugins = AdminUtil.getIACPlugins();
26
		assertTrue(plugins.length > 0);
27
		
28
		
29
		String[] expectedPlugins = {"org.apache.commons_logging","org.eclipse.hyades.execution","org.eclipse.hyades.logging.core","org.eclipse.hyades.probekit","org.eclipse.hyades.test.core","org.eclipse.hyades.test.tools.core","org.eclipse.tptp.platform.collection.framework","org.eclipse.tptp.platform.logging.events","org.eclipse.tptp.platform.models","org.eclipse.tptp.platform.models.hierarchy"};
30
		
31
		for(int i=0; i < plugins.length; i++)
32
		{
33
			/* Plugin name with version */
34
			String pluginName = plugins[i].getName();
35
			
36
			assertEquals(-1, pluginName.indexOf('\\'));
37
			assertEquals(-1, pluginName.indexOf('/'));
38
			assertTrue(pluginName.indexOf('_') >= 0);
39
			
40
			/* Plugin name without version */
41
			pluginName = pluginName.substring(0, pluginName.lastIndexOf('_'));
42
			
43
			found = false;
44
			/* Find the plugin in our list of expected plugins */
45
			for (int k=0; k < expectedPlugins.length; k++)
46
			{
47
				if(pluginName.equals(expectedPlugins[k]))
48
				{
49
					found = true;
50
					expectedPlugins[k] = "";
51
					break;
52
				}
53
			}
54
			assertTrue("Couldn't find " + pluginName + " in our list of expected plugins", found);
55
		}
56
		
57
		/* Make sure everything in our expected plugins list has been found */
58
		for (int i=0; i < expectedPlugins.length; i++)
59
		{
60
			assertTrue("Didn't find plugin " + expectedPlugins[i] + " in our list of actual plugins", expectedPlugins[i].equals(""));
61
		}
62
	}
63
	
64
	public void testGetIACBinFolder()
65
	{
66
		assertNotNull(AdminUtil.getIACBinFolder());
67
	}
68
	
69
	public void testGetIACHome()
70
	{
71
		assertNotNull(AdminUtil.getIACHome());
72
	}
73
	
74
	public void testGetPluginsFolder()
75
	{
76
		assertNotNull(AdminUtil.getPluginsFolder());
77
	}
78
	
79
	public void testGetJvmtiNativePath()
80
	{
81
		assertNotNull(AdminUtil.getJvmtiNativePath());
82
	}
83
84
}
(-)src/org/eclipse/tptp/platform/iac/administrator/internal/test/AutoStartStopTest.java (-73 lines)
Removed Link Here
1
/**********************************************************************
2
 Copyright (c) 2007 IBM Corporation and others.
3
 All rights reserved. This program and the accompanying materials
4
 are made available under the terms of the Eclipse Public License v1.0
5
 which accompanies this distribution, and is available at
6
 http://www.eclipse.org/legal/epl-v10.html
7
 $Id: ConfigGenerator.java,
8
 
9
 Contributors:
10
     IBM - initial implementation
11
 **********************************************************************/
12
13
package org.eclipse.tptp.platform.iac.administrator.internal.test;
14
15
import junit.framework.TestCase;
16
17
import org.eclipse.tptp.platform.iac.administrator.internal.startstop.AutoStartStop;
18
19
public class AutoStartStopTest extends TestCase  {
20
	
21
	/**
22
	 * Make sure Agent Controller isn't running
23
	 */
24
	public void setUp()
25
	{
26
		assertEquals(0, AutoStartStop.stopIAC());
27
		assertFalse(AutoStartStop.isIACRunning());
28
	}
29
	
30
	/**
31
	 * Test just start
32
	 */
33
	public void testStart()
34
	{
35
		assertEquals(0, AutoStartStop.startIAC());
36
		assertTrue(AutoStartStop.isIACRunning());
37
	}
38
	
39
	/**
40
	 * Test both start and stop
41
	 */
42
	public void testAutoStartStop()
43
	{
44
		assertEquals(0, AutoStartStop.startIAC());
45
		assertTrue(AutoStartStop.isIACRunning());
46
		assertEquals(0, AutoStartStop.stopIAC());
47
		assertFalse(AutoStartStop.isIACRunning());
48
	}
49
	
50
	/**
51
	 * Test restart
52
	 */
53
	public void testRestart()
54
	{
55
		assertEquals(0, AutoStartStop.restartIAC());
56
		assertTrue(AutoStartStop.isIACRunning());
57
	}
58
	
59
	/**
60
	 * Load test start/stop
61
	 */
62
	public void testMultipleCalls()
63
	{
64
		/* Call start/stop multiple times */
65
		for (int i=0; i < 5; i++)
66
		{
67
			assertEquals(0, AutoStartStop.startIAC());
68
			assertTrue(AutoStartStop.isIACRunning());
69
			assertEquals(0, AutoStartStop.stopIAC());
70
			assertFalse(AutoStartStop.isIACRunning());
71
		}
72
	}
73
}
(-)src/org/eclipse/tptp/platform/iac/administrator/internal/test/ConfigGeneratorTest.java (-168 lines)
Removed Link Here
1
/**********************************************************************
2
 Copyright (c) 2007, 2008 IBM Corporation and others.
3
 All rights reserved. This program and the accompanying materials
4
 are made available under the terms of the Eclipse Public License v1.0
5
 which accompanies this distribution, and is available at
6
 http://www.eclipse.org/legal/epl-v10.html
7
 $Id: ConfigGeneratorTest.java,v 1.5 2008/11/13 20:02:14 jkubasta Exp $
8
 
9
 Contributors:
10
     IBM - initial implementation
11
 **********************************************************************/
12
13
package org.eclipse.tptp.platform.iac.administrator.internal.test;
14
15
import java.io.File;
16
17
import junit.framework.TestCase;
18
19
import org.eclipse.tptp.platform.iac.administrator.internal.common.AdminUtil;
20
import org.eclipse.tptp.platform.iac.administrator.internal.common.CommonConstants;
21
import org.eclipse.tptp.platform.iac.administrator.internal.config.ConfigGenerator;
22
import org.w3c.dom.Document;
23
24
/**
25
 * Note that this has to be run as a JUnit plug-in test
26
 * 
27
 * @author Navid Mehregani
28
 *
29
 */
30
public class ConfigGeneratorTest extends TestCase {
31
	
32
	/* These values need to change to match location for the machine being tested */ 
33
	public static String acHome = "C:\\Documents and Settings\\Administrator\\workspace_iac_poc\\org.eclipse.tptp.platform.ac.win_ia32\\agent_controller";
34
	public static String javaExecutable = "C:\\java\\ibm_jdk1.5\\jre\\bin\\java.exe";	
35
	public static String pluginsFolder = "D:\\TPTP_Drivers\\TPTP-4.4.0-200702211545\\eclipse\\plugins";
36
	
37
	/* Absolute path to the serviceconfig.xml file of Agent Controller */ 
38
	private String configLocation = acHome + CommonConstants.FILE_SEPARATOR + "config" + CommonConstants.FILE_SEPARATOR + "serviceconfig.xml";
39
	
40
	/* All the AC Plugins */
41
	private File[] plugins = null;
42
	
43
	/* Config file */
44
	private File configFile = new File(configLocation);
45
	
46
	protected void setUp() throws Exception 
47
	{
48
		/* Delete the config file before starting */
49
		configFile.delete(); 
50
		
51
		/* Get the AC plugins */
52
		plugins = AdminUtil.getIACPlugins();
53
	}
54
	
55
	public void testAllowAllWithNoSecurity() {
56
		ConfigGenerator configGenerator = new ConfigGenerator();
57
		configGenerator.allowAllWithNoSecurity(acHome, javaExecutable, pluginsFolder, plugins);
58
		
59
		Document document = AdminUtil.parseFile(configLocation, false);
60
		
61
		/* Check java executable */
62
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value"));
63
		
64
		/* Check AC home */
65
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value"));
66
		
67
		/* Check accessibility */
68
		assertEquals("ALL", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
69
		
70
		/* Check security */
71
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0));
72
	}
73
74
	public void testSetUpLocallyWithNoSecurity() {
75
		ConfigGenerator configGenerator = new ConfigGenerator();
76
		configGenerator.setUpLocallyWithNoSecurity(acHome, javaExecutable, pluginsFolder, plugins); 
77
		
78
		Document document = AdminUtil.parseFile(configLocation, false);
79
		
80
		/* Check java executable */
81
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value"));
82
		
83
		/* Check AC home */
84
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value"));
85
		
86
		/* Check accessibility */
87
		assertEquals("LOCAL", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
88
		
89
		/* Check security */
90
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0));
91
	}
92
93
	public void testCustomAccessWithNoSecurity() {
94
		ConfigGenerator configGenerator = new ConfigGenerator();
95
		
96
		/* Check with Null passed in for hosts */
97
		configGenerator.customAccessWithNoSecurity(null, acHome, javaExecutable, pluginsFolder, plugins);
98
		Document document = AdminUtil.parseFile(configLocation, false);			
99
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
100
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value")); /* Check AC home */
101
		assertEquals("localhost", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0)); /* Check accessibility */
102
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
103
		
104
		/* Check with empty string passed in for hosts */
105
		configGenerator.customAccessWithNoSecurity("", acHome, javaExecutable, pluginsFolder, plugins);
106
		document = AdminUtil.parseFile(configLocation, false);		
107
		assertEquals("localhost", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
108
		
109
		/* Check with specific machines passed in for hosts */ 
110
		configGenerator.customAccessWithNoSecurity("host1, host2, host3", acHome, javaExecutable, pluginsFolder, plugins);
111
		document = AdminUtil.parseFile(configLocation, false);		
112
		assertEquals("host1", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
113
		assertEquals("host2", AdminUtil.getAttributeOfElement(document, "Allow", "host", 1));
114
		assertEquals("host3", AdminUtil.getAttributeOfElement(document, "Allow", "host", 2));
115
	}
116
117
	public void testAllowAllWithSecurity() {
118
		ConfigGenerator configGenerator = new ConfigGenerator();
119
		
120
		/* Check with Null passed in for users */
121
		configGenerator.allowAllWithSecurity(null, null, acHome, javaExecutable, pluginsFolder, plugins); 
122
		Document document = AdminUtil.parseFile(configLocation, false);			
123
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
124
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value")); /* Check AC home */
125
		assertEquals("ALL", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0)); /* Check accessibility */
126
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
127
		assertEquals("ANY", AdminUtil.getElementValue(document, "UserDefinition", 0));
128
		
129
		/* Check with empty string passed in for users */
130
		configGenerator.allowAllWithSecurity("", "", acHome, javaExecutable, pluginsFolder, plugins); 
131
		document = AdminUtil.parseFile(configLocation, false);			
132
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
133
		assertEquals("ANY", AdminUtil.getElementValue(document, "UserDefinition", 0));
134
		
135
		/* Check with specific users passed in for users */
136
		configGenerator.allowAllWithSecurity("CUSTOM", "user1,user2,user3", acHome, javaExecutable, pluginsFolder, plugins); 
137
		document = AdminUtil.parseFile(configLocation, false);
138
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
139
		assertEquals("user1,user2,user3", AdminUtil.getElementValue(document, "UserDefinition", 0));
140
	}
141
142
	public void testSetUpLocallyWithSecurity() {
143
		ConfigGenerator configGenerator = new ConfigGenerator();
144
		configGenerator.setUpLocallyWithSecurity("ANY", "user1, user2, user3", acHome, javaExecutable, pluginsFolder, plugins); 
145
		
146
		Document document = AdminUtil.parseFile(configLocation, false);			
147
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
148
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value")); /* Check AC home */
149
		assertEquals("LOCAL", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0)); /* Check accessibility */
150
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
151
		assertEquals("user1,user2,user3", AdminUtil.getElementValue(document, "UserDefinition", 0));
152
	}
153
154
	public void testCustomAccessWithSecurity() {
155
		ConfigGenerator configGenerator = new ConfigGenerator();
156
		configGenerator.customAccessWithSecurity("host1, host2, host3","CUSTOM", "user1,user2,user3", acHome, javaExecutable, pluginsFolder, plugins);
157
		
158
		Document document = AdminUtil.parseFile(configLocation, false);			
159
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
160
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value")); /* Check AC home */
161
		assertEquals("host1", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0)); /* Check accessibility */
162
		assertEquals("host2", AdminUtil.getAttributeOfElement(document, "Allow", "host", 1)); /* Check accessibility */
163
		assertEquals("host3", AdminUtil.getAttributeOfElement(document, "Allow", "host", 2)); /* Check accessibility */
164
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
165
		assertEquals("user1,user2,user3", AdminUtil.getElementValue(document, "UserDefinition", 0));
166
	}
167
168
}

Return to bug 301264