Search in sources :

Example 16 with IonCatalog

use of com.amazon.ion.IonCatalog in project ion-java by amzn.

the class IonSystemBuilderTest method testCustomCatalog.

@Test
public void testCustomCatalog() {
    IonCatalog catalog = new SimpleCatalog();
    IonSystemBuilder b = IonSystemBuilder.standard().copy();
    b.setCatalog(catalog);
    assertSame(catalog, b.getCatalog());
    IonSystem ion = b.build();
    assertSame(catalog, ion.getCatalog());
}
Also used : IonSystem(com.amazon.ion.IonSystem) IonCatalog(com.amazon.ion.IonCatalog) Test(org.junit.Test)

Example 17 with IonCatalog

use of com.amazon.ion.IonCatalog in project ion-java by amzn.

the class IonSystemBuilderTest method testWithCatalog.

@Test
public void testWithCatalog() {
    IonCatalog catalog = new SimpleCatalog();
    IonSystemBuilder b = IonSystemBuilder.standard().withCatalog(catalog);
    assertSame(catalog, b.getCatalog());
}
Also used : IonCatalog(com.amazon.ion.IonCatalog) Test(org.junit.Test)

Example 18 with IonCatalog

use of com.amazon.ion.IonCatalog in project ion-java by amzn.

the class IonTextWriterBuilderTest method testCustomCatalog.

// -------------------------------------------------------------------------
@Test
public void testCustomCatalog() {
    IonCatalog catalog = new SimpleCatalog();
    IonTextWriterBuilder b = IonTextWriterBuilder.standard();
    b.setCatalog(catalog);
    assertSame(catalog, b.getCatalog());
    StringBuilder out = new StringBuilder();
    IonWriter writer = b.build(out);
    assertSame(catalog, ((_Private_IonWriter) writer).getCatalog());
    IonCatalog catalog2 = new SimpleCatalog();
    b.setCatalog(catalog2);
    assertSame(catalog2, b.getCatalog());
    // Test with...() on mutable builder
    IonTextWriterBuilder b2 = b.withCatalog(catalog);
    assertSame(b, b2);
    assertSame(catalog, b2.getCatalog());
    // Test with...() on immutable builder
    b2 = b.immutable();
    assertSame(catalog, b2.getCatalog());
    IonTextWriterBuilder b3 = b2.withCatalog(catalog2);
    assertNotSame(b2, b3);
    assertSame(catalog, b2.getCatalog());
    assertSame(catalog2, b3.getCatalog());
}
Also used : IonCatalog(com.amazon.ion.IonCatalog) IonWriter(com.amazon.ion.IonWriter) com.amazon.ion.impl._Private_IonWriter(com.amazon.ion.impl._Private_IonWriter) Test(org.junit.Test)

Example 19 with IonCatalog

use of com.amazon.ion.IonCatalog in project ion-java by amzn.

the class IonTextWriterBuilderTest method testCatalogImmutability.

@Test(expected = UnsupportedOperationException.class)
public void testCatalogImmutability() {
    IonCatalog catalog = new SimpleCatalog();
    IonTextWriterBuilder b = IonTextWriterBuilder.standard();
    b.setCatalog(catalog);
    IonTextWriterBuilder b2 = b.immutable();
    assertSame(catalog, b2.getCatalog());
    b2.setCatalog(null);
}
Also used : IonCatalog(com.amazon.ion.IonCatalog) Test(org.junit.Test)

Aggregations

IonCatalog (com.amazon.ion.IonCatalog)19 Test (org.junit.Test)12 IonSystem (com.amazon.ion.IonSystem)5 SymbolTable (com.amazon.ion.SymbolTable)5 IonWriter (com.amazon.ion.IonWriter)4 com.amazon.ion.impl._Private_IonBinaryWriterBuilder (com.amazon.ion.impl._Private_IonBinaryWriterBuilder)3 com.amazon.ion.impl._Private_IonWriter (com.amazon.ion.impl._Private_IonWriter)2 IonDatagram (com.amazon.ion.IonDatagram)1 IonException (com.amazon.ion.IonException)1 IonReader (com.amazon.ion.IonReader)1 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1