IonFactory extends JsonFactory { @Override public JsonParser createParser(InputStream in) throws IOException, JsonParseException { return new IonParser(ionSystem.newReader(in), SHOULD_CLOSE_READER_NO); } IonFactory(IonSystem ionSystem); @Override JsonParser createParser(InputStream in); @Override JsonParser createParser(byte[] data); @Override JsonParser createParser(byte[] data, int offset, int length); @Override JsonParser createParser(char[] data); @Override JsonParser createParser(char[] data, int offset, int length); @Override JsonParser createParser(String data); @Override JsonParser createParser(Reader data); @Override JsonParser createParser(File data); @Override JsonParser createParser(URL data);  }
@Test public void createParserFromByteArray() throws Exception { assertThat(factory.createParser(new byte[0]), instanceOf(IonParser.class)); }
@Test(expected = UnsupportedOperationException.class) public void createParserFromCharArray() throws Exception { assertThat(factory.createParser(new char[0]), instanceOf(IonParser.class)); }
@Test public void createParserFromFile() throws Exception { File file = File.createTempFile("IonFactoryTest", null); file.deleteOnExit(); assertThat(factory.createParser(file), instanceOf(IonParser.class)); }
@Test public void createParserFromInputStream() throws Exception { assertThat(factory.createParser(new ByteArrayInputStream(new byte[0])), instanceOf(IonParser.class)); }
@Test public void createParserFromReader() throws Exception { assertThat(factory.createParser(new InputStreamReader(new ByteArrayInputStream(new byte[0]))), instanceOf(IonParser.class)); }
@Test public void createParserFromString() throws Exception { assertThat(factory.createParser(""), instanceOf(IonParser.class)); }
@Test public void createParserFromUrl() throws Exception { class NullUrlConnection extends URLConnection { protected NullUrlConnection(URL url) { super(url); } @Override public void connect() throws IOException { } @Override public InputStream getInputStream() { return new ByteArrayInputStream(new byte[0]); } }; class NullUrlStreamHandler extends URLStreamHandler { @Override protected URLConnection openConnection(URL u) throws IOException { return new NullUrlConnection(u); } }; assertThat(factory.createParser(new URL("foo", "bar", 99, "baz", new NullUrlStreamHandler())), instanceOf(IonParser.class)); }
@Test public void createParserFromByteArrayWithOffsetAndLength() throws Exception { assertThat(factory.createParser(new byte[0], 0, 0), instanceOf(IonParser.class)); }
@Test(expected = UnsupportedOperationException.class) public void createParserFromCharArrayWithOffsetAndLength() throws Exception { factory.createParser(new char[0], 0, 0); }