use of com.yahoo.foo.SimpletypesConfig in project vespa by vespa-engine.
the class JRTConfigRequesterTest method testClosedSubscription.
@Test
public void testClosedSubscription() {
ConfigSubscriber subscriber = new ConfigSubscriber();
final TimingValues timingValues = getTestTimingValues();
JRTConfigSubscription<SimpletypesConfig> sub = createSubscription(subscriber, timingValues);
sub.close();
final MockConnection connection = new MockConnection(new MockConnection.OKResponseHandler());
JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
requester.request(sub);
assertThat(connection.getNumberOfRequests(), is(1));
// Check that no further request was sent?
try {
Thread.sleep(timingValues.getFixedDelay() * 2);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertThat(connection.getNumberOfRequests(), is(1));
}
use of com.yahoo.foo.SimpletypesConfig in project vespa by vespa-engine.
the class JRTConfigRequesterTest method testFatalErrorSubscribed.
@Test
public void testFatalErrorSubscribed() {
ConfigSubscriber subscriber = new ConfigSubscriber();
final TimingValues timingValues = getTestTimingValues();
JRTConfigSubscription<SimpletypesConfig> sub = createSubscription(subscriber, timingValues);
sub.setConfig(1L, config());
final MockConnection connection = new MockConnection(new ErrorResponseHandler());
JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
requester.request(sub);
waitUntilResponse(connection);
assertThat(requester.getFatalFailures(), is(1));
assertThat(requester.getTransientFailures(), is(0));
}
use of com.yahoo.foo.SimpletypesConfig in project vespa by vespa-engine.
the class ConfigResponseTest method require_that_slime_response_is_initialized.
@Test
public void require_that_slime_response_is_initialized() throws IOException {
ConfigPayload configPayload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
InnerCNode targetDef = dParser.getTree();
ConfigResponse response = SlimeConfigResponse.fromConfigPayload(configPayload, targetDef, 3, "mymd5");
List<String> payload = response.getLegacyPayload();
assertNotNull(payload);
assertThat(payload.size(), is(6));
assertThat(payload.get(0), is("boolval false"));
assertThat(response.getGeneration(), is(3L));
assertThat(response.getConfigMd5(), is("mymd5"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.serialize(baos, CompressionType.UNCOMPRESSED);
assertThat(baos.toString(), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
use of com.yahoo.foo.SimpletypesConfig in project vespa by vespa-engine.
the class ConfigResponseTest method require_that_slime_response_decompresses_on_serialize.
@Test
public void require_that_slime_response_decompresses_on_serialize() throws IOException {
ConfigPayload configPayload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
InnerCNode targetDef = dParser.getTree();
Utf8Array data = configPayload.toUtf8Array(true);
Utf8Array bytes = new Utf8Array(new LZ4PayloadCompressor().compress(data.getBytes()));
ConfigResponse response = new SlimeConfigResponse(bytes, targetDef, 3, "mymd5", CompressionInfo.create(CompressionType.LZ4, data.getByteLength()));
List<String> payload = response.getLegacyPayload();
assertNotNull(payload);
assertThat(payload.size(), is(6));
assertThat(payload.get(0), is("boolval false"));
assertThat(response.getGeneration(), is(3L));
assertThat(response.getConfigMd5(), is("mymd5"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.serialize(baos, CompressionType.UNCOMPRESSED);
assertThat(baos.toString(), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
Aggregations