Bug 581626 - Clean up WebImportDataModelVerifier and JEEImportDataModelVerifier Change-Id: I047eeff1cd5942c38c816adc957cb62bc9631507
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/j2ee/verifiers/JEEImportDataModelVerifier.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/j2ee/verifiers/JEEImportDataModelVerifier.java index c31b794..4978ef8 100644 --- a/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/j2ee/verifiers/JEEImportDataModelVerifier.java +++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/j2ee/verifiers/JEEImportDataModelVerifier.java
@@ -1,6 +1,6 @@ /* * Created on Jan 5, 2004 - * + * * To change the template for this generated file go to Window - Preferences - Java - Code * Generation - Code and Comments */ @@ -38,7 +38,7 @@ /** * @author Administrator * @author Ian Tewksbury (ictewksb@us.ibm.com) - * + * * To change the template for this generated type comment go to Window - Preferences - Java - Code * Generation - Code and Comments */ @@ -48,7 +48,7 @@ private static final String JAR_EXTENSION = "jar"; private static final String RAR_EXTENSION = "rar"; private static final String WAR_EXTENSION = "war"; - + protected IDataModel model; protected IProject project; @@ -63,24 +63,24 @@ this.verifyProjectCreated(); String archivePath = model.getStringProperty(IJ2EEModuleImportDataModelProperties.FILE_NAME); - + IArchive archive = null; try { archive = JavaEEArchiveUtilities.INSTANCE.openArchive(new Path(archivePath)); this.verifyImportedProjectTypeAndVersion(archive); this.verifyAllFilesImported(archive); - + } finally { if (null != archive && archive.isOpen()) { JavaEEArchiveUtilities.INSTANCE.closeArchive(archive); } } } - + /** * used for verifying imported archives that are nested inside of other archives - * + * * @param nestedArchiveImportModel * @param importedNestedArchive */ @@ -90,7 +90,7 @@ project = ProjectUtility.getProject(projectName); this.verifyProjectCreated(); - + this.verifyImportedProjectTypeAndVersion(importedNestedArchive); this.verifyAllFilesImported(importedNestedArchive); } @@ -107,11 +107,11 @@ } else { JavaEEQuickPeek archiveQuickPeek = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(archive); int type = archiveQuickPeek.getType(); - + if(getExportType() != type){ AssertWarn.warnEquals("Archive type did not match imported project type, archive="+archive, getExportType(), type); } - + String sProjVersion = J2EEProjectUtilities.getJ2EEDDProjectVersion(project); int iProjVersion = J2EEVersionUtil.convertVersionStringToInt(sProjVersion); int iVersionConstant = archiveQuickPeek.getVersion(); @@ -125,7 +125,7 @@ Assert.assertTrue("A project with name, " + project.getName() + ", should have been created by import", project.exists()); } - + protected boolean isClassWithoutSource(IArchive archive, IArchiveResource aFile) { String javaUri = classUriToJavaUri(aFile.getPath().toString()); if (javaUri == null) @@ -136,7 +136,7 @@ protected final String DOT_CLASS = ".class"; //$NON-NLS-1$ protected final String DOT_JAVA = ".java"; //$NON-NLS-1$ - + public String classUriToJavaUri(String classUri) { if (classUri == null || !classUri.endsWith(DOT_CLASS)) return null; @@ -145,7 +145,7 @@ StringTokenizer tok = new StringTokenizer(truncated, "$"); //$NON-NLS-1$ return tok.nextToken().concat(DOT_JAVA); } - + /** * Return a substring of the first parameter, up to the last index of the * second @@ -165,7 +165,7 @@ IVirtualFolder rootVirtFolder = projectComponent.getRootFolder(); IContainer rootFolder = rootVirtFolder.getUnderlyingFolder(); Assert.assertTrue("The root folder " + rootFolder.getName() + " should exist in the project" , rootFolder.exists()); - + // when the for loops is done the classes will contain only those classes that were imported, // the sourceResources list will contain a list of all of the java source resources, // the otherResources list will contain all other resources that are not nested archives, @@ -173,7 +173,7 @@ List<IArchiveResource> classes = new ArrayList<IArchiveResource>(); List<IArchiveResource> sourceResources = new ArrayList<IArchiveResource>(); List<IArchiveResource> otherResources = new ArrayList<IArchiveResource>(); - + String extension = null; for(IArchiveResource resource : resources) { resourcePath = resource.getPath(); @@ -181,7 +181,7 @@ switch (resource.getType()) { case IArchiveResource.FILE_TYPE : extension = resourcePath.getFileExtension(); - + // Note: For war archive, the class must be in WEB-INF/classes, otherwise it's just content if(extension.equals(CLASS_EXTENSION) && ((getExportType() == J2EEVersionConstants.WEB_TYPE) ? (resourcePath.segmentCount() > 2 && resourcePath.segment(0).equals("WEB-INF") && resourcePath.segment(1).equals("classes")) : true)){ @@ -195,21 +195,21 @@ } else { otherResources.add(resource); } - + break; case IArchiveResource.DIRECTORY_TYPE : - + break; case IArchiveResource.ARCHIVE_TYPE : - + break; } } - + List<IArchive> nestedArchives = archive.getNestedArchives(); - + verifyImportedResources(sourceResources, classes, otherResources, nestedArchives, rootFolder, importedClassesFolder); } - + protected abstract void verifyImportedResources(Collection<IArchiveResource> sourceResources, Collection<IArchiveResource> importedClassesResources, Collection<IArchiveResource> otherResources, Collection<IArchive> nestedArchives, IContainer rootFolder, IFolder importedClassesFolder) throws Exception; }
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/web/verifiers/WebImportDataModelVerifier.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/web/verifiers/WebImportDataModelVerifier.java index cbbfffd..297583d 100644 --- a/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/web/verifiers/WebImportDataModelVerifier.java +++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/web/verifiers/WebImportDataModelVerifier.java
@@ -36,12 +36,12 @@ public void verify(IDataModel model) throws Exception { super.verify(model); } - + @Override protected int getExportType() { return J2EEVersionConstants.WEB_TYPE; } - + @Override protected void verifyImportedResources( Collection<IArchiveResource> sourceResources, @@ -49,11 +49,11 @@ Collection<IArchiveResource> otherResources, Collection<IArchive> nestedArchives, IContainer rootFolder, IFolder importedClassesFolder) { - + IPath resourcePath = null; IFile resourceFile = null; IFolder sourceFolder = project.getFolder("src"); - + //verify all of the resources from the archive were imported to the project correctly for(IArchiveResource sourceResource : sourceResources) { resourcePath = sourceResource.getPath(); @@ -61,7 +61,7 @@ resourceFile = sourceFolder.getFile(resourcePath); Assert.assertTrue("The file " + resourcePath + " should exist in the project", resourceFile.exists()); } - + for(IArchiveResource importedClassResource : importedClassesResources) { resourcePath = importedClassResource.getPath().removeFirstSegments(2); resourceFile = importedClassesFolder.getFile(resourcePath); @@ -69,18 +69,18 @@ Assert.fail("The imported class " + resourcePath + " should exist in the project"); } } - + for(IArchiveResource otherResource : otherResources) { resourcePath = otherResource.getPath(); resourceFile = rootFolder.getFile(resourcePath); Assert.assertTrue("The resource " + resourcePath + " should exist in the project", resourceFile.exists()); } - + for(IArchive nestedArchive : nestedArchives) { - + } } - + protected boolean isClassWithoutSource(IArchive archive, IArchiveResource aFile) { String javaUri = ArchiveUtil.classUriToJavaUri(aFile.getPath().toString()); if (javaUri == null) @@ -117,11 +117,11 @@ } } catch (FileNotFoundException e) { } - + } - + } - + return true; } }