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

(-)src/org/eclipse/hyades/use/cases/junit/iac/administrator/internal/test/AdminUtilTest.java (-2 / +22 lines)
Lines 13-24 Link Here
13
package org.eclipse.hyades.use.cases.junit.iac.administrator.internal.test;
13
package org.eclipse.hyades.use.cases.junit.iac.administrator.internal.test;
14
14
15
import java.io.File;
15
import java.io.File;
16
import java.util.ArrayList;
17
import java.util.List;
16
18
17
import junit.framework.TestCase;
19
import junit.framework.TestCase;
18
20
19
import org.eclipse.tptp.platform.iac.administrator.internal.common.AdminUtil;
21
import org.eclipse.tptp.platform.iac.administrator.internal.common.AdminUtil;
20
22
21
/**
23
/**
24
 * This test needs to be run as a JUnit Plug-in Test.
25
 * 
22
 * Note: Test case moved from platform/org.eclipse.tptp.platform.iac.administrator/
26
 * 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. 
27
 * org.eclipse.tptp.platform.iac.administrator.internal.test as part of bug 302579. 
24
 *
28
 *
Lines 29-38 Link Here
29
	public void testGetIACPlugins() {		
33
	public void testGetIACPlugins() {		
30
		boolean found;
34
		boolean found;
31
		File[] plugins = AdminUtil.getIACPlugins();
35
		File[] plugins = AdminUtil.getIACPlugins();
36
		List<String> checkedPlugins = new ArrayList<String>();
32
		assertTrue(plugins.length > 0);
37
		assertTrue(plugins.length > 0);
33
		
38
		
34
		
39
		/* The list of plug-ins with a config.jar */
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"};
40
		String[] expectedPlugins = {"org.eclipse.hyades.execution",
41
									"org.eclipse.hyades.logging.core",
42
									"org.eclipse.hyades.probekit",
43
									"org.eclipse.hyades.test.core",
44
									"org.eclipse.hyades.test.tools.core",
45
									"org.eclipse.tptp.platform.collection.framework",
46
									"org.eclipse.tptp.platform.jvmti.runtime",
47
									"org.eclipse.tptp.platform.logging.events",
48
									"org.eclipse.tptp.test.tools.junit.plugin"};
36
		
49
		
37
		for(int i=0; i < plugins.length; i++)
50
		for(int i=0; i < plugins.length; i++)
38
		{
51
		{
Lines 46-51 Link Here
46
			/* Plugin name without version */
59
			/* Plugin name without version */
47
			pluginName = pluginName.substring(0, pluginName.lastIndexOf('_'));
60
			pluginName = pluginName.substring(0, pluginName.lastIndexOf('_'));
48
			
61
			
62
			/* Ignore checking duplicate entries */
63
			if(checkedPlugins.contains(pluginName))
64
				continue;
65
			
66
			/* Store the names of checked plug-ins */
67
			checkedPlugins.add(pluginName);
68
			
49
			found = false;
69
			found = false;
50
			/* Find the plugin in our list of expected plugins */
70
			/* Find the plugin in our list of expected plugins */
51
			for (int k=0; k < expectedPlugins.length; k++)
71
			for (int k=0; k < expectedPlugins.length; k++)
(-)src/org/eclipse/hyades/use/cases/junit/iac/administrator/internal/test/AutoStartStopTest.java (+2 lines)
Lines 17-22 Link Here
17
import org.eclipse.tptp.platform.iac.administrator.internal.startstop.AutoStartStop;
17
import org.eclipse.tptp.platform.iac.administrator.internal.startstop.AutoStartStop;
18
18
19
/**
19
/**
20
 * This test needs to be run as a JUnit Plug-in Test.
21
 * 
20
 * Note: Test case moved from platform/org.eclipse.tptp.platform.iac.administrator/
22
 * 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. 
23
 * org.eclipse.tptp.platform.iac.administrator.internal.test as part of bug 302579. 
22
 *
24
 *
(-)src/org/eclipse/hyades/use/cases/junit/iac/administrator/internal/test/ConfigGeneratorTest.java (-18 / +21 lines)
Lines 68-74 Link Here
68
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value"));
68
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value"));
69
		
69
		
70
		/* Check accessibility */
70
		/* Check accessibility */
71
		assertEquals("ALL", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
71
		assertEquals("ALL", AdminUtil.getAttributeOfElement(document, "Allow", "type", 0));
72
		
72
		
73
		/* Check security */
73
		/* Check security */
74
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0));
74
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0));
Lines 87-93 Link Here
87
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value"));
87
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value"));
88
		
88
		
89
		/* Check accessibility */
89
		/* Check accessibility */
90
		assertEquals("LOCAL", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
90
		assertEquals("LOCAL", AdminUtil.getAttributeOfElement(document, "Allow", "type", 0));
91
		
91
		
92
		/* Check security */
92
		/* Check security */
93
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0));
93
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0));
Lines 101-120 Link Here
101
		Document document = AdminUtil.parseFile(configLocation, false);			
101
		Document document = AdminUtil.parseFile(configLocation, false);			
102
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
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 */
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 */
104
		assertEquals("CUSTOM", AdminUtil.getAttributeOfElement(document, "Allow", "type", 0)); /* Check accessibility */
105
		assertEquals("localhost", AdminUtil.getAttributeOfElement(document, "Allow", "list", 0)); /* Check accessibility */
105
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
106
		assertEquals("false", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
106
		
107
		
107
		/* Check with empty string passed in for hosts */
108
		/* Check with empty string passed in for hosts */
108
		configGenerator.customAccessWithNoSecurity("", acHome, javaExecutable, pluginsFolder, plugins);
109
		configGenerator.customAccessWithNoSecurity("", acHome, javaExecutable, pluginsFolder, plugins);
109
		document = AdminUtil.parseFile(configLocation, false);		
110
		document = AdminUtil.parseFile(configLocation, false);		
110
		assertEquals("localhost", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
111
		assertEquals("CUSTOM", AdminUtil.getAttributeOfElement(document, "Allow", "type", 0));
112
		assertEquals("localhost", AdminUtil.getAttributeOfElement(document, "Allow", "list", 0));
111
		
113
		
112
		/* Check with specific machines passed in for hosts */ 
114
		/* Check with specific machines passed in for hosts */ 
113
		configGenerator.customAccessWithNoSecurity("host1, host2, host3", acHome, javaExecutable, pluginsFolder, plugins);
115
		configGenerator.customAccessWithNoSecurity("host1, host2, host3", acHome, javaExecutable, pluginsFolder, plugins);
114
		document = AdminUtil.parseFile(configLocation, false);		
116
		document = AdminUtil.parseFile(configLocation, false);		
115
		assertEquals("host1", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0));
117
		assertEquals("CUSTOM", AdminUtil.getAttributeOfElement(document, "Allow", "type", 0));
116
		assertEquals("host2", AdminUtil.getAttributeOfElement(document, "Allow", "host", 1));
118
		assertEquals("host1, host2, host3", AdminUtil.getAttributeOfElement(document, "Allow", "list", 0));
117
		assertEquals("host3", AdminUtil.getAttributeOfElement(document, "Allow", "host", 2));
118
	}
119
	}
119
120
120
	public void testAllowAllWithSecurity() {
121
	public void testAllowAllWithSecurity() {
Lines 125-157 Link Here
125
		Document document = AdminUtil.parseFile(configLocation, false);			
126
		Document document = AdminUtil.parseFile(configLocation, false);			
126
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
127
		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(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("ALL", AdminUtil.getAttributeOfElement(document, "Allow", "type", 0)); /* Check accessibility */
129
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
130
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
130
		assertEquals("ANY", AdminUtil.getElementValue(document, "UserDefinition", 0));
131
		assertEquals("ANY", AdminUtil.getAttributeOfElement(document, "UserDefinition", "type", 0));
131
		
132
		
132
		/* Check with empty string passed in for users */
133
		/* Check with empty string passed in for users */
133
		configGenerator.allowAllWithSecurity("", "", acHome, javaExecutable, pluginsFolder, plugins); 
134
		configGenerator.allowAllWithSecurity("", "", acHome, javaExecutable, pluginsFolder, plugins); 
134
		document = AdminUtil.parseFile(configLocation, false);			
135
		document = AdminUtil.parseFile(configLocation, false);			
135
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
136
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
136
		assertEquals("ANY", AdminUtil.getElementValue(document, "UserDefinition", 0));
137
		assertEquals("ANY", AdminUtil.getAttributeOfElement(document, "UserDefinition", "type", 0));
137
		
138
		
138
		/* Check with specific users passed in for users */
139
		/* Check with specific users passed in for users */
139
		configGenerator.allowAllWithSecurity("CUSTOM", "user1,user2,user3", acHome, javaExecutable, pluginsFolder, plugins); 
140
		configGenerator.allowAllWithSecurity("CUSTOM", "user1,user2,user3", acHome, javaExecutable, pluginsFolder, plugins); 
140
		document = AdminUtil.parseFile(configLocation, false);
141
		document = AdminUtil.parseFile(configLocation, false);
141
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
142
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
142
		assertEquals("user1,user2,user3", AdminUtil.getElementValue(document, "UserDefinition", 0));
143
		assertEquals("CUSTOM", AdminUtil.getAttributeOfElement(document, "UserDefinition", "type", 0));
144
		assertEquals("user1,user2,user3", AdminUtil.getAttributeOfElement(document, "UserDefinition", "list", 0));
143
	}
145
	}
144
146
145
	public void testSetUpLocallyWithSecurity() {
147
	public void testSetUpLocallyWithSecurity() {
146
		ConfigGenerator configGenerator = new ConfigGenerator();
148
		ConfigGenerator configGenerator = new ConfigGenerator();
147
		configGenerator.setUpLocallyWithSecurity("ANY", "user1, user2, user3", acHome, javaExecutable, pluginsFolder, plugins); 
149
		configGenerator.setUpLocallyWithSecurity("CUSTOM", "user1, user2, user3", acHome, javaExecutable, pluginsFolder, plugins); 
148
		
150
		
149
		Document document = AdminUtil.parseFile(configLocation, false);			
151
		Document document = AdminUtil.parseFile(configLocation, false);			
150
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
152
		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 */
153
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value")); /* Check AC home */
152
		assertEquals("LOCAL", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0)); /* Check accessibility */
154
		assertEquals("LOCAL", AdminUtil.getAttributeOfElement(document, "Allow", "type", 0)); /* Check accessibility */
153
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
155
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
154
		assertEquals("user1,user2,user3", AdminUtil.getElementValue(document, "UserDefinition", 0));
156
		assertEquals("CUSTOM", AdminUtil.getAttributeOfElement(document, "UserDefinition", "type", 0));
157
		assertEquals("user1,user2,user3", AdminUtil.getAttributeOfElement(document, "UserDefinition", "list", 0));
155
	}
158
	}
156
159
157
	public void testCustomAccessWithSecurity() {
160
	public void testCustomAccessWithSecurity() {
Lines 161-171 Link Here
161
		Document document = AdminUtil.parseFile(configLocation, false);			
164
		Document document = AdminUtil.parseFile(configLocation, false);			
162
		assertEquals(javaExecutable, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "JAVA_PATH", "value")); /* Check java executable */
165
		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 */
166
		assertEquals(acHome, AdminUtil.getAttributeWithMoreDetails(document, "Variable", "name", "RASERVER_HOME", "value")); /* Check AC home */
164
		assertEquals("host1", AdminUtil.getAttributeOfElement(document, "Allow", "host", 0)); /* Check accessibility */
167
		assertEquals("CUSTOM", AdminUtil.getAttributeOfElement(document, "Allow", "type", 0)); /* Check accessibility */
165
		assertEquals("host2", AdminUtil.getAttributeOfElement(document, "Allow", "host", 1)); /* Check accessibility */
168
		assertEquals("host1, host2, host3", AdminUtil.getAttributeOfElement(document, "Allow", "list", 0)); /* Check accessibility */
166
		assertEquals("host3", AdminUtil.getAttributeOfElement(document, "Allow", "host", 2)); /* Check accessibility */
167
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
169
		assertEquals("true", AdminUtil.getElementValue(document, "SecurityEnabled", 0)); /* Check security */
168
		assertEquals("user1,user2,user3", AdminUtil.getElementValue(document, "UserDefinition", 0));
170
		assertEquals("CUSTOM", AdminUtil.getAttributeOfElement(document, "UserDefinition", "type", 0));
171
		assertEquals("user1,user2,user3", AdminUtil.getAttributeOfElement(document, "UserDefinition", "list", 0));
169
	}
172
	}
170
173
171
}
174
}

Return to bug 301264