summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Tsao2014-04-02 12:43:42 (EDT)
committerRoberto Sanchez2014-04-02 12:43:42 (EDT)
commite32407bd2a114af3aa4d8666ffed32910d4d93c3 (patch)
tree1e5a0db97465ae750291fd4777e4b126c91f1965
parent44a5c81b150be392004828587b4cbe249b0b8d59 (diff)
downloadwebtools.javaee.tests-e32407bd2a114af3aa4d8666ffed32910d4d93c3.zip
webtools.javaee.tests-e32407bd2a114af3aa4d8666ffed32910d4d93c3.tar.gz
webtools.javaee.tests-e32407bd2a114af3aa4d8666ffed32910d4d93c3.tar.bz2
[431725] Update AddWebArtifactOperationTest to test annotated classesv201404021700
-rw-r--r--tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/operations/JavaEEFacetConstants.java7
-rw-r--r--tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/AddWebArtifactOperationTest.java442
-rw-r--r--tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/WebProjectCreationOperationTest.java10
-rw-r--r--tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/web/verifiers/WebProjectCreationDataModelVerifier.java2
4 files changed, 454 insertions, 7 deletions
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/operations/JavaEEFacetConstants.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/operations/JavaEEFacetConstants.java
index 287f332..808ff5f 100644
--- a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/operations/JavaEEFacetConstants.java
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/operations/JavaEEFacetConstants.java
@@ -13,6 +13,7 @@ public class JavaEEFacetConstants {
public static final IProjectFacetVersion APP_CLIENT_14 = APP_CLIENT_FACET.getVersion("1.4"); //$NON-NLS-1$
public static final IProjectFacetVersion APP_CLIENT_5 = APP_CLIENT_FACET.getVersion("5.0"); //$NON-NLS-1$
public static final IProjectFacetVersion APP_CLIENT_6 = APP_CLIENT_FACET.getVersion("6.0"); //$NON-NLS-1$
+ public static final IProjectFacetVersion APP_CLIENT_7 = APP_CLIENT_FACET.getVersion("7.0"); //$NON-NLS-1$
public static final IProjectFacet EJB_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_EJB_MODULE); //$NON-NLS-1$
public static final IProjectFacetVersion EJB_11 = EJB_FACET.getVersion("1.1"); //$NON-NLS-1$
@@ -20,6 +21,7 @@ public class JavaEEFacetConstants {
public static final IProjectFacetVersion EJB_21 = EJB_FACET.getVersion("2.1"); //$NON-NLS-1$
public static final IProjectFacetVersion EJB_3 = EJB_FACET.getVersion("3.0"); //$NON-NLS-1$
public static final IProjectFacetVersion EJB_31 = EJB_FACET.getVersion("3.1"); //$NON-NLS-1$
+ public static final IProjectFacetVersion EJB_32 = EJB_FACET.getVersion("3.2"); //$NON-NLS-1$
public static final IProjectFacet WEB_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_WEB_MODULE); //$NON-NLS-1$
public static final IProjectFacetVersion WEB_22 = WEB_FACET.getVersion("2.2"); //$NON-NLS-1$
@@ -27,11 +29,13 @@ public class JavaEEFacetConstants {
public static final IProjectFacetVersion WEB_24 = WEB_FACET.getVersion("2.4"); //$NON-NLS-1$
public static final IProjectFacetVersion WEB_25 = WEB_FACET.getVersion("2.5"); //$NON-NLS-1$
public static final IProjectFacetVersion WEB_30 = WEB_FACET.getVersion("3.0"); //$NON-NLS-1$
+ public static final IProjectFacetVersion WEB_31 = WEB_FACET.getVersion("3.1"); //$NON-NLS-1$
public static final IProjectFacet CONNECTOR_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_CONNECTOR_MODULE); //$NON-NLS-1$
public static final IProjectFacetVersion CONNECTOR_1 = CONNECTOR_FACET.getVersion("1.0"); //$NON-NLS-1$
public static final IProjectFacetVersion CONNECTOR_15 = CONNECTOR_FACET.getVersion("1.5"); //$NON-NLS-1$
public static final IProjectFacetVersion CONNECTOR_16 = CONNECTOR_FACET.getVersion("1.6"); //$NON-NLS-1$
+ public static final IProjectFacetVersion CONNECTOR_17 = CONNECTOR_FACET.getVersion("1.7"); //$NON-NLS-1$
public static final IProjectFacet EAR_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_EAR_MODULE); //$NON-NLS-1$
public static final IProjectFacetVersion EAR_12 = EAR_FACET.getVersion("1.2"); //$NON-NLS-1$
@@ -39,13 +43,16 @@ public class JavaEEFacetConstants {
public static final IProjectFacetVersion EAR_14 = EAR_FACET.getVersion("1.4"); //$NON-NLS-1$
public static final IProjectFacetVersion EAR_5 = EAR_FACET.getVersion("5.0"); //$NON-NLS-1$
public static final IProjectFacetVersion EAR_6 = EAR_FACET.getVersion("6.0"); //$NON-NLS-1$
+ public static final IProjectFacetVersion EAR_7 = EAR_FACET.getVersion("7.0"); //$NON-NLS-1$
public static final IProjectFacet JAVA_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_JAVA); //$NON-NLS-1$
public static final IProjectFacetVersion JAVA_13 = JAVA_FACET.getVersion("1.3"); //$NON-NLS-1$
public static final IProjectFacetVersion JAVA_14 = JAVA_FACET.getVersion("1.4"); //$NON-NLS-1$
public static final IProjectFacetVersion JAVA_5 = JAVA_FACET.getVersion("5.0"); //$NON-NLS-1$
public static final IProjectFacetVersion JAVA_6 = JAVA_FACET.getVersion("6.0"); //$NON-NLS-1$
+ public static final IProjectFacetVersion JAVA_7 = JAVA_FACET.getVersion("1.7"); //$NON-NLS-1$
public static final IProjectFacet WEBFRAGMENT_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_WEBFRAGMENT_MODULE);
public static final IProjectFacetVersion WEBFRAGMENT_30 = WEBFRAGMENT_FACET.getVersion("3.0"); //$NON-NLS-1$
+ public static final IProjectFacetVersion WEBFRAGMENT_31 = WEBFRAGMENT_FACET.getVersion("3.1"); //$NON-NLS-1$
}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/AddWebArtifactOperationTest.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/AddWebArtifactOperationTest.java
index d43870e..cfe3cc9 100644
--- a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/AddWebArtifactOperationTest.java
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/AddWebArtifactOperationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,6 +20,7 @@ import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -32,6 +33,8 @@ import org.eclipse.jst.j2ee.common.Listener;
import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties;
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences;
+import org.eclipse.jst.j2ee.internal.web.operations.INewFilterClassDataModelProperties;
+import org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties;
import org.eclipse.jst.j2ee.internal.web.operations.NewFilterClassDataModelProvider;
import org.eclipse.jst.j2ee.internal.web.operations.NewListenerClassDataModelProvider;
import org.eclipse.jst.j2ee.internal.web.operations.NewServletClassDataModelProvider;
@@ -46,8 +49,10 @@ import org.eclipse.jst.j2ee.webapplication.ServletMapping;
import org.eclipse.jst.j2ee.webapplication.WebApp;
import org.eclipse.jst.javaee.core.DisplayName;
import org.eclipse.jst.javaee.core.UrlPatternType;
+import org.eclipse.jst.jee.model.tests.SynchronousModelChangedListener;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.tests.OperationTestCase;
import org.eclipse.wtp.j2ee.headless.tests.j2ee.operations.JavaEEFacetConstants;
@@ -72,7 +77,8 @@ public class AddWebArtifactOperationTest extends OperationTestCase implements
public static final String LISTENER_NAME = "TestListener"; //$NON-NLS-1$
public static final String LISTENER_CLASS_NAME = PACKAGE + "." + LISTENER_NAME; //$NON-NLS-1$
-
+ private IModelProvider mergedModelProvider;
+
/**
* @param name
*/
@@ -189,6 +195,132 @@ public class AddWebArtifactOperationTest extends OperationTestCase implements
SERVLET_DEFAULT_MAPPING, urlPattern.getValue());
}
+
+ public void testAddServlet_Web30_Defaults() throws Exception{
+ createWebProject(WEB_PROJECT_NAME, JavaEEFacetConstants.WEB_30);
+ IProject proj = ProjectUtilities.getProject(WEB_PROJECT_NAME);
+
+ mergedModelProvider = ModelProviderManager.getModelProvider(proj);
+ org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) mergedModelProvider.getModelObject();
+
+ addServlet_Defaults_Annotations();
+
+ assertJavaFileExists(SERVLET_CLASS_NAME);
+
+ List servlets = webApp.getServlets();
+ assertEquals("Exactly one servlet is expected in the model, but " + servlets.size() + " are found",
+ 1, servlets.size());
+ org.eclipse.jst.javaee.web.Servlet servlet = (org.eclipse.jst.javaee.web.Servlet) servlets.get(0);
+ assertEquals("Servlet name is expected to be " + SERVLET_NAME + ", but it is " + servlet.getServletName(),
+ SERVLET_NAME, servlet.getServletName());
+ assertEquals("Servlet class name is expected to be " + SERVLET_CLASS_NAME + ", but it is " + servlet.getServletClass(),
+ SERVLET_CLASS_NAME, servlet.getServletClass());
+
+ List params = servlet.getInitParams();
+ assertNotNull("List of initialization parameters cannot be retrieved", params);
+ assertEquals("None initialization parameter is expected, but " + params.size() + " are found",
+ 0, params.size());
+
+ List mappings = webApp.getServletMappings();
+ assertEquals("Exactly one servlet mapping is expected, but " + mappings.size() + " are found",
+ 1, mappings.size());
+ org.eclipse.jst.javaee.web.ServletMapping mapping = (org.eclipse.jst.javaee.web.ServletMapping) mappings.get(0);
+ assertEquals("Servlet name of the mapping is expected to be " + SERVLET_NAME + ", but it is " + mapping.getServletName(),
+ SERVLET_NAME, mapping.getServletName());
+ List urlPatterns = mapping.getUrlPatterns();
+ assertEquals("Exactly one URL pattern is expected in the mapping, but " + urlPatterns.size() + " are found",
+ 1, urlPatterns.size());
+ UrlPatternType urlPattern = (UrlPatternType) urlPatterns.get(0);
+ assertEquals("Servlet mapping URL pattern value is expected to be " + SERVLET_DEFAULT_MAPPING + ", but it is " + urlPattern.getValue(),
+ SERVLET_DEFAULT_MAPPING, urlPattern.getValue());
+ }
+
+
+ public void testAddServlet_Web30_Async() throws Exception {
+ createWebProject(WEB_PROJECT_NAME, JavaEEFacetConstants.WEB_30);
+ IProject proj = ProjectUtilities.getProject(WEB_PROJECT_NAME);
+
+ mergedModelProvider = ModelProviderManager.getModelProvider(proj);
+ org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) mergedModelProvider.getModelObject();
+
+ addServlet_Async();
+
+ assertJavaFileExists(SERVLET_CLASS_NAME);
+
+ List servlets = webApp.getServlets();
+ assertEquals("Exactly one servlet is expected in the model, but " + servlets.size() + " are found",
+ 1, servlets.size());
+ org.eclipse.jst.javaee.web.Servlet servlet = (org.eclipse.jst.javaee.web.Servlet) servlets.get(0);
+ assertEquals("Servlet name is expected to be " + SERVLET_NAME + ", but it is " + servlet.getServletName(),
+ SERVLET_NAME, servlet.getServletName());
+ assertEquals("Servlet class name is expected to be " + SERVLET_CLASS_NAME + ", but it is " + servlet.getServletClass(),
+ SERVLET_CLASS_NAME, servlet.getServletClass());
+
+ List params = servlet.getInitParams();
+ assertNotNull("List of initialization parameters cannot be retrieved", params);
+ assertEquals("None initialization parameter is expected, but " + params.size() + " are found",
+ 0, params.size());
+
+ List mappings = webApp.getServletMappings();
+ assertEquals("Exactly one servlet mapping is expected, but " + mappings.size() + " are found",
+ 1, mappings.size());
+ org.eclipse.jst.javaee.web.ServletMapping mapping = (org.eclipse.jst.javaee.web.ServletMapping) mappings.get(0);
+ assertEquals("Servlet name of the mapping is expected to be " + SERVLET_NAME + ", but it is " + mapping.getServletName(),
+ SERVLET_NAME, mapping.getServletName());
+ List urlPatterns = mapping.getUrlPatterns();
+ assertEquals("Exactly one URL pattern is expected in the mapping, but " + urlPatterns.size() + " are found",
+ 1, urlPatterns.size());
+ UrlPatternType urlPattern = (UrlPatternType) urlPatterns.get(0);
+ assertEquals("Servlet mapping URL pattern value is expected to be " + SERVLET_DEFAULT_MAPPING + ", but it is " + urlPattern.getValue(),
+ SERVLET_DEFAULT_MAPPING, urlPattern.getValue());
+
+
+ assertTrue(servlet.isAsyncSupported());
+ }
+
+ public void testAddServlet_Web31_Async() throws Exception {
+ createWebProject(WEB_PROJECT_NAME, JavaEEFacetConstants.WEB_31);
+ IProject proj = ProjectUtilities.getProject(WEB_PROJECT_NAME);
+
+ mergedModelProvider = ModelProviderManager.getModelProvider(proj);
+ org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) mergedModelProvider.getModelObject();
+
+ addServlet_Async();
+
+ assertJavaFileExists(SERVLET_CLASS_NAME);
+
+ List servlets = webApp.getServlets();
+ assertEquals("Exactly one servlet is expected in the model, but " + servlets.size() + " are found",
+ 1, servlets.size());
+ org.eclipse.jst.javaee.web.Servlet servlet = (org.eclipse.jst.javaee.web.Servlet) servlets.get(0);
+ assertEquals("Servlet name is expected to be " + SERVLET_NAME + ", but it is " + servlet.getServletName(),
+ SERVLET_NAME, servlet.getServletName());
+ assertEquals("Servlet class name is expected to be " + SERVLET_CLASS_NAME + ", but it is " + servlet.getServletClass(),
+ SERVLET_CLASS_NAME, servlet.getServletClass());
+
+ List params = servlet.getInitParams();
+ assertNotNull("List of initialization parameters cannot be retrieved", params);
+ assertEquals("None initialization parameter is expected, but " + params.size() + " are found",
+ 0, params.size());
+
+ List mappings = webApp.getServletMappings();
+ assertEquals("Exactly one servlet mapping is expected, but " + mappings.size() + " are found",
+ 1, mappings.size());
+ org.eclipse.jst.javaee.web.ServletMapping mapping = (org.eclipse.jst.javaee.web.ServletMapping) mappings.get(0);
+ assertEquals("Servlet name of the mapping is expected to be " + SERVLET_NAME + ", but it is " + mapping.getServletName(),
+ SERVLET_NAME, mapping.getServletName());
+ List urlPatterns = mapping.getUrlPatterns();
+ assertEquals("Exactly one URL pattern is expected in the mapping, but " + urlPatterns.size() + " are found",
+ 1, urlPatterns.size());
+ UrlPatternType urlPattern = (UrlPatternType) urlPatterns.get(0);
+ assertEquals("Servlet mapping URL pattern value is expected to be " + SERVLET_DEFAULT_MAPPING + ", but it is " + urlPattern.getValue(),
+ SERVLET_DEFAULT_MAPPING, urlPattern.getValue());
+
+
+ assertTrue(servlet.isAsyncSupported());
+ }
+
+
public void testAddFilter_Web24_Defaults_NoJETEmitter() throws Exception {
disableJETEmitter();
testAddFilter_Web24_Defaults();
@@ -297,6 +429,136 @@ public class AddWebArtifactOperationTest extends OperationTestCase implements
0, mapping.getDispatchers().size());
}
+ public void testAddFilter_Web30_Defaults() throws Exception {
+ createWebProject(WEB_PROJECT_NAME, JavaEEFacetConstants.WEB_30);
+ IProject proj = ProjectUtilities.getProject(WEB_PROJECT_NAME);
+
+ mergedModelProvider = ModelProviderManager.getModelProvider(proj);
+ org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) mergedModelProvider.getModelObject();
+
+ addFilter_Defaults_Annotations();
+
+ assertJavaFileExists(FILTER_CLASS_NAME);
+
+ List filters = webApp.getFilters();
+ assertEquals("Exactly one filter is expected in the model, but " + filters.size() + " are found",
+ 1, filters.size());
+ org.eclipse.jst.javaee.web.Filter filter = (org.eclipse.jst.javaee.web.Filter) filters.get(0);
+ assertEquals("Filter name is expected to be " + FILTER_NAME + ", but it is " + filter.getFilterName(),
+ FILTER_NAME, filter.getFilterName());
+ assertEquals("Filter class name is expected to be " + FILTER_CLASS_NAME + ", but it is " + filter.getFilterClass(),
+ FILTER_CLASS_NAME, filter.getFilterClass());
+
+ List params = filter.getInitParams();
+ assertNotNull("List of initialization parameters cannot be retrieved", params);
+ assertEquals("None initialization parameter is expected, but " + params.size() + " are found",
+ 0, params.size());
+
+ List mappings = webApp.getFilterMappings();
+ assertEquals("Exactly one filter mapping is expected, but " + mappings.size() + " are found",
+ 1, mappings.size());
+ org.eclipse.jst.javaee.web.FilterMapping mapping = (org.eclipse.jst.javaee.web.FilterMapping) mappings.get(0);
+ assertEquals("Filter name of the mapping is expected to be " + FILTER_NAME + ", but it is " + mapping.getFilterName(),
+ FILTER_NAME, mapping.getFilterName());
+ List urlPatterns = mapping.getUrlPatterns();
+ assertEquals("Exactly one URL pattern is expected in the mapping, but " + urlPatterns.size() + " are found",
+ 1, urlPatterns.size());
+ UrlPatternType urlPattern = (UrlPatternType) urlPatterns.get(0);
+ assertEquals("Filter mapping URL pattern value is expected to be " + FILTER_DEFAULT_MAPPING + ", but it is " + urlPattern.getValue(),
+ FILTER_DEFAULT_MAPPING, urlPattern.getValue());
+ assertEquals("None servlet name is expected in the filter mapping, but " + mapping.getServletNames().size() + " are found",
+ 0, mapping.getServletNames().size());
+ assertEquals("None dispatcher is expected in the filter mapping, but " + mapping.getDispatchers().size() + " are found",
+ 0, mapping.getDispatchers().size());
+ }
+
+ public void testAddFilter_Web30_Async() throws Exception {
+ createWebProject(WEB_PROJECT_NAME, JavaEEFacetConstants.WEB_30);
+ IProject proj = ProjectUtilities.getProject(WEB_PROJECT_NAME);
+
+ mergedModelProvider = ModelProviderManager.getModelProvider(proj);
+ org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) mergedModelProvider.getModelObject();
+
+ addFilter_Async();
+
+ assertJavaFileExists(FILTER_CLASS_NAME);
+
+ List filters = webApp.getFilters();
+ assertEquals("Exactly one filter is expected in the model, but " + filters.size() + " are found",
+ 1, filters.size());
+ org.eclipse.jst.javaee.web.Filter filter = (org.eclipse.jst.javaee.web.Filter) filters.get(0);
+ assertEquals("Filter name is expected to be " + FILTER_NAME + ", but it is " + filter.getFilterName(),
+ FILTER_NAME, filter.getFilterName());
+ assertEquals("Filter class name is expected to be " + FILTER_CLASS_NAME + ", but it is " + filter.getFilterClass(),
+ FILTER_CLASS_NAME, filter.getFilterClass());
+
+ List params = filter.getInitParams();
+ assertNotNull("List of initialization parameters cannot be retrieved", params);
+ assertEquals("None initialization parameter is expected, but " + params.size() + " are found",
+ 0, params.size());
+
+ List mappings = webApp.getFilterMappings();
+ assertEquals("Exactly one filter mapping is expected, but " + mappings.size() + " are found",
+ 1, mappings.size());
+ org.eclipse.jst.javaee.web.FilterMapping mapping = (org.eclipse.jst.javaee.web.FilterMapping) mappings.get(0);
+ assertEquals("Filter name of the mapping is expected to be " + FILTER_NAME + ", but it is " + mapping.getFilterName(),
+ FILTER_NAME, mapping.getFilterName());
+ List urlPatterns = mapping.getUrlPatterns();
+ assertEquals("Exactly one URL pattern is expected in the mapping, but " + urlPatterns.size() + " are found",
+ 1, urlPatterns.size());
+ UrlPatternType urlPattern = (UrlPatternType) urlPatterns.get(0);
+ assertEquals("Filter mapping URL pattern value is expected to be " + FILTER_DEFAULT_MAPPING + ", but it is " + urlPattern.getValue(),
+ FILTER_DEFAULT_MAPPING, urlPattern.getValue());
+ assertEquals("None servlet name is expected in the filter mapping, but " + mapping.getServletNames().size() + " are found",
+ 0, mapping.getServletNames().size());
+ assertEquals("None dispatcher is expected in the filter mapping, but " + mapping.getDispatchers().size() + " are found",
+ 0, mapping.getDispatchers().size());
+ }
+
+
+ public void testAddFilter_Web31_Async() throws Exception {
+ createWebProject(WEB_PROJECT_NAME, JavaEEFacetConstants.WEB_31);
+ IProject proj = ProjectUtilities.getProject(WEB_PROJECT_NAME);
+
+ mergedModelProvider = ModelProviderManager.getModelProvider(proj);
+ org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) mergedModelProvider.getModelObject();
+
+ addFilter_Async();
+
+ assertJavaFileExists(FILTER_CLASS_NAME);
+
+ List filters = webApp.getFilters();
+ assertEquals("Exactly one filter is expected in the model, but " + filters.size() + " are found",
+ 1, filters.size());
+ org.eclipse.jst.javaee.web.Filter filter = (org.eclipse.jst.javaee.web.Filter) filters.get(0);
+ assertEquals("Filter name is expected to be " + FILTER_NAME + ", but it is " + filter.getFilterName(),
+ FILTER_NAME, filter.getFilterName());
+ assertEquals("Filter class name is expected to be " + FILTER_CLASS_NAME + ", but it is " + filter.getFilterClass(),
+ FILTER_CLASS_NAME, filter.getFilterClass());
+
+ List params = filter.getInitParams();
+ assertNotNull("List of initialization parameters cannot be retrieved", params);
+ assertEquals("None initialization parameter is expected, but " + params.size() + " are found",
+ 0, params.size());
+
+ List mappings = webApp.getFilterMappings();
+ assertEquals("Exactly one filter mapping is expected, but " + mappings.size() + " are found",
+ 1, mappings.size());
+ org.eclipse.jst.javaee.web.FilterMapping mapping = (org.eclipse.jst.javaee.web.FilterMapping) mappings.get(0);
+ assertEquals("Filter name of the mapping is expected to be " + FILTER_NAME + ", but it is " + mapping.getFilterName(),
+ FILTER_NAME, mapping.getFilterName());
+ List urlPatterns = mapping.getUrlPatterns();
+ assertEquals("Exactly one URL pattern is expected in the mapping, but " + urlPatterns.size() + " are found",
+ 1, urlPatterns.size());
+ UrlPatternType urlPattern = (UrlPatternType) urlPatterns.get(0);
+ assertEquals("Filter mapping URL pattern value is expected to be " + FILTER_DEFAULT_MAPPING + ", but it is " + urlPattern.getValue(),
+ FILTER_DEFAULT_MAPPING, urlPattern.getValue());
+ assertEquals("None servlet name is expected in the filter mapping, but " + mapping.getServletNames().size() + " are found",
+ 0, mapping.getServletNames().size());
+ assertEquals("None dispatcher is expected in the filter mapping, but " + mapping.getDispatchers().size() + " are found",
+ 0, mapping.getDispatchers().size());
+ }
+
public void testAddListener_Web24_Defaults_NoJETEmitter() throws Exception {
disableJETEmitter();
testAddListener_Web24_Defaults();
@@ -352,6 +614,89 @@ public class AddWebArtifactOperationTest extends OperationTestCase implements
LISTENER_CLASS_NAME, listener.getListenerClass());
}
+
+ public void testAddListener_Web30_Defaults() throws Exception {
+ createWebProject(WEB_PROJECT_NAME, JavaEEFacetConstants.WEB_30);
+ IProject proj = ProjectUtilities.getProject(WEB_PROJECT_NAME);
+
+ mergedModelProvider = ModelProviderManager.getModelProvider(proj);
+ org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) mergedModelProvider.getModelObject();
+
+ addListener_Defaults_Annotations();
+
+ assertJavaFileExists(LISTENER_CLASS_NAME);
+
+ List listeners = webApp.getListeners();
+ assertEquals("Exactly one listener is expected in the model, but " + listeners.size() + " are found",
+ 1, listeners.size());
+ org.eclipse.jst.javaee.core.Listener listener = (org.eclipse.jst.javaee.core.Listener) listeners.get(0);
+ assertEquals("Listener " + LISTENER_CLASS_NAME + " is expected in the model, but " + listener.getListenerClass() + " is found",
+ LISTENER_CLASS_NAME, listener.getListenerClass());
+ }
+
+
+
+ public void testAddListener_Web31_AsyncListener() throws Exception {
+ createWebProject(WEB_PROJECT_NAME, JavaEEFacetConstants.WEB_31);
+ IProject proj = ProjectUtilities.getProject(WEB_PROJECT_NAME);
+
+ mergedModelProvider = ModelProviderManager.getModelProvider(proj);
+ org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) mergedModelProvider.getModelObject();
+
+ addListener_AsyncListener();
+ assertJavaFileExists(LISTENER_CLASS_NAME);
+
+ List listeners = webApp.getListeners();
+ assertEquals("Exactly one listener is expected in the model, but " + listeners.size() + " are found",
+ 1, listeners.size());
+ org.eclipse.jst.javaee.core.Listener listener = (org.eclipse.jst.javaee.core.Listener) listeners.get(0);
+ assertEquals("Listener " + LISTENER_CLASS_NAME + " is expected in the model, but " + listener.getListenerClass() + " is found",
+ LISTENER_CLASS_NAME, listener.getListenerClass());
+
+
+ }
+
+
+ public void testAddListener_Web31_HttpSessionIdListener() throws Exception {
+ createWebProject(WEB_PROJECT_NAME, JavaEEFacetConstants.WEB_31);
+ IProject proj = ProjectUtilities.getProject(WEB_PROJECT_NAME);
+
+ mergedModelProvider = ModelProviderManager.getModelProvider(proj);
+ org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) mergedModelProvider.getModelObject();
+
+ addListener_HttpSessionIdListener();
+ assertJavaFileExists(LISTENER_CLASS_NAME);
+
+ List listeners = webApp.getListeners();
+ assertEquals("Exactly one listener is expected in the model, but " + listeners.size() + " are found",
+ 1, listeners.size());
+ org.eclipse.jst.javaee.core.Listener listener = (org.eclipse.jst.javaee.core.Listener) listeners.get(0);
+ assertEquals("Listener " + LISTENER_CLASS_NAME + " is expected in the model, but " + listener.getListenerClass() + " is found",
+ LISTENER_CLASS_NAME, listener.getListenerClass());
+
+
+ }
+
+ public void testAddListener_Web31_MultiListeners() throws Exception {
+ createWebProject(WEB_PROJECT_NAME, JavaEEFacetConstants.WEB_31);
+ IProject proj = ProjectUtilities.getProject(WEB_PROJECT_NAME);
+
+ mergedModelProvider = ModelProviderManager.getModelProvider(proj);
+ org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) mergedModelProvider.getModelObject();
+
+ addListener_MultiInterfaces();
+ assertJavaFileExists(LISTENER_CLASS_NAME);
+
+ List listeners = webApp.getListeners();
+ assertEquals("Exactly one listener is expected in the model, but " + listeners.size() + " are found",
+ 1, listeners.size());
+ org.eclipse.jst.javaee.core.Listener listener = (org.eclipse.jst.javaee.core.Listener) listeners.get(0);
+ assertEquals("Listener " + LISTENER_CLASS_NAME + " is expected in the model, but " + listener.getListenerClass() + " is found",
+ LISTENER_CLASS_NAME, listener.getListenerClass());
+
+
+ }
+
@Override
protected void tearDown() throws Exception {
// uncomment the below line if you want to dump a check whether the
@@ -376,7 +721,7 @@ public class AddWebArtifactOperationTest extends OperationTestCase implements
public void createWebProject(String projectName, IProjectFacetVersion version) throws Exception {
IDataModel dm = WebProjectCreationOperationTest.getWebDataModel(
projectName, null, null, null, null, version, false);
- runAndVerify(dm);
+ runAndVerify(dm);
}
private void addServlet_Defaults() throws Exception {
@@ -387,6 +732,32 @@ public class AddWebArtifactOperationTest extends OperationTestCase implements
runAndVerify(dm);
}
+ private void addServlet_Defaults_Annotations() throws Exception {
+ IDataModel dm = DataModelFactory.createDataModel(NewServletClassDataModelProvider.class);
+ dm.setProperty(PROJECT_NAME, WEB_PROJECT_NAME);
+ dm.setProperty(JAVA_PACKAGE, PACKAGE);
+ dm.setProperty(CLASS_NAME, SERVLET_NAME);
+ executeAndWait(dm.getDefaultOperation());
+ }
+
+
+ private void addServlet_Async() throws Exception {
+ IDataModel dm = DataModelFactory.createDataModel(NewServletClassDataModelProvider.class);
+ dm.setProperty(PROJECT_NAME, WEB_PROJECT_NAME);
+ dm.setProperty(JAVA_PACKAGE, PACKAGE);
+ dm.setProperty(CLASS_NAME, SERVLET_NAME);
+ dm.setBooleanProperty(INewServletClassDataModelProperties.ASYNC_SUPPORT, true);
+ executeAndWait(dm.getDefaultOperation());
+ }
+
+ private void executeAndWait(IDataModelOperation dataModelOperation) throws InterruptedException, ExecutionException {
+ SynchronousModelChangedListener listener = new SynchronousModelChangedListener(1);
+ mergedModelProvider.addListener(listener);
+ dataModelOperation.execute(null, null);
+ listener.waitForEvents();
+ mergedModelProvider.removeListener(listener);
+ }
+
private void addFilter_Defaults() throws Exception {
IDataModel dm = DataModelFactory.createDataModel(NewFilterClassDataModelProvider.class);
dm.setProperty(PROJECT_NAME, WEB_PROJECT_NAME);
@@ -395,6 +766,23 @@ public class AddWebArtifactOperationTest extends OperationTestCase implements
runAndVerify(dm);
}
+ private void addFilter_Defaults_Annotations() throws Exception {
+ IDataModel dm = DataModelFactory.createDataModel(NewFilterClassDataModelProvider.class);
+ dm.setProperty(PROJECT_NAME, WEB_PROJECT_NAME);
+ dm.setProperty(JAVA_PACKAGE, PACKAGE);
+ dm.setProperty(CLASS_NAME, FILTER_NAME);
+ executeAndWait(dm.getDefaultOperation());
+ }
+
+ private void addFilter_Async() throws Exception {
+ IDataModel dm = DataModelFactory.createDataModel(NewFilterClassDataModelProvider.class);
+ dm.setProperty(PROJECT_NAME, WEB_PROJECT_NAME);
+ dm.setProperty(JAVA_PACKAGE, PACKAGE);
+ dm.setProperty(CLASS_NAME, FILTER_NAME);
+ dm.setBooleanProperty(INewFilterClassDataModelProperties.ASYNC_SUPPORT, true);
+ executeAndWait(dm.getDefaultOperation());
+ }
+
private void addListener_Defaults() throws Exception {
IDataModel dm = DataModelFactory.createDataModel(NewListenerClassDataModelProvider.class);
dm.setProperty(PROJECT_NAME, WEB_PROJECT_NAME);
@@ -406,6 +794,54 @@ public class AddWebArtifactOperationTest extends OperationTestCase implements
runAndVerify(dm);
}
+
+ private void addListener_Defaults_Annotations() throws Exception {
+ IDataModel dm = DataModelFactory.createDataModel(NewListenerClassDataModelProvider.class);
+ dm.setProperty(PROJECT_NAME, WEB_PROJECT_NAME);
+ dm.setProperty(JAVA_PACKAGE, PACKAGE);
+ dm.setProperty(CLASS_NAME, LISTENER_NAME);
+ List interfaces = new ArrayList();
+ interfaces.add(NewListenerClassDataModelProvider.LISTENER_INTERFACES[0]);
+ dm.setProperty(INTERFACES, interfaces);
+ executeAndWait(dm.getDefaultOperation());
+ }
+
+
+ private void addListener_AsyncListener() throws Exception {
+ IDataModel dm = DataModelFactory.createDataModel(NewListenerClassDataModelProvider.class);
+ dm.setProperty(PROJECT_NAME, WEB_PROJECT_NAME);
+ dm.setProperty(JAVA_PACKAGE, PACKAGE);
+ dm.setProperty(CLASS_NAME, LISTENER_NAME);
+ List interfaces = new ArrayList();
+ interfaces.add(NewListenerClassDataModelProvider.LISTENER_INTERFACES[9]);
+ dm.setProperty(INTERFACES, interfaces);
+ executeAndWait(dm.getDefaultOperation());
+ }
+
+ private void addListener_HttpSessionIdListener() throws Exception {
+ IDataModel dm = DataModelFactory.createDataModel(NewListenerClassDataModelProvider.class);
+ dm.setProperty(PROJECT_NAME, WEB_PROJECT_NAME);
+ dm.setProperty(JAVA_PACKAGE, PACKAGE);
+ dm.setProperty(CLASS_NAME, LISTENER_NAME);
+ List interfaces = new ArrayList();
+ interfaces.add(NewListenerClassDataModelProvider.LISTENER_INTERFACES[6]);
+ dm.setProperty(INTERFACES, interfaces);
+ executeAndWait(dm.getDefaultOperation());
+ }
+
+ private void addListener_MultiInterfaces() throws Exception{
+ //add sessionid and async listeners
+ IDataModel dm = DataModelFactory.createDataModel(NewListenerClassDataModelProvider.class);
+ dm.setProperty(PROJECT_NAME, WEB_PROJECT_NAME);
+ dm.setProperty(JAVA_PACKAGE, PACKAGE);
+ dm.setProperty(CLASS_NAME, LISTENER_NAME);
+ List interfaces = new ArrayList();
+ interfaces.add(NewListenerClassDataModelProvider.LISTENER_INTERFACES[9]);
+ interfaces.add(NewListenerClassDataModelProvider.LISTENER_INTERFACES[6]);
+ dm.setProperty(INTERFACES, interfaces);
+ executeAndWait(dm.getDefaultOperation());
+ }
+
private void assertJavaFileExists(String fullyQualifiedName) throws JavaModelException {
IJavaProject javaProject = JavaCore.create(
ResourcesPlugin.getWorkspace().getRoot())
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/WebProjectCreationOperationTest.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/WebProjectCreationOperationTest.java
index 9b88cee..3517bfe 100644
--- a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/WebProjectCreationOperationTest.java
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/WebProjectCreationOperationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -75,7 +75,7 @@ public class WebProjectCreationOperationTest extends ModuleProjectCreationOperat
OperationTestCase.runAndVerify(dm);
}
-
+
public void testWeb22_ChangedContentDir() throws Exception {
IDataModel dm = getWebDataModel("goodWeb", null, null, "myAwesomeContentDir", null, JavaEEFacetConstants.WEB_22, true);
OperationTestCase.runAndVerify(dm);
@@ -559,7 +559,11 @@ public class WebProjectCreationOperationTest extends ModuleProjectCreationOperat
facetModel.setBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD, createDD);
- if(version.equals(JavaEEFacetConstants.WEB_30)) {
+ if (version.equals(JavaEEFacetConstants.WEB_31)){
+ IDataModel javaFacetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+ javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, JavaEEFacetConstants.JAVA_7);
+ }
+ else if(version.equals(JavaEEFacetConstants.WEB_30)) {
IDataModel javaFacetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, JavaEEFacetConstants.JAVA_6);
}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/web/verifiers/WebProjectCreationDataModelVerifier.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/web/verifiers/WebProjectCreationDataModelVerifier.java
index 154f1cc..310bfcb 100644
--- a/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/web/verifiers/WebProjectCreationDataModelVerifier.java
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-verifiers/org/eclipse/wtp/j2ee/headless/tests/web/verifiers/WebProjectCreationDataModelVerifier.java
@@ -65,7 +65,7 @@ public class WebProjectCreationDataModelVerifier extends ModuleProjectCreationDa
@Override
protected void verifyDD(Object modelObj) {
String version = J2EEProjectUtilities.getJ2EEProjectVersion(project);
- if(version.equals(J2EEVersionConstants.VERSION_2_5_TEXT) || version.equals(J2EEVersionConstants.VERSION_3_0_TEXT)){
+ if(version.equals(J2EEVersionConstants.VERSION_2_5_TEXT) || version.equals(J2EEVersionConstants.VERSION_3_0_TEXT) || version.equals(J2EEVersionConstants.VERSION_3_1_TEXT)){
WebApp web = (WebApp)modelObj;
Assert.assertEquals("Invalid project version", version, web.getVersion().getLiteral());
} else {