Skip to content

Commit ed111da

Browse files
committed
WW-5532 Upgrade and align various dependencies
1 parent 5c22c0d commit ed111da

File tree

14 files changed

+187
-349
lines changed

14 files changed

+187
-349
lines changed

apps/pom.xml

-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
<dependency>
100100
<groupId>org.springframework</groupId>
101101
<artifactId>spring-test</artifactId>
102-
<version>${spring.platformVersion}</version>
103102
<scope>test</scope>
104103
</dependency>
105104
</dependencies>

apps/showcase/src/test/java/it/org/apache/struts2/showcase/StrutsParametersTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ public void private_MyDtoField_WithGetter_MethodAnnotatedDepthOne() throws Excep
229229
}
230230

231231
private void assertText(Map<String, String> params, String text) throws IOException {
232-
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(ParameterUtils.getBaseUrl()).path("/paramsannotation/test.action");
232+
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(ParameterUtils.getBaseUrl())
233+
.path("/paramsannotation/test.action");
233234
params.forEach(builder::queryParam);
234235
String url = builder.toUriString();
235236
HtmlPage page = webClient.getPage(url);

core/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
<dependency>
230230
<groupId>junit</groupId>
231231
<artifactId>junit</artifactId>
232+
<scope>compile</scope>
232233
<optional>true</optional>
233234
</dependency>
234235

plugins/cdi/pom.xml

+11-10
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
<packaging>jar</packaging>
3434

3535
<dependencies>
36-
3736
<dependency>
3837
<groupId>jakarta.enterprise</groupId>
3938
<artifactId>jakarta.enterprise.cdi-api</artifactId>
@@ -43,29 +42,31 @@
4342
<dependency>
4443
<groupId>org.jboss.weld</groupId>
4544
<artifactId>weld-core-impl</artifactId>
46-
<scope>provided</scope>
45+
<version>${weld.version}</version>
46+
<scope>test</scope>
4747
</dependency>
48-
4948
<dependency>
5049
<groupId>org.jboss.weld.se</groupId>
5150
<artifactId>weld-se-core</artifactId>
51+
<version>${weld.version}</version>
5252
<scope>test</scope>
5353
</dependency>
54-
5554
<dependency>
56-
<groupId>org.springframework</groupId>
57-
<artifactId>spring-test</artifactId>
58-
<!-- org.springframework.mock.jndi.SimpleNamingContextBuilder removed from newer version -->
59-
<version>4.3.0.RELEASE</version>
55+
<groupId>com.github.h-thurow</groupId>
56+
<artifactId>simple-jndi</artifactId>
57+
<version>0.25.0</version>
6058
<scope>test</scope>
6159
</dependency>
62-
6360
<dependency>
6461
<groupId>commons-logging</groupId>
6562
<artifactId>commons-logging</artifactId>
6663
<scope>test</scope>
6764
</dependency>
68-
65+
<dependency>
66+
<groupId>jakarta.inject</groupId>
67+
<artifactId>jakarta.inject-api</artifactId>
68+
<scope>test</scope>
69+
</dependency>
6970
</dependencies>
7071

7172
<properties>

plugins/cdi/src/test/java/org/apache/struts2/cdi/CdiObjectFactoryTest.java

+27-10
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,43 @@
2121
import org.jboss.weld.bootstrap.api.helpers.RegistrySingletonProvider;
2222
import org.jboss.weld.environment.se.Weld;
2323
import org.jboss.weld.environment.se.WeldContainer;
24+
import org.junit.AfterClass;
2425
import org.junit.BeforeClass;
2526
import org.junit.Test;
26-
import org.springframework.mock.jndi.SimpleNamingContextBuilder;
2727

2828
import jakarta.enterprise.inject.spi.InjectionTarget;
29+
import javax.naming.Context;
30+
import javax.naming.InitialContext;
31+
import javax.naming.NamingException;
2932

3033
import static org.junit.Assert.assertNotNull;
3134
import static org.junit.Assert.assertSame;
3235
import static org.junit.Assert.assertTrue;
3336

3437
public class CdiObjectFactoryTest {
3538

39+
private static final String SHARED_JNDI = "org.osjava.sj.jndi.shared";
40+
private static InitialContext context;
41+
private static WeldContainer container;
42+
3643
@BeforeClass
3744
public static void setup() throws Exception {
38-
Weld weld = new Weld().containerId(RegistrySingletonProvider.STATIC_INSTANCE);
39-
WeldContainer container = weld.initialize();
45+
container = new Weld().containerId(RegistrySingletonProvider.STATIC_INSTANCE).initialize();
46+
47+
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.osjava.sj.SimpleContextFactory");
48+
System.setProperty(SHARED_JNDI, "true");
49+
context = new InitialContext();
50+
context.bind(CdiObjectFactory.CDI_JNDIKEY_BEANMANAGER_COMP, container.getBeanManager());
51+
}
52+
53+
@AfterClass
54+
public static void tearDown() throws NamingException {
55+
container.shutdown();
4056

41-
SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
42-
builder.activate();
43-
builder.bind(CdiObjectFactory.CDI_JNDIKEY_BEANMANAGER_COMP, container.getBeanManager());
57+
context.unbind(CdiObjectFactory.CDI_JNDIKEY_BEANMANAGER_COMP);
58+
context.close();
59+
System.clearProperty(Context.INITIAL_CONTEXT_FACTORY);
60+
System.clearProperty(SHARED_JNDI);
4461
}
4562

4663
@Test
@@ -50,16 +67,16 @@ public void testFindBeanManager() {
5067

5168
@Test
5269
public void testGetBean() throws Exception {
53-
final CdiObjectFactory cdiObjectFactory = new CdiObjectFactory();
54-
FooConsumer fooConsumer = (FooConsumer) cdiObjectFactory.buildBean(FooConsumer.class.getCanonicalName(), null, false);
70+
var cdiObjectFactory = new CdiObjectFactory();
71+
var fooConsumer = (FooConsumer) cdiObjectFactory.buildBean(FooConsumer.class.getCanonicalName(), null, false);
5572
assertNotNull(fooConsumer);
5673
assertNotNull(fooConsumer.fooService);
5774
}
5875

5976
@Test
6077
public void testGetInjectionTarget() {
61-
final CdiObjectFactory cdiObjectFactory = new CdiObjectFactory();
62-
final InjectionTarget<?> injectionTarget = cdiObjectFactory.getInjectionTarget(FooConsumer.class);
78+
var cdiObjectFactory = new CdiObjectFactory();
79+
InjectionTarget<?> injectionTarget = cdiObjectFactory.getInjectionTarget(FooConsumer.class);
6380
assertNotNull(injectionTarget);
6481
assertTrue(cdiObjectFactory.injectionTargetCache.containsKey(FooConsumer.class));
6582
assertSame(cdiObjectFactory.getInjectionTarget(FooConsumer.class), injectionTarget);

plugins/jfreechart/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
<scope>test</scope>
6363
</dependency>
6464
<dependency>
65-
<groupId>org.easymock</groupId>
66-
<artifactId>easymock</artifactId>
65+
<groupId>org.springframework</groupId>
66+
<artifactId>spring-web</artifactId>
6767
<scope>test</scope>
6868
</dependency>
6969
</dependencies>

plugins/jfreechart/src/test/java/org/apache/struts2/dispatcher/ChartResultTest.java

+34-82
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020

2121
import org.apache.struts2.ActionContext;
2222
import org.apache.struts2.ActionInvocation;
23-
import org.apache.struts2.ActionProxy;
24-
import org.apache.struts2.util.ValueStack;
2523
import org.apache.struts2.ServletActionContext;
2624
import org.apache.struts2.junit.StrutsTestCase;
27-
import org.easymock.EasyMock;
25+
import org.apache.struts2.util.ValueStack;
2826
import org.jfree.chart.ChartFactory;
2927
import org.jfree.chart.JFreeChart;
3028
import org.jfree.data.general.DefaultPieDataset;
@@ -34,96 +32,85 @@
3432
import jakarta.servlet.http.HttpServletResponse;
3533
import java.io.IOException;
3634

35+
import static org.junit.Assert.assertThrows;
36+
import static org.mockito.Mockito.mock;
37+
import static org.mockito.Mockito.verify;
38+
import static org.mockito.Mockito.when;
3739

38-
/**
39-
*
40-
*/
4140
public class ChartResultTest extends StrutsTestCase {
4241

42+
private ChartResult result;
43+
4344
private ActionInvocation actionInvocation;
4445
private JFreeChart mockChart;
4546
private MockServletOutputStream os;
46-
private ValueStack stack;
47-
private ActionProxy mockActionProxy;
4847
private HttpServletResponse responseMock;
4948

49+
@Override
50+
protected void setUp() throws Exception {
51+
super.setUp();
5052

51-
public void testChart() throws Exception {
52-
EasyMock.expect(responseMock.getOutputStream()).andReturn(os);
53-
EasyMock.replay(responseMock, mockActionProxy, actionInvocation);
53+
result = new ChartResult();
54+
55+
var data = new DefaultPieDataset<String>();
56+
data.setValue("Java", Double.valueOf(43.2));
57+
data.setValue("Visual Basic", Double.valueOf(0.0));
58+
data.setValue("C/C++", Double.valueOf(17.5));
59+
mockChart = ChartFactory.createPieChart("Pie Chart", data, true, true, false);
60+
61+
actionInvocation = mock(ActionInvocation.class);
62+
when(actionInvocation.getStack()).thenReturn(ActionContext.getContext().getValueStack());
5463

55-
ChartResult result = new ChartResult();
64+
os = new MockServletOutputStream();
65+
responseMock = mock(HttpServletResponse.class);
66+
when(responseMock.getOutputStream()).thenReturn(os);
67+
68+
ServletActionContext.setResponse(responseMock);
69+
}
5670

71+
public void testChart() throws Exception {
5772
result.setChart(mockChart);
5873

5974
result.setHeight("10");
6075
result.setWidth("10");
6176
result.execute(actionInvocation);
6277

63-
EasyMock.verify(responseMock);
6478
assertTrue(os.isWritten());
6579
}
6680

6781
public void testContentTypePng() throws Exception {
68-
EasyMock.expect(responseMock.getOutputStream()).andReturn(os);
69-
responseMock.setContentType("image/png");
70-
EasyMock.replay(responseMock, mockActionProxy, actionInvocation);
71-
ChartResult result = new ChartResult();
72-
7382
result.setChart(mockChart);
7483

7584
result.setHeight("10");
7685
result.setWidth("10");
7786
result.setType("png");
7887
result.execute(actionInvocation);
7988

80-
EasyMock.verify(responseMock);
89+
verify(responseMock).setContentType("image/png");
8190
assertTrue(os.isWritten());
8291
}
8392

8493
public void testContentTypeJpg() throws Exception {
85-
EasyMock.expect(responseMock.getOutputStream()).andReturn(os);
86-
responseMock.setContentType("image/jpg");
87-
EasyMock.replay(responseMock, mockActionProxy, actionInvocation);
88-
ChartResult result = new ChartResult();
89-
9094
result.setChart(mockChart);
9195

9296
result.setHeight("10");
9397
result.setWidth("10");
9498
result.setType("jpg");
9599
result.execute(actionInvocation);
96100

97-
EasyMock.verify(responseMock);
101+
verify(responseMock).setContentType("image/jpg");
98102
assertTrue(os.isWritten());
99103
}
100104

101-
102105
public void testChartNotSet() {
103-
ChartResult result = new ChartResult();
104-
EasyMock.replay(responseMock, mockActionProxy, actionInvocation);
105-
106-
// expect exception if chart not set.
107106
result.setChart(null);
108107

109-
try {
110-
result.execute(actionInvocation);
111-
fail();
112-
} catch (Exception e) {
113-
}
108+
assertThrows(NullPointerException.class, () -> result.execute(actionInvocation));
114109

115-
EasyMock.verify(responseMock);
116110
assertFalse(os.isWritten());
117111
}
118112

119-
120113
public void testChartWithOGNLProperties() throws Exception {
121-
EasyMock.expect(responseMock.getOutputStream()).andReturn(os);
122-
EasyMock.replay(responseMock, mockActionProxy, actionInvocation);
123-
124-
125-
ChartResult result = new ChartResult();
126-
127114
result.setChart(mockChart);
128115

129116
result.setHeight("${myHeight}");
@@ -135,50 +122,14 @@ public void testChartWithOGNLProperties() throws Exception {
135122

136123
result.execute(actionInvocation);
137124

138-
EasyMock.verify(responseMock);
139125
assertEquals(result.getHeight(), stack.findValue("myHeight").toString());
140126
assertEquals(result.getWidth(), stack.findValue("myWidth").toString());
141-
assertEquals("250", result.getHeight().toString());
142-
assertEquals("150", result.getWidth().toString());
127+
assertEquals("250", result.getHeight());
128+
assertEquals("150", result.getWidth());
143129
assertTrue(os.isWritten());
144130
}
145131

146-
protected void setUp() throws Exception {
147-
super.setUp();
148-
149-
DefaultPieDataset data = new DefaultPieDataset();
150-
data.setValue("Java", new Double(43.2));
151-
data.setValue("Visual Basic", new Double(0.0));
152-
data.setValue("C/C++", new Double(17.5));
153-
mockChart = ChartFactory.createPieChart("Pie Chart", data, true, true, false);
154-
155-
156-
stack = ActionContext.getContext().getValueStack();
157-
158-
mockActionProxy = EasyMock.createNiceMock(ActionProxy.class);
159-
EasyMock.expect(mockActionProxy.getNamespace()).andReturn("/html");
160-
161-
actionInvocation = EasyMock.createMock(ActionInvocation.class);
162-
163-
EasyMock.expect(actionInvocation.getStack()).andReturn(stack).anyTimes();
164-
165-
166-
os = new MockServletOutputStream();
167-
responseMock = EasyMock.createNiceMock(HttpServletResponse.class);
168-
169-
ServletActionContext.setResponse((HttpServletResponse) responseMock);
170-
}
171-
172-
protected void tearDown() throws Exception {
173-
actionInvocation = null;
174-
os = null;
175-
responseMock = null;
176-
stack = null;
177-
mockActionProxy = null;
178-
}
179-
180-
181-
private class MockServletOutputStream extends ServletOutputStream {
132+
private static class MockServletOutputStream extends ServletOutputStream {
182133
// very simple check that outputStream was written to.
183134
private boolean written = false;
184135

@@ -189,6 +140,7 @@ public boolean isWritten() {
189140
return written;
190141
}
191142

143+
@Override
192144
public void write(int arg0) throws IOException {
193145
written = true;
194146
}

plugins/junit/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<dependency>
5353
<groupId>junit</groupId>
5454
<artifactId>junit</artifactId>
55+
<scope>compile</scope>
5556
</dependency>
5657
</dependencies>
5758

plugins/rest/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<dependency>
5959
<groupId>org.apache.juneau</groupId>
6060
<artifactId>juneau-marshall</artifactId>
61+
<version>8.1.3</version>
6162
<optional>true</optional>
6263
</dependency>
6364

plugins/testng/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<dependency>
3636
<groupId>org.testng</groupId>
3737
<artifactId>testng</artifactId>
38+
<scope>compile</scope>
3839
</dependency>
3940
<dependency>
4041
<groupId>org.springframework</groupId>

0 commit comments

Comments
 (0)