Révision 3056
tmp/org.txm.core.tests/projectSet.psf (revision 3056) | ||
---|---|---|
68 | 68 |
<project reference="1.0.1,https://forge.cbp.ens-lyon.fr/svn/txm/tmp/org.txm.libs.cqp.macosx,org.txm.libs.cqp.macosx,a0a75db469ef00161bbdeb2037bd6a92;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;branches;tags;trunk;true;865c2c80-10f3-4e06-9fd7-61c4de9d188b;https://forge.cbp.ens-lyon.fr/svn/txm;;false;<https://forge.cbp.ens-lyon.fr:443> Redmine SVN Repository;;0"/> |
69 | 69 |
<project reference="1.0.1,https://forge.cbp.ens-lyon.fr/svn/txm/tmp/org.txm.libs.cqp.win32,org.txm.libs.cqp.win32,a0a75db469ef00161bbdeb2037bd6a92;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;branches;tags;trunk;true;865c2c80-10f3-4e06-9fd7-61c4de9d188b;https://forge.cbp.ens-lyon.fr/svn/txm;;false;<https://forge.cbp.ens-lyon.fr:443> Redmine SVN Repository;;0"/> |
70 | 70 |
<project reference="1.0.1,https://forge.cbp.ens-lyon.fr/svn/txm/tmp/org.txm.libs.groovy-all,org.txm.libs.groovy-all,a0a75db469ef00161bbdeb2037bd6a92;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;branches;tags;trunk;true;865c2c80-10f3-4e06-9fd7-61c4de9d188b;https://forge.cbp.ens-lyon.fr/svn/txm;;false;<https://forge.cbp.ens-lyon.fr:443> Redmine SVN Repository;;0"/> |
71 |
<project reference="1.0.1,https://forge.cbp.ens-lyon.fr/svn/txm/tmp/org.txm.libs.gson,org.txm.libs.gson,a0a75db469ef00161bbdeb2037bd6a92;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;branches;tags;trunk;true;865c2c80-10f3-4e06-9fd7-61c4de9d188b;https://forge.cbp.ens-lyon.fr/svn/txm;;false;<https://forge.cbp.ens-lyon.fr:443> Redmine SVN Repository;;0"/> |
|
71 | 72 |
<project reference="1.0.1,https://forge.cbp.ens-lyon.fr/svn/txm/tmp/org.txm.libs.hsqldb,org.txm.libs.hsqldb,a0a75db469ef00161bbdeb2037bd6a92;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;branches;tags;trunk;true;865c2c80-10f3-4e06-9fd7-61c4de9d188b;https://forge.cbp.ens-lyon.fr/svn/txm;;false;<https://forge.cbp.ens-lyon.fr:443> Redmine SVN Repository;;0"/> |
72 | 73 |
<project reference="1.0.1,https://forge.cbp.ens-lyon.fr/svn/txm/tmp/org.txm.libs.itext,org.txm.libs.itext,a0a75db469ef00161bbdeb2037bd6a92;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;branches;tags;trunk;true;865c2c80-10f3-4e06-9fd7-61c4de9d188b;https://forge.cbp.ens-lyon.fr/svn/txm;;false;<https://forge.cbp.ens-lyon.fr:443> Redmine SVN Repository;;0"/> |
73 | 74 |
<project reference="1.0.1,https://forge.cbp.ens-lyon.fr/svn/txm/tmp/org.txm.libs.javafx,org.txm.libs.javafx,a0a75db469ef00161bbdeb2037bd6a92;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;https://forge.cbp.ens-lyon.fr/svn/txm/tmp;branches;tags;trunk;true;865c2c80-10f3-4e06-9fd7-61c4de9d188b;https://forge.cbp.ens-lyon.fr/svn/txm;;false;<https://forge.cbp.ens-lyon.fr:443> Redmine SVN Repository;;0"/> |
tmp/org.txm.core.tests/META-INF/MANIFEST.MF (revision 3056) | ||
---|---|---|
4 | 4 |
.txm.rcp.commands.tests |
5 | 5 |
Bundle-Name: Core Toolbox Tests |
6 | 6 |
Bundle-Version: 1.0.0.qualifier |
7 |
Require-Bundle: org.txm.statsengine.r.core;visibility:=reexport,org.tx |
|
8 |
m.searchengine.cqp.core;bundle-version="1.1.0";visibility:=reexport,o |
|
9 |
rg.txm.utils.core,org.eclipse.core.runtime;bundle-version="3.10.0",or |
|
10 |
g.txm.core;bundle-version="0.7.0",org.txm.ca.core;bundle-version="1.0 |
|
11 |
.0",org.txm.ahc.core;bundle-version="1.0.0",org.txm.chartsengine.core |
|
12 |
;bundle-version="1.0.0",org.txm.chartsengine.jfreechart.core;bundle-v |
|
13 |
ersion="1.0.0",org.txm.chartsengine.r.core;bundle-version="1.0.0",org |
|
14 |
.txm.concordance.core;bundle-version="1.0.0",org.txm.cooccurrence.cor |
|
15 |
e;bundle-version="1.0.0",org.txm.index.core;bundle-version="1.0.0",or |
|
16 |
g.txm.lexicaltable.core;bundle-version="1.0.0",org.txm.partition.core |
|
17 |
;bundle-version="1.0.0",org.txm.progression.core;bundle-version="1.0. |
|
18 |
0";visibility:=reexport,org.txm.specificities.core;bundle-version="1. |
|
19 |
0.0",org.txm.referencer.core;bundle-version="1.0.0",org.txm.rcp;bundl |
|
20 |
e-version="0.8.0";visibility:=reexport,org.polarion.eclipse.team.svn. |
|
21 |
connector.svnkit18;bundle-version="6.0.4",org.eclipse.jdt.core;bundle |
|
22 |
-version="3.13.102",org.txm.annotation.kr.core;bundle-version="1.0.0" |
|
23 |
,org.txm.chartsengine.svgbatik.rcp;bundle-version="1.0.0",org.txm.int |
|
24 |
ernalview.core;bundle-version="1.0.0",org.txm.properties.core;bundle- |
|
25 |
version="1.0.0",org.txm.searchengine.cqp.rcp;bundle-version="1.0.0" |
|
7 |
Require-Bundle: org.txm.statsengine.r.core;visibility:=reexport, |
|
8 |
org.txm.searchengine.cqp.core;bundle-version="1.1.0";visibility:=reexport, |
|
9 |
org.txm.utils.core;visibility:=reexport, |
|
10 |
org.eclipse.core.runtime;bundle-version="3.10.0";visibility:=reexport, |
|
11 |
org.txm.core;bundle-version="0.7.0";visibility:=reexport, |
|
12 |
org.txm.ca.core;bundle-version="1.0.0";visibility:=reexport, |
|
13 |
org.txm.ahc.core;bundle-version="1.0.0";visibility:=reexport, |
|
14 |
org.txm.chartsengine.core;bundle-version="1.0.0";visibility:=reexport, |
|
15 |
org.txm.chartsengine.jfreechart.core;bundle-version="1.0.0";visibility:=reexport, |
|
16 |
org.txm.chartsengine.r.core;bundle-version="1.0.0";visibility:=reexport, |
|
17 |
org.txm.concordance.core;bundle-version="1.0.0";visibility:=reexport, |
|
18 |
org.txm.cooccurrence.core;bundle-version="1.0.0";visibility:=reexport, |
|
19 |
org.txm.index.core;bundle-version="1.0.0";visibility:=reexport, |
|
20 |
org.txm.lexicaltable.core;bundle-version="1.0.0";visibility:=reexport, |
|
21 |
org.txm.partition.core;bundle-version="1.0.0";visibility:=reexport, |
|
22 |
org.txm.progression.core;bundle-version="1.0.0";visibility:=reexport, |
|
23 |
org.txm.specificities.core;bundle-version="1.0.0";visibility:=reexport, |
|
24 |
org.txm.referencer.core;bundle-version="1.0.0";visibility:=reexport, |
|
25 |
org.txm.rcp;bundle-version="0.8.0";visibility:=reexport, |
|
26 |
org.polarion.eclipse.team.svn.connector.svnkit18;bundle-version="6.0.4";visibility:=reexport, |
|
27 |
org.eclipse.jdt.core;bundle-version="3.13.102";visibility:=reexport, |
|
28 |
org.txm.annotation.kr.core;bundle-version="1.0.0";visibility:=reexport, |
|
29 |
org.txm.chartsengine.svgbatik.rcp;bundle-version="1.0.0";visibility:=reexport, |
|
30 |
org.txm.internalview.core;bundle-version="1.0.0";visibility:=reexport, |
|
31 |
org.txm.properties.core;bundle-version="1.0.0";visibility:=reexport, |
|
32 |
org.txm.searchengine.cqp.rcp;bundle-version="1.0.0";visibility:=reexport |
|
26 | 33 |
Bundle-ManifestVersion: 2 |
27 | 34 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 |
28 | 35 |
Bundle-Vendor: Textometrie.org |
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/PluginXMLIDs.java (revision 3056) | ||
---|---|---|
9 | 9 |
import org.txm.utils.io.IOUtils; |
10 | 10 |
|
11 | 11 |
public class PluginXMLIDs extends TXMPluginTest { |
12 |
|
|
12 |
|
|
13 | 13 |
@Override |
14 | 14 |
public void TBXPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
15 | 15 |
File javaSrcDirectory = getJavaSrcDirectory(projectDirectory); |
16 | 16 |
} |
17 |
|
|
17 |
|
|
18 | 18 |
@Override |
19 | 19 |
public void RCPPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
20 | 20 |
File pluginXML = new File(projectDirectory, "plugin.xml"); |
21 | 21 |
if (!pluginXML.exists()) { |
22 |
error("missing file "+pluginXML);
|
|
22 |
error("missing file " + pluginXML);
|
|
23 | 23 |
} |
24 | 24 |
File javaSrcDirectory = getJavaSrcDirectory(projectDirectory); |
25 |
|
|
26 |
LinkedHashSet<String> ids = new LinkedHashSet<String>();
|
|
25 |
|
|
26 |
LinkedHashSet<String> ids = new LinkedHashSet<>(); |
|
27 | 27 |
ids.addAll(IOUtils.findWithGroup(pluginXML, "id=\"([^\"]+)\"")); |
28 | 28 |
for (String id : ids) { |
29 | 29 |
if (id.startsWith(name)) { |
30 |
//System.out.println("id="+id); |
|
30 |
// System.out.println("id="+id);
|
|
31 | 31 |
String path = id.substring(0, id.lastIndexOf(".")).replace(".", "/"); |
32 |
String className = id.substring(id.lastIndexOf(".")+1);
|
|
32 |
String className = id.substring(id.lastIndexOf(".") + 1);
|
|
33 | 33 |
if (className.matches("[A-Z].+")) { |
34 |
File classFile = new File(javaSrcDirectory, path+"/"+className+".java");
|
|
34 |
File classFile = new File(javaSrcDirectory, path + "/" + className + ".java");
|
|
35 | 35 |
if (!classFile.exists()) { |
36 |
error("unbound id "+id+" "+classFile);
|
|
36 |
error("unbound id " + id + " " + classFile);
|
|
37 | 37 |
} |
38 | 38 |
} |
39 | 39 |
} |
40 | 40 |
} |
41 |
|
|
41 |
|
|
42 | 42 |
testClassExistance(pluginXML, javaSrcDirectory, name, "id=\"([^\"]+)\"", "id"); |
43 | 43 |
testClassExistance(pluginXML, javaSrcDirectory, name, "adaptableType=\"([^\"]+)\"", "adaptableType"); |
44 | 44 |
testClassExistance(pluginXML, javaSrcDirectory, name, "class=\"([^\"]+)\"", "class"); |
... | ... | |
57 | 57 |
* @throws IOException |
58 | 58 |
*/ |
59 | 59 |
private void testClassExistance(File pluginXML, File javaSrcDirectory, String name, String pattern, String type) throws IOException { |
60 |
LinkedHashSet<String> classes = new LinkedHashSet<String>();
|
|
60 |
LinkedHashSet<String> classes = new LinkedHashSet<>(); |
|
61 | 61 |
classes.addAll(IOUtils.findWithGroup(pluginXML, pattern, true)); |
62 | 62 |
for (String id : classes) { |
63 | 63 |
if (id.startsWith(name)) { |
64 |
//System.out.println("id="+id); |
|
64 |
// System.out.println("id="+id);
|
|
65 | 65 |
String path = id.substring(0, id.lastIndexOf(".")).replace(".", "/"); |
66 |
String className = id.substring(id.lastIndexOf(".")+1);
|
|
66 |
String className = id.substring(id.lastIndexOf(".") + 1);
|
|
67 | 67 |
if (className.matches("[A-Z].+")) { |
68 |
File classFile = new File(javaSrcDirectory, path+"/"+className+".java");
|
|
68 |
File classFile = new File(javaSrcDirectory, path + "/" + className + ".java");
|
|
69 | 69 |
if (!classFile.exists()) { |
70 |
error("unbound "+type+" "+id+" "+classFile);
|
|
70 |
error("unbound " + type + " " + id + " " + classFile);
|
|
71 | 71 |
} |
72 | 72 |
} |
73 | 73 |
} |
74 | 74 |
} |
75 | 75 |
} |
76 |
|
|
76 |
|
|
77 | 77 |
@Override |
78 | 78 |
public void gatherData() { |
79 | 79 |
// TODO Auto-generated method stub |
80 | 80 |
|
81 | 81 |
} |
82 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public void finalReport() { |
|
85 |
// TODO Auto-generated method stub |
|
86 |
|
|
87 |
} |
|
88 |
} |
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/PluginPreferences.java (revision 3056) | ||
---|---|---|
1 | 1 |
package org.txm.core.tests.junit; |
2 | 2 |
|
3 |
import static org.junit.Assert.fail; |
|
4 |
|
|
5 | 3 |
import java.io.File; |
6 | 4 |
|
7 | 5 |
import org.txm.utils.io.IOUtils; |
8 | 6 |
|
9 | 7 |
public class PluginPreferences extends TXMPluginTest { |
10 |
|
|
8 |
|
|
9 |
@Override |
|
11 | 10 |
public void RCPPluginTest(File projectDirectory, String name, String packagePath) { |
12 | 11 |
|
13 | 12 |
} |
... | ... | |
15 | 14 |
@Override |
16 | 15 |
public void TBXPluginTest(File projectDirectory, String name, String packagePath) { |
17 | 16 |
File javaSrcDirectory = getJavaSrcDirectory(projectDirectory); |
18 |
File preferencePackageDirectory = new File(javaSrcDirectory, packagePath+"/preferences");
|
|
17 |
File preferencePackageDirectory = new File(javaSrcDirectory, packagePath + "/preferences");
|
|
19 | 18 |
if (!preferencePackageDirectory.exists()) { |
20 |
error(preferencePackageDirectory.getAbsolutePath()+" is missing.");
|
|
19 |
error(preferencePackageDirectory.getAbsolutePath() + " is missing.");
|
|
21 | 20 |
return; |
22 | 21 |
} |
23 | 22 |
|
... | ... | |
31 | 30 |
for (File prefFile : files) { |
32 | 31 |
if (prefFile.getName().endsWith("Preferences.java")) c++; |
33 | 32 |
} |
34 |
if (c == 0) error("No preference class file in "+preferencePackageDirectory);
|
|
33 |
if (c == 0) error("No preference class file in " + preferencePackageDirectory);
|
|
35 | 34 |
} |
36 |
|
|
35 |
|
|
37 | 36 |
@Override |
38 | 37 |
public void gatherData() { |
39 | 38 |
// TODO Auto-generated method stub |
40 | 39 |
|
41 | 40 |
} |
41 |
|
|
42 |
@Override |
|
43 |
public void finalReport() { |
|
44 |
// TODO Auto-generated method stub |
|
45 |
|
|
46 |
} |
|
42 | 47 |
} |
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/AllTXMPluginTests.java (revision 3056) | ||
---|---|---|
5 | 5 |
import org.junit.runners.Suite.SuiteClasses; |
6 | 6 |
|
7 | 7 |
@RunWith(Suite.class) |
8 |
@SuiteClasses({ |
|
9 |
PluginPreferences.class, |
|
10 |
PluginMessages.class, |
|
11 |
PluginXMLIDs.class, |
|
12 |
PluginExtPoints.class, |
|
13 |
PluginBuildProperties.class, |
|
14 |
PluginMenuContributions.class, |
|
15 |
PluginsManifest.class |
|
16 |
}) |
|
8 |
@SuiteClasses({ |
|
9 |
PluginPreferences.class, |
|
10 |
PluginMessages.class, |
|
11 |
PluginXMLIDs.class, |
|
12 |
PluginExtPoints.class, |
|
13 |
PluginBuildProperties.class, |
|
14 |
PluginMenuContributions.class, |
|
15 |
PluginsManifest.class, |
|
16 |
WorkspaceProjects.class |
|
17 |
}) |
|
17 | 18 |
public class AllTXMPluginTests { |
18 |
|
|
19 |
} |
|
19 |
|
|
20 |
} |
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/PluginMenuContributions.java (revision 3056) | ||
---|---|---|
10 | 10 |
|
11 | 11 |
/** |
12 | 12 |
* check that all menu contributions point to an existing menu |
13 |
* |
|
13 | 14 |
* @author mdecorde |
14 | 15 |
* |
15 | 16 |
*/ |
16 | 17 |
public class PluginMenuContributions extends TXMPluginTest { |
17 |
|
|
18 |
HashSet<String> allMenus = new HashSet<String>(); |
|
19 |
HashSet<String> allSeparators = new HashSet<String>(); |
|
20 |
|
|
18 |
|
|
19 |
HashSet<String> allMenus = new HashSet<>(); |
|
20 |
|
|
21 |
HashSet<String> allSeparators = new HashSet<>(); |
|
22 |
|
|
21 | 23 |
@Override |
22 | 24 |
public void TBXPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
23 | 25 |
File javaSrcDirectory = getJavaSrcDirectory(projectDirectory); |
24 |
|
|
26 |
|
|
25 | 27 |
testDeclaredExtPoints(projectDirectory); |
26 | 28 |
} |
27 |
|
|
29 |
|
|
28 | 30 |
@Override |
29 | 31 |
public void RCPPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
30 | 32 |
File pluginXML = new File(projectDirectory, "plugin.xml"); |
31 | 33 |
if (!pluginXML.exists()) { |
32 |
error("missing file "+pluginXML);
|
|
34 |
error("missing file " + pluginXML);
|
|
33 | 35 |
} |
34 | 36 |
File javaSrcDirectory = getJavaSrcDirectory(projectDirectory); |
35 |
|
|
37 |
|
|
36 | 38 |
testDeclaredExtPoints(projectDirectory); |
37 | 39 |
} |
38 |
|
|
40 |
|
|
39 | 41 |
private void testDeclaredExtPoints(File projectDirectory) throws IOException { |
40 | 42 |
File pluginXML = new File(projectDirectory, "plugin.xml"); |
41 | 43 |
if (pluginXML.exists()) { |
42 | 44 |
ArrayList<String> locations = IOUtils.findWithGroup(pluginXML, "<menuContribution locationURI=\"([^\"]+)\"", true); |
43 |
//System.out.println("Test locations: "+locations); |
|
45 |
// System.out.println("Test locations: "+locations);
|
|
44 | 46 |
for (String location : locations) { |
45 | 47 |
String type = ""; |
46 | 48 |
String target = ""; |
47 | 49 |
if (location.startsWith("toolbar:")) { |
48 |
type= "toolbar"; |
|
50 |
type = "toolbar";
|
|
49 | 51 |
target = location.substring(8); |
50 |
} else if (location.startsWith("menu:")) { |
|
51 |
type= "menu"; |
|
52 |
} |
|
53 |
else if (location.startsWith("menu:")) { |
|
54 |
type = "menu"; |
|
52 | 55 |
target = location.substring(5); |
53 |
} else if (location.startsWith("popup:")) { |
|
54 |
type= "popup"; |
|
56 |
} |
|
57 |
else if (location.startsWith("popup:")) { |
|
58 |
type = "popup"; |
|
55 | 59 |
target = location.substring(6); |
56 |
} else { |
|
57 |
error("wrong contribution type ("+type+"): "+location); |
|
58 | 60 |
} |
59 |
|
|
61 |
else { |
|
62 |
error("wrong contribution type (" + type + "): " + location); |
|
63 |
} |
|
64 |
|
|
60 | 65 |
String position = ""; |
61 | 66 |
if (target.contains("?")) { |
62 |
position = target.substring(target.indexOf("?")+1);
|
|
67 |
position = target.substring(target.indexOf("?") + 1);
|
|
63 | 68 |
if (position.startsWith("after=")) { |
64 | 69 |
position = position.substring(6); |
65 |
} else if (position.startsWith("before=")) { |
|
70 |
} |
|
71 |
else if (position.startsWith("before=")) { |
|
66 | 72 |
position = position.substring(7); |
67 | 73 |
} |
68 | 74 |
|
69 | 75 |
target = target.substring(0, target.indexOf("?")); |
70 | 76 |
} |
71 |
//System.out.println(type+" -> "+target+" : "+position); |
|
77 |
// System.out.println(type+" -> "+target+" : "+position);
|
|
72 | 78 |
if (!allMenus.contains(target)) { |
73 |
error("wrong contribution target ("+target+"): "+location);
|
|
79 |
error("wrong contribution target (" + target + "): " + location);
|
|
74 | 80 |
} |
75 |
|
|
81 |
|
|
76 | 82 |
if (position.length() > 0) { |
77 | 83 |
if (!allSeparators.contains(position)) { |
78 |
//System.out.println("ERROR '"+position+"' not in "+allSeparators); |
|
79 |
error("wrong contribution position ("+position+"): "+location);
|
|
84 |
// System.out.println("ERROR '"+position+"' not in "+allSeparators);
|
|
85 |
error("wrong contribution position (" + position + "): " + location);
|
|
80 | 86 |
} |
81 | 87 |
} |
82 | 88 |
} |
83 |
|
|
89 |
|
|
84 | 90 |
} |
85 | 91 |
} |
86 |
|
|
92 |
|
|
87 | 93 |
@Override |
88 | 94 |
public void gatherData() { |
89 | 95 |
try { |
90 | 96 |
allMenus.add("org.eclipse.ui.main.menu"); // eclipse main menu |
91 | 97 |
allMenus.add("#TextEditorContext"); // text editor context |
92 | 98 |
for (File projectDirectory : projects) { |
93 |
|
|
99 |
|
|
94 | 100 |
File pluginXML = new File(projectDirectory, "plugin.xml"); |
95 | 101 |
if (pluginXML.exists()) { |
96 | 102 |
ArrayList<String> ids = IOUtils.findWithGroup(pluginXML, "menu id=\"([^\"]+)\"", true); |
... | ... | |
101 | 107 |
allMenus.addAll(ids); |
102 | 108 |
allSeparators.addAll(ids); |
103 | 109 |
|
104 |
//allowMultiple="false" |
|
110 |
// allowMultiple="false"
|
|
105 | 111 |
ArrayList<String> views = IOUtils.findWithGroup(pluginXML, "<view category=\"[^\"]+\" class=\"([^\"]+)\"", true); |
106 | 112 |
for (String view : views) { |
107 | 113 |
allMenus.add(view); |
108 | 114 |
} |
109 |
|
|
115 |
|
|
110 | 116 |
views = IOUtils.findWithGroup(pluginXML, "<view allowMultiple=\"[^\"]+\" category=\"[^\"]+\" class=\"([^\"]+)\"", true); |
111 | 117 |
for (String view : views) { |
112 | 118 |
allMenus.add(view); |
113 | 119 |
} |
114 |
|
|
120 |
|
|
115 | 121 |
views = IOUtils.findWithGroup(pluginXML, "<view class=\"([^\"]+)\"", true); |
116 | 122 |
for (String view : views) { |
117 | 123 |
allMenus.add(view); |
118 | 124 |
} |
119 |
|
|
125 |
|
|
120 | 126 |
ArrayList<String> editors = IOUtils.findWithGroup(pluginXML, "<editor class=\"([^\"]+)\"", true); |
121 | 127 |
for (String editor : editors) { |
122 | 128 |
allMenus.add(editor); |
123 | 129 |
} |
124 |
|
|
130 |
|
|
125 | 131 |
ArrayList<String> toolbars = IOUtils.findWithGroup(pluginXML, "<toolbar id=\"([^\"]+)\"", true); |
126 | 132 |
for (String toolbar : toolbars) { |
127 | 133 |
allMenus.add(toolbar); |
128 | 134 |
} |
129 |
|
|
135 |
|
|
130 | 136 |
ArrayList<String> separators = IOUtils.findWithGroup(pluginXML, "<separator name=\"([^\"]+)\"", true); |
131 | 137 |
for (String separator : separators) { |
132 | 138 |
allSeparators.add(separator); |
133 | 139 |
} |
134 |
|
|
140 |
|
|
135 | 141 |
ArrayList<String> commands = IOUtils.findWithGroup(pluginXML, "<command commandId=\"([^\"]+)\"", true); |
136 | 142 |
for (String command : commands) { |
137 | 143 |
allSeparators.add(command); |
138 | 144 |
} |
139 |
|
|
145 |
|
|
140 | 146 |
} |
141 | 147 |
} |
142 | 148 |
|
143 |
System.out.println("all menus: "+allMenus); |
|
144 |
|
|
145 |
System.out.println("all separators: "+allSeparators); |
|
146 |
} catch (IOException e) { |
|
149 |
System.out.println("all menus: " + allMenus); |
|
150 |
|
|
151 |
System.out.println("all separators: " + allSeparators); |
|
152 |
} |
|
153 |
catch (IOException e) { |
|
147 | 154 |
// TODO Auto-generated catch block |
148 | 155 |
e.printStackTrace(); |
149 | 156 |
} |
150 | 157 |
} |
151 |
} |
|
158 |
|
|
159 |
@Override |
|
160 |
public void finalReport() { |
|
161 |
// TODO Auto-generated method stub |
|
162 |
|
|
163 |
} |
|
164 |
} |
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/PluginMessages.java (revision 3056) | ||
---|---|---|
13 | 13 |
import org.txm.utils.io.IOUtils; |
14 | 14 |
|
15 | 15 |
public class PluginMessages extends TXMPluginTest { |
16 |
|
|
17 |
String langs[] = {""};
|
|
18 |
|
|
16 |
|
|
17 |
String langs[] = { "" };
|
|
18 |
|
|
19 | 19 |
@Override |
20 | 20 |
public void TBXPluginTest(File projectDirectory, String name, String packagePath) throws UnsupportedEncodingException, FileNotFoundException, IOException { |
21 | 21 |
commonTest(projectDirectory, name, packagePath); |
22 | 22 |
} |
23 |
|
|
23 |
|
|
24 | 24 |
@Override |
25 | 25 |
public void RCPPluginTest(File projectDirectory, String name, String packagePath) throws UnsupportedEncodingException, FileNotFoundException, IOException { |
26 | 26 |
commonTest(projectDirectory, name, packagePath); |
27 |
|
|
27 |
|
|
28 | 28 |
File pluginXML = new File(projectDirectory, "plugin.xml"); |
29 | 29 |
try { |
30 | 30 |
// OSGI-INF test |
31 | 31 |
File OSGI = new File(projectDirectory, "OSGI-INF/l10n"); |
32 | 32 |
for (String lang : langs) { |
33 |
File propertiesFile = new File(OSGI, "bundle"+lang+".properties");
|
|
33 |
File propertiesFile = new File(OSGI, "bundle" + lang + ".properties");
|
|
34 | 34 |
if (!propertiesFile.exists()) { |
35 |
error("No "+propertiesFile.getAbsolutePath());
|
|
35 |
error("No " + propertiesFile.getAbsolutePath());
|
|
36 | 36 |
return; |
37 |
} else { |
|
37 |
} |
|
38 |
else { |
|
38 | 39 |
testKeys(propertiesFile, pluginXML, "=\"%([^\"]+)\""); |
39 | 40 |
} |
40 | 41 |
} |
41 |
|
|
42 |
} catch (IOException e) { |
|
42 |
|
|
43 |
} |
|
44 |
catch (IOException e) { |
|
43 | 45 |
error(e.getLocalizedMessage()); |
44 | 46 |
e.printStackTrace(); |
45 | 47 |
} |
46 | 48 |
} |
47 |
|
|
49 |
|
|
48 | 50 |
public void commonTest(File projectDirectory, String name, String packagePath) throws UnsupportedEncodingException, FileNotFoundException, IOException { |
49 | 51 |
File javaSrcDirectory = getJavaSrcDirectory(projectDirectory); |
50 |
|
|
51 |
File messagesPackageDirectory = new File(javaSrcDirectory, packagePath+"/messages");
|
|
52 |
|
|
53 |
File messagesPackageDirectory = new File(javaSrcDirectory, packagePath + "/messages");
|
|
52 | 54 |
if (!messagesPackageDirectory.exists()) { |
53 |
error("missing file "+messagesPackageDirectory.getAbsolutePath());
|
|
55 |
error("missing file " + messagesPackageDirectory.getAbsolutePath());
|
|
54 | 56 |
return; |
55 | 57 |
} |
56 |
|
|
58 |
|
|
57 | 59 |
// test content |
58 | 60 |
File[] files = messagesPackageDirectory.listFiles(IOUtils.HIDDENFILE_FILTER); |
59 | 61 |
if (files == null) { |
... | ... | |
61 | 63 |
return; |
62 | 64 |
} |
63 | 65 |
int c = 0; |
64 |
|
|
66 |
|
|
65 | 67 |
File classFile = null; |
66 | 68 |
for (File file : files) { |
67 | 69 |
if (file.getName().endsWith("Messages.java")) classFile = file; |
68 | 70 |
} |
69 |
|
|
71 |
|
|
70 | 72 |
if (classFile == null) { |
71 |
error("missing Java file "+messagesPackageDirectory);
|
|
73 |
error("missing Java file " + messagesPackageDirectory);
|
|
72 | 74 |
return; |
73 | 75 |
} |
74 |
|
|
76 |
|
|
75 | 77 |
for (String lang : langs) { |
76 | 78 |
|
77 |
File propertiesFile = new File(messagesPackageDirectory, "messages"+lang+".properties");
|
|
79 |
File propertiesFile = new File(messagesPackageDirectory, "messages" + lang + ".properties");
|
|
78 | 80 |
if (!propertiesFile.exists()) { |
79 |
error("missing properties "+propertiesFile.getAbsolutePath());
|
|
81 |
error("missing properties " + propertiesFile.getAbsolutePath());
|
|
80 | 82 |
return; |
81 |
} else { |
|
83 |
} |
|
84 |
else { |
|
82 | 85 |
testKeys(propertiesFile, classFile, "public static String ([^;]+);"); |
83 | 86 |
} |
84 | 87 |
} |
85 | 88 |
} |
86 |
|
|
89 |
|
|
87 | 90 |
/** |
88 | 91 |
* Compare keys of @param propertiesFile with keys found in @param classFile with @param pattern |
92 |
* |
|
89 | 93 |
* @param propertiesFile |
90 | 94 |
* @param classFile |
91 | 95 |
* @param pattern |
... | ... | |
97 | 101 |
Properties props = new Properties(); |
98 | 102 |
props.load(IOUtils.getReader(propertiesFile, "UTF-8")); |
99 | 103 |
|
100 |
LinkedHashSet<String> keys = new LinkedHashSet<String>();
|
|
104 |
LinkedHashSet<String> keys = new LinkedHashSet<>(); |
|
101 | 105 |
keys.addAll(IOUtils.findWithGroup(classFile, pattern)); |
102 | 106 |
|
103 | 107 |
// find missing keys in prop file |
104 | 108 |
for (String key : keys) { |
105 | 109 |
if (props.getProperty(key) == null) { |
106 |
error("missing key '"+key+"' "+propertiesFile.getName());
|
|
110 |
error("missing key '" + key + "' " + propertiesFile.getName());
|
|
107 | 111 |
} |
108 | 112 |
} |
109 | 113 |
|
... | ... | |
111 | 115 |
for (Object key : props.keySet()) { |
112 | 116 |
String s = key.toString(); |
113 | 117 |
if (!keys.contains(s)) { |
114 |
error("unused key '"+key+"' "+propertiesFile.getName());
|
|
118 |
error("unused key '" + key + "' " + propertiesFile.getName());
|
|
115 | 119 |
} |
116 | 120 |
} |
117 | 121 |
} |
118 |
|
|
122 |
|
|
119 | 123 |
@Override |
120 | 124 |
public void gatherData() { |
121 | 125 |
// TODO Auto-generated method stub |
122 | 126 |
|
123 | 127 |
} |
128 |
|
|
129 |
@Override |
|
130 |
public void finalReport() { |
|
131 |
// TODO Auto-generated method stub |
|
132 |
|
|
133 |
} |
|
124 | 134 |
} |
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/TXMPluginTest.java (revision 3056) | ||
---|---|---|
22 | 22 |
* |
23 | 23 |
*/ |
24 | 24 |
public abstract class TXMPluginTest { |
25 |
|
|
25 | 26 |
public static int LEVEL = 3; // 1 errors, 2 warnings, 3 infos messages |
26 | 27 |
|
27 | 28 |
/** |
28 | 29 |
* error counter |
29 | 30 |
*/ |
30 | 31 |
int error = 0; |
31 |
|
|
32 |
|
|
32 | 33 |
protected ArrayList<File> projects; |
33 |
protected ArrayList<String> messages = new ArrayList<String>(); |
|
34 |
|
|
35 |
|
|
34 |
|
|
35 |
protected ArrayList<String> messages = new ArrayList<>(); |
|
36 |
|
|
37 |
|
|
36 | 38 |
public static File workspace = new File(System.getProperty("user.home"), "workspace047"); // MD |
37 |
//public static File workspace = new File("C:\\Tools\\Coding\\Java\\workspace_txm2"); // SJ |
|
38 |
|
|
39 |
// public static File workspace = new File("C:\\Tools\\Coding\\Java\\workspace_txm2"); // SJ
|
|
40 |
|
|
39 | 41 |
/** |
40 |
* fetch the org.txm projects that ends with core or rcp |
|
42 |
* fetch the org.txm projects that ends with core or rcp |
|
43 |
* |
|
41 | 44 |
* @return |
42 | 45 |
*/ |
43 | 46 |
protected static ArrayList<File> getProjects() { |
44 |
ArrayList<File> ret = new ArrayList<File>();
|
|
47 |
ArrayList<File> ret = new ArrayList<>(); |
|
45 | 48 |
if (!workspace.exists()) { |
46 |
System.out.println("ERROR: "+workspace+" does not exists. Set it in TXMPluginTest.java.");
|
|
49 |
System.out.println("ERROR: " + workspace + " does not exists. Set it in TXMPluginTest.java.");
|
|
47 | 50 |
return ret; |
48 |
}
|
|
49 |
|
|
51 |
} |
|
52 |
|
|
50 | 53 |
ret.addAll(Arrays.asList(workspace.listFiles(new FileFilter() { |
54 |
|
|
51 | 55 |
@Override |
52 | 56 |
public boolean accept(File pathname) { |
53 | 57 |
return pathname.isDirectory() && pathname.getName().startsWith("org.txm"); |
54 | 58 |
} |
55 | 59 |
}))); |
56 |
|
|
60 |
|
|
57 | 61 |
Collections.sort(ret); |
58 | 62 |
return ret; |
59 | 63 |
} |
60 |
|
|
64 |
|
|
61 | 65 |
/** |
62 | 66 |
* store and count error messages |
67 |
* |
|
63 | 68 |
* @param string |
64 | 69 |
*/ |
65 | 70 |
protected void error(String string) { |
66 |
if (LEVEL >= 1) messages.add(" ERROR "+string);
|
|
71 |
if (LEVEL >= 1) messages.add(" ERROR " + string);
|
|
67 | 72 |
error++; |
68 | 73 |
} |
69 |
|
|
74 |
|
|
70 | 75 |
/** |
71 | 76 |
* store warning messages |
77 |
* |
|
72 | 78 |
* @param string |
73 | 79 |
*/ |
74 | 80 |
protected void warning(String string) { |
75 |
if (LEVEL >= 2) messages.add(" WARNING "+string);
|
|
81 |
if (LEVEL >= 2) messages.add(" WARNING " + string);
|
|
76 | 82 |
} |
77 |
|
|
83 |
|
|
78 | 84 |
/** |
79 | 85 |
* store info messages |
86 |
* |
|
80 | 87 |
* @param string |
81 | 88 |
*/ |
82 | 89 |
protected void info(String string) { |
83 |
if (LEVEL >= 3) messages.add(" INFO "+string);
|
|
90 |
if (LEVEL >= 3) messages.add(" INFO " + string);
|
|
84 | 91 |
} |
85 |
|
|
92 |
|
|
86 | 93 |
/** |
87 | 94 |
* All Test must starts with "super.test();" Usually you don't need to Override this method |
88 | 95 |
*/ |
89 | 96 |
@Test |
90 | 97 |
public void test() { |
91 |
|
|
92 |
System.out.print("Testing "+this.getClass().getSimpleName()+"...");
|
|
98 |
|
|
99 |
System.out.print("Testing " + this.getClass().getSimpleName() + "...");
|
|
93 | 100 |
try { |
94 | 101 |
projects = getProjects(); |
95 |
|
|
96 |
if (projects.size() == 0) fail("No project found in "+workspace);
|
|
97 |
|
|
102 |
|
|
103 |
if (projects.size() == 0) fail("No project found in " + workspace);
|
|
104 |
|
|
98 | 105 |
gatherData(); |
99 |
|
|
106 |
|
|
100 | 107 |
int nProjectMessage = 0; |
101 | 108 |
for (File projectDirectory : projects) { |
102 | 109 |
messages.clear(); |
103 | 110 |
String plugin_name = projectDirectory.getName(); |
104 | 111 |
String plugin_package = plugin_name.replace(".", "/"); |
105 |
|
|
106 |
if (projectDirectory.getName().endsWith(".core")) { |
|
107 |
//plugin_package = plugin_package.substring(0, plugin_package.length()-5); |
|
112 |
|
|
113 |
if (projectDirectory.getName().endsWith(".feature")) { |
|
114 |
// plugin_package = plugin_package.substring(0, plugin_package.length()-4); |
|
115 |
FeaturePluginTest(projectDirectory, plugin_name, plugin_package); |
|
116 |
} |
|
117 |
else if (projectDirectory.getName().contains(".core")) { |
|
118 |
// plugin_package = plugin_package.substring(0, plugin_package.length()-5); |
|
108 | 119 |
TBXPluginTest(projectDirectory, plugin_name, plugin_package); |
109 |
} else if (projectDirectory.getName().endsWith(".rcp")) { |
|
110 |
//plugin_package = plugin_package.substring(0, plugin_package.length()-4); |
|
120 |
} |
|
121 |
else if (projectDirectory.getName().endsWith(".rcp")) { |
|
122 |
// plugin_package = plugin_package.substring(0, plugin_package.length()-4); |
|
111 | 123 |
RCPPluginTest(projectDirectory, plugin_name, plugin_package); |
112 |
} else if (projectDirectory.getName().endsWith(".feature")) { |
|
113 |
//plugin_package = plugin_package.substring(0, plugin_package.length()-4); |
|
114 |
FeaturePluginTest(projectDirectory, plugin_name, plugin_package); |
|
115 |
} else if (projectDirectory.getName().startsWith("org.txm.libs.")) { |
|
116 |
//plugin_package = plugin_package.substring(0, plugin_package.length()-4); |
|
117 |
LIBPluginTest(projectDirectory, plugin_name, plugin_package);} else { |
|
118 |
info("ignoring project: "+projectDirectory); |
|
119 | 124 |
} |
120 |
|
|
125 |
else if (projectDirectory.getName().startsWith("org.txm.libs.")) { |
|
126 |
// plugin_package = plugin_package.substring(0, plugin_package.length()-4); |
|
127 |
LIBPluginTest(projectDirectory, plugin_name, plugin_package); |
|
128 |
} |
|
129 |
else { |
|
130 |
OTHERPluginTest(projectDirectory, plugin_name, plugin_package); |
|
131 |
} |
|
132 |
|
|
121 | 133 |
if (messages.size() > 0) { |
122 | 134 |
if (nProjectMessage == 0) { |
123 | 135 |
System.out.println(); |
124 | 136 |
nProjectMessage++; |
125 | 137 |
} |
126 |
System.out.println(" P "+projectDirectory.getName()); |
|
127 |
for (String s : messages) System.out.println(s); |
|
138 |
System.out.println(" P " + projectDirectory.getName()); |
|
139 |
for (String s : messages) |
|
140 |
System.out.println(s); |
|
128 | 141 |
} |
129 |
|
|
130 | 142 |
} |
131 |
} catch(Exception e) { |
|
143 |
|
|
144 |
finalReport(); |
|
145 |
} |
|
146 |
catch (Exception e) { |
|
132 | 147 |
e.printStackTrace(); |
133 |
fail("Internal test error: "+e.getLocalizedMessage());
|
|
148 |
fail("Internal test error: " + e.getLocalizedMessage());
|
|
134 | 149 |
} |
135 | 150 |
if (error > 0) { |
136 |
fail("Errors during test "+this.getClass().getName()); |
|
137 |
} else System.out.println("OK!"); |
|
151 |
fail("Errors during test " + this.getClass().getName()); |
|
152 |
} |
|
153 |
else System.out.println("OK!"); |
|
138 | 154 |
} |
139 |
|
|
155 |
|
|
140 | 156 |
public void FeaturePluginTest(File projectDirectory, String plugin_name, String plugin_package) throws Exception { |
141 | 157 |
|
142 | 158 |
} |
143 |
|
|
159 |
|
|
144 | 160 |
/** |
145 | 161 |
* fetch info before testing individually the projects |
146 | 162 |
*/ |
147 | 163 |
public abstract void gatherData(); |
148 |
|
|
149 |
|
|
164 |
|
|
150 | 165 |
/** |
166 |
* final test done after all projects have been tested |
|
167 |
*/ |
|
168 |
public abstract void finalReport(); |
|
169 |
|
|
170 |
|
|
171 |
/** |
|
151 | 172 |
* |
152 | 173 |
* @param projectDirectory |
153 | 174 |
* @return find out the main Java src directory of the project |
... | ... | |
158 | 179 |
if (!javaSrcDirectory.exists()) javaSrcDirectory = new File(projectDirectory, "src/"); |
159 | 180 |
return javaSrcDirectory; |
160 | 181 |
} |
161 |
|
|
182 |
|
|
162 | 183 |
/** |
163 | 184 |
* test a TBX project |
164 | 185 |
* |
... | ... | |
168 | 189 |
* @throws Exception |
169 | 190 |
*/ |
170 | 191 |
public abstract void TBXPluginTest(File projectDirectory, String name, String packagePath) throws Exception; |
171 |
|
|
192 |
|
|
172 | 193 |
/** |
173 | 194 |
* test a LIB project |
174 | 195 |
* |
... | ... | |
180 | 201 |
public void LIBPluginTest(File projectDirectory, String name, String packagePath) throws Exception { |
181 | 202 |
|
182 | 203 |
} |
183 |
|
|
184 | 204 |
|
185 | 205 |
/** |
206 |
* test a project that was not recognized |
|
207 |
* |
|
208 |
* @param projectDirectory |
|
209 |
* @param name |
|
210 |
* @param packagePath |
|
211 |
* @throws Exception |
|
212 |
*/ |
|
213 |
public void OTHERPluginTest(File projectDirectory, String name, String packagePath) throws Exception { |
|
214 |
|
|
215 |
} |
|
216 |
|
|
217 |
/** |
|
186 | 218 |
* test a RCP project |
219 |
* |
|
187 | 220 |
* @param projectDirectory |
188 | 221 |
* @param name |
189 | 222 |
* @param packagePath |
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/PluginsManifest.java (revision 3056) | ||
---|---|---|
10 | 10 |
import org.txm.utils.io.IOUtils; |
11 | 11 |
|
12 | 12 |
public class PluginsManifest extends TXMPluginTest { |
13 |
|
|
13 |
|
|
14 | 14 |
boolean massFix = false; |
15 | 15 |
|
16 |
HashMap<String, HashMap<String, String>> ext_points = new HashMap<String, HashMap<String, String>>();
|
|
17 |
|
|
16 |
HashMap<String, HashMap<String, String>> ext_points = new HashMap<>(); |
|
17 |
|
|
18 | 18 |
@Override |
19 | 19 |
public void TBXPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
20 | 20 |
testDependenciesExport(projectDirectory); |
21 | 21 |
} |
22 |
|
|
22 |
|
|
23 | 23 |
@Override |
24 | 24 |
public void RCPPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
25 | 25 |
testDependenciesExport(projectDirectory); |
... | ... | |
27 | 27 |
|
28 | 28 |
@Override |
29 | 29 |
public void FeaturePluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
30 |
//testDependenciesExport(projectDirectory); |
|
30 |
// testDependenciesExport(projectDirectory);
|
|
31 | 31 |
} |
32 |
|
|
32 |
|
|
33 | 33 |
private void testDependenciesExport(File projectDirectory) throws IOException { |
34 | 34 |
File manifestFile = new File(projectDirectory, "META-INF/MANIFEST.MF"); |
35 | 35 |
|
36 | 36 |
if (!manifestFile.exists()) { |
37 |
error("missing file "+manifestFile);
|
|
37 |
error("missing file " + manifestFile);
|
|
38 | 38 |
return; |
39 | 39 |
} |
40 | 40 |
|
... | ... | |
49 | 49 |
StringBuilder fixed = new StringBuilder(""); |
50 | 50 |
String[] deps = depsString.split(","); |
51 | 51 |
for (String dep : deps) { |
52 |
fixed.append(","+dep);
|
|
52 |
fixed.append("," + dep);
|
|
53 | 53 |
if (!dep.contains("visibility:=reexport")) { |
54 |
error("not exported: "+dep);
|
|
54 |
error("not exported: " + dep);
|
|
55 | 55 |
fixed.append(";visibility:=reexport"); |
56 | 56 |
} |
57 | 57 |
} |
58 |
//System.out.println("FIX="+fixed); |
|
58 |
// System.out.println("FIX="+fixed);
|
|
59 | 59 |
attributes.put(k, fixed.substring(1)); |
60 |
} else if (k.toString().equals("Bundle-SymbolicName")) { |
|
60 |
} |
|
61 |
else if (k.toString().equals("Bundle-SymbolicName")) { |
|
61 | 62 |
String id = attributes.get(k).toString(); |
62 | 63 |
if (id.indexOf(";") > 0) { |
63 | 64 |
id = id.substring(0, id.indexOf(";")); |
64 | 65 |
} |
65 | 66 |
if (!projectDirectory.getName().equals(id)) { |
66 |
error("Project directory is not id. id="+id+" dir="+projectDirectory);
|
|
67 |
error("Project directory is not id. id=" + id + " dir=" + projectDirectory);
|
|
67 | 68 |
} |
68 | 69 |
} |
69 | 70 |
} |
... | ... | |
72 | 73 |
} |
73 | 74 |
inputData.close(); |
74 | 75 |
} |
75 |
|
|
76 |
|
|
76 | 77 |
@Override |
77 | 78 |
public void gatherData() { |
79 |
|
|
80 |
} |
|
78 | 81 |
|
82 |
@Override |
|
83 |
public void finalReport() { |
|
84 |
// TODO Auto-generated method stub |
|
85 |
|
|
79 | 86 |
} |
80 |
} |
|
87 |
} |
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/WorkspaceProjects.java (revision 3056) | ||
---|---|---|
1 |
package org.txm.core.tests.junit; |
|
2 |
|
|
3 |
import static org.junit.Assert.fail; |
|
4 |
|
|
5 |
import java.io.File; |
|
6 |
import java.io.IOException; |
|
7 |
import java.util.ArrayList; |
|
8 |
|
|
9 |
import javax.xml.parsers.ParserConfigurationException; |
|
10 |
|
|
11 |
import org.txm.utils.xml.DomUtils; |
|
12 |
import org.w3c.dom.Document; |
|
13 |
import org.w3c.dom.Element; |
|
14 |
import org.w3c.dom.NodeList; |
|
15 |
import org.xml.sax.SAXException; |
|
16 |
|
|
17 |
public class WorkspaceProjects extends TXMPluginTest { |
|
18 |
|
|
19 |
ArrayList<File> declaredProjects; |
|
20 |
|
|
21 |
@Override |
|
22 |
public void gatherData() { |
|
23 |
|
|
24 |
File projectSetXMLFile = new File(workspace, "org.txm.tests.core/projectSet.psf"); |
|
25 |
|
|
26 |
if (!projectSetXMLFile.exists()) { |
|
27 |
error("No project set file found in " + projectSetXMLFile); |
|
28 |
} |
|
29 |
|
|
30 |
declaredProjects = new ArrayList<>(); |
|
31 |
try { |
|
32 |
Document doc = DomUtils.load(projectSetXMLFile); |
|
33 |
NodeList nodes = doc.getElementsByTagName("project"); |
|
34 |
for (int i = 0; i < nodes.getLength(); i++) { |
|
35 |
Element projectElement = (Element) nodes.item(i); |
|
36 |
String ref = projectElement.getAttribute("reference"); |
|
37 |
String[] split = ref.split(","); |
|
38 |
if (split.length >= 3) { |
|
39 |
String name = split[2]; |
|
40 |
declaredProjects.add(new File(workspace, name)); |
|
41 |
} |
|
42 |
else { |
|
43 |
|
|
44 |
} |
|
45 |
} |
|
46 |
} |
|
47 |
catch (ParserConfigurationException | SAXException | IOException e) { |
|
48 |
e.printStackTrace(); |
|
49 |
error("Internal error: " + e); |
|
50 |
} |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public void TBXPluginTest(File projectDirectory, String name, String packagePath) throws Exception {} |
|
55 |
|
|
56 |
@Override |
|
57 |
public void RCPPluginTest(File projectDirectory, String name, String packagePath) throws Exception {} |
|
58 |
|
|
59 |
@Override |
|
60 |
public void finalReport() { |
|
61 |
int size = declaredProjects.size(); |
|
62 |
declaredProjects.removeAll(projects); |
|
63 |
if (declaredProjects.size() > 0) { // some projects are absent |
|
64 |
error("Some mandatory projects are missing in your current workspace: " + declaredProjects); |
|
65 |
} |
|
66 |
else { |
|
67 |
info("All the mandatory projects are here: " + size); |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
0 | 71 |
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/PluginsJavaVersion.java (revision 3056) | ||
---|---|---|
18 | 18 |
import org.xml.sax.SAXException; |
19 | 19 |
|
20 | 20 |
public class PluginsJavaVersion extends TXMPluginTest { |
21 |
|
|
21 |
|
|
22 | 22 |
private static final String CURRENT_JAVA_VERSION = "JavaSE-1.8"; |
23 |
|
|
23 | 24 |
private static final String classPathJREPreference = "org.eclipse.jdt.launching.JRE_CONTAINER"; |
25 |
|
|
24 | 26 |
boolean massFix = true; |
25 | 27 |
|
26 |
HashMap<String, HashMap<String, String>> ext_points = new HashMap<String, HashMap<String, String>>();
|
|
27 |
|
|
28 |
HashMap<String, HashMap<String, String>> ext_points = new HashMap<>(); |
|
29 |
|
|
28 | 30 |
@Override |
29 | 31 |
public void TBXPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
30 | 32 |
RCPPluginTest(projectDirectory, name, packagePath); |
31 | 33 |
} |
32 |
|
|
34 |
|
|
33 | 35 |
@Override |
34 | 36 |
public void RCPPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
35 | 37 |
testJavaVersionInManifest(projectDirectory); |
... | ... | |
43 | 45 |
|
44 | 46 |
@Override |
45 | 47 |
public void FeaturePluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
46 |
//testDependenciesExport(projectDirectory); |
|
48 |
// testDependenciesExport(projectDirectory);
|
|
47 | 49 |
} |
48 | 50 |
|
49 | 51 |
private void testJavaVersionInClasspath(File projectDirectory) throws IOException { |
50 | 52 |
File classpathFile = new File(projectDirectory, ".classpath"); |
51 | 53 |
if (!classpathFile.exists()) { |
52 |
error("missing file "+classpathFile);
|
|
54 |
error("missing file " + classpathFile);
|
|
53 | 55 |
return; |
54 | 56 |
} |
55 | 57 |
|
56 | 58 |
try { |
57 | 59 |
Document doc = DomUtils.load(classpathFile); |
58 | 60 |
NodeList elements = doc.getElementsByTagName("classpathentry"); |
59 |
for (int i = 0 ; i < elements.getLength() ; i++) {
|
|
61 |
for (int i = 0; i < elements.getLength(); i++) {
|
|
60 | 62 |
Element element = (Element) elements.item(i); |
61 | 63 |
String path = element.getAttribute("path"); |
62 | 64 |
if (path.startsWith(classPathJREPreference) && !path.equals(classPathJREPreference)) { |
... | ... | |
74 | 76 |
e.printStackTrace(); |
75 | 77 |
} |
76 | 78 |
} |
77 |
|
|
79 |
|
|
78 | 80 |
private void testJavaVersionInManifest(File projectDirectory) throws IOException { |
79 | 81 |
File manifestFile = new File(projectDirectory, "META-INF/MANIFEST.MF"); |
80 | 82 |
|
81 | 83 |
if (!manifestFile.exists()) { |
82 |
error("missing file "+manifestFile);
|
|
84 |
error("missing file " + manifestFile);
|
|
83 | 85 |
return; |
84 | 86 |
} |
85 | 87 |
|
... | ... | |
100 | 102 |
} |
101 | 103 |
inputData.close(); |
102 | 104 |
} |
103 |
|
|
105 |
|
|
104 | 106 |
@Override |
105 | 107 |
public void gatherData() { |
108 |
|
|
109 |
} |
|
106 | 110 |
|
111 |
@Override |
|
112 |
public void finalReport() { |
|
113 |
// TODO Auto-generated method stub |
|
114 |
|
|
107 | 115 |
} |
108 |
} |
|
116 |
} |
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/PluginBuildProperties.java (revision 3056) | ||
---|---|---|
10 | 10 |
import org.txm.utils.io.IOUtils; |
11 | 11 |
|
12 | 12 |
public class PluginBuildProperties extends TXMPluginTest { |
13 |
|
|
14 |
HashMap<String, HashMap<String, String>> ext_points = new HashMap<String, HashMap<String, String>>(); |
|
13 |
|
|
14 |
HashMap<String, HashMap<String, String>> ext_points = new HashMap<>(); |
|
15 |
|
|
15 | 16 |
boolean massfix = false; |
16 |
|
|
17 |
|
|
17 | 18 |
@Override |
18 | 19 |
public void TBXPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
19 | 20 |
File buildFile = testBuildFile(projectDirectory); |
20 | 21 |
if (buildFile == null) { |
21 | 22 |
return; |
22 | 23 |
} |
23 |
|
|
24 |
|
|
24 | 25 |
Properties props = getProperties(buildFile); |
25 |
|
|
26 |
|
|
26 | 27 |
testBinIncludes(props, buildFile); |
27 | 28 |
testQualifier(props, buildFile); |
28 | 29 |
} |
29 |
|
|
30 |
|
|
30 | 31 |
@Override |
31 | 32 |
public void RCPPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
32 | 33 |
File buildFile = testBuildFile(projectDirectory); |
33 | 34 |
if (buildFile == null) |
34 | 35 |
return; |
35 |
|
|
36 |
|
|
36 | 37 |
Properties props = getProperties(buildFile); |
37 |
|
|
38 |
|
|
38 | 39 |
testBinIncludes(props, buildFile); |
39 | 40 |
testQualifier(props, buildFile); |
40 | 41 |
} |
41 |
|
|
42 |
|
|
42 | 43 |
@Override |
43 | 44 |
public void FeaturePluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
44 | 45 |
File buildFile = testBuildFile(projectDirectory); |
45 | 46 |
if (buildFile == null) |
46 | 47 |
return; |
47 |
|
|
48 |
|
|
48 | 49 |
Properties props = getProperties(buildFile); |
49 |
|
|
50 |
|
|
50 | 51 |
testQualifier(props, buildFile); |
51 | 52 |
} |
52 |
|
|
53 |
|
|
53 | 54 |
public static Properties getProperties(File buildFile) throws UnsupportedEncodingException, FileNotFoundException, IOException { |
54 | 55 |
Properties props = new Properties(); |
55 | 56 |
props.load(IOUtils.getReader(buildFile)); |
56 | 57 |
return props; |
57 | 58 |
} |
58 |
|
|
59 |
|
|
59 | 60 |
public void testQualifier(Properties props, File buildFile) throws UnsupportedEncodingException, FileNotFoundException, IOException { |
60 | 61 |
Object o = props.get("qualifier"); |
61 | 62 |
if (o == null) { |
62 | 63 |
error("QUALIFIER not set to 'svn': " + buildFile.getAbsolutePath()); |
63 |
} else { |
|
64 |
} |
|
65 |
else { |
|
64 | 66 |
String value = o.toString(); |
65 | 67 |
if (!value.equals("svn")) { |
66 | 68 |
error("QUALIFIER not set to 'svn': " + buildFile.getAbsolutePath()); |
... | ... | |
70 | 72 |
} |
71 | 73 |
} |
72 | 74 |
} |
73 |
|
|
75 |
|
|
74 | 76 |
public void testBinIncludes(Properties props, File buildFile) { |
75 | 77 |
String value = (String) props.get("bin.includes"); |
76 | 78 |
// System.out.println("buildFile="+buildFile+" value="+value); |
... | ... | |
82 | 84 |
error("META-INF is not exported: " + buildFile.getAbsolutePath()); |
83 | 85 |
} |
84 | 86 |
} |
85 |
|
|
87 |
|
|
86 | 88 |
private File testBuildFile(File projectDirectory) throws IOException { |
87 | 89 |
File buildFile = new File(projectDirectory, "build.properties"); |
88 |
|
|
90 |
|
|
89 | 91 |
if (!buildFile.exists()) { |
90 | 92 |
error("no build.properties: " + buildFile.getAbsolutePath()); |
91 | 93 |
return null; |
92 | 94 |
} |
93 |
|
|
95 |
|
|
94 | 96 |
return buildFile; |
95 | 97 |
} |
96 |
|
|
98 |
|
|
97 | 99 |
@Override |
98 | 100 |
public void gatherData() { |
99 |
|
|
101 |
|
|
100 | 102 |
} |
101 |
} |
|
103 |
|
|
104 |
@Override |
|
105 |
public void finalReport() { |
|
106 |
// TODO Auto-generated method stub |
|
107 |
|
|
108 |
} |
|
109 |
} |
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/PluginExtPoints.java (revision 3056) | ||
---|---|---|
8 | 8 |
import org.txm.utils.io.IOUtils; |
9 | 9 |
|
10 | 10 |
public class PluginExtPoints extends TXMPluginTest { |
11 |
|
|
12 |
HashMap<String, HashMap<String, String>> ext_points = new HashMap<String, HashMap<String, String>>();
|
|
13 |
|
|
11 |
|
|
12 |
HashMap<String, HashMap<String, String>> ext_points = new HashMap<>(); |
|
13 |
|
|
14 | 14 |
@Override |
15 | 15 |
public void TBXPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
16 | 16 |
File javaSrcDirectory = getJavaSrcDirectory(projectDirectory); |
17 |
|
|
17 |
|
|
18 | 18 |
testDeclaredExtPoints(projectDirectory); |
19 | 19 |
testImplementedextPoints(projectDirectory); |
20 | 20 |
} |
21 |
|
|
22 |
|
|
23 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 | 24 |
@Override |
25 | 25 |
public void RCPPluginTest(File projectDirectory, String name, String packagePath) throws IOException { |
26 | 26 |
File pluginXML = new File(projectDirectory, "plugin.xml"); |
27 | 27 |
if (!pluginXML.exists()) { |
28 |
error("missing file "+pluginXML);
|
|
28 |
error("missing file " + pluginXML);
|
|
29 | 29 |
} |
30 | 30 |
File javaSrcDirectory = getJavaSrcDirectory(projectDirectory); |
31 |
|
|
31 |
|
|
32 | 32 |
testDeclaredExtPoints(projectDirectory); |
33 | 33 |
testImplementedextPoints(projectDirectory); |
34 | 34 |
} |
35 |
|
|
35 |
|
|
36 | 36 |
private void testDeclaredExtPoints(File projectDirectory) throws IOException { |
37 | 37 |
File schemaDirectory = new File(projectDirectory, "schema"); |
38 | 38 |
if (schemaDirectory.exists()) { |
... | ... | |
43 | 43 |
if (ids.size() != classes.size()) { |
44 | 44 |
continue; // not a Java based extension |
45 | 45 |
} |
46 |
for (int i = 0 ; i < ids.size() ; i++) {
|
|
46 |
for (int i = 0; i < ids.size(); i++) {
|
|
47 | 47 |
String id = ids.get(i); |
48 | 48 |
String clazz = classes.get(i); |
49 |
|
|
49 |
|
|
50 | 50 |
if (!ext_points.containsKey(id)) { |
51 |
error("ext file id\t"+id+" not found in plugin XML files. schema file "+schemaXML.getAbsolutePath());
|
|
51 |
error("ext file id\t" + id + " not found in plugin XML files. schema file " + schemaXML.getAbsolutePath());
|
|
52 | 52 |
} |
53 | 53 |
|
54 |
File classFile = new File(getJavaSrcDirectory(projectDirectory), clazz.replace(".", "/")+".java");
|
|
54 |
File classFile = new File(getJavaSrcDirectory(projectDirectory), clazz.replace(".", "/") + ".java");
|
|
55 | 55 |
if (!classFile.exists()) { |
56 |
error("Java class\t"+classFile+"\tnot found for ext point\t"+id);
|
|
56 |
error("Java class\t" + classFile + "\tnot found for ext point\t" + id);
|
|
57 | 57 |
} |
58 | 58 |
} |
59 | 59 |
} |
60 | 60 |
} |
61 | 61 |
} |
62 |
|
|
62 |
|
|
63 | 63 |
private void testImplementedextPoints(File projectDirectory) { |
64 | 64 |
File pluginXML = new File(projectDirectory, "plugin.xml"); |
65 | 65 |
if (pluginXML.exists()) { |
66 |
//find out implemented ext point declared in ext_points
|
|
66 |
// find out implemented ext point declared in ext_points
|
|
67 | 67 |
} |
68 | 68 |
} |
69 |
|
|
69 |
|
|
70 | 70 |
@Override |
71 | 71 |
public void gatherData() { |
72 | 72 |
try { |
... | ... | |
75 | 75 |
if (pluginXML.exists()) { |
76 | 76 |
ArrayList<String> ids = IOUtils.findWithGroup(pluginXML, "<extension-point id=\"([^\"]+)\"", true); |
77 | 77 |
ArrayList<String> files = IOUtils.findWithGroup(pluginXML, "schema=\"([^\"]+)\\.exsd\"", true); |
78 |
for (int i = 0 ; i < ids.size() ; i++) {
|
|
78 |
for (int i = 0; i < ids.size(); i++) {
|
|
79 | 79 |
String id = ids.get(i); |
80 | 80 |
String file = files.get(i); |
81 | 81 |
if (ext_points.containsKey(id)) { |
82 |
System.out.println("WARNING: duplicated extension point: "+id+" in "+pluginXML.getAbsolutePath());
|
|
82 |
System.out.println("WARNING: duplicated extension point: " + id + " in " + pluginXML.getAbsolutePath());
|
|
83 | 83 |
} |
84 | 84 |
ext_points.put(id, new HashMap<String, String>()); |
85 | 85 |
ext_points.get(id).put("file", file); |
86 | 86 |
} |
87 | 87 |
} |
88 |
|
|
88 |
|
|
89 | 89 |
File schemaDirectory = new File(projectDirectory, "schema"); |
90 | 90 |
if (schemaDirectory.exists()) { |
91 | 91 |
for (File schemaXML : schemaDirectory.listFiles(IOUtils.HIDDENFILE_FILTER)) { |
... | ... | |
98 | 98 |
continue; // not a Java based schema |
99 | 99 |
} |
100 | 100 |
|
101 |
for (int i = 0 ; i < ids.size() ; i++) {
|
|
101 |
for (int i = 0; i < ids.size(); i++) {
|
|
102 | 102 |
String id = ids.get(i); |
103 | 103 |
String clazz = classes.get(i); |
104 |
|
|
104 |
|
|
105 | 105 |
if (ext_points.containsKey(id)) { |
106 | 106 |
ext_points.get(id).put("class", clazz); |
107 | 107 |
} |
... | ... | |
109 | 109 |
} |
110 | 110 |
} |
111 | 111 |
} |
112 |
} catch (IOException e) { |
|
112 |
} |
|
113 |
catch (IOException e) { |
|
113 | 114 |
// TODO Auto-generated catch block |
114 | 115 |
e.printStackTrace(); |
115 | 116 |
} |
116 | 117 |
} |
117 |
} |
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
@Override |
|
122 |
public void finalReport() { |
|
123 |
// TODO Auto-generated method stub |
|
124 |
|
|
125 |
} |
|
126 |
} |
Formats disponibles : Unified diff