use of com.netflix.discovery.converters.wrappers.EncoderWrapper in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testInstanceInfoEncodeDecodeLegacyJacksonToJackson.
/**
* @deprecated see to do note in {@link com.netflix.appinfo.LeaseInfo} and delete once legacy is removed
*/
@Deprecated
@Test
public void testInstanceInfoEncodeDecodeLegacyJacksonToJackson() 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);
// convert the field from the json string to what the legacy json would encode as
encodedString = encodedString.replaceFirst("lastRenewalTimestamp", "renewalTimestamp");
InstanceInfo decodedValue = decodingCodec.decode(encodedString, InstanceInfo.class);
assertThat(EurekaEntityComparators.equal(instanceInfo, decodedValue, new EurekaEntityComparators.RawIdEqualFunc()), is(true));
assertThat(EurekaEntityComparators.equal(instanceInfo, decodedValue), is(true));
}
};
verifyForPair(codingAction, InstanceInfo.class, new CodecWrappers.LegacyJacksonJson(), new CodecWrappers.JacksonJson());
}
use of com.netflix.discovery.converters.wrappers.EncoderWrapper in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testBatchRequestEncoding.
@Test
public void testBatchRequestEncoding() throws Exception {
InstanceInfo instance = InstanceInfoGenerator.takeOne();
List<ReplicationInstance> replicationInstances = new ArrayList<>();
replicationInstances.add(new ReplicationInstance(instance.getAppName(), instance.getId(), System.currentTimeMillis(), null, instance.getStatus().name(), instance, Action.Register));
final ReplicationList replicationList = new ReplicationList(replicationInstances);
Action2 codingAction = new Action2() {
@Override
public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException {
String encodedString = encodingCodec.encode(replicationList);
ReplicationList decodedValue = decodingCodec.decode(encodedString, ReplicationList.class);
assertThat(decodedValue.getReplicationList().size(), is(equalTo(1)));
}
};
// In replication channel we use JSON only
List<CodecWrapper> jsonCodes = Arrays.asList(new CodecWrappers.JacksonJson(), new CodecWrappers.LegacyJacksonJson());
verifyAllPairs(codingAction, ReplicationList.class, jsonCodes);
}
use of com.netflix.discovery.converters.wrappers.EncoderWrapper in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testInstanceInfoFullEncodeMiniDecodeJackson.
/**
* During deserialization process in compact mode not all fields might be filtered out. If JVM memory
* is an issue, compact version of the encoder should be used on the server side.
*/
@Test
public void testInstanceInfoFullEncodeMiniDecodeJackson() 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.equalMini(instanceInfo, decodedValue), is(true));
}
};
verifyForPair(codingAction, InstanceInfo.class, new CodecWrappers.JacksonJson(), new CodecWrappers.JacksonJsonMini());
}
use of com.netflix.discovery.converters.wrappers.EncoderWrapper in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testInstanceInfoFullEncodeMiniDecodeJacksonWithMyOwnDataCenterInfo.
@Test
public void testInstanceInfoFullEncodeMiniDecodeJacksonWithMyOwnDataCenterInfo() throws Exception {
final InstanceInfo base = infoIterator.next();
final InstanceInfo instanceInfo = new InstanceInfo.Builder(base).setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)).build();
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.equalMini(instanceInfo, decodedValue), is(true));
}
};
verifyForPair(codingAction, InstanceInfo.class, new CodecWrappers.JacksonJson(), new CodecWrappers.JacksonJsonMini());
}
use of com.netflix.discovery.converters.wrappers.EncoderWrapper in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testInstanceInfoMiniEncodeMiniDecodeJackson.
@Test
public void testInstanceInfoMiniEncodeMiniDecodeJackson() 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.equalMini(instanceInfo, decodedValue), is(true));
}
};
verifyForPair(codingAction, InstanceInfo.class, new CodecWrappers.JacksonJsonMini(), new CodecWrappers.JacksonJsonMini());
}
Aggregations