1 | package org.modelica.mdt.test; |
---|
2 | |
---|
3 | import java.util.List; |
---|
4 | |
---|
5 | import org.eclipse.core.resources.IProject; |
---|
6 | import org.modelica.mdt.core.IModelicaPackage; |
---|
7 | import org.modelica.mdt.core.IModelicaProject; |
---|
8 | import org.modelica.mdt.core.ISystemLibrary; |
---|
9 | import org.modelica.mdt.internal.core.SystemLibrary; |
---|
10 | |
---|
11 | import junit.framework.TestCase; |
---|
12 | |
---|
13 | /** |
---|
14 | * |
---|
15 | * @author Andreas Remar |
---|
16 | * |
---|
17 | */ |
---|
18 | //TODO clean me up ! |
---|
19 | // all warnings and System.out.println() must be removed |
---|
20 | public class TestModelicaProject extends TestCase |
---|
21 | { |
---|
22 | |
---|
23 | IProject project; |
---|
24 | IModelicaProject modelicaProject; |
---|
25 | |
---|
26 | public void testStuff() |
---|
27 | { |
---|
28 | ISystemLibrary isl = new SystemLibrary(); |
---|
29 | List<IModelicaPackage> imps = isl.getPackages(); |
---|
30 | for(IModelicaPackage i : imps) |
---|
31 | { |
---|
32 | assertTrue("System library doesn't contain Modelica", |
---|
33 | i.getElementName().equals("Modelica")); |
---|
34 | |
---|
35 | System.out.println(i.getElementName()); |
---|
36 | |
---|
37 | List<IModelicaPackage> imps2 = i.getPackages(); |
---|
38 | String[] names = {"UsersGuide", "Media", "Utilities", "Mechanics", |
---|
39 | "Electrical", "Math", "Blocks", "Thermal", |
---|
40 | "Icons", "Constants", "SIunits", "StateGraph"}; |
---|
41 | for(int j = 0;j < imps2.size();j++) |
---|
42 | { |
---|
43 | assertTrue("Name doesn't match: " + names[j] + " != " + |
---|
44 | imps2.get(j).getElementName(), |
---|
45 | names[j].equals(imps2.get(j).getElementName())); |
---|
46 | System.out.println(" " + imps2.get(j).getElementName()); |
---|
47 | } |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | private void traverse(IModelicaPackage imp, int depth) |
---|
52 | { |
---|
53 | System.out.println(imp.getElementName()); |
---|
54 | |
---|
55 | if(depth <= 0) |
---|
56 | return; |
---|
57 | |
---|
58 | List<IModelicaPackage> imps = imp.getPackages(); |
---|
59 | for(IModelicaPackage i : imps) |
---|
60 | { |
---|
61 | traverse(i, depth-1); |
---|
62 | } |
---|
63 | } |
---|
64 | } |
---|