01: /*
02: * EntityRESTServicesCodeGeneratorTest.java
03: * JUnit 4.x based test
04: *
05: * Created on May 17, 2007, 8:31 PM
06: */
07:
08: package org.netbeans.modules.websvc.rest.codegen;
09:
10: import java.io.File;
11: import java.net.MalformedURLException;
12: import java.net.URL;
13: import java.util.ArrayList;
14: import java.util.Collections;
15: import java.util.Iterator;
16: import java.util.List;
17: import junit.framework.Assert;
18: import org.netbeans.api.java.classpath.ClassPath;
19: import org.netbeans.api.java.source.ClasspathInfo;
20: import org.netbeans.api.java.source.JavaSource;
21: import org.netbeans.junit.NbTestCase;
22: import org.netbeans.modules.websvc.rest.support.JavaSourceHelper;
23: import org.netbeans.modules.websvc.rest.wizard.Util;
24: import org.netbeans.spi.java.classpath.support.ClassPathSupport;
25: import org.openide.filesystems.FileObject;
26: import org.openide.filesystems.FileSystem;
27: import org.openide.filesystems.FileUtil;
28:
29: /**
30: *
31: * @author nam
32: */
33: public class EntityRESTServicesCodeGeneratorTest extends TestBase {
34: public EntityRESTServicesCodeGeneratorTest(String name) {
35: super (name);
36: }
37:
38: @Override
39: protected void setUp() throws Exception {
40: }
41:
42: @Override
43: protected void tearDown() throws Exception {
44: }
45:
46: public void testGenerate() throws Exception {
47: getEntities();
48: List<JavaSource> entities = new ArrayList<JavaSource>();
49: for (FileObject child : entityClassDirFO.getChildren()) {
50: if (!child.isData() || !"java".equals(child.getExt())) {
51: continue;
52: }
53: FileObject entityFO = entityClassDirFO.getFileObject(child
54: .getNameExt());
55: JavaSource js = JavaSource.create(ClasspathInfo.create(
56: defaultCPP.getBootClassPath(), defaultCPP
57: .getCompileClassPath(), defaultCPP
58: .getSourceClassPath()), Collections
59: .singleton(entityFO));
60: assertNotNull("can't get javasource for "
61: + entityFO.getPath(), js);
62: if (js != null && JavaSourceHelper.isEntity(js)) {
63: entities.add(js);
64: }
65: }
66: /*EntityRESTServicesCodeGenerator gen = new EntityRESTServicesCodeGenerator(
67: entities, entityClassDirFO, PACKAGE_ACME, "AcmePU");*/
68:
69: //FIXME faile on generic java template processing on include of default-license.text
70: //gen.generate();
71: }
72:
73: public void testSingularizePluralize() throws Exception {
74: assertEquals("Product", Util.singularize("Products"));
75: assertEquals("Product", Util.singularize("Product"));
76: assertEquals("Products", Util.pluralize("Products"));
77: assertEquals("Products", Util.pluralize("Product"));
78: assertEquals("Address", Util.singularize("Addresses"));
79: assertEquals("Address", Util.singularize("Address"));
80: assertEquals("Addresses", Util.pluralize("Address"));
81: assertEquals("Addresses", Util.pluralize("Addresses"));
82: assertEquals("Airline", Util.singularize("Airlines"));
83: assertEquals("Airlines", Util.pluralize("Airlines"));
84: }
85: }
|