Пример #1
0
 public void testWebApp() {
   String testName = "WebAppModelTest:testPaths:attribute";
   IModelNature n = EclipseResourceUtil.getModelNature(project);
   doAttributeTest(n.getModel(), testName);
   XModelObject o = n.getModel().getByPath("/web30.xml");
   printPaths(o);
 }
Пример #2
0
  public void testPaths() {
    IModelNature n = EclipseResourceUtil.getModelNature(project);
    String testName = "JSFModelTest:testPaths";
    IFile f = project.getFile(new Path("/testCases.xml"));
    ArrayList<TestDescription> tests = new TestDescriptionFactory(f).getTestDescriptions(testName);
    System.out.println(testName + " " + (tests == null ? -1 : tests.size()));
    StringBuilder sb = new StringBuilder();
    int errorCount = 0;

    if (tests != null)
      for (int i = 0; i < tests.size(); i++) {
        TestDescription t = tests.get(i);
        String path = t.getProperty("path");
        XModelObject o = n.getModel().getByPath(path);
        if (o == null) {
          sb.append(path).append("\n");
          errorCount++;
        }
      }
    assertTrue(
        "Cannot find objects at " + errorCount + " paths\n" + sb.toString(), errorCount == 0);

    testName = "JSFModelTest:testPaths:attribute";
    doAttributeTest(n.getModel(), testName);
  }
 public static XModelObject getJarEntryObject(IProject p, String jarFile, String entry) {
   if (p == null) {
     IFile f = EclipseResourceUtil.getFile(jarFile);
     if (f == null) return null;
     p = f.getProject();
   }
   if (p == null) return null;
   IModelNature n = EclipseResourceUtil.getModelNature(p);
   XModel model = null;
   if (n != null) {
     model = n.getModel();
   } else {
     XModelObject o = EclipseResourceUtil.createObjectForResource(p);
     if (o != null) model = o.getModel();
   }
   if (model == null) return null;
   XModelObject[] fs = FileSystemsHelper.getFileSystems(model).getChildren();
   for (XModelObject s : fs) {
     String loc =
         Paths.expand(s.get(XModelObjectConstants.ATTR_NAME_LOCATION), model.getProperties());
     if (new File(loc).equals(new File(jarFile))) {
       XModelObject result = s.getChildByPath(entry);
       if (result == null && entry != null) {
         int q = entry.indexOf('/');
         int d = entry.indexOf('.');
         if (q > d && d >= 0) {
           String entry1 = entry.substring(0, q).replace('.', '/') + entry.substring(q);
           result = s.getChildByPath(entry1);
         }
       }
       if (result != null) return result;
     }
   }
   return (n == null) ? null : n.getModel().getByPath("/" + entry); // $NON-NLS-1$
 }
 public static XModel getXModel(IFile file) {
   if (file == null) return null;
   XModelObject fs = EclipseResourceUtil.getObjectByResource(file);
   if (fs != null) return fs.getModel();
   IProject project = file.getProject();
   IModelNature nature = EclipseResourceUtil.getModelNature(project);
   return (nature == null) ? null : nature.getModel();
 }
Пример #5
0
 public void testJSFProjectStructure() {
   IModelNature n = EclipseResourceUtil.getModelNature(project);
   JSFProjectsRoot root = JSFProjectsTree.getProjectsRoot(n.getModel());
   assertTrue("Cannot find root object.", root != null);
   XModelObject[] cs = root.getTreeChildren();
   for (int i = 0; i < cs.length; i++) {
     System.out.println(cs[i].getPath());
   }
 }
Пример #6
0
 public void testWebAppLoader() {
   IModelNature n = EclipseResourceUtil.getModelNature(project);
   XModelObject o = n.getModel().getByPath("/web30.xml");
   String error = ((AbstractXMLFileImpl) o).getLoaderError();
   assertNull("Loader reported an error.", error);
 }
Пример #7
0
 public void testModelExists() {
   IModelNature n = EclipseResourceUtil.getModelNature(project);
   assertTrue("Test project " + project.getName() + " has no model nature.", n != null);
   assertTrue("XModel for project " + project.getName() + " is not loaded.", n.getModel() != null);
 }
Пример #8
0
 public void testRecognizer() {
   IModelNature n = EclipseResourceUtil.getModelNature(project);
   EntityRecognizer recognizer = n.getModel().getEntityRecognizer();
   String entity = recognizer.getEntityName(new EntityRecognizerContext("tld", TLD_FILE));
   assertEquals("FileTLD_1_2", entity);
 }