From dde1e2d70ff3708cce85b37342e0171be51a331d Mon Sep 17 00:00:00 2001 From: koyi2016 Date: Fri, 14 May 2021 14:51:03 +0900 Subject: [PATCH 1/4] Update pom.xml to 6-NEXT-SNAPSHOT (#30) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update pom.xml to 6-NEXT-SNAPSHOT * 依存ライブラリのバージョン設定を削除 --- nablarch-jackson-adaptor/pom.xml | 4 ++-- nablarch-jersey-adaptor/pom.xml | 5 ++--- nablarch-resteasy-adaptor/pom.xml | 5 ++--- pom.xml | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/nablarch-jackson-adaptor/pom.xml b/nablarch-jackson-adaptor/pom.xml index c1e89a2..03f64a0 100644 --- a/nablarch-jackson-adaptor/pom.xml +++ b/nablarch-jackson-adaptor/pom.xml @@ -5,12 +5,12 @@ 4.0.0 com.nablarch.integration nablarch-jackson-adaptor - 5-NEXT-SNAPSHOT + 6-NEXT-SNAPSHOT com.nablarch.integration nablarch-jaxrs-adaptor - 5-NEXT-SNAPSHOT + 6-NEXT-SNAPSHOT diff --git a/nablarch-jersey-adaptor/pom.xml b/nablarch-jersey-adaptor/pom.xml index 4f99c4b..16813ae 100644 --- a/nablarch-jersey-adaptor/pom.xml +++ b/nablarch-jersey-adaptor/pom.xml @@ -4,19 +4,18 @@ 4.0.0 com.nablarch.integration nablarch-jersey-adaptor - 5-NEXT-SNAPSHOT + 6-NEXT-SNAPSHOT com.nablarch.integration nablarch-jaxrs-adaptor - 5-NEXT-SNAPSHOT + 6-NEXT-SNAPSHOT com.nablarch.integration nablarch-jackson-adaptor - 5-NEXT-SNAPSHOT com.fasterxml.jackson.core diff --git a/nablarch-resteasy-adaptor/pom.xml b/nablarch-resteasy-adaptor/pom.xml index fc75746..d5f6660 100644 --- a/nablarch-resteasy-adaptor/pom.xml +++ b/nablarch-resteasy-adaptor/pom.xml @@ -4,19 +4,18 @@ 4.0.0 com.nablarch.integration nablarch-resteasy-adaptor - 5-NEXT-SNAPSHOT + 6-NEXT-SNAPSHOT com.nablarch.integration nablarch-jaxrs-adaptor - 5-NEXT-SNAPSHOT + 6-NEXT-SNAPSHOT com.nablarch.integration nablarch-jackson-adaptor - 5-NEXT-SNAPSHOT com.fasterxml.jackson.core diff --git a/pom.xml b/pom.xml index 196962b..33745d1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.nablarch.integration nablarch-jaxrs-adaptor - 5-NEXT-SNAPSHOT + 6-NEXT-SNAPSHOT pom @@ -18,7 +18,7 @@ com.nablarch nablarch-parent - 5-NEXT-SNAPSHOT + 6-NEXT-SNAPSHOT From 68370dfd2d5bd95e1deb5cb3c46c09068c0cf3fa Mon Sep 17 00:00:00 2001 From: opengl-8080 Date: Tue, 21 Feb 2023 17:40:34 +0900 Subject: [PATCH 2/4] =?UTF-8?q?Jakarta=20EE=20=E5=AF=BE=E5=BF=9C=20(#41)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: javax -> jakarta * feat: バージョン管理をparentに集約 --- nablarch-jackson-adaptor/pom.xml | 10 ++++------ .../jaxrs/jackson/JacksonBodyConverterSupport.java | 2 +- .../jaxrs/jackson/JacksonBodyConverterTestSupport.java | 6 +++--- nablarch-jersey-adaptor/pom.xml | 10 ++++------ nablarch-resteasy-adaptor/pom.xml | 10 ++++------ 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/nablarch-jackson-adaptor/pom.xml b/nablarch-jackson-adaptor/pom.xml index 03f64a0..693a289 100644 --- a/nablarch-jackson-adaptor/pom.xml +++ b/nablarch-jackson-adaptor/pom.xml @@ -26,9 +26,8 @@ - javax - javaee-api - 7.0 + jakarta.platform + jakarta.jakartaee-api provided @@ -39,9 +38,8 @@ provided - javax.servlet - servlet-api - 2.5 + jakarta.servlet + jakarta.servlet-api test diff --git a/nablarch-jackson-adaptor/src/main/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterSupport.java b/nablarch-jackson-adaptor/src/main/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterSupport.java index a1309b9..946ceae 100644 --- a/nablarch-jackson-adaptor/src/main/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterSupport.java +++ b/nablarch-jackson-adaptor/src/main/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterSupport.java @@ -10,7 +10,7 @@ import nablarch.fw.web.HttpResponse; import nablarch.fw.web.servlet.ServletExecutionContext; -import javax.servlet.ServletRequest; +import jakarta.servlet.ServletRequest; import java.io.IOException; import java.io.Reader; diff --git a/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterTestSupport.java b/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterTestSupport.java index f2a6580..cd53f56 100644 --- a/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterTestSupport.java +++ b/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterTestSupport.java @@ -16,15 +16,15 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.UnsupportedCharsetException; -import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.notNullValue; diff --git a/nablarch-jersey-adaptor/pom.xml b/nablarch-jersey-adaptor/pom.xml index 16813ae..1da4be3 100644 --- a/nablarch-jersey-adaptor/pom.xml +++ b/nablarch-jersey-adaptor/pom.xml @@ -30,9 +30,8 @@ - javax - javaee-api - 7.0 + jakarta.platform + jakarta.jakartaee-api provided @@ -43,9 +42,8 @@ provided - javax.servlet - servlet-api - 2.5 + jakarta.servlet + jakarta.servlet-api test diff --git a/nablarch-resteasy-adaptor/pom.xml b/nablarch-resteasy-adaptor/pom.xml index d5f6660..e46dce1 100644 --- a/nablarch-resteasy-adaptor/pom.xml +++ b/nablarch-resteasy-adaptor/pom.xml @@ -30,9 +30,8 @@ - javax - javaee-api - 7.0 + jakarta.platform + jakarta.jakartaee-api provided @@ -43,9 +42,8 @@ provided - javax.servlet - servlet-api - 2.5 + jakarta.servlet + jakarta.servlet-api test From 4abe4205f3d62c561df13adc31642a9bd4213b65 Mon Sep 17 00:00:00 2001 From: opengl-8080 Date: Thu, 27 Apr 2023 20:13:57 +0900 Subject: [PATCH 3/4] test: jmockit -> mockito (#42) --- nablarch-jackson-adaptor/pom.xml | 4 +- .../jackson/Jackson2BodyConverterTest.java | 22 +- .../JacksonBodyConverterTestSupport.java | 189 +++++++----------- nablarch-jersey-adaptor/pom.xml | 5 - .../JerseyJaxRsHandlerListFactoryTest.java | 4 +- nablarch-resteasy-adaptor/pom.xml | 5 - .../ResteasyJaxRsHandlerListFactoryTest.java | 4 +- 7 files changed, 85 insertions(+), 148 deletions(-) diff --git a/nablarch-jackson-adaptor/pom.xml b/nablarch-jackson-adaptor/pom.xml index 693a289..2ba7a95 100644 --- a/nablarch-jackson-adaptor/pom.xml +++ b/nablarch-jackson-adaptor/pom.xml @@ -48,8 +48,8 @@ test - org.jmockit - jmockit + org.mockito + mockito-core test diff --git a/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/Jackson2BodyConverterTest.java b/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/Jackson2BodyConverterTest.java index 0156992..288bee1 100644 --- a/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/Jackson2BodyConverterTest.java +++ b/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/Jackson2BodyConverterTest.java @@ -5,15 +5,16 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; -import mockit.Mocked; -import mockit.Expectations; +import nablarch.test.support.reflection.ReflectionUtil; import org.junit.Test; +import org.mockito.Mockito; + +import static org.mockito.Mockito.when; /** * {@link Jackson2BodyConverter}のテストクラス。 */ public class Jackson2BodyConverterTest extends JacksonBodyConverterTestSupport { - @Override protected Jackson2BodyConverter createSut() { return new Jackson2BodyConverter(); @@ -45,17 +46,18 @@ protected Class getUnrecognizedPropertyExceptionClass() { } @Test - public void testWrite_json_failed(@Mocked final ObjectMapper mapper) throws Exception { + public void testWrite_json_failed() throws Exception { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("failed to write response."); final TestBean bean = new TestBean("aaa",123L, true); - new Expectations() {{ - jaxRsContext.getProducesMediaType(); - result = "application/json;charset=utf-8"; - mapper.writeValueAsString(bean); - result = new JsonMappingException("error"); - }}; + when(jaxRsContext.getProducesMediaType()).thenReturn("application/json;charset=utf-8"); + + // mockConstruction だとなぜか ObjectMapper のコンストラクタをモック化できなかったので、 + // リフレクションで強制的にモックオブジェクトを設定している + final ObjectMapper objectMapper = Mockito.mock(ObjectMapper.class); + when(objectMapper.writeValueAsString(bean)).thenThrow(new JsonMappingException("error")); + ReflectionUtil.setFieldValue(sut, "objectMapper", objectMapper); sut.write(bean, executionContext); } diff --git a/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterTestSupport.java b/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterTestSupport.java index cd53f56..9bb7574 100644 --- a/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterTestSupport.java +++ b/nablarch-jackson-adaptor/src/test/java/nablarch/integration/jaxrs/jackson/JacksonBodyConverterTestSupport.java @@ -1,7 +1,7 @@ package nablarch.integration.jaxrs.jackson; -import mockit.Expectations; -import mockit.Mocked; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; import nablarch.fw.ExecutionContext; import nablarch.fw.jaxrs.BodyConverterSupport; import nablarch.fw.jaxrs.JaxRsContext; @@ -11,17 +11,18 @@ import nablarch.fw.web.servlet.NablarchHttpServletRequestWrapper; import nablarch.fw.web.servlet.ServletExecutionContext; import nablarch.test.support.log.app.OnMemoryLogWriter; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.MockedStatic; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.MultivaluedMap; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.nio.charset.UnsupportedCharsetException; import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; @@ -31,6 +32,10 @@ import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.when; /** * {@link JacksonBodyConverterSupport}を実装したクラスのテストをサポートするクラス。 @@ -42,21 +47,27 @@ public abstract class JacksonBodyConverterTestSupport jaxRsContextMockedStatic; + protected JaxRsContext jaxRsContext = mock(JaxRsContext.class); @Before public void setUp() { sut = createSut(); + jaxRsContextMockedStatic = mockStatic(JaxRsContext.class); + jaxRsContextMockedStatic.when(() -> JaxRsContext.get(executionContext)).thenReturn(jaxRsContext); + + when(executionContext.getServletRequest()).thenReturn(servletRequest); + } + + @After + public void tearDown() throws Exception { + jaxRsContextMockedStatic.close(); } protected abstract T createSut(); @@ -67,35 +78,23 @@ public void setUp() { @Test public void testRead_json() throws Exception { - new Expectations() {{ - jaxRsContext.getRequestClass(); - result = TestBean.class; - jaxRsContext.getConsumesMediaType(); - result = "application/json"; - minTimes = 0; - servletRequest.getCharacterEncoding(); - result = "utf-8"; - servletRequest.getReader(); - result = new BufferedReader(new InputStreamReader(new ByteArrayInputStream("{\"str\":\"あいう\", \"num\":123, \"flg\":1}".getBytes("utf-8")), "utf-8")); - }}; + doReturn(TestBean.class).when(jaxRsContext).getRequestClass(); + when(jaxRsContext.getConsumesMediaType()).thenReturn("application/json"); + when(servletRequest.getCharacterEncoding()).thenReturn("utf-8"); + when(servletRequest.getReader()).thenReturn(new BufferedReader(new InputStreamReader( + new ByteArrayInputStream("{\"str\":\"あいう\", \"num\":123, \"flg\":1}".getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8))); + TestBean bean = (TestBean)sut.read(request, executionContext); assertThat(bean.getStr(), is("あいう")); assertThat(bean.getNum(), is(123L)); assertThat(bean.isFlg(), is(true)); - new Expectations() {{ - jaxRsContext.getRequestClass(); - result = TestBean.class; - jaxRsContext.getConsumesMediaType(); - result = "application/json"; - minTimes = 0; - executionContext.getServletRequest(); - result = servletRequest; - servletRequest.getCharacterEncoding(); - result = "windows-31j"; - servletRequest.getReader(); - result = new BufferedReader(new InputStreamReader(new ByteArrayInputStream("{\"str\":\"あいう\", \"num\":123, \"flg\":1}".getBytes("windows-31j")), "windows-31j")); - }}; + doReturn(TestBean.class).when(jaxRsContext).getRequestClass(); + when(jaxRsContext.getConsumesMediaType()).thenReturn("application/json"); + when(executionContext.getServletRequest()).thenReturn(servletRequest); + when(servletRequest.getCharacterEncoding()).thenReturn("windows-31j"); + when(servletRequest.getReader()).thenReturn(new BufferedReader(new InputStreamReader( + new ByteArrayInputStream("{\"str\":\"あいう\", \"num\":123, \"flg\":1}".getBytes("windows-31j")), "windows-31j"))); bean = (TestBean)sut.read(request, executionContext); assertThat(bean.getStr(), is("あいう")); assertThat(bean.getNum(), is(123L)); @@ -104,17 +103,11 @@ public void testRead_json() throws Exception { @Test public void testRead_with_context() throws Exception { - new Expectations() {{ - jaxRsContext.getRequestClass(); - result = TestBean.class; - jaxRsContext.getConsumesMediaType(); - result = "application/json"; - minTimes = 0; - servletRequest.getCharacterEncoding(); - result = "utf-8"; - servletRequest.getReader(); - result = new BufferedReader(new InputStreamReader(new ByteArrayInputStream("{\"str\":\"bbb\", \"num\":456789, \"flg\":0}".getBytes("utf-8")), "utf-8")); - }}; + doReturn(TestBean.class).when(jaxRsContext).getRequestClass(); + when(jaxRsContext.getConsumesMediaType()).thenReturn("application/json"); + when(servletRequest.getCharacterEncoding()).thenReturn("utf-8"); + when(servletRequest.getReader()).thenReturn(new BufferedReader(new InputStreamReader( + new ByteArrayInputStream("{\"str\":\"bbb\", \"num\":456789, \"flg\":0}".getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8))); TestBean bean = (TestBean)sut.read(request, executionContext); assertThat(bean.getStr(), is("bbb")); @@ -127,26 +120,17 @@ public void testRead_bean_null() throws Exception { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("consumes media type and resource method signature is mismatch."); - new Expectations() {{ - jaxRsContext.getRequestClass(); - result = null; - }}; + when(jaxRsContext.getRequestClass()).thenReturn(null); sut.read(request, executionContext); } @Test public void testRead_charset_invalid() throws Exception { - new Expectations() {{ - jaxRsContext.getRequestClass(); - result = TestBean.class; - jaxRsContext.getConsumesMediaType(); - result = "application/json"; - minTimes = 0; - servletRequest.getCharacterEncoding(); - result = "test"; - }}; - + doReturn(TestBean.class).when(jaxRsContext).getRequestClass(); + when(jaxRsContext.getConsumesMediaType()).thenReturn("application/json"); + when(servletRequest.getCharacterEncoding()).thenReturn("test"); + try { sut.read(request, executionContext); fail("サポートされていないcharsetによる例外が発生"); @@ -158,17 +142,11 @@ public void testRead_charset_invalid() throws Exception { @Test public void testRead_json_failed() throws Exception { - new Expectations() {{ - jaxRsContext.getRequestClass(); - result = TestBean.class; - jaxRsContext.getConsumesMediaType(); - result = "application/json"; - minTimes = 0; - servletRequest.getCharacterEncoding(); - result = "utf-8"; - servletRequest.getReader(); - result = new BufferedReader(new InputStreamReader(new ByteArrayInputStream("test=aaa".getBytes("utf-8")), "utf-8")); - }}; + doReturn(TestBean.class).when(jaxRsContext).getRequestClass(); + when(jaxRsContext.getConsumesMediaType()).thenReturn("application/json"); + when(servletRequest.getCharacterEncoding()).thenReturn("utf-8"); + when(servletRequest.getReader()).thenReturn(new BufferedReader(new InputStreamReader( + new ByteArrayInputStream("test=aaa".getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8))); try { sut.read(request, executionContext); @@ -187,17 +165,11 @@ public void testRead_json_failed() throws Exception { */ @Test public void unknownPropertyInJson_shouldThrowError_defaultImplementation() throws Exception { - new Expectations() {{ - jaxRsContext.getRequestClass(); - result = TestBean.class; - jaxRsContext.getConsumesMediaType(); - result = "application/json"; - minTimes = 0; - servletRequest.getCharacterEncoding(); - result = "utf-8"; - servletRequest.getReader(); - result = new BufferedReader(new InputStreamReader(new ByteArrayInputStream("{\"str\":\"あいう\", \"num\":123, \"flg\":1, \"unknown_property\":true}".getBytes("utf-8")), "utf-8")); - }}; + doReturn(TestBean.class).when(jaxRsContext).getRequestClass(); + when(jaxRsContext.getConsumesMediaType()).thenReturn("application/json"); + when(servletRequest.getCharacterEncoding()).thenReturn("utf-8"); + when(servletRequest.getReader()).thenReturn(new BufferedReader(new InputStreamReader( + new ByteArrayInputStream("{\"str\":\"あいう\", \"num\":123, \"flg\":1, \"unknown_property\":true}".getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8))); try { sut.read(request, executionContext); fail("未知のプロパティによるエラーが発生"); @@ -218,17 +190,11 @@ public void unknownPropertyInJson_shouldThrowError_defaultImplementation() throw */ @Test public void unknownPropertyInJson_shouldThrowError_customImplementation() throws Exception { - new Expectations() {{ - jaxRsContext.getRequestClass(); - result = TestBean.class; - jaxRsContext.getConsumesMediaType(); - result = "application/json"; - minTimes = 0; - servletRequest.getCharacterEncoding(); - result = "utf-8"; - servletRequest.getReader(); - result = new BufferedReader(new InputStreamReader(new ByteArrayInputStream("{\"str\":\"あいう\", \"num\":123, \"flg\":true, \"unknown_property\":true}".getBytes("utf-8")), "utf-8")); - }}; + doReturn(TestBean.class).when(jaxRsContext).getRequestClass(); + when(jaxRsContext.getConsumesMediaType()).thenReturn("application/json"); + when(servletRequest.getCharacterEncoding()).thenReturn("utf-8"); + when(servletRequest.getReader()).thenReturn(new BufferedReader(new InputStreamReader( + new ByteArrayInputStream("{\"str\":\"あいう\", \"num\":123, \"flg\":true, \"unknown_property\":true}".getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8))); sut = createSutWithDisableFailOnUnknownProperties(); @@ -246,10 +212,7 @@ public void testWrite_json() throws Exception { TestBean bean = new TestBean("aaa",123L, true); // ProducesMediaTypeにcharset=utf-8が設定されているパターン - new Expectations() {{ - jaxRsContext.getProducesMediaType(); - result = "application/json;charset=utf-8"; - }}; + when(jaxRsContext.getProducesMediaType()).thenReturn("application/json;charset=utf-8"); HttpResponse response = sut.write(bean, executionContext); assertThat(response.getBodyString(), is("{\"str\":\"aaa\",\"num\":123,\"flg\":true}")); @@ -258,10 +221,7 @@ public void testWrite_json() throws Exception { assertThat(response.getStatusCode(), is(200)); // ProducesMediaTypeにcharset=windows-31jが設定されているパターン - new Expectations() {{ - jaxRsContext.getProducesMediaType(); - result = "application/json;charset=windows-31j"; - }}; + when(jaxRsContext.getProducesMediaType()).thenReturn("application/json;charset=windows-31j"); response = sut.write(bean, executionContext); assertThat(response.getBodyString(), is("{\"str\":\"aaa\",\"num\":123,\"flg\":true}")); @@ -270,10 +230,7 @@ public void testWrite_json() throws Exception { assertThat(response.getStatusCode(), is(200)); // ProducesMediaTypeにcharsetが設定されていないパターン - new Expectations() {{ - jaxRsContext.getProducesMediaType(); - result = "application/json"; - }}; + when(jaxRsContext.getProducesMediaType()).thenReturn("application/json"); response = sut.write(bean, executionContext); assertThat(response.getBodyString(), is("{\"str\":\"aaa\",\"num\":123,\"flg\":true}")); @@ -282,10 +239,7 @@ public void testWrite_json() throws Exception { assertThat(response.getStatusCode(), is(200)); // ProducesMediaTypeにcharsetが設定されておらず、デフォルトエンコーディングにISO-8859-1を指定しているパターン - new Expectations() {{ - jaxRsContext.getProducesMediaType(); - result = "application/json"; - }}; + when(jaxRsContext.getProducesMediaType()).thenReturn("application/json"); sut.setDefaultEncoding("ISO-8859-1"); response = sut.write(bean, executionContext); @@ -300,10 +254,7 @@ public void testWrite_charset_invalid() throws Exception { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("produces charset is invalid. charset = [test]"); - new Expectations() {{ - jaxRsContext.getProducesMediaType(); - result = "application/json;charset=test"; - }}; + when(jaxRsContext.getProducesMediaType()).thenReturn("application/json;charset=test"); sut.write(new TestBean(), executionContext); } @@ -323,10 +274,7 @@ public void testWrite_httpResponse() throws Exception { public void enum_shouldReturnEnumName_defaultImplementation() throws Exception { // ProducesMediaTypeにcharset=utf-8が設定されているパターン - new Expectations() {{ - jaxRsContext.getProducesMediaType(); - result = "application/json;charset=utf-8"; - }}; + when(jaxRsContext.getProducesMediaType()).thenReturn("application/json;charset=utf-8"); HasEnumBean bean = new HasEnumBean(); bean.type = HasEnumBean.TYPE.TYPE1; @@ -345,10 +293,7 @@ public void enum_shouldReturnEnumName_defaultImplementation() throws Exception { public void enum_shouldReturnEnumName_customImplementation() throws Exception { // ProducesMediaTypeにcharset=utf-8が設定されているパターン - new Expectations() {{ - jaxRsContext.getProducesMediaType(); - result = "application/json;charset=utf-8"; - }}; + when(jaxRsContext.getProducesMediaType()).thenReturn("application/json;charset=utf-8"); sut = createSutWithEnableWriteEnumsUsingToString(); diff --git a/nablarch-jersey-adaptor/pom.xml b/nablarch-jersey-adaptor/pom.xml index 1da4be3..09acdf9 100644 --- a/nablarch-jersey-adaptor/pom.xml +++ b/nablarch-jersey-adaptor/pom.xml @@ -51,11 +51,6 @@ nablarch-test-support test - - org.jmockit - jmockit - test - diff --git a/nablarch-jersey-adaptor/src/test/java/nablarch/integration/jaxrs/jersey/JerseyJaxRsHandlerListFactoryTest.java b/nablarch-jersey-adaptor/src/test/java/nablarch/integration/jaxrs/jersey/JerseyJaxRsHandlerListFactoryTest.java index 33bc7e4..57a00f3 100644 --- a/nablarch-jersey-adaptor/src/test/java/nablarch/integration/jaxrs/jersey/JerseyJaxRsHandlerListFactoryTest.java +++ b/nablarch-jersey-adaptor/src/test/java/nablarch/integration/jaxrs/jersey/JerseyJaxRsHandlerListFactoryTest.java @@ -1,6 +1,5 @@ package nablarch.integration.jaxrs.jersey; -import mockit.Deencapsulation; import nablarch.fw.Handler; import nablarch.fw.jaxrs.BodyConvertHandler; import nablarch.fw.jaxrs.BodyConverter; @@ -9,6 +8,7 @@ import nablarch.fw.jaxrs.JaxbBodyConverter; import nablarch.fw.web.HttpRequest; import nablarch.integration.jaxrs.jackson.Jackson2BodyConverter; +import nablarch.test.support.reflection.ReflectionUtil; import org.junit.Test; import java.util.List; @@ -32,7 +32,7 @@ public void testCreate() throws Exception { assertThat(list.size(), is(2)); assertThat(list.get(0), instanceOf(BodyConvertHandler.class)); - List bodyConverters = Deencapsulation.getField(list.get(0), "bodyConverters"); + List bodyConverters = ReflectionUtil.getFieldValue(list.get(0), "bodyConverters"); assertThat(bodyConverters.size(), is(3)); assertThat(bodyConverters.get(0), instanceOf(Jackson2BodyConverter.class)); assertThat(bodyConverters.get(1), instanceOf(JaxbBodyConverter.class)); diff --git a/nablarch-resteasy-adaptor/pom.xml b/nablarch-resteasy-adaptor/pom.xml index e46dce1..e0cb6d6 100644 --- a/nablarch-resteasy-adaptor/pom.xml +++ b/nablarch-resteasy-adaptor/pom.xml @@ -51,11 +51,6 @@ nablarch-test-support test - - org.jmockit - jmockit - test - diff --git a/nablarch-resteasy-adaptor/src/test/java/nablarch/integration/jaxrs/resteasy/ResteasyJaxRsHandlerListFactoryTest.java b/nablarch-resteasy-adaptor/src/test/java/nablarch/integration/jaxrs/resteasy/ResteasyJaxRsHandlerListFactoryTest.java index 9c29795..c7a02a3 100644 --- a/nablarch-resteasy-adaptor/src/test/java/nablarch/integration/jaxrs/resteasy/ResteasyJaxRsHandlerListFactoryTest.java +++ b/nablarch-resteasy-adaptor/src/test/java/nablarch/integration/jaxrs/resteasy/ResteasyJaxRsHandlerListFactoryTest.java @@ -1,6 +1,5 @@ package nablarch.integration.jaxrs.resteasy; -import mockit.Deencapsulation; import nablarch.fw.Handler; import nablarch.fw.jaxrs.BodyConvertHandler; import nablarch.fw.jaxrs.BodyConverter; @@ -9,6 +8,7 @@ import nablarch.fw.jaxrs.JaxbBodyConverter; import nablarch.fw.web.HttpRequest; import nablarch.integration.jaxrs.jackson.Jackson2BodyConverter; +import nablarch.test.support.reflection.ReflectionUtil; import org.junit.Test; import java.util.List; @@ -32,7 +32,7 @@ public void testCreate() throws Exception { assertThat(list.size(), is(2)); assertThat(list.get(0), instanceOf(BodyConvertHandler.class)); - List bodyConverters = Deencapsulation.getField(list.get(0), "bodyConverters"); + List bodyConverters = ReflectionUtil.getFieldValue(list.get(0), "bodyConverters"); assertThat(bodyConverters.size(), is(3)); assertThat(bodyConverters.get(0), instanceOf(Jackson2BodyConverter.class)); assertThat(bodyConverters.get(1), instanceOf(JaxbBodyConverter.class)); From dee1b3d22ee08c8f2dd19bd336ec5b404ed3db27 Mon Sep 17 00:00:00 2001 From: Takayuki Uchida Date: Fri, 15 Dec 2023 19:59:56 +0900 Subject: [PATCH 4/4] create-release-branch --- nablarch-jackson-adaptor/pom.xml | 4 ++-- nablarch-jersey-adaptor/pom.xml | 4 ++-- nablarch-resteasy-adaptor/pom.xml | 4 ++-- pom.xml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nablarch-jackson-adaptor/pom.xml b/nablarch-jackson-adaptor/pom.xml index 2ba7a95..fd5d6c6 100644 --- a/nablarch-jackson-adaptor/pom.xml +++ b/nablarch-jackson-adaptor/pom.xml @@ -5,12 +5,12 @@ 4.0.0 com.nablarch.integration nablarch-jackson-adaptor - 6-NEXT-SNAPSHOT + 2.0.0 com.nablarch.integration nablarch-jaxrs-adaptor - 6-NEXT-SNAPSHOT + 2.0.0 diff --git a/nablarch-jersey-adaptor/pom.xml b/nablarch-jersey-adaptor/pom.xml index 09acdf9..ce8195e 100644 --- a/nablarch-jersey-adaptor/pom.xml +++ b/nablarch-jersey-adaptor/pom.xml @@ -4,12 +4,12 @@ 4.0.0 com.nablarch.integration nablarch-jersey-adaptor - 6-NEXT-SNAPSHOT + 2.0.0 com.nablarch.integration nablarch-jaxrs-adaptor - 6-NEXT-SNAPSHOT + 2.0.0 diff --git a/nablarch-resteasy-adaptor/pom.xml b/nablarch-resteasy-adaptor/pom.xml index e0cb6d6..bc55807 100644 --- a/nablarch-resteasy-adaptor/pom.xml +++ b/nablarch-resteasy-adaptor/pom.xml @@ -4,12 +4,12 @@ 4.0.0 com.nablarch.integration nablarch-resteasy-adaptor - 6-NEXT-SNAPSHOT + 2.0.0 com.nablarch.integration nablarch-jaxrs-adaptor - 6-NEXT-SNAPSHOT + 2.0.0 diff --git a/pom.xml b/pom.xml index 33745d1..602169f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.nablarch.integration nablarch-jaxrs-adaptor - 6-NEXT-SNAPSHOT + 2.0.0 pom @@ -18,7 +18,7 @@ com.nablarch nablarch-parent - 6-NEXT-SNAPSHOT + 6