@Test public void should_read_non_jta_datasource_name_from_xml_file() throws Exception { String singleNonJtaDataSourceDescriptor = FileLoader.loadAsString("persistence-non-jta.xml"); String dataSourceName = parser.obtainDataSourceName(singleNonJtaDataSourceDescriptor); assertThat(dataSourceName).isEqualTo("java:app/datasources/postgresql_ds_non_jta"); }
public String obtainDataSourceName(final String descriptor) { Document document = parseXmlDescriptor(descriptor); final NodeList persistenceUnits = document.getElementsByTagName("persistence-unit"); if (persistenceUnits.getLength() > 1) { throw new MultiplePersistenceUnitsException( "Multiple persistence units defined. Please specify default data source either in 'arquillian.xml' or by using @DataSource annotation"); } final Node persistenceUnit = persistenceUnits.item(0); Node dataSource = getJtaDataSource(persistenceUnit); if (dataSource == null) { dataSource = getNonJtaDataSource(persistenceUnit); } return dataSource.getTextContent(); }
PersistenceDescriptorParser { public String obtainDataSourceName(final String descriptor) { Document document = parseXmlDescriptor(descriptor); final NodeList persistenceUnits = document.getElementsByTagName("persistence-unit"); if (persistenceUnits.getLength() > 1) { throw new MultiplePersistenceUnitsException( "Multiple persistence units defined. Please specify default data source either in 'arquillian.xml' or by using @DataSource annotation"); } final Node persistenceUnit = persistenceUnits.item(0); Node dataSource = getJtaDataSource(persistenceUnit); if (dataSource == null) { dataSource = getNonJtaDataSource(persistenceUnit); } return dataSource.getTextContent(); } }
PersistenceDescriptorParser { public String obtainDataSourceName(final String descriptor) { Document document = parseXmlDescriptor(descriptor); final NodeList persistenceUnits = document.getElementsByTagName("persistence-unit"); if (persistenceUnits.getLength() > 1) { throw new MultiplePersistenceUnitsException( "Multiple persistence units defined. Please specify default data source either in 'arquillian.xml' or by using @DataSource annotation"); } final Node persistenceUnit = persistenceUnits.item(0); Node dataSource = getJtaDataSource(persistenceUnit); if (dataSource == null) { dataSource = getNonJtaDataSource(persistenceUnit); } return dataSource.getTextContent(); }  }
PersistenceDescriptorParser { public String obtainDataSourceName(final String descriptor) { Document document = parseXmlDescriptor(descriptor); final NodeList persistenceUnits = document.getElementsByTagName("persistence-unit"); if (persistenceUnits.getLength() > 1) { throw new MultiplePersistenceUnitsException( "Multiple persistence units defined. Please specify default data source either in 'arquillian.xml' or by using @DataSource annotation"); } final Node persistenceUnit = persistenceUnits.item(0); Node dataSource = getJtaDataSource(persistenceUnit); if (dataSource == null) { dataSource = getNonJtaDataSource(persistenceUnit); } return dataSource.getTextContent(); }  String obtainDataSourceName(final String descriptor); String obtainDataSourceName(final InputStream inputStream); }
PersistenceDescriptorParser { public String obtainDataSourceName(final String descriptor) { Document document = parseXmlDescriptor(descriptor); final NodeList persistenceUnits = document.getElementsByTagName("persistence-unit"); if (persistenceUnits.getLength() > 1) { throw new MultiplePersistenceUnitsException( "Multiple persistence units defined. Please specify default data source either in 'arquillian.xml' or by using @DataSource annotation"); } final Node persistenceUnit = persistenceUnits.item(0); Node dataSource = getJtaDataSource(persistenceUnit); if (dataSource == null) { dataSource = getNonJtaDataSource(persistenceUnit); } return dataSource.getTextContent(); }  String obtainDataSourceName(final String descriptor); String obtainDataSourceName(final InputStream inputStream);  }