Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WW-5220 Moves JUnit related test into the JUnit plugin #595

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.opensymphony.xwork2.util.ValueStack;
import net.sf.jasperreports.engine.JasperCompileManager;
import org.apache.struts2.StrutsStatics;
import org.apache.struts2.StrutsTestCase;
import org.apache.struts2.junit.StrutsTestCase;

import javax.servlet.ServletException;
import java.net.URL;
Expand Down Expand Up @@ -82,7 +82,7 @@ public Map<String, String>[] getDatasource() {
result.execute(this.invocation);
} catch (ServletException e) {
assertEquals("Error building dataSource for excluded or not accepted [getDatasource()]",
e.getMessage());
e.getMessage());
}

// verify that above test has really effect
Expand Down Expand Up @@ -242,14 +242,14 @@ protected void setUp() throws Exception {


private static final Map<String, String>[] JR_MAP_ARRAY_DATA_SOURCE = new Map[]{
new HashMap<String, String>() {{
put("firstName", "Foo");
put("lastName", "Bar");
}}
new HashMap<String, String>() {{
put("firstName", "Foo");
put("lastName", "Bar");
}}
};

private static final NotExcludedAcceptedPatternsChecker NO_EXCLUSION_ACCEPT_ALL_PATTERNS_CHECKER
= new NotExcludedAcceptedPatternsChecker() {
= new NotExcludedAcceptedPatternsChecker() {
@Override
public IsAllowed isAllowed(String value) {
return IsAllowed.yes("*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsTestCase;
import org.apache.struts2.junit.StrutsTestCase;
import org.easymock.EasyMock;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
Expand All @@ -36,6 +36,7 @@


/**
*
*/
public class ChartResultTest extends StrutsTestCase {

Expand All @@ -50,7 +51,7 @@ public class ChartResultTest extends StrutsTestCase {
public void testChart() throws Exception {
EasyMock.expect(responseMock.getOutputStream()).andReturn(os);
EasyMock.replay(responseMock, mockActionProxy, actionInvocation);

ChartResult result = new ChartResult();

result.setChart(mockChart);
Expand All @@ -62,7 +63,7 @@ public void testChart() throws Exception {
EasyMock.verify(responseMock);
assertTrue(os.isWritten());
}

public void testContentTypePng() throws Exception {
EasyMock.expect(responseMock.getOutputStream()).andReturn(os);
responseMock.setContentType("image/png");
Expand All @@ -79,7 +80,7 @@ public void testContentTypePng() throws Exception {
EasyMock.verify(responseMock);
assertTrue(os.isWritten());
}

public void testContentTypeJpg() throws Exception {
EasyMock.expect(responseMock.getOutputStream()).andReturn(os);
responseMock.setContentType("image/jpg");
Expand All @@ -101,7 +102,7 @@ public void testContentTypeJpg() throws Exception {
public void testChartNotSet() {
ChartResult result = new ChartResult();
EasyMock.replay(responseMock, mockActionProxy, actionInvocation);

// expect exception if chart not set.
result.setChart(null);

Expand Down Expand Up @@ -141,7 +142,7 @@ public void testChartWithOGNLProperties() throws Exception {
assertEquals("150", result.getWidth().toString());
assertTrue(os.isWritten());
}

protected void setUp() throws Exception {
super.setUp();

Expand All @@ -160,8 +161,8 @@ protected void setUp() throws Exception {
actionInvocation = EasyMock.createMock(ActionInvocation.class);

EasyMock.expect(actionInvocation.getStack()).andReturn(stack).anyTimes();


os = new MockServletOutputStream();
responseMock = EasyMock.createNiceMock(HttpServletResponse.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/
package org.apache.struts2.json;

import org.apache.struts2.StrutsTestCase;
import org.apache.struts2.json.annotations.JSONFieldBridge;
import org.apache.struts2.json.bridge.StringBridge;
import org.apache.struts2.util.TestUtils;
import org.apache.struts2.junit.StrutsTestCase;
import org.apache.struts2.junit.util.TestUtils;
import org.junit.Test;

import java.net.URL;
Expand All @@ -32,10 +32,10 @@
import java.util.Map;
import java.util.TimeZone;

public class DefaultJSONWriterTest extends StrutsTestCase{
public class DefaultJSONWriterTest extends StrutsTestCase {
@Test
public void testWrite() throws Exception {
Bean bean1=new Bean();
Bean bean1 = new Bean();
bean1.setStringField("str");
bean1.setBooleanField(true);
bean1.setCharField('s');
Expand All @@ -54,7 +54,7 @@ public void testWrite() throws Exception {

@Test
public void testWriteExcludeNull() throws Exception {
BeanWithMap bean1=new BeanWithMap();
BeanWithMap bean1 = new BeanWithMap();
bean1.setStringField("str");
bean1.setBooleanField(true);
bean1.setCharField('s');
Expand All @@ -78,7 +78,7 @@ public void testWriteExcludeNull() throws Exception {
TestUtils.assertEquals(DefaultJSONWriter.class.getResource("jsonwriter-write-bean-03.txt"), json);
}

private class BeanWithMap extends Bean{
private class BeanWithMap extends Bean {
private Map map;

public Map getMap() {
Expand All @@ -92,7 +92,7 @@ public void setMap(Map map) {

@Test
public void testWriteAnnotatedBean() throws Exception {
AnnotatedBean bean1=new AnnotatedBean();
AnnotatedBean bean1 = new AnnotatedBean();
bean1.setStringField("str");
bean1.setBooleanField(true);
bean1.setCharField('s');
Expand Down Expand Up @@ -146,7 +146,7 @@ public void setErrors(List<String> errors) {
}
}

private class AnnotatedBean extends Bean{
private class AnnotatedBean extends Bean {
private URL url;

@JSONFieldBridge(impl = StringBridge.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@
*/
package org.apache.struts2.json;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.mock.MockActionInvocation;
import com.opensymphony.xwork2.mock.MockActionProxy;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.StrutsStatics;
import org.apache.struts2.StrutsTestCase;
import org.apache.struts2.dispatcher.mapper.DefaultActionMapper;
import org.apache.struts2.junit.StrutsTestCase;
import org.apache.struts2.views.util.DefaultUrlHelper;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.mock.MockActionInvocation;
import com.opensymphony.xwork2.mock.MockActionProxy;
import com.opensymphony.xwork2.util.ValueStack;

public class JSONActionRedirectResultTest extends StrutsTestCase {

MockActionInvocation invocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@
*/
package org.apache.struts2.json;

import java.util.Calendar;
import java.util.List;
import java.util.Map;

import org.apache.struts2.StrutsTestCase;
import org.apache.struts2.util.TestUtils;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.mock.MockActionInvocation;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.junit.StrutsTestCase;
import org.apache.struts2.junit.util.TestUtils;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.mock.MockActionInvocation;
import com.opensymphony.xwork2.util.ValueStack;
import java.util.Calendar;
import java.util.List;
import java.util.Map;

public class JSONInterceptorTest extends StrutsTestCase {
private MockActionInvocationEx invocation;
Expand Down Expand Up @@ -294,7 +293,7 @@ public void testSMDObjectsNoResult() throws Exception {
assertEquals("application/json;charset=UTF-8", response.getContentType());
}

@SuppressWarnings( { "unchecked", "unchecked" })
@SuppressWarnings({"unchecked", "unchecked"})
public void testReadEmpty() throws Exception {
// request
setRequestContent("json-6.txt");
Expand All @@ -309,7 +308,7 @@ public void testReadEmpty() throws Exception {
interceptor.intercept(this.invocation);
}

@SuppressWarnings( { "unchecked", "unchecked" })
@SuppressWarnings({"unchecked", "unchecked"})
public void test() throws Exception {
// request
setRequestContent("json-1.txt");
Expand Down Expand Up @@ -457,7 +456,7 @@ public void testRoot() throws Exception {
assertEquals(bean2.getDoubleField(), 10.1);
assertEquals(bean2.getByteField(), 3);
}

public void testJSONArray() throws Exception {
setRequestContent("json-12.txt");
this.request.addHeader("Content-Type", "application/json");
Expand Down Expand Up @@ -509,7 +508,7 @@ public void testJSONArray2() throws Exception {
assertEquals(beans.get(0).getDoubleField(), 10.1);
assertEquals(beans.get(0).getByteField(), 3);
}

@Override
protected void setUp() throws Exception {
super.setUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Map;

import junit.framework.TestCase;
import org.apache.struts2.util.TestUtils;
import org.apache.struts2.junit.util.TestUtils;

public class JSONPopulatorTest extends TestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
*/
package org.apache.struts2.json;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.mock.MockActionInvocation;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.StrutsStatics;
import org.apache.struts2.junit.StrutsTestCase;
import org.apache.struts2.junit.util.TestUtils;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
Expand All @@ -33,21 +46,6 @@
import java.util.Set;
import java.util.regex.Pattern;

import javax.servlet.http.HttpServletResponse;

import com.opensymphony.xwork2.Result;
import org.apache.struts2.StrutsStatics;
import org.apache.struts2.StrutsTestCase;
import org.apache.struts2.util.TestUtils;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.mock.MockActionInvocation;
import com.opensymphony.xwork2.util.ValueStack;

/**
* JSONResultTest
*/
Expand Down Expand Up @@ -298,13 +296,13 @@ public void test() throws Exception {
stack.push(action);

// test scape characters
action.setArray(new String[] { "a", "a", "\"", "\\", "/", "\b", "\f", "\n", "\r", "\t" });
action.setArray(new String[]{"a", "a", "\"", "\\", "/", "\b", "\f", "\n", "\r", "\t"});

List list = new ArrayList();

list.add("b");
list.add(1);
list.add(new int[] { 10, 12 });
list.add(new int[]{10, 12});
action.setCollection(list);

// beans
Expand Down Expand Up @@ -343,7 +341,7 @@ public void test() throws Exception {
Map map = new LinkedHashMap();

map.put("a", 1);
map.put("c", new float[] { 1.0f, 2.0f });
map.put("c", new float[]{1.0f, 2.0f});
action.setMap(map);

action.setFoo("foo");
Expand Down Expand Up @@ -403,13 +401,13 @@ public void testCommentWrap() throws Exception {
stack.push(action);

// test scape characters
action.setArray(new String[] { "a", "a", "\"", "\\", "/", "\b", "\f", "\n", "\r", "\t" });
action.setArray(new String[]{"a", "a", "\"", "\\", "/", "\b", "\f", "\n", "\r", "\t"});

List list = new ArrayList();

list.add("b");
list.add(1);
list.add(new int[] { 10, 12 });
list.add(new int[]{10, 12});
action.setCollection(list);

// beans
Expand Down Expand Up @@ -446,7 +444,7 @@ public void testCommentWrap() throws Exception {
Map map = new LinkedHashMap();

map.put("a", 1);
map.put("c", new float[] { 1.0f, 2.0f });
map.put("c", new float[]{1.0f, 2.0f});
action.setMap(map);

action.setFoo("foo");
Expand Down Expand Up @@ -714,7 +712,7 @@ public void testEncoding() throws Exception {
assertEquals("UTF-8", encoding);
}

public void testPassingNullInvocation() throws Exception{
public void testPassingNullInvocation() throws Exception {
Result result = new JSONResult();
try {
result.execute(null);
Expand Down
Loading