JetConfigXmlGenerator { public static String generate(JetConfig jetConfig) { return generate(jetConfig, -1); } private  JetConfigXmlGenerator(); static String generate(JetConfig jetConfig); static String generate(JetConfig jetConfig, int indent);  }
@Test public void when_defaultJetConfig_thenGeneratesDefaultXml() { JetConfig jetConfig = new JetConfig(); String xml = generate(jetConfig); JetConfig generatedConfig = jetConfig(xml); assertInstanceConfig(jetConfig.getInstanceConfig(), generatedConfig.getInstanceConfig()); assertEdgeConfig(jetConfig.getDefaultEdgeConfig(), generatedConfig.getDefaultEdgeConfig()); assertProperties(jetConfig.getProperties(), generatedConfig.getProperties()); }
@Test public void properties() { JetConfig jetConfig = new JetConfig(); jetConfig.setProperty("key", "value"); jetConfig.setProperty("toEscape", TO_ESCAPE); String xml = generate(jetConfig, 5); JetConfig generatedConfig = jetConfig(xml); assertProperties(jetConfig.getProperties(), generatedConfig.getProperties()); }
@Test public void instanceConfig() { JetConfig jetConfig = new JetConfig(); InstanceConfig instanceConfig = jetConfig.getInstanceConfig(); instanceConfig.setCooperativeThreadCount(randomInt()) .setBackupCount(randomInt(6)) .setScaleUpDelayMillis(randomInt()) .setFlowControlPeriodMs(randomInt()) .setLosslessRestartEnabled(true); String xml = generate(jetConfig); JetConfig generatedConfig = jetConfig(xml); assertInstanceConfig(instanceConfig, generatedConfig.getInstanceConfig()); }
@Test public void edgeConfig() { JetConfig jetConfig = new JetConfig(); EdgeConfig defaultEdgeConfig = jetConfig.getDefaultEdgeConfig(); defaultEdgeConfig.setQueueSize(randomInt()) .setPacketSizeLimit(randomInt()) .setReceiveWindowMultiplier(randomInt()); String xml = generate(jetConfig); JetConfig generatedConfig = jetConfig(xml); assertEdgeConfig(defaultEdgeConfig, generatedConfig.getDefaultEdgeConfig()); }