use of org.xipki.ca.client.shell.loadtest.jaxb.EnrollTemplateType in project xipki by xipki.
the class CaLoadTestTemplateEnroll method parse.
// method nextCertRequests
public static EnrollTemplateType parse(InputStream configStream) throws InvalidConfException {
ParamUtil.requireNonNull("configStream", configStream);
Object root;
synchronized (jaxbUnmarshallerLock) {
try {
if (jaxbUnmarshaller == null) {
JAXBContext context = JAXBContext.newInstance(ObjectFactory.class);
jaxbUnmarshaller = context.createUnmarshaller();
final SchemaFactory schemaFact = SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
URL url = ObjectFactory.class.getResource("/xsd/loadtest.xsd");
jaxbUnmarshaller.setSchema(schemaFact.newSchema(url));
}
root = jaxbUnmarshaller.unmarshal(configStream);
} catch (SAXException ex) {
throw new InvalidConfException("parsing profile failed, message: " + ex.getMessage(), ex);
} catch (JAXBException ex) {
throw new InvalidConfException("parsing profile failed, message: " + XmlUtil.getMessage(ex), ex);
}
}
try {
configStream.close();
} catch (IOException ex) {
LOG.warn("could not close xmlConfStream: {}", ex.getMessage());
}
if (root instanceof JAXBElement) {
return (EnrollTemplateType) ((JAXBElement<?>) root).getValue();
} else {
throw new InvalidConfException("invalid root element type");
}
}
use of org.xipki.ca.client.shell.loadtest.jaxb.EnrollTemplateType in project xipki by xipki.
the class CaLoadTestTemplateEnrollCmd method execute0.
@Override
protected Object execute0() throws Exception {
if (numThreads < 1) {
throw new IllegalCmdParamException("invalid number of threads " + numThreads);
}
EnrollTemplateType template = CaLoadTestTemplateEnroll.parse(new FileInputStream(templateFile));
int size = template.getEnrollCert().size();
String description = StringUtil.concatObjectsCap(200, "template: ", templateFile, "\nmaxRequests: ", maxRequests, "\nunit: ", size, " certificate", (size > 1 ? "s" : ""), "\n");
CaLoadTestTemplateEnroll loadTest = new CaLoadTestTemplateEnroll(caClient, template, maxRequests, description);
loadTest.setDuration(duration);
loadTest.setThreads(numThreads);
loadTest.test();
return null;
}
Aggregations