/** * Creates a new <code>RequestCtx</code> by parsing XML from an * input stream. Note that this a convenience method, and it will * not do schema validation by default. You should be parsing the data * yourself, and then providing the root node to the other * <code>getInstance</code> method. If you use this convenience * method, you probably want to turn on validation by setting the * context schema file (see the programmer guide for more information * on this). * * @param input a stream providing the XML data * * @return a new <code>RequestCtx</code> * * @throws ParsingException if there is an error parsing the input */ public static RequestCtx getInstance(InputStream input) throws ParsingException { return getInstance(InputParser.parseInput(input, "Request")); }
/** * Creates a new <code>RequestCtx</code> by parsing XML from an * input stream. Note that this a convenience method, and it will * not do schema validation by default. You should be parsing the data * yourself, and then providing the root node to the other * <code>getInstance</code> method. If you use this convenience * method, you probably want to turn on validation by setting the * context schema file (see the programmer guide for more information * on this). * * @param input a stream providing the XML data * * @return a new <code>RequestCtx</code> * * @throws ParsingException if there is an error parsing the input */ public static RequestCtx getInstance(InputStream input) throws ParsingException { return getInstance(InputParser.parseInput(input, "Request")); }
@Test public void testSingletonRoundtrip() throws ParsingException { URI id = URI.create("lol:wut"); String issuer = null; Attribute expected = new SingletonAttribute(id, issuer, null, StringAttribute.getInstance("foo")); String encoded = expected.encode(); ByteArrayInputStream input = new ByteArrayInputStream(encoded.getBytes()); Attribute actual = BasicAttribute.getInstance(InputParser.parseInput(input, "Attribute")); assertEquals(expected, actual); } // Supports legacy test runners
@Test public void testBasicRoundtrip() throws ParsingException { URI id = URI.create("lol:wut"); String issuer = null; BasicAttribute expected = new BasicAttribute(id, issuer, null, StringAttribute.getInstance("foo")); String encoded = expected.encode(); ByteArrayInputStream input = new ByteArrayInputStream(encoded.getBytes()); Attribute actual = BasicAttribute.getInstance(InputParser.parseInput(input, "Attribute")); assertEquals(expected, actual); }