use of javax.xml.bind.Unmarshaller in project asterixdb by apache.
the class TestHelper method getConfigurations.
public static AsterixConfiguration getConfigurations(String fileName) throws IOException, JAXBException, AsterixException {
try (InputStream is = TestHelper.class.getClassLoader().getResourceAsStream(fileName)) {
if (is != null) {
JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
Unmarshaller unmarshaller = ctx.createUnmarshaller();
return (AsterixConfiguration) unmarshaller.unmarshal(is);
} else {
throw new AsterixException("Could not find configuration file " + fileName);
}
}
}
use of javax.xml.bind.Unmarshaller in project asterixdb by apache.
the class Utils method loadAsterixConfig.
public static AsterixConfiguration loadAsterixConfig(String path) throws IOException {
File f = new File(path);
try {
JAXBContext configCtx = JAXBContext.newInstance(AsterixConfiguration.class);
Unmarshaller unmarshaller = configCtx.createUnmarshaller();
AsterixConfiguration conf = (AsterixConfiguration) unmarshaller.unmarshal(f);
return conf;
} catch (JAXBException e) {
throw new IOException(e);
}
}
use of javax.xml.bind.Unmarshaller in project asterixdb by apache.
the class AsterixInstallerIntegrationUtil method initZookeeperTestConfiguration.
private static void initZookeeperTestConfiguration(int port) throws JAXBException, FileNotFoundException {
String installerConfPath = InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_CONF_XML;
JAXBContext ctx = JAXBContext.newInstance(Configuration.class);
Unmarshaller unmarshaller = ctx.createUnmarshaller();
Configuration configuration = (Configuration) unmarshaller.unmarshal(new File(installerConfPath));
configuration.getZookeeper().setClientPort(new BigInteger("" + port));
Marshaller marshaller = ctx.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(configuration, new FileOutputStream(installerConfPath));
}
use of javax.xml.bind.Unmarshaller in project asterixdb by apache.
the class InstallerUtil method getAsterixConfiguration.
public static AsterixConfiguration getAsterixConfiguration(String asterixConf) throws FileNotFoundException, IOException, JAXBException {
if (asterixConf == null) {
asterixConf = InstallerDriver.getManagixHome() + File.separator + DEFAULT_ASTERIX_CONFIGURATION_PATH;
}
File file = new File(asterixConf);
JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
Unmarshaller unmarshaller = ctx.createUnmarshaller();
AsterixConfiguration asterixConfiguration = (AsterixConfiguration) unmarshaller.unmarshal(file);
return asterixConfiguration;
}
use of javax.xml.bind.Unmarshaller in project asterixdb by apache.
the class TestSuiteParser method parse.
public org.apache.asterix.testframework.xml.TestSuite parse(File testSuiteCatalog) throws Exception {
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setNamespaceAware(true);
saxParserFactory.setXIncludeAware(true);
SAXParser saxParser = saxParserFactory.newSAXParser();
saxParser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "file");
JAXBContext ctx = JAXBContext.newInstance(org.apache.asterix.testframework.xml.TestSuite.class);
Unmarshaller um = ctx.createUnmarshaller();
return (org.apache.asterix.testframework.xml.TestSuite) um.unmarshal(new SAXSource(saxParser.getXMLReader(), new InputSource(testSuiteCatalog.toURI().toString())));
}
Aggregations