Author: scabanovich
Date: 2012-01-03 19:40:06 -0500 (Tue, 03 Jan 2012)
New Revision: 37622
Added:
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testWebProject/WebContent/WEB-INF/web30.xml
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebAppHelperTest.java
Modified:
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java
Log:
JBIDE-10579
https://issues.joss.org/browse/JBIDE-10579
Tests are added.
Added:
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testWebProject/WebContent/WEB-INF/web30.xml
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testWebProject/WebContent/WEB-INF/web30.xml
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testWebProject/WebContent/WEB-INF/web30.xml 2012-01-04
00:40:06 UTC (rev 37622)
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+ <display-name>jsf2</display-name>
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ <welcome-file>index.htm</welcome-file>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>default.html</welcome-file>
+ <welcome-file>default.htm</welcome-file>
+ <welcome-file>default.jsp</welcome-file>
+ </welcome-file-list>
+<filter-mapping>
+ <filter-name>compressionFilter</filter-name>
+ <url-pattern>*</url-pattern>
+ </filter-mapping>
+
+ <filter>
+ <display-name>CompressionFilter</display-name>
+ <filter-name>compressionFilter</filter-name>
+ <filter-class>demo.CompressionFilter</filter-class>
+ <init-param>
+ <param-name>compressionThreshold</param-name>
+ <param-value>500</param-value> <!-- compress anything above 1kb -->
+ </init-param>
+ <init-param>
+ <param-name>ignoreURLPattern</param-name>
+ <param-value>.*\.(flv|mp3|mpg)</param-value> <!-- regex -->
+ </init-param>
+ <init-param>
+ <param-name>ignoreMimes</param-name>
+ <param-value>images/*,video/*, multipart/x-gzip</param-value> <!--
ignore -->
+ </init-param>
+ <init-param>
+ <param-name>ignoreUserAgentsPattern</param-name>
+ <param-value>.*MSIE.*</param-value> <!-- regex -->
+ </init-param>
+ </filter>
+</web-app>
Property changes on:
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testWebProject/WebContent/WEB-INF/web30.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java 2012-01-04
00:38:59 UTC (rev 37621)
+++
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java 2012-01-04
00:40:06 UTC (rev 37622)
@@ -25,7 +25,8 @@
suite.addTestSuite(WebContentAssistProviderTest.class);
// suite.addTestSuite(BuilderTest.class);
suite.addTest(new WebValidationTestSetup(new TestSuite(
- WebUtilTest.class,
+ WebUtilTest.class,
+ WebAppHelperTest.class,
WebXMLValidationTest.class)));
return suite;
}
Added:
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebAppHelperTest.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebAppHelperTest.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebAppHelperTest.java 2012-01-04
00:40:06 UTC (rev 37622)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.test;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.jboss.tools.common.base.test.validation.TestUtil;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.web.WebUtils;
+import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
+import org.jboss.tools.test.util.ProjectImportTestSetup;
+import org.jboss.tools.test.util.ResourcesUtils;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class WebAppHelperTest extends TestCase {
+
+ private IProject project;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ project = getTestProject();
+ }
+
+ public IProject getTestProject() {
+ if(project==null) {
+ try {
+ project = findTestProject();
+ if(project==null || !project.exists()) {
+ project = ResourcesUtils.importProject(JstWebAllTests.PLUGIN_ID,
JstWebAllTests.PROJECT_PATH);
+ TestUtil._waitForValidation(project);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Can't import CDI test project: " + e.getMessage());
+ }
+ }
+ return project;
+ }
+
+ public static IProject findTestProject() {
+ return
ResourcesPlugin.getWorkspace().getRoot().getProject(JstWebAllTests.PROJECT_NAME);
+ }
+
+ /**
+ * See
https://issues.jboss.org/browse/JBIDE-10579
+ * @throws Exception
+ */
+ public void testFilters() throws Exception {
+ XModelObject o = getWebXML30();
+
+ assertEquals("3.0", WebAppHelper.getServletVersion(o));
+
+ XModelObject[] fs = WebAppHelper.getFilters(o);
+ assertEquals(1, fs.length);
+
+ XModelObject[] ms = WebAppHelper.getFilterMappings(o);
+ assertEquals(1, ms.length);
+ }
+
+ public void testServlets() throws Exception {
+ XModelObject o = getWebXML30();
+
+ XModelObject s = WebAppHelper.findOrCreateServlet(o, "a.b.C", "C",
0);
+
+ XModelObject[] ss = WebAppHelper.getServlets(o);
+ assertEquals(1, ss.length);
+ assertTrue(s == ss[0]);
+
+ }
+
+ private XModelObject getWebXML30() {
+ IFile f = project.getFile("WebContent/WEB-INF/web30.xml");
+ assertTrue(f.exists());
+ XModelObject o = EclipseResourceUtil.createObjectForResource(f);
+ assertNotNull(o);
+ return o;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebAppHelperTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain