Skip to content

Commit

Permalink
More test fixes to help with Eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 31, 2025
1 parent 3704683 commit f12cd41
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 55 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@

public class EnumHandlingTest extends ProtobufTestBase
{
enum TinyEnum {
public enum TinyEnum {
X;
}

enum BigEnum {
public enum BigEnum {
A, B, C, D, E,
F, G, H, I, J;
}

static class TinyEnumWrapper {
public static class TinyEnumWrapper {
public TinyEnum value;

TinyEnumWrapper() { }
public TinyEnumWrapper() { }
public TinyEnumWrapper(TinyEnum v) { value = v; }
}

static class BigEnumWrapper {
public static class BigEnumWrapper {
public BigEnum value;

BigEnumWrapper() { }
public BigEnumWrapper() { }
public BigEnumWrapper(BigEnum v) { value = v; }
}

Expand All @@ -43,7 +43,7 @@ static class BigEnumWrapper {
/**********************************************************
*/

final ProtobufMapper MAPPER = new ProtobufMapper();
final ProtobufMapper MAPPER = newObjectMapper();

@Test
public void testBigEnum() throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public class NextXxxParsingTest extends ProtobufTestBase
+"}\n"
;

static class Strings {
public static class Strings {
public String[] values;

public Strings() { }
public Strings(String... v) { values = v; }
}

final ObjectMapper MAPPER = new ObjectMapper(new ProtobufFactory());
final ObjectMapper MAPPER = newObjectMapper();

@Test
public void testNextFieldAndText() throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public boolean equals(Object o) {
public static class Point3 {
public int x, y, z;

protected Point3() { }
public Point3() { }

public Point3(int x, int y, int z) {
this.x = x;
Expand All @@ -206,7 +206,7 @@ public static class PointL {
public long x;
public long y;

protected PointL() { }
public PointL() { }

public PointL(long x, long y) {
this.x = x;
Expand All @@ -231,7 +231,7 @@ public static class OptionalValue {
public boolean present;
public String value;

protected OptionalValue() { }
public OptionalValue() { }
public OptionalValue(boolean p, String v) {
present = p;
value = v;
Expand Down Expand Up @@ -259,7 +259,7 @@ public static class PointD {
public double x;
public double y;

protected PointD() { }
public PointD() { }

public PointD(double x, double y) {
this.x = x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
public class ReadUnknownFields202Test extends ProtobufTestBase
{
// [dataformats-binary#202]
static class TestMessageV0
public static class TestMessageV0
{
@JsonProperty(required = true, index = 1)
private String id;
protected String id;
@JsonProperty(required = false, index = 2)
private String plant;
protected String plant;

public TestMessageV0() { }

Expand All @@ -39,20 +39,20 @@ public String getPlant() {
}
}

static class TestMessageV1
public static class TestMessageV1
{
@JsonProperty(required = true, index = 1)
private String id;
protected String id;
@JsonProperty(required = false, index = 2)
private String plant;
protected String plant;
@JsonProperty(required = false, index = 3)
private Double length;
protected Double length;
@JsonProperty(required = false, index = 4)
private Double width;
protected Double width;
@JsonProperty(required = false, index = 5)
private String descr;
protected String descr;
@JsonProperty(required = false, index = 6)
private String source;
protected String source;

public TestMessageV1() { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

public class ReadUnkownFieldsTest extends ProtobufTestBase
{
static class OneField {
public static class OneField {
@JsonProperty(value = "f3", index = 3)
public int f3;
}

static class ThreeField {
public static class ThreeField {

@JsonProperty(value = "f1", index = 1)
private int f1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class RoundtripNestedMessageTest extends ProtobufTestBase
"optional string a = 1;\n" + //
"}\n"; //

static class TestObject {
public static class TestObject {
String a;
TestSub b;

Expand All @@ -59,7 +59,7 @@ public void setB(TestSub b) {

// ordering would be needed prior to fix for [#59]
//@com.fasterxml.jackson.annotation.JsonPropertyOrder({"d", "b", "c"})
static class TestSub {
public static class TestSub {
String b;
String c;
TestSubSub d;
Expand Down Expand Up @@ -103,7 +103,7 @@ public void setA(String a) {

// [dataformats-binary#135]: endless END_OBJECT at end of doc
@JsonPropertyOrder({ "name", "age", "emails", "boss" })
static class Employee135 {
public static class Employee135 {
public int age;

public String[] emails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,24 @@

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class SerDeserLongTest extends ProtobufTestBase
{
@JsonPropertyOrder({ "long1", "long2" })
public static class BigNumPair {
public static final String protobuf_str =
"message BigNumPair {\n"
+ " required int64 long1 = 1;\n"
+ " required int64 long2 = 2;\n"
+ "}\n";

public long long1;
public long long2;
}

@Test
public void testWeirdLongSerDeser() throws Exception {
ObjectMapper mapper = newObjectMapper();
Expand All @@ -21,7 +37,7 @@ public void testWeirdLongSerDeser() throws Exception {

BigNumPair parsed = mapper.readerFor(BigNumPair.class).with(schema).readValue(encoded);

assert parsed.long1 == bnp.long1;
assert parsed.long2 == bnp.long2;
assertEquals(bnp.long1, parsed.long1);
assertEquals(bnp.long2, parsed.long2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ public class WriteArrayTest extends ProtobufTestBase
+PROTOC_POINT;
;

static class StringArray {
public static class StringArray {
public String[] values;

public StringArray(String... v) {
values = v;
}
}

static class PointArray {
public static class PointArray {
public Point[] points;

public PointArray(Point... p) {
points = p;
}
}

final ObjectMapper MAPPER = new ObjectMapper(new ProtobufFactory());
private final ObjectMapper MAPPER = newObjectMapper();

final ProtobufSchema SPARSE_STRING_SCHEMA;
final ProtobufSchema PACKED_STRING_SCHEMA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testWriteAsMap() throws Exception
phone2.put("number", "654321");
phones.add(phone2);

Map<String,Object> person = new LinkedHashMap<String,Object>(); // it is ok if using HashMap.
Map<String,Object> person = new LinkedHashMap<>(); // it is ok if using HashMap.
person.put("id", 1111);
person.put("name", "aaaa");
person.put("phone", phones);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public WriteBigArrayTest() throws Exception {
PACKED_STRING_SCHEMA = ProtobufSchemaLoader.std.parse(PROTOC_STRING_ARRAY_PACKED);
}

static class StringArray {
public static class StringArray {
public String[] values;

public StringArray() { }
Expand All @@ -51,7 +51,7 @@ public StringArray(List<String> v) {
public int size() { return values.length; }
}

static class StringArrayWrapper
public static class StringArrayWrapper
{
public StringArray values;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class WriteBinaryTest extends ProtobufTestBase
;

@JsonPropertyOrder({ "id", "trailer", "data"})
static class Binary {
public static class Binary {
public int id, trailer;
public byte[] data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
*/
public class WriteErrorsTest extends ProtobufTestBase
{
static class Point3D extends Point {
public static class Point3D extends Point {
public int z;

protected Point3D() { }
public Point3D() { }
public Point3D(int x, int y, int z) {
super(x, y);
this.z = z;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class WriteSimpleTest extends ProtobufTestBase
{
static class Point3D extends Point {
public static class Point3D extends Point {
public int z;

public Point3D(int x, int y, int z) {
Expand All @@ -39,11 +39,11 @@ public Point3D(int x, int y, int z) {
;

@JsonPropertyOrder({ "id", "point" })
static class IdPoints {
public static class IdPoints {
public int id;
public List<Point> points;

protected IdPoints() { }
public IdPoints() { }

public IdPoints(int id, int x, int y) {
this.id = id;
Expand All @@ -64,7 +64,7 @@ public boolean equals(Object o) {
}
}

private final ObjectMapper MAPPER = new ObjectMapper(new ProtobufFactory());
private final ObjectMapper MAPPER = newObjectMapper();

/*
/**********************************************************
Expand Down

0 comments on commit f12cd41

Please sign in to comment.