use of com.yahoo.config.subscription.impl.MockConnection in project vespa by vespa-engine.
the class JRTConfigRequestBase method created_from_existing_subscription.
@Test
public void created_from_existing_subscription() {
System.setProperty("VESPA_CONFIG_PROTOCOL_VERSION", getProtocolVersion());
MockConnection connection = new MockConnection(new MockConnection.AbstractResponseHandler() {
@Override
protected void createResponse() {
JRTServerConfigRequest serverRequest = createReq(request);
serverRequest.addOkResponse(createPayload(), currentGeneration, configMd5);
}
});
ConfigSourceSet src = new ConfigSourceSet();
ConfigSubscriber subscriber = new GenericConfigSubscriber(Collections.singletonMap(src, JRTConfigRequester.get(connection, new TimingValues())));
JRTConfigSubscription<SimpletypesConfig> sub = new JRTConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, configId), subscriber, src, new TimingValues());
sub.subscribe(120_0000);
assertTrue(sub.nextConfig(120_0000));
sub.close();
JRTClientConfigRequest nextReq = createReq(sub, Trace.createNew());
SimpletypesConfig config = sub.getConfigState().getConfig();
assertThat(nextReq.getRequestConfigMd5(), is(config.getConfigMd5()));
assertThat(nextReq.getRequestGeneration(), is(currentGeneration));
System.setProperty("VESPA_CONFIG_PROTOCOL_VERSION", "");
}
use of com.yahoo.config.subscription.impl.MockConnection in project vespa by vespa-engine.
the class GenericConfigSubscriberTest method testSubscribeGeneric.
@Test
public void testSubscribeGeneric() {
Map<ConfigSourceSet, JRTConfigRequester> requesters = new HashMap<>();
ConfigSourceSet sourceSet = new ConfigSourceSet("blabla");
requesters.put(sourceSet, JRTConfigRequester.get(new MockConnection(), JRTConfigRequesterTest.getTestTimingValues()));
GenericConfigSubscriber sub = new GenericConfigSubscriber(requesters);
final List<String> defContent = Arrays.asList("myVal int");
GenericConfigHandle handle = sub.subscribe(new ConfigKey<>("simpletypes", "id", "config"), defContent, sourceSet, JRTConfigRequesterTest.getTestTimingValues());
assertTrue(sub.nextConfig());
assertTrue(handle.isChanged());
// MockConnection returns empty string
assertThat(handle.getRawConfig().getPayload().withCompression(CompressionType.UNCOMPRESSED).toString(), is("{}"));
assertFalse(sub.nextConfig());
assertFalse(handle.isChanged());
}
Aggregations