pull/1290/merge
akib6075 7 months ago committed by GitHub
commit 2c11ecf084
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,27 @@
name: Test:JSONUtilTest.assertToJSONString
run-name: New known Flaky test
on: [push]
jobs:
Test_Without_Nondex_Shuffling:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Test
run: mvn -pl hippo4j-common test -Dtest=cn.hippo4j.common.toolkit.JSONUtilTest#assertToJSONString
Test_With_Nondex_Shuffling:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Test
run: mvn -pl hippo4j-common edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=cn.hippo4j.common.toolkit.JSONUtilTest#assertToJSONString

@ -48,6 +48,7 @@ public class JacksonHandler implements JsonFacade {
MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);
MAPPER.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); MAPPER.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
MAPPER.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
} }
@Override @Override

@ -31,7 +31,7 @@ public class ContentUtilTest {
.itemId("dynamic-threadpool-example").tpId("message-consume").content("描述信息").corePoolSize(1) .itemId("dynamic-threadpool-example").tpId("message-consume").content("描述信息").corePoolSize(1)
.maximumPoolSize(2).queueType(1).capacity(4).keepAliveTime(513L).executeTimeOut(null).rejectedType(4) .maximumPoolSize(2).queueType(1).capacity(4).keepAliveTime(513L).executeTimeOut(null).rejectedType(4)
.isAlarm(1).capacityAlarm(80).livenessAlarm(80).allowCoreThreadTimeOut(1).build(); .isAlarm(1).capacityAlarm(80).livenessAlarm(80).allowCoreThreadTimeOut(1).build();
Assert.isTrue(testText.equals(ContentUtil.getPoolContent(threadPoolParameterInfo))); Assert.isTrue(ContentUtil.getPoolContent(JSONUtil.parseObject(testText, ThreadPoolParameterInfo.class)).equals(ContentUtil.getPoolContent(threadPoolParameterInfo)));
} }
@Test @Test

@ -14,9 +14,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.hippo4j.common.toolkit;
package cn.hippo4j.common.toolkit; <<<<<<< HEAD:infra/common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java
<<<<<<< HEAD:infra/common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -92,3 +93,82 @@ public class JSONUtilTest {
private Foo foo; private Foo foo;
} }
} }
=======
=======
>>>>>>> b720f264c81b2a05ab8b4b0a58f8f0282dcf0d2c:hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class JSONUtilTest {
private static final Foo EXPECTED_FOO = new Foo(new Foo(null, 2, "foo2"), 1, "foo1");
private static final List<Foo> EXPECTED_FOO_ARRAY = Arrays.asList(EXPECTED_FOO, EXPECTED_FOO);
private static final String EXPECTED_FOO_JSON = "{\"foo\":{\"id\":2,\"name\":\"foo2\"},\"id\":1,\"name\":\"foo1\"}";
private static final String EXPECTED_FOO_JSON_ARRAY = "[" + EXPECTED_FOO_JSON + "," + EXPECTED_FOO_JSON + "]";
@Test
public void assertToJSONString() {
Assert.assertNull(JSONUtil.toJSONString(null));
Assert.assertEquals(EXPECTED_FOO_JSON, JSONUtil.toJSONString(EXPECTED_FOO));
}
@Test
public void assertParseObject() {
Assert.assertNull(JSONUtil.parseObject(null, Foo.class));
Assert.assertNull(JSONUtil.parseObject(" ", Foo.class));
Assert.assertEquals(EXPECTED_FOO, JSONUtil.parseObject(EXPECTED_FOO_JSON, Foo.class));
}
@Test
public void assertParseObjectTypeReference() {
Assert.assertNull(JSONUtil.parseObject(null, new TypeReference<List<Foo>>() {
}));
Assert.assertNull(JSONUtil.parseObject(" ", new TypeReference<List<Foo>>() {
}));
Assert.assertEquals(
EXPECTED_FOO_ARRAY,
JSONUtil.parseObject(EXPECTED_FOO_JSON_ARRAY, new TypeReference<List<Foo>>() {
}));
}
@Test
public void assertParseArray() {
Assert.assertEquals(Collections.emptyList(), JSONUtil.parseArray(null, Foo.class));
Assert.assertEquals(Collections.emptyList(), JSONUtil.parseArray(" ", Foo.class));
Assert.assertEquals(
EXPECTED_FOO_ARRAY,
JSONUtil.parseArray(EXPECTED_FOO_JSON_ARRAY, Foo.class));
}
@EqualsAndHashCode
@AllArgsConstructor
@NoArgsConstructor
@Data
private static class Foo {
private Foo foo;
private Integer id;
private String name;
}
}
<<<<<<< HEAD:infra/common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java
>>>>>>> ed2db3f3 (potentially issue fixed):hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java
=======
>>>>>>> b720f264c81b2a05ab8b4b0a58f8f0282dcf0d2c:hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java

Loading…
Cancel
Save