blob: 34e0022e85339844e0e2c57dc3f3e9f753c74313 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.properties.runtime.tests.controller;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.eclipse.gmf.runtime.common.core.service.Service;
import org.eclipse.papyrus.views.properties.runtime.controller.PropertyEditorControllerService;
import org.junit.Test;
/**
* Test case for the property editor controller service
*/
public class PropertyEditorControllerServiceTestCase extends PropertyEditorControllerService {
/**
* Test method for {@link PropertyEditorControllerService}.
*/
@Test
public void testServiceCreation() {
PropertyEditorControllerService instance = PropertyEditorControllerService.getInstance();
assertNotNull(instance);
}
/**
* Test method for {@link org.eclipse.papyrus.diagram.common.parser.HTMLCleaner#cleanHTMLTags(java.lang.String)}.
*/
@Test
public void testProviders() {
ArrayList<?> providersList = retrieveProviderList();
assertNotNull(providersList);
}
/**
* Test method for {@link org.eclipse.papyrus.diagram.common.parser.HTMLCleaner#cleanHTMLTags(java.lang.String)}.
*/
@Test
public void testProvidersNumber() {
ArrayList<?> providersList = retrieveProviderList();
assertTrue(providersList.size() == 2);
// get the name of the 2 providers
for(Object object : providersList) {
assertTrue("object is a " + object.getClass().getName(), (object instanceof org.eclipse.papyrus.views.properties.runtime.controller.PropertyEditorControllerService.ProviderDescriptor));
}
}
/**
* Retrieves the list of providers provided by the service
*/
protected ArrayList<?> retrieveProviderList() {
Object providerList = null;
for(Method method : Service.class.getDeclaredMethods()) {
if("getAllProviders".equals(method.getName())) {
method.setAccessible(true);
try {
providerList = method.invoke(getInstance());
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
break;
}
}
return (providerList instanceof ArrayList<?>) ? (ArrayList<?>)providerList : null;
}
}
|