mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Generics.
This commit is contained in:
parent
2ee14c041c
commit
a19dfee63c
4 changed files with 42 additions and 62 deletions
|
@ -65,19 +65,19 @@ public class TemplateEngineTestsHelper {
|
|||
|
||||
public static TemplateCore[] getTestTemplates() {
|
||||
TemplateCore[] templates = TemplateEngine.getDefault().getTemplates();
|
||||
List testTemplates = new ArrayList();
|
||||
for (int i =0; i < templates.length; i++) {
|
||||
List<TemplateCore> testTemplates = new ArrayList<TemplateCore>();
|
||||
for (int i = 0; i < templates.length; i++) {
|
||||
if (templates[i].getTemplateType().equals("TestTemplate")) {
|
||||
testTemplates.add(templates[i]);
|
||||
}
|
||||
}
|
||||
return (TemplateCore[]) testTemplates.toArray(new TemplateCore[testTemplates.size()]);
|
||||
return testTemplates.toArray(new TemplateCore[testTemplates.size()]);
|
||||
}
|
||||
|
||||
public static int getChildCount(TemplateDescriptor templateDescriptor, String propertyGroupID){
|
||||
List list = templateDescriptor.getPropertyGroupList();
|
||||
List<Element> list = templateDescriptor.getPropertyGroupList();
|
||||
for (int i = 0, l = list.size(); i < l; i++) {
|
||||
Element element = (Element) list.get(i);
|
||||
Element element = list.get(i);
|
||||
NamedNodeMap attributes = element.getAttributes();
|
||||
for (int j = 0, l1 = attributes.getLength(); j < l1; j++) {
|
||||
String value = attributes.item(j).getNodeValue();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Bala Torati (Symbian) - Initial API and implementation
|
||||
* Bala Torati (Symbian) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.templateengine;
|
||||
|
||||
|
@ -28,7 +28,6 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
public class TestProcesses extends BaseTestCase {
|
||||
|
||||
private static final String workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toOSString();
|
||||
private static final String PROJECT_NAME = "TemplateEngineTestsProject"; //$NON-NLS-1$
|
||||
private static final String SOURCE_FOLDER = "Source"; //$NON-NLS-1$
|
||||
|
@ -63,7 +62,7 @@ public class TestProcesses extends BaseTestCase {
|
|||
|
||||
public void testAddFile() {
|
||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddFile"); //$NON-NLS-1$
|
||||
Map valueStore = template.getValueStore();
|
||||
Map<String, String> valueStore = template.getValueStore();
|
||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -84,7 +83,7 @@ public class TestProcesses extends BaseTestCase {
|
|||
|
||||
public void testAddFiles() {
|
||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddFiles"); //$NON-NLS-1$
|
||||
Map valueStore = template.getValueStore();
|
||||
Map<String, String> valueStore = template.getValueStore();
|
||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -105,7 +104,7 @@ public class TestProcesses extends BaseTestCase {
|
|||
|
||||
public void testAddLink() {
|
||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddLink"); //$NON-NLS-1$
|
||||
Map valueStore = template.getValueStore();
|
||||
Map<String, String> valueStore = template.getValueStore();
|
||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -131,7 +130,7 @@ public class TestProcesses extends BaseTestCase {
|
|||
|
||||
public void testAppend() {
|
||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*Append"); //$NON-NLS-1$
|
||||
Map valueStore = template.getValueStore();
|
||||
Map<String, String> valueStore = template.getValueStore();
|
||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -160,7 +159,7 @@ public class TestProcesses extends BaseTestCase {
|
|||
|
||||
public void testAppendCreate() {
|
||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AppendCreate"); //$NON-NLS-1$
|
||||
Map valueStore = template.getValueStore();
|
||||
Map<String, String> valueStore = template.getValueStore();
|
||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -184,7 +183,7 @@ public class TestProcesses extends BaseTestCase {
|
|||
|
||||
public void testCopy() {
|
||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*Copy"); //$NON-NLS-1$
|
||||
Map valueStore = template.getValueStore();
|
||||
Map<String, String> valueStore = template.getValueStore();
|
||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -213,7 +212,7 @@ public class TestProcesses extends BaseTestCase {
|
|||
|
||||
public void testCreateResourceIdentifier() {
|
||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*CreateResourceIdentifier"); //$NON-NLS-1$
|
||||
Map valueStore = template.getValueStore();
|
||||
Map<String, String> valueStore = template.getValueStore();
|
||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -237,7 +236,7 @@ public class TestProcesses extends BaseTestCase {
|
|||
|
||||
public void testCreateSourceFolder() {
|
||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*CreateSourceFolder"); //$NON-NLS-1$
|
||||
Map valueStore = template.getValueStore();
|
||||
Map<String, String> valueStore = template.getValueStore();
|
||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Bala Torati (Symbian) - Initial API and implementation
|
||||
* Bala Torati (Symbian) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.templateengine;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -18,7 +17,6 @@ import java.util.Set;
|
|||
import org.eclipse.cdt.core.templateengine.SharedDefaults;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
|
||||
|
||||
/**
|
||||
* Executes all the test cases of SharedDefaults backend functionality
|
||||
*/
|
||||
|
@ -36,7 +34,6 @@ public class TestSharedDefaults extends BaseTestCase {
|
|||
/*
|
||||
* @see TestCase#tearDown()
|
||||
*/
|
||||
|
||||
protected void tearDown(){
|
||||
sharedDefaults = null;
|
||||
}
|
||||
|
@ -45,47 +42,39 @@ public class TestSharedDefaults extends BaseTestCase {
|
|||
* This test checks if data gets added to the back end
|
||||
* New data gets persisted in SharedDefault XML file
|
||||
*/
|
||||
|
||||
public void testAddToBackEndStorage() {
|
||||
Map actualSharedDefaults=sharedDefaults.getSharedDefaultsMap();
|
||||
Map<String, String> actualSharedDefaults= sharedDefaults.getSharedDefaultsMap();
|
||||
|
||||
actualSharedDefaults.put("provider.name","eclipse"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
actualSharedDefaults.put("copyright","Symbian Software Ltd."); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
actualSharedDefaults.put("author","Bala Torati"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap();
|
||||
Map<String, String> expectedSharedDefaults= sharedDefaults.getSharedDefaultsMap();
|
||||
|
||||
assertEquals("Contents are different :", //$NON-NLS-1$
|
||||
expectedSharedDefaults,
|
||||
actualSharedDefaults);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests the updateToBackEndStorage of SharedDefaults
|
||||
* to verify whether the key-value pair gets updated with new value
|
||||
* New data gets persisted in SharedDefault XML file
|
||||
*/
|
||||
|
||||
public void testUpdateToBackEndStorage() {
|
||||
Map actualSharedDefaults = sharedDefaults.getSharedDefaultsMap();
|
||||
Set keySet = actualSharedDefaults.keySet();
|
||||
Iterator iterator = keySet.iterator();
|
||||
Map<String, String> actualSharedDefaults = sharedDefaults.getSharedDefaultsMap();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Object key = iterator.next();
|
||||
Object value = actualSharedDefaults.get(key);
|
||||
String keyName = (String)key;
|
||||
String valueName = (String)value;
|
||||
if (keyName.equals("org.eclipse.cdt.templateengine.project.HelloWorld.basename")){ //$NON-NLS-1$
|
||||
valueName = "Astala Vista"; //$NON-NLS-1$
|
||||
actualSharedDefaults.put(keyName, valueName);
|
||||
sharedDefaults.updateToBackEndStorage("org.eclipse.cdt.templateengine.project.HelloWorld.basename", valueName); //$NON-NLS-1$
|
||||
for (Map.Entry<String, String> entry : actualSharedDefaults.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
if (key.equals("org.eclipse.cdt.templateengine.project.HelloWorld.basename")) { //$NON-NLS-1$
|
||||
entry.setValue("Astala Vista"); //$NON-NLS-1$
|
||||
sharedDefaults.updateToBackEndStorage("org.eclipse.cdt.templateengine.project.HelloWorld.basename", value); //$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap();
|
||||
Map<String, String> expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap();
|
||||
|
||||
assertEquals("Contents are different :", //$NON-NLS-1$
|
||||
expectedSharedDefaults,
|
||||
|
@ -96,25 +85,23 @@ public class TestSharedDefaults extends BaseTestCase {
|
|||
* This tests the deleteBackEndStorage of SharedDefaults
|
||||
* to verify whether the key-value pair gets deleted at the backend
|
||||
*/
|
||||
|
||||
public void testDeleteBackEndStorage() {
|
||||
Map actualSharedDefaults=sharedDefaults.getSharedDefaultsMap();
|
||||
Set keySet = actualSharedDefaults.keySet();
|
||||
Iterator iterator = keySet.iterator();
|
||||
Map<String, String> actualSharedDefaults= sharedDefaults.getSharedDefaultsMap();
|
||||
Set<String> keySet = actualSharedDefaults.keySet();
|
||||
Iterator<String> iterator = keySet.iterator();
|
||||
String keyName = null;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
|
||||
Object key = iterator.next();
|
||||
keyName = (String)key;
|
||||
String key = iterator.next();
|
||||
keyName = key;
|
||||
if (keyName.equals("org.eclipse.cdt.templateengine.project.HelloWorld.basename")) { //$NON-NLS-1$
|
||||
actualSharedDefaults.remove(keyName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sharedDefaults.deleteBackEndStorage(new String[]{keyName});
|
||||
Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap();
|
||||
sharedDefaults.deleteBackEndStorage(new String[] { keyName });
|
||||
Map<String, String> expectedSharedDefaults= sharedDefaults.getSharedDefaultsMap();
|
||||
|
||||
assertEquals("Contents are different :", //$NON-NLS-1$
|
||||
expectedSharedDefaults,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Bala Torati (Symbian) - Initial API and implementation
|
||||
* Bala Torati (Symbian) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.templateengine;
|
||||
|
||||
|
@ -17,13 +17,10 @@ import org.eclipse.cdt.core.templateengine.TemplateCore;
|
|||
import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
|
||||
|
||||
/**
|
||||
* Test the functionality of the ValueStore class.
|
||||
*/
|
||||
public class TestValueStore extends BaseTestCase {
|
||||
|
||||
|
||||
/**
|
||||
* setUp is called before execution of test method.
|
||||
*/
|
||||
|
@ -44,12 +41,11 @@ public class TestValueStore extends BaseTestCase {
|
|||
|
||||
/**
|
||||
* Test ValueStore for Not Null condition.
|
||||
*
|
||||
*/
|
||||
public void testValueStoreNotNull(){
|
||||
TemplateCore[] templates = TemplateEngineTestsHelper.getTestTemplates();
|
||||
for (int i=0; i <templates.length; i++) {
|
||||
Map valueStore = templates[i].getValueStore();
|
||||
for (int i = 0; i < templates.length; i++) {
|
||||
Map<String, String> valueStore = templates[i].getValueStore();
|
||||
assertNotNull(valueStore);
|
||||
}
|
||||
}
|
||||
|
@ -60,18 +56,16 @@ public class TestValueStore extends BaseTestCase {
|
|||
*/
|
||||
public void testCompareValueStoreWithTemplateDefaluts(){
|
||||
TemplateCore[] templates = TemplateEngineTestsHelper.getTestTemplates();
|
||||
for (int i=0; i <templates.length; i++) {
|
||||
Map valueStore = templates[i].getValueStore();
|
||||
for (int i = 0; i < templates.length; i++) {
|
||||
Map<String, String> valueStore = templates[i].getValueStore();
|
||||
TemplateDescriptor templateDescriptor = templates[i].getTemplateDescriptor();
|
||||
Map templateDefaults = templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement());
|
||||
Map<String, String> templateDefaults = templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement());
|
||||
|
||||
Iterator defaultsIterator = templateDefaults.keySet().iterator();
|
||||
while(defaultsIterator.hasNext()){
|
||||
String key = (String)defaultsIterator.next();
|
||||
Iterator<String> defaultsIterator = templateDefaults.keySet().iterator();
|
||||
while (defaultsIterator.hasNext()){
|
||||
String key = defaultsIterator.next();
|
||||
assertNotNull(valueStore.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue