use of com.netflix.discovery.converters.wrappers.DecoderWrapper in project eureka by Netflix.
the class ApplicationResourceTest method testMiniAppGet.
@Test
public void testMiniAppGet() throws Exception {
Response response = applicationResource.getApplication(Version.V2.name(), MediaType.APPLICATION_JSON, EurekaAccept.compact.name());
String json = String.valueOf(response.getEntity());
DecoderWrapper decoder = CodecWrappers.getDecoder(CodecWrappers.LegacyJacksonJson.class);
Application decodedApp = decoder.decode(json, Application.class);
// assert false as one is mini, so should NOT equal
assertThat(EurekaEntityComparators.equal(testApplication, decodedApp), is(false));
for (InstanceInfo instanceInfo : testApplication.getInstances()) {
InstanceInfo decodedInfo = decodedApp.getByInstanceId(instanceInfo.getId());
assertThat(EurekaEntityComparators.equalMini(instanceInfo, decodedInfo), is(true));
}
}
use of com.netflix.discovery.converters.wrappers.DecoderWrapper in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testInstanceInfoEncodeDecodeJsonWithEmptyMetadataMap.
@Test
public void testInstanceInfoEncodeDecodeJsonWithEmptyMetadataMap() throws Exception {
final InstanceInfo base = infoIterator.next();
final InstanceInfo instanceInfo = new InstanceInfo.Builder(base).setMetadata(Collections.EMPTY_MAP).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.equal(instanceInfo, decodedValue), is(true));
}
};
verifyAllPairs(codingAction, Application.class, availableJsonWrappers);
verifyAllPairs(codingAction, Application.class, availableXmlWrappers);
}
use of com.netflix.discovery.converters.wrappers.DecoderWrapper 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.DecoderWrapper 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.DecoderWrapper 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);
}
Aggregations