use of com.netflix.discovery.converters.wrappers.EncoderWrapper in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testApplicationEncodeDecode.
@Test
public void testApplicationEncodeDecode() throws Exception {
final Application application = new Application("testApp");
application.addInstance(infoIterator.next());
application.addInstance(infoIterator.next());
Action2 codingAction = new Action2() {
@Override
public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException {
String encodedString = encodingCodec.encode(application);
Application decodedValue = decodingCodec.decode(encodedString, Application.class);
assertThat(EurekaEntityComparators.equal(application, decodedValue), is(true));
}
};
verifyAllPairs(codingAction, Application.class, availableJsonWrappers);
verifyAllPairs(codingAction, Application.class, availableXmlWrappers);
}
use of com.netflix.discovery.converters.wrappers.EncoderWrapper in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testInstanceInfoEncodeDecodeCompatibilityDueToOverriddenStatusRenamingV1.
// https://github.com/Netflix/eureka/issues/1051
// test going from camel case to lower case
@Test
public void testInstanceInfoEncodeDecodeCompatibilityDueToOverriddenStatusRenamingV1() throws Exception {
final InstanceInfo instanceInfo = infoIterator.next();
new InstanceInfo.Builder(instanceInfo).setOverriddenStatus(InstanceInfo.InstanceStatus.OUT_OF_SERVICE);
Action2 codingAction = new Action2() {
@Override
public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException {
String encodedString = encodingCodec.encode(instanceInfo);
// sed to older naming to test
encodedString = encodedString.replace("overriddenStatus", "overriddenstatus");
InstanceInfo decodedValue = decodingCodec.decode(encodedString, InstanceInfo.class);
assertThat(EurekaEntityComparators.equal(instanceInfo, decodedValue), is(true));
assertThat(EurekaEntityComparators.equal(instanceInfo, decodedValue, new EurekaEntityComparators.RawIdEqualFunc()), is(true));
}
};
verifyAllPairs(codingAction, Application.class, availableJsonWrappers);
verifyAllPairs(codingAction, Application.class, availableXmlWrappers);
}
use of com.netflix.discovery.converters.wrappers.EncoderWrapper in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testBatchResponseEncoding.
@Test
public void testBatchResponseEncoding() throws Exception {
List<ReplicationInstanceResponse> responseList = new ArrayList<>();
responseList.add(new ReplicationInstanceResponse(200, InstanceInfoGenerator.takeOne()));
final ReplicationListResponse replicationListResponse = new ReplicationListResponse(responseList);
Action2 codingAction = new Action2() {
@Override
public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException {
String encodedString = encodingCodec.encode(replicationListResponse);
ReplicationListResponse decodedValue = decodingCodec.decode(encodedString, ReplicationListResponse.class);
assertThat(decodedValue.getResponseList().size(), is(equalTo(1)));
}
};
// In replication channel we use JSON only
List<CodecWrapper> jsonCodes = Arrays.asList(new CodecWrappers.JacksonJson(), new CodecWrappers.LegacyJacksonJson());
verifyAllPairs(codingAction, ReplicationListResponse.class, jsonCodes);
}
use of com.netflix.discovery.converters.wrappers.EncoderWrapper in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testInstanceInfoEncodeDecode.
@Test
public void testInstanceInfoEncodeDecode() throws Exception {
final InstanceInfo instanceInfo = infoIterator.next();
Action2 codingAction = new Action2() {
@Override
public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException {
String encodedString = encodingCodec.encode(instanceInfo);
InstanceInfo decodedValue = decodingCodec.decode(encodedString, InstanceInfo.class);
assertThat(EurekaEntityComparators.equal(instanceInfo, decodedValue), is(true));
assertThat(EurekaEntityComparators.equal(instanceInfo, decodedValue, new EurekaEntityComparators.RawIdEqualFunc()), is(true));
}
};
verifyAllPairs(codingAction, InstanceInfo.class, availableJsonWrappers);
verifyAllPairs(codingAction, InstanceInfo.class, availableXmlWrappers);
}
use of com.netflix.discovery.converters.wrappers.EncoderWrapper in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testInstanceInfoEncodeDecodeCompatibilityDueToOverriddenStatusRenamingV2.
// same as the above, but go from lower case to camel case
@Test
public void testInstanceInfoEncodeDecodeCompatibilityDueToOverriddenStatusRenamingV2() throws Exception {
final InstanceInfo instanceInfo = infoIterator.next();
new InstanceInfo.Builder(instanceInfo).setOverriddenStatus(InstanceInfo.InstanceStatus.OUT_OF_SERVICE);
Action2 codingAction = new Action2() {
@Override
public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException {
String encodedString = encodingCodec.encode(instanceInfo);
// sed to older naming to test
encodedString = encodedString.replace("overriddenstatus", "overriddenStatus");
InstanceInfo decodedValue = decodingCodec.decode(encodedString, InstanceInfo.class);
assertThat(EurekaEntityComparators.equal(instanceInfo, decodedValue), is(true));
assertThat(EurekaEntityComparators.equal(instanceInfo, decodedValue, new EurekaEntityComparators.RawIdEqualFunc()), is(true));
}
};
verifyAllPairs(codingAction, Application.class, availableJsonWrappers);
verifyAllPairs(codingAction, Application.class, availableXmlWrappers);
}
Aggregations