use of org.apache.tools.ant.filters.StringInputStream in project OpenGrok by OpenGrok.
the class RuntimeEnvironmentTest method testLoadStatistics.
@Test
public void testLoadStatistics() throws IOException, ParseException {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
String json = "{" + "\"requests_per_minute_max\":3," + "\"timing\":{" + "\"*\":2288," + "\"xref\":53," + "\"root\":2235" + "}," + "\"minutes\":756," + "\"timing_min\":{" + "\"*\":2," + "\"xref\":2," + "\"root\":2235" + "}," + "\"timing_avg\":{" + "\"*\":572.0," + "\"xref\":17.666666666666668," + "\"root\":2235.0" + "}," + "\"request_categories\":{" + "\"*\":4," + "\"xref\":3," + "\"root\":1" + "}," + "\"day_histogram\":[0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,1]," + "\"requests\":4," + "\"requests_per_minute_min\":1," + "\"requests_per_minute\":3," + "\"requests_per_minute_avg\":0.005291005291005291," + "\"month_histogram\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0]," + "\"timing_max\":{" + "\"*\":2235," + "\"xref\":48," + "\"root\":2235" + "}" + "}";
try (InputStream in = new StringInputStream(json)) {
env.loadStatistics(in);
}
Statistics stats = env.getStatistics();
Assert.assertNotNull(stats);
Assert.assertEquals(756, stats.getMinutes());
Assert.assertEquals(4, stats.getRequests());
Assert.assertEquals(3, stats.getRequestsPerMinute());
Assert.assertEquals(1, stats.getRequestsPerMinuteMin());
Assert.assertEquals(3, stats.getRequestsPerMinuteMax());
Assert.assertEquals(0.005291005291005291, stats.getRequestsPerMinuteAvg(), 0.00005);
Assert.assertArrayEquals(new long[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, stats.getDayHistogram());
Assert.assertArrayEquals(new long[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0 }, stats.getMonthHistogram());
Assert.assertEquals(createMap(new Object[][] { { "*", 4L }, { "xref", 3L }, { "root", 1L } }), stats.getRequestCategories());
Assert.assertEquals(createMap(new Object[][] { { "*", 2288L }, { "xref", 53L }, { "root", 2235L } }), stats.getTiming());
Assert.assertEquals(createMap(new Object[][] { { "*", 2L }, { "xref", 2L }, { "root", 2235L } }), stats.getTimingMin());
Assert.assertEquals(createMap(new Object[][] { { "*", 2235L }, { "xref", 48L }, { "root", 2235L } }), stats.getTimingMax());
}
use of org.apache.tools.ant.filters.StringInputStream in project Gemma by PavlidisLab.
the class EutilFetch method parseStringInputStream.
public static Document parseStringInputStream(String details) throws SAXException, IOException, ParserConfigurationException {
DocumentBuilder builder = EutilFetch.factory.newDocumentBuilder();
int tries = 0;
while (true) {
try (InputStream is = new StringInputStream(details)) {
return builder.parse(is);
} catch (IOException e) {
tries = EutilFetch.tryAgainOrFail(tries, e);
}
}
}
use of org.apache.tools.ant.filters.StringInputStream in project jbosstools-hibernate by jbosstools.
the class ConsoleConfigUtils method customizeCfgXmlForPack.
/**
* Customize hibernate.cfg.xml file for the particular test package content.
* @param pack
* @throws CoreException
*/
public static void customizeCfgXmlForPack(IPackageFragment pack) throws CoreException {
StringInputStream sis = new StringInputStream(createCfgXmlContent(pack));
IFolder srcFolder = (IFolder) pack.getParent().getResource();
IFile iFile = srcFolder.getFile(CFG_FILE_NAME);
if (iFile.exists()) {
iFile.delete(true, null);
}
iFile.create(sis, true, null);
try {
sis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.apache.tools.ant.filters.StringInputStream in project jbosstools-hibernate by jbosstools.
the class ConsoleConfigUtils method customizeCfgXmlForPack.
/**
* Customize hibernate.cfg.xml file for the particular test package content.
* @param pack
* @throws CoreException
*/
public static void customizeCfgXmlForPack(IPackageFragment pack) throws CoreException {
StringInputStream sis = new StringInputStream(createCfgXmlContent(pack));
IFolder srcFolder = (IFolder) pack.getParent().getResource();
IFile iFile = srcFolder.getFile(CFG_FILE_NAME);
if (iFile.exists()) {
iFile.delete(true, null);
}
iFile.create(sis, true, null);
try {
sis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.apache.tools.ant.filters.StringInputStream in project kie-wb-common by kiegroup.
the class DMNMarshallerStandaloneTest method testContextEntryDataType.
@Test
@SuppressWarnings("unchecked")
public void testContextEntryDataType() throws Exception {
final DMNMarshallerStandalone marshaller = getDMNMarshaller();
final Context context = new Context();
context.setTypeRef(BuiltInType.DATE_TIME.asQName());
final ContextEntry contextEntry = new ContextEntry();
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.setTypeRef(BuiltInType.BOOLEAN.asQName());
literalExpression.getText().setValue("feel");
contextEntry.setExpression(literalExpression);
context.getContextEntry().add(contextEntry);
final Diagram<Graph, Metadata> mockedDiagram = newDiagramDecisionWithExpression(context);
final String marshalledSource = marshaller.marshall(mockedDiagram);
final Graph<?, Node<View, ?>> unmarshalledGraph = marshaller.unmarshall(createMetadata(), new StringInputStream(marshalledSource));
assertThat(unmarshalledGraph.nodes()).hasSize(2);
checkDecisionExpression(unmarshalledGraph, context);
}
Aggregations