Search in sources :

Example 11 with CheckResult

use of aQute.bnd.deployer.repository.api.CheckResult in project bnd by bndtools.

the class TestR5Recognition method testAcceptOnCapabilityChildElementNames.

public static void testAcceptOnCapabilityChildElementNames() throws Exception {
    String testdata;
    ByteArrayInputStream stream;
    CheckResult result;
    // Must be R5
    testdata = "<repository><resource><capability><attribute/>...";
    stream = new ByteArrayInputStream(testdata.getBytes());
    result = new R5RepoContentProvider().checkStream("xxx", stream);
    assertEquals(accept, result.getDecision());
    // Must be R5
    testdata = "<repository><resource><capability><directive/>...";
    stream = new ByteArrayInputStream(testdata.getBytes());
    result = new R5RepoContentProvider().checkStream("xxx", stream);
    assertEquals(accept, result.getDecision());
    // Arbitrary elements under repo, resource and capability are allowed
    testdata = "<repository><XXX/><resource><YYY/><capability><ZZZ/><attribute/>...";
    stream = new ByteArrayInputStream(testdata.getBytes());
    result = new R5RepoContentProvider().checkStream("xxx", stream);
    assertEquals(accept, result.getDecision());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) CheckResult(aQute.bnd.deployer.repository.api.CheckResult)

Example 12 with CheckResult

use of aQute.bnd.deployer.repository.api.CheckResult in project bnd by bndtools.

the class TestR5Recognition method testUnparseable.

public static void testUnparseable() throws Exception {
    String testdata = "<?xml version='1.0' encoding='utf-8'?>" + "<repository name='index1'>";
    ByteArrayInputStream stream = new ByteArrayInputStream(testdata.getBytes());
    CheckResult result = new R5RepoContentProvider().checkStream("xxx", stream);
    assertEquals(reject, result.getDecision());
    assertTrue(result.getException() != null && result.getException() instanceof XMLStreamException);
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ByteArrayInputStream(java.io.ByteArrayInputStream) CheckResult(aQute.bnd.deployer.repository.api.CheckResult)

Aggregations

CheckResult (aQute.bnd.deployer.repository.api.CheckResult)12 ByteArrayInputStream (java.io.ByteArrayInputStream)9 XMLStreamException (javax.xml.stream.XMLStreamException)4 XMLInputFactory (javax.xml.stream.XMLInputFactory)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 IRepositoryContentProvider (aQute.bnd.deployer.repository.api.IRepositoryContentProvider)1 BufferedInputStream (java.io.BufferedInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1