use of org.xml.sax.InputSource in project liquibase by liquibase.
the class LiquibaseSchemaResolver method getInputSourceFromXsd.
private InputSource getInputSourceFromXsd(NamespaceDetails namespaceDetails) {
if (systemId == null) {
return null;
}
LOGGER.debug("Found namespace details class " + namespaceDetails.getClass().getName() + " for " + systemId);
String xsdFile = namespaceDetails.getLocalPath(systemId);
LOGGER.debug("Local path for " + systemId + " is " + xsdFile);
if (xsdFile == null) {
return null;
}
try {
InputStream resourceAsStream = resourceAccessorXsdStreamResolver.getResourceAsStream(xsdFile);
if (resourceAsStream == null) {
LOGGER.debug("Could not find " + xsdFile + " locally");
return null;
}
LOGGER.debug("Successfully loaded XSD from " + xsdFile);
org.xml.sax.InputSource source = new org.xml.sax.InputSource(resourceAsStream);
source.setPublicId(publicId);
source.setSystemId(systemId);
return source;
} catch (Exception ex) {
LOGGER.debug("Error loading XSD", ex);
// We don't have the schema, try the network
return null;
}
}
use of org.xml.sax.InputSource in project liquibase by liquibase.
the class LiquibaseEntityResolverTest method resolveEntityWithOnlyPublicIdAndSystemIdDelegatesToSchemResolver.
@Test
public void resolveEntityWithOnlyPublicIdAndSystemIdDelegatesToSchemResolver() throws IOException, SAXException {
InputSource result = liquibaseEntityResolver.resolveEntity(PUBLIC_ID, SYSTEM_ID);
assertThat(result).isSameAs(inputSource);
}
use of org.xml.sax.InputSource in project liquibase by liquibase.
the class LiquibaseEntityResolverTest method getExternalSubsetShouldReturnNull.
@Test
public void getExternalSubsetShouldReturnNull() throws IOException, SAXException {
InputSource externalSubset = liquibaseEntityResolver.getExternalSubset(NAME, BASE_URI);
assertThat(externalSubset).isNull();
}
use of org.xml.sax.InputSource in project liquibase by liquibase.
the class LiquibaseEntityResolverTest method shouldReturnNullSystemIdIsNull.
@Test
public void shouldReturnNullSystemIdIsNull() throws Exception {
InputSource result = liquibaseEntityResolver.resolveEntity(NAME, PUBLIC_ID, BASE_URI, null);
assertThat(result).isNull();
}
use of org.xml.sax.InputSource in project liquibase by liquibase.
the class LiquibaseEntityResolverTest method whenSystemIdIsNotXsdAndResourceExceptionOccursReturnNull.
@Test
public void whenSystemIdIsNotXsdAndResourceExceptionOccursReturnNull() throws IOException, SAXException {
PowerMockito.when(StreamUtil.singleInputStream(PATH_AND_SYSTEM_ID, resourceAccessor)).thenThrow(new RuntimeException());
InputSource result = liquibaseEntityResolver.resolveEntity(NAME, PUBLIC_ID, BASE_URI, FILE_SYSTEM_ID);
assertThat(result).isEqualTo(null);
}
Aggregations