Repository: struts Updated Branches: refs/heads/master f819486c3 -> cd4eb6f26
WW-4522 Support latest stable AngularJS version in maven angularjs archetype - Merge Application into Index Action - Use StrutsRestTestCase - Use Junit4 - Add default action to package config - Use latest eclipse jetty plugin Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/cd4eb6f2 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/cd4eb6f2 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/cd4eb6f2 Branch: refs/heads/master Commit: cd4eb6f26d4736ab6110c816eb4d95a257798bf0 Parents: f819486 Author: Johannes Geppert <jo...@apache.org> Authored: Sun Sep 27 14:06:55 2015 +0200 Committer: Johannes Geppert <jo...@apache.org> Committed: Sun Sep 27 14:06:55 2015 +0200 ---------------------------------------------------------------------- .../main/resources/archetype-resources/pom.xml | 14 ++----- .../main/java/actions/ApplicationAction.java | 44 -------------------- .../src/main/java/actions/Index.java | 26 +++++------- .../main/java/actions/data/ProjectsAction.java | 2 - .../main/java/actions/data/package-info.java | 24 +++++++++++ .../src/main/resources/struts.xml | 4 +- .../main/webapp/WEB-INF/content/application.jsp | 38 ----------------- .../src/main/webapp/WEB-INF/content/index.jsp | 38 +++++++++++++++++ .../java/actions/ApplicationActionTest.java | 32 -------------- .../src/test/java/actions/IndexTest.java | 13 +++--- 10 files changed, 88 insertions(+), 147 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/cd4eb6f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/pom.xml ---------------------------------------------------------------------- diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/pom.xml b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/pom.xml index 7fc4ff7..70c58c4 100644 --- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/pom.xml @@ -86,8 +86,8 @@ <version>3.3</version> <configuration> <encoding>UTF-8</encoding> - <source>1.5</source> - <target>1.5</target> + <source>1.7</source> + <target>1.7</target> </configuration> </plugin> <plugin> @@ -159,18 +159,12 @@ </executions> </plugin> <plugin> - <groupId>org.mortbay.jetty</groupId> + <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> - <version>8.1.16.v20140903</version> + <version>9.3.3.v20150827</version> <configuration> <stopKey>CTRL+C</stopKey> <stopPort>8999</stopPort> - <systemProperties> - <systemProperty> - <name>xwork.loggerFactory</name> - <value>com.opensymphony.xwork2.util.logging.log4j2.Log4j2LoggerFactory</value> - </systemProperty> - </systemProperties> <scanIntervalSeconds>10</scanIntervalSeconds> <webAppSourceDirectory>\${basedir}/src/main/webapp/</webAppSourceDirectory> <webAppConfig> http://git-wip-us.apache.org/repos/asf/struts/blob/cd4eb6f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/ApplicationAction.java ---------------------------------------------------------------------- diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/ApplicationAction.java b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/ApplicationAction.java deleted file mode 100644 index b6440cc..0000000 --- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/ApplicationAction.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package ${package}.actions; - -import com.opensymphony.xwork2.ActionSupport; - -/** - * <code>Set welcome message.</code> - */ -public class ApplicationAction extends ActionSupport { - - private static final long serialVersionUID = -3243216917801206214L; - - private boolean useMinifiedResources = false; - - public String execute() throws Exception { - return SUCCESS; - } - - public boolean isUseMinifiedResources() { - return useMinifiedResources; - } - - public void setUseMinifiedResources(boolean useMinifiedResources) { - this.useMinifiedResources = useMinifiedResources; - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/cd4eb6f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/Index.java ---------------------------------------------------------------------- diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/Index.java b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/Index.java index 5643b4a..4d8600a 100644 --- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/Index.java +++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/Index.java @@ -1,6 +1,4 @@ /* - * $Id$ - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -20,27 +18,25 @@ */ package ${package}.actions; -import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionSupport; -import org.apache.struts2.convention.annotation.Result; -import org.apache.struts2.convention.annotation.Results; -@Results({ - @Result(name = Action.SUCCESS, location = "${redirectName}", type = "redirectAction") -}) +/* Default action when enter the application */ public class Index extends ActionSupport { - private static final long serialVersionUID = 6153177836211979662L; + private static final long serialVersionUID = -3243216917801206214L; - private String redirectName; + private boolean useMinifiedResources = false; - public String execute() { - redirectName = "application"; - return Action.SUCCESS; + public String execute() throws Exception { + return SUCCESS; } - public String getRedirectName() { - return redirectName; + public boolean isUseMinifiedResources() { + return useMinifiedResources; } + public void setUseMinifiedResources(boolean useMinifiedResources) { + this.useMinifiedResources = useMinifiedResources; + } } + http://git-wip-us.apache.org/repos/asf/struts/blob/cd4eb6f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/ProjectsAction.java ---------------------------------------------------------------------- diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/ProjectsAction.java b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/ProjectsAction.java index ddbe7da..996d089 100644 --- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/ProjectsAction.java +++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/ProjectsAction.java @@ -1,6 +1,4 @@ /* - * $Id$ - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information http://git-wip-us.apache.org/repos/asf/struts/blob/cd4eb6f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/package-info.java ---------------------------------------------------------------------- diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/package-info.java b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/package-info.java new file mode 100644 index 0000000..3e4af32 --- /dev/null +++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/package-info.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +@ParentPackage("data") +@Namespace("/data") +package ${package}.actions.data; + +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.ParentPackage; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/cd4eb6f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/struts.xml ---------------------------------------------------------------------- diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/struts.xml b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/struts.xml index e725380..0c73523 100644 --- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/struts.xml +++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/struts.xml @@ -8,7 +8,9 @@ <constant name="struts.devMode" value="true"/> <constant name="struts.convention.default.parent.package" value="angularstruts"/> - <package name="angularstruts" extends="json-default"></package> + <package name="angularstruts" extends="json-default"> + <default-action-ref name="index" /> + </package> <package name="data" extends="angularstruts" namespace="/data"></package> </struts> http://git-wip-us.apache.org/repos/asf/struts/blob/cd4eb6f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/application.jsp ---------------------------------------------------------------------- diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/application.jsp b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/application.jsp deleted file mode 100644 index 3f6c374..0000000 --- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/application.jsp +++ /dev/null @@ -1,38 +0,0 @@ -<!DOCTYPE html> -<%@ page contentType="text/html; charset=UTF-8" %> -<%@ taglib prefix="s" uri="/struts-tags" %> -<html lang="en" ng-app="app"> -<head> - <meta charset="utf-8"> - <title>My AngularJS Struts2 App</title> - - <base href="<s:url forceAddSchemeHostAndPort="true" includeContext="true" value="/" namespace="/" />"> -</head> -<body> - -<h2><s:property value="message"/></h2> - -<div> - <a href="/home">Home</a> - <a href="/projects">Projects</a> -</div> - -<div ng-controller="AppController as app"> - <div ng-view></div> -</div> - -<s:if test="useMinifiedResources"> - <script src="<s:url value="js/external.js" />"></script> - <script src="<s:url value="js/application.js" />"></script> -</s:if> -<s:else> - <script src="<s:url value="js/lib/angular/angular.min.js" />"></script> - <script src="<s:url value="js/lib/angular/angular-route.min.js" />"></script> - <script src="<s:url value="js/app.js" />"></script> - <script src="<s:url value="js/config.js" />"></script> - <script src="<s:url value="js/services/DataService.js" />"></script> - <script src="<s:url value="js/controllers/AppController.js" />"></script> - <script src="<s:url value="js/controllers/HomeController.js" />"></script> - <script src="<s:url value="js/controllers/ApacheProjectsController.js" />"></script> -</s:else> -</body> -</html> http://git-wip-us.apache.org/repos/asf/struts/blob/cd4eb6f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/index.jsp ---------------------------------------------------------------------- diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/index.jsp b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/index.jsp new file mode 100644 index 0000000..3f6c374 --- /dev/null +++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/index.jsp @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<%@ page contentType="text/html; charset=UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<html lang="en" ng-app="app"> +<head> + <meta charset="utf-8"> + <title>My AngularJS Struts2 App</title> + + <base href="<s:url forceAddSchemeHostAndPort="true" includeContext="true" value="/" namespace="/" />"> +</head> +<body> + +<h2><s:property value="message"/></h2> + +<div> + <a href="/home">Home</a> - <a href="/projects">Projects</a> +</div> + +<div ng-controller="AppController as app"> + <div ng-view></div> +</div> + +<s:if test="useMinifiedResources"> + <script src="<s:url value="js/external.js" />"></script> + <script src="<s:url value="js/application.js" />"></script> +</s:if> +<s:else> + <script src="<s:url value="js/lib/angular/angular.min.js" />"></script> + <script src="<s:url value="js/lib/angular/angular-route.min.js" />"></script> + <script src="<s:url value="js/app.js" />"></script> + <script src="<s:url value="js/config.js" />"></script> + <script src="<s:url value="js/services/DataService.js" />"></script> + <script src="<s:url value="js/controllers/AppController.js" />"></script> + <script src="<s:url value="js/controllers/HomeController.js" />"></script> + <script src="<s:url value="js/controllers/ApacheProjectsController.js" />"></script> +</s:else> +</body> +</html> http://git-wip-us.apache.org/repos/asf/struts/blob/cd4eb6f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/test/java/actions/ApplicationActionTest.java ---------------------------------------------------------------------- diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/test/java/actions/ApplicationActionTest.java b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/test/java/actions/ApplicationActionTest.java deleted file mode 100644 index 2bef998..0000000 --- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/test/java/actions/ApplicationActionTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package ${package}.actions; - -import com.opensymphony.xwork2.ActionSupport; -import org.apache.struts2.StrutsTestCase; - -public class ApplicationActionTest extends StrutsTestCase { - - public void testApplicationAction() throws Exception { - ApplicationAction hello = new ApplicationAction(); - String result = hello.execute(); - assertTrue("Expected a success result!", ActionSupport.SUCCESS.equals(result)); - assertFalse(hello.isUseMinifiedResources()); - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/cd4eb6f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/test/java/actions/IndexTest.java ---------------------------------------------------------------------- diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/test/java/actions/IndexTest.java b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/test/java/actions/IndexTest.java index 1c3fc20..dde937a 100644 --- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/test/java/actions/IndexTest.java +++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/test/java/actions/IndexTest.java @@ -1,6 +1,4 @@ /* - * $Id$ - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -21,14 +19,19 @@ package ${package}.actions; import com.opensymphony.xwork2.ActionSupport; -import org.apache.struts2.StrutsTestCase; +import org.apache.struts2.StrutsRestTestCase; +import org.junit.Test; + +import static org.junit.Assert.*; -public class IndexTest extends StrutsTestCase { +public class IndexTest extends StrutsRestTestCase<Index> { + @Test public void testIndex() throws Exception { Index index = new Index(); String result = index.execute(); assertTrue("Expected a success result!", ActionSupport.SUCCESS.equals(result)); - assertTrue("Expected the 'hello' action name!!", "application".equals(index.getRedirectName())); + assertFalse(index.isUseMinifiedResources()); } } +