List of usage examples for javax.xml.stream XMLStreamException XMLStreamException
public XMLStreamException(String msg, Location location)
From source file:org.wso2.dss.integration.test.services.DistributedTransactionTestCase.java
private DataHandler getArtifactWithDTP(String serviceFile) throws Exception { SqlDataSourceUtil dataSource1;// ww w . ja v a 2s .c o m SqlDataSourceUtil dataSource2; String dtpDriver; dataSource1 = new SqlDataSourceUtil(sessionCookie, dssContext.getContextUrls().getBackEndUrl()); dataSource2 = new SqlDataSourceUtil(sessionCookie, dssContext.getContextUrls().getBackEndUrl()); dataSource1.createDataSource(getSqlScript()); dataSource2.createDataSource(databaseNameNew, getSqlScript()); //this should be set according to tha database server if (dataSource1.getDriver().contains("h2")) { dtpDriver = "org.h2.jdbcx.JdbcDataSource"; } else if (dataSource1.getDriver().contains("mysql")) { dtpDriver = "com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"; } else { dtpDriver = "Not.Defined"; } try { OMElement dbsFile = AXIOMUtil .stringToOM( FileManager .readFile(getResourceLocation() + File.separator + "dbs" + File.separator + "rdbms" + File.separator + "MySql" + File.separator + serviceFile) .trim()); OMElement dbsConfig; Iterator config = dbsFile.getChildrenWithName(new QName("config")); while (config.hasNext()) { String jdbc; String user; String passwd; dbsConfig = (OMElement) config.next(); if (dbsConfig.getAttributeValue(new QName("id")).equals("MySqlDataSource1")) { jdbc = dataSource1.getJdbcUrl(); user = dataSource1.getDatabaseUser(); passwd = dataSource1.getDatabasePassword(); } else { jdbc = dataSource2.getJdbcUrl(); user = dataSource2.getDatabaseUser(); passwd = dataSource2.getDatabasePassword(); } Iterator configElement = dbsConfig.getChildElements(); while (configElement.hasNext()) { OMElement properties = (OMElement) configElement.next(); String datasource = properties.getAttributeValue(new QName("name")); if (datasource.equals("org.wso2.ws.dataservice.xa_datasource_properties")) { Iterator dbPropertyElement = properties.getChildElements(); while (dbPropertyElement.hasNext()) { OMElement property = (OMElement) dbPropertyElement.next(); String value = property.getAttributeValue(new QName("name")); if ("URL".equals(value)) { property.setText(jdbc); } else if ("user".equals(value)) { property.setText(user); } else if ("password".equals(value)) { property.setText(passwd); } } } else if (datasource.equals("org.wso2.ws.dataservice.xa_datasource_class")) { properties.setText(dtpDriver); } } } log.debug(dbsFile); ByteArrayDataSource dbs = new ByteArrayDataSource(dbsFile.toString().getBytes()); return new DataHandler(dbs); } catch (XMLStreamException e) { log.error("XMLStreamException when Reading Service File", e); throw new XMLStreamException("XMLStreamException when Reading Service File", e); } catch (IOException e) { log.error("IOException when Reading Service File", e); throw new IOException("IOException when Reading Service File", e); } }
From source file:org.wso2.ei.dataservice.integration.test.datasource.DataSourceInitializationAtStartUpTestCase.java
private DataHandler createArtifactWithDataSource(String serviceFileName) throws XMLStreamException, IOException, XPathExpressionException { Assert.assertNotNull("Carbon datasource name null. create carbon datasource first", carbonDataSourceName); try {/*from ww w . j a v a 2s . c o m*/ OMElement dbsFile = AXIOMUtil .stringToOM( FileManager .readFile(getResourceLocation() + File.separator + "dbs" + File.separator + "rdbms" + File.separator + "MySql" + File.separator + serviceFileName) .trim()); OMElement dbsConfig = dbsFile.getFirstChildWithName(new QName("config")); Iterator configElement1 = dbsConfig.getChildElements(); while (configElement1.hasNext()) { OMElement property = (OMElement) configElement1.next(); String value = property.getAttributeValue(new QName("name")); if ("carbon_datasource_name".equals(value)) { property.setText(carbonDataSourceName); } } if (log.isDebugEnabled()) { log.debug(dbsFile); } ByteArrayDataSource dbs = new ByteArrayDataSource(dbsFile.toString().getBytes()); return new DataHandler(dbs); } catch (XMLStreamException e) { log.error("XMLStreamException when Reading Service File", e); throw new XMLStreamException("XMLStreamException when Reading Service File", e); } catch (IOException e) { log.error("IOException when Reading Service File", e); throw new IOException("IOException when Reading Service File", e); } }
From source file:org.wso2.ei.dataservice.integration.test.faulty.service.EditFaultyDataServiceTest.java
@Test(groups = "wso2.dss", dependsOnMethods = { "isFaultyService" }, description = "Fix the fault and redeploy") public void editFaultyService() throws Exception { DataServiceAdminClient dataServiceAdminService = new DataServiceAdminClient( dssContext.getContextUrls().getBackEndUrl(), sessionCookie); String serviceContent;/* w ww. ja v a 2s . c o m*/ String newServiceContent; SqlDataSourceUtil dssUtil = new SqlDataSourceUtil(sessionCookie, dssContext.getContextUrls().getBackEndUrl()); dssUtil.createDataSource(getSqlScript()); serviceContent = dataServiceAdminService.getDataServiceContent(serviceName); try { OMElement dbsFile = AXIOMUtil.stringToOM(serviceContent); OMElement dbsConfig = dbsFile.getFirstChildWithName(new QName("config")); Iterator configElement1 = dbsConfig.getChildElements(); while (configElement1.hasNext()) { OMElement property = (OMElement) configElement1.next(); String value = property.getAttributeValue(new QName("name")); if ("org.wso2.ws.dataservice.protocol".equals(value)) { property.setText(dssUtil.getJdbcUrl()); } else if ("org.wso2.ws.dataservice.driver".equals(value)) { property.setText(dssUtil.getDriver()); } else if ("org.wso2.ws.dataservice.user".equals(value)) { property.setText(dssUtil.getDatabaseUser()); } else if ("org.wso2.ws.dataservice.password".equals(value)) { property.setText(dssUtil.getDatabasePassword()); } } if (log.isDebugEnabled()) { log.debug(dbsFile); } newServiceContent = dbsFile.toString(); } catch (XMLStreamException e) { log.error("XMLStreamException while handling data service content ", e); throw new XMLStreamException("XMLStreamException while handling data service content ", e); } Assert.assertNotNull("Could not edited service content", newServiceContent); dataServiceAdminService.editDataService(serviceName, "", newServiceContent); log.info(serviceName + " edited"); }