use of org.commonjava.maven.galley.model.SimpleLocation in project indy by Commonjava.
the class ContentControllerTest method detectHtml_HtmlDoctypeDeclaration.
@Test
public void detectHtml_HtmlDoctypeDeclaration() throws Exception {
final ConcreteResource res = new ConcreteResource(new SimpleLocation("test:uri"), "file.html");
final Transfer tx = fixture.getCache().getTransfer(res);
PrintWriter writer = null;
try {
writer = new PrintWriter(new OutputStreamWriter(tx.openOutputStream(TransferOperation.GENERATE)));
writer.print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n" + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
writer.flush();
} finally {
IOUtils.closeQuietly(writer);
}
assertThat(content.isHtmlContent(tx), equalTo(true));
}
use of org.commonjava.maven.galley.model.SimpleLocation in project indy by Commonjava.
the class ContentControllerTest method detectHtml_MultipleHtmlElementsOnALine.
@Test
public void detectHtml_MultipleHtmlElementsOnALine() throws Exception {
final ConcreteResource res = new ConcreteResource(new SimpleLocation("test:uri"), "file.html");
final Transfer tx = fixture.getCache().getTransfer(res);
PrintWriter writer = null;
try {
writer = new PrintWriter(new OutputStreamWriter(tx.openOutputStream(TransferOperation.GENERATE)));
writer.print("<html><body><h1>FOO</h1>");
writer.flush();
} finally {
IOUtils.closeQuietly(writer);
}
assertThat(content.isHtmlContent(tx), equalTo(true));
}
use of org.commonjava.maven.galley.model.SimpleLocation in project indy by Commonjava.
the class ContentControllerTest method detectHtml_SingleHtmlElementLineWithPrecedingWhitespace.
@Test
public void detectHtml_SingleHtmlElementLineWithPrecedingWhitespace() throws Exception {
final ConcreteResource res = new ConcreteResource(new SimpleLocation("test:uri"), "file.html");
final Transfer tx = fixture.getCache().getTransfer(res);
PrintWriter writer = null;
try {
writer = new PrintWriter(new OutputStreamWriter(tx.openOutputStream(TransferOperation.GENERATE)));
writer.print(" <html>");
writer.flush();
} finally {
IOUtils.closeQuietly(writer);
}
assertThat(content.isHtmlContent(tx), equalTo(true));
}
use of org.commonjava.maven.galley.model.SimpleLocation in project galley by Commonjava.
the class AbstractMavenViewTest method loadPoms.
protected MavenPomView loadPoms(final String[] activeProfileIds, final String... pomNames) throws Exception {
final List<DocRef<ProjectVersionRef>> stack = new ArrayList<DocRef<ProjectVersionRef>>();
ProjectVersionRef pvr = null;
for (final String pomName : pomNames) {
final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(getBaseResource() + pomName);
final Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
final ProjectVersionRef ref = xml.getProjectVersionRef(document);
if (pvr == null) {
pvr = ref;
}
final DocRef<ProjectVersionRef> dr = new DocRef<ProjectVersionRef>(ref, new SimpleLocation("http://localhost:8080/"), document);
stack.add(dr);
}
return new MavenPomView(pvr, stack, xpath, new StandardMaven304PluginDefaults(), new StandardMavenPluginImplications(xml), xml, activeProfileIds);
}
use of org.commonjava.maven.galley.model.SimpleLocation in project galley by Commonjava.
the class AbstractMavenViewTest method loadDocs.
protected MavenXmlView<ProjectRef> loadDocs(final Set<String> localOnlyPaths, final String... docNames) throws Exception {
final List<DocRef<ProjectRef>> stack = new ArrayList<DocRef<ProjectRef>>();
final ProjectRef pr = new SimpleProjectRef("not.used", "project-ref");
for (final String pomName : docNames) {
final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(getBaseResource() + pomName);
final Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
final DocRef<ProjectRef> dr = new DocRef<ProjectRef>(pr, new SimpleLocation("http://localhost:8080/"), document);
stack.add(dr);
}
return new MavenXmlView<ProjectRef>(stack, xpath, xml, localOnlyPaths.toArray(new String[localOnlyPaths.size()]));
}
Aggregations