diff --git a/plugins/junit/pom.xml b/plugins/junit/pom.xml index e4f24bcea..987210461 100644 --- a/plugins/junit/pom.xml +++ b/plugins/junit/pom.xml @@ -66,6 +66,14 @@ junit junit + + + + org.apache.struts + struts2-convention-plugin + test + + javax.portlet diff --git a/plugins/junit/src/test/java/actions/ViewAction.java b/plugins/junit/src/test/java/actions/ViewAction.java new file mode 100644 index 000000000..4c1141b8d --- /dev/null +++ b/plugins/junit/src/test/java/actions/ViewAction.java @@ -0,0 +1,42 @@ +/* + * $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 + * 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 actions; + +import com.opensymphony.xwork2.ActionSupport; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Result; + +/** + * Example action, which is called by the convention plugin test case + */ +public class ViewAction extends ActionSupport { + private String message; + + public String getMessage() { + return message; + } + + + public String execute() { + message = "Hello World"; + return SUCCESS; + } +} diff --git a/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java b/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java new file mode 100644 index 000000000..f2c96ea21 --- /dev/null +++ b/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java @@ -0,0 +1,46 @@ +/* + * $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 + * 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 org.apache.struts2.convention; + +import actions.ViewAction; +import org.apache.struts2.StrutsJUnit4TestCase; +import org.junit.Assert; +import org.junit.Test; + +/** + * Uses the convention plugin to execute actions + */ +public class StrutsJUnit4ConventionTestCaseTest extends StrutsJUnit4TestCase{ + @Test + public void testConventionUrl() throws Exception { + // TODO: Currently output is empty + String output = executeAction("/view.action"); + + ViewAction action = this.getAction(); + Assert.assertEquals("Hello World", action.getMessage()); + } + + @Override + protected String getConfigPath() { + return "struts-convention-configuration.xml"; + } +} + diff --git a/plugins/junit/src/test/resources/struts-convention-configuration.xml b/plugins/junit/src/test/resources/struts-convention-configuration.xml new file mode 100644 index 000000000..3495c184a --- /dev/null +++ b/plugins/junit/src/test/resources/struts-convention-configuration.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/junit/src/test/resources/view-success.jsp b/plugins/junit/src/test/resources/view-success.jsp new file mode 100644 index 000000000..b2cd0da7f --- /dev/null +++ b/plugins/junit/src/test/resources/view-success.jsp @@ -0,0 +1,25 @@ +<%-- + ~ $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 + ~ 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. + --%> + + +This is the view + + \ No newline at end of file