Search in sources :

Example 41 with InputSource

use of org.xml.sax.InputSource in project liquibase by liquibase.

the class LiquibaseEntityResolverTest method whenSystemIdIsNotXsdLoadResourceFromBasepathWithResourceAccessor.

@Test
public void whenSystemIdIsNotXsdLoadResourceFromBasepathWithResourceAccessor() throws IOException, SAXException {
    PowerMockito.when(StreamUtil.singleInputStream(PATH_AND_SYSTEM_ID, resourceAccessor)).thenReturn(inputStream);
    InputSource result = liquibaseEntityResolver.resolveEntity(NAME, PUBLIC_ID, BASE_URI, FILE_SYSTEM_ID);
    assertThat(result.getByteStream()).isEqualTo(inputStream);
}
Also used : InputSource(org.xml.sax.InputSource) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 42 with InputSource

use of org.xml.sax.InputSource in project liquibase by liquibase.

the class LiquibaseEntityResolverTest method shouldReturnSchemaResolverResultWhenSystemIdIsValidXsd.

@Test
public void shouldReturnSchemaResolverResultWhenSystemIdIsValidXsd() throws IOException, SAXException {
    InputSource result = liquibaseEntityResolver.resolveEntity(NAME, PUBLIC_ID, BASE_URI, SYSTEM_ID);
    assertThat(result).isSameAs(inputSource);
}
Also used : InputSource(org.xml.sax.InputSource) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 43 with InputSource

use of org.xml.sax.InputSource in project liquibase by liquibase.

the class LiquibaseEntityResolverTest method whenSystemIdIsNotXsdAndResourceCouldNotBeLoadedFromResourceAccessorReturnNull.

@Test
public void whenSystemIdIsNotXsdAndResourceCouldNotBeLoadedFromResourceAccessorReturnNull() throws IOException, SAXException {
    PowerMockito.when(StreamUtil.singleInputStream(PATH_AND_SYSTEM_ID, resourceAccessor)).thenReturn(null);
    InputSource result = liquibaseEntityResolver.resolveEntity(NAME, PUBLIC_ID, BASE_URI, FILE_SYSTEM_ID);
    assertThat(result).isEqualTo(null);
}
Also used : InputSource(org.xml.sax.InputSource) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 44 with InputSource

use of org.xml.sax.InputSource in project liquibase by liquibase.

the class LiquibaseEntityResolverTest method shouldReturnSchemaResolverResultWhenSystemIdIsValidXsdAndSerializerIsNotNull.

@Test
public void shouldReturnSchemaResolverResultWhenSystemIdIsValidXsdAndSerializerIsNotNull() throws IOException, SAXException {
    liquibaseEntityResolver = new LiquibaseEntityResolver(serializer);
    liquibaseEntityResolver.useResoureAccessor(resourceAccessor, BASE_PATH);
    InputSource result = liquibaseEntityResolver.resolveEntity(NAME, PUBLIC_ID, BASE_URI, SYSTEM_ID);
    assertThat(result).isSameAs(inputSource);
}
Also used : InputSource(org.xml.sax.InputSource) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 45 with InputSource

use of org.xml.sax.InputSource in project liquibase by liquibase.

the class LiquibaseSchemaResolverTest method shouldReturnNullWhenXsdFileFoundIsNull.

@Test
public void shouldReturnNullWhenXsdFileFoundIsNull() {
    when(nameSpaceDetialsForParser.getLocalPath(SYSTEM_ID)).thenReturn(null);
    InputSource inputSource = liquibaseSchemaResolver.resolve(liquibaseParser);
    assertThat(inputSource).isNull();
}
Also used : InputSource(org.xml.sax.InputSource) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

InputSource (org.xml.sax.InputSource)1126 StringReader (java.io.StringReader)403 IOException (java.io.IOException)304 Document (org.w3c.dom.Document)282 SAXException (org.xml.sax.SAXException)281 DocumentBuilder (javax.xml.parsers.DocumentBuilder)263 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)214 XMLReader (org.xml.sax.XMLReader)194 Test (org.junit.Test)160 InputStream (java.io.InputStream)158 NodeList (org.w3c.dom.NodeList)146 Element (org.w3c.dom.Element)144 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)143 ByteArrayInputStream (java.io.ByteArrayInputStream)103 SAXParser (javax.xml.parsers.SAXParser)103 SAXSource (javax.xml.transform.sax.SAXSource)95 SAXParserFactory (javax.xml.parsers.SAXParserFactory)90 File (java.io.File)82 Node (org.w3c.dom.Node)82 URL (java.net.URL)65