Author: dmaliarevich
Date: 2009-06-25 11:15:44 -0400 (Thu, 25 Jun 2009)
New Revision: 16204
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4510Test.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4510, JUnit was added, doctype processing was
updated.
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-06-25
15:08:55 UTC (rev 16203)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-06-25
15:15:44 UTC (rev 16204)
@@ -61,6 +61,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4337Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4373Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4509Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4510Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE675Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE924Test;
@@ -149,6 +150,7 @@
suite.addTestSuite(JBIDE4337Test.class);
suite.addTestSuite(JBIDE4179Test.class);
suite.addTestSuite(JBIDE4509Test.class);
+ suite.addTestSuite(JBIDE4510Test.class);
// $JUnit-END$
// added by Max Areshkau
// add here projects which should be imported for junit tests
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4510Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4510Test.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4510Test.java 2009-06-25
15:15:44 UTC (rev 16204)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.core.JarEntryFile;
+import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
+import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.jdt.internal.ui.javaeditor.JarEntryEditorInput;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMDocumentType;
+
+public class JBIDE4510Test extends VpeTest {
+
+ private static final String JAR_NAME = "WebContent/WEB-INF/lib/mareshkau.jar";
//$NON-NLS-1$
+ private static final String FILE_NAME = "components/paginator.xhtml";
//$NON-NLS-1$
+
+ public JBIDE4510Test(String name) {
+ super(name);
+ }
+
+ public void testCorrectDoctypeOnFileFromJarArchive() throws Throwable {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME);
+ /*
+ * Project should exist in the workspace
+ */
+ assertNotNull("Project was not found in the workspace: " //$NON-NLS-1$
+ + JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME, project);
+ IFile jarArchive = (IFile) project.findMember(JAR_NAME);
+ /*
+ * Jar file should exist in the project.
+ */
+ assertNotNull("File was not found in the project: " //$NON-NLS-1$
+ + JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME + "/" + JAR_NAME,
//$NON-NLS-1$
+ jarArchive);
+ IJavaProject javaProject = JavaCore.create(project);
+ /*
+ * Project should be correctly transformed.
+ */
+ assertNotNull("Cannot process java project:" //$NON-NLS-1$
+ + JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME, javaProject);
+
+ IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(jarArchive);
+ /*
+ * Root element should have the correct type.
+ */
+ if (root instanceof JarPackageFragmentRoot) {
+ JarPackageFragmentRoot jarRoot = (JarPackageFragmentRoot) root;
+ JarEntryFile jarFile = new JarEntryFile(FILE_NAME);
+ jarFile.setParent(jarRoot);
+ JarEntryEditorInput jarEditorInput = new JarEntryEditorInput(jarFile);
+ JSPMultiPageEditor editor = openEditor(jarEditorInput);
+ /*
+ * Verify that the editor is opened.
+ */
+ assertNotNull(
+ "Visual Page Editor with a file from the jar archive should have been opened
but it wasn't.", //$NON-NLS-1$
+ editor);
+ /*
+ * Get the DOM document
+ */
+ nsIDOMDocument document = TestUtil.getVpeVisualDocument(editor);
+ nsIDOMDocumentType doctype = document.getDoctype();
+ /*
+ * Doctype should present for the current file.
+ */
+ assertNotNull("Doctype should present for the specified file: "
//$NON-NLS-1$
+ + JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME + "/" //$NON-NLS-1$
+ + JAR_NAME + "/" + FILE_NAME, doctype); //$NON-NLS-1$
+
+ /*
+ * Doctype should have the correct type.
+ */
+ assertEquals(
+ "Doctype should have the correct type: \" html \", but was: "+
doctype.getNodeName(), //$NON-NLS-1$
+ "html", doctype.getNodeName()); //$NON-NLS-1$
+ } else {
+ /*
+ * Fail the test when we cannot process jar file correctly.
+ */
+ fail("Jar file cannot be processed. Jar file: " //$NON-NLS-1$
+ + JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME + "/" //$NON-NLS-1$
+ + JAR_NAME);
+ }
+ }
+
+}
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4510Test.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2009-06-25
15:08:55 UTC (rev 16203)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2009-06-25
15:15:44 UTC (rev 16204)
@@ -133,7 +133,7 @@
/*
* Create temporally IFile.
*/
- iFile = project.getFile(TEMP_FILE_NAME + jarFile.getName());
+ iFile = project.getFile(TEMP_FILE_NAME + jarFile.getFullPath().lastSegment());
/*
* Delete any previously saved file.
*/