15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 package com.nokia.helium.ant.data.tests; |
18 package com.nokia.helium.ant.data.tests; |
19 |
19 |
|
20 import static org.junit.Assert.assertTrue; |
|
21 |
20 import java.io.File; |
22 import java.io.File; |
21 import java.io.IOException; |
23 import java.io.IOException; |
22 import java.io.StringWriter; |
24 import java.io.StringWriter; |
23 import java.util.ArrayList; |
25 import java.util.ArrayList; |
24 import java.util.List; |
26 import java.util.List; |
26 import org.dom4j.Document; |
28 import org.dom4j.Document; |
27 import org.dom4j.DocumentException; |
29 import org.dom4j.DocumentException; |
28 import org.dom4j.DocumentHelper; |
30 import org.dom4j.DocumentHelper; |
29 import org.dom4j.Node; |
31 import org.dom4j.Node; |
30 import org.junit.Test; |
32 import org.junit.Test; |
31 import static org.junit.Assert.*; |
|
32 |
33 |
33 import com.nokia.helium.ant.data.Database; |
34 import com.nokia.helium.ant.data.Database; |
34 |
35 |
35 public class TestMeta { |
36 public class TestMeta { |
36 @Test |
37 @Test |
80 Node macro = project.selectSingleNode("macro"); |
81 Node macro = project.selectSingleNode("macro"); |
81 assertTrue(macro.valueOf("name").equals("test_macro")); |
82 assertTrue(macro.valueOf("name").equals("test_macro")); |
82 assertTrue(macro.valueOf("scope").equals("public")); |
83 assertTrue(macro.valueOf("scope").equals("public")); |
83 assertTrue(macro.valueOf("deprecated").equals("")); |
84 assertTrue(macro.valueOf("deprecated").equals("")); |
84 } |
85 } |
|
86 |
|
87 @Test |
|
88 public void testProjectMetaScope() throws IOException, DocumentException { |
|
89 readPropertyTotal("public", 3); |
|
90 readPropertyTotal("private", 7); |
|
91 } |
|
92 |
|
93 private void readPropertyTotal(String scope, int total) throws IOException, DocumentException { |
|
94 Database db = new Database(null, scope); |
|
95 List<String> paths = new ArrayList<String>(); |
|
96 File testAntFile = new File(System.getProperty("testdir"), "tests/data/test_project_scopes.ant.xml"); |
|
97 paths.add(testAntFile.getCanonicalPath()); |
|
98 db.setScopeFilter(scope); |
|
99 db.addAntFilePaths(paths); |
|
100 StringWriter out = new StringWriter(); |
|
101 db.toXML(out); |
|
102 |
|
103 Document doc = DocumentHelper.parseText(out.toString()); |
|
104 System.out.println(doc.asXML()); |
|
105 |
|
106 Node database = doc.selectSingleNode("//antDatabase"); |
|
107 |
|
108 Node project = database.selectSingleNode("project"); |
|
109 |
|
110 List properties = project.selectNodes("property"); |
|
111 System.out.println(properties.size()); |
|
112 assertTrue(properties.size() == total); |
|
113 } |
85 } |
114 } |