package org openbravo test javascript import java io File Generates de

 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
/**
package org.openbravo.test.javascript;
import java.io.File;
/**
* Generates a description file for each JavaScript in web/js
*
* @author iperdomo
*
*/
public class JavaScriptAPITest extends TestCase {
@Override
protected void setUp() throws Exception {
setConfigPropertyFiles();
super.setUp();
}
protected void setConfigPropertyFiles() {
// get the location of the current class file
final URL url = this.getClass().getResource(getClass().getSimpleName() + ".class");
File f = new File(url.getPath());
// go up 7 levels
for (int i = 0; i < 7; i++) {
f = f.getParentFile();
}
final File configDirectory = new File(f, "config");
f = new File(configDirectory, "Openbravo.properties");
if (!f.exists()) {
throw new OBException("The testrun assumes that it is run from "
+ "within eclipse and that the Openbravo.properties "
+ "file is located as a grandchild of the 7th ancestor " + "of this class");
}
OBPropertiesProvider.getInstance().setProperties(f.getAbsolutePath());
}
public void testJavaScriptAPI() {
JavaScriptAPIChecker apiCheck = new JavaScriptAPIChecker();
final String tmpPath = System.getProperty("java.io.tmpdir");
final Properties props = OBPropertiesProvider.getInstance().getOpenbravoProperties();
final String sourcePath = (String) props.get("source.path");
apiCheck.setDetailsFolder(new File(tmpPath));
apiCheck.setJSFolder(new File(sourcePath + File.separator + "web" + File.separator + "js"));
apiCheck.process();
assertTrue("API Map should be empty: " + apiCheck.getAPIMap(), apiCheck.getAPIMap().isEmpty());
}