### Question:
SpecificData extends GenericData { public static SpecificData get() { return INSTANCE; } SpecificData();  SpecificData(ClassLoader classLoader); @Override DatumReader createDatumReader(Schema schema); @Override DatumReader createDatumReader(Schema writer, Schema reader); @Override DatumWriter createDatumWriter(Schema schema); static SpecificData get(); static SpecificData getForSchema(Schema reader); static SpecificData getForClass(Class<T> c); boolean useCustomCoders(); void setCustomCoders(boolean flag); @Override Object createEnum(String symbol, Schema schema); Class getClass(Schema schema); static String getClassName(Schema schema); Schema getSchema(java.lang.reflect.Type type); Protocol getProtocol(Class iface); @SuppressWarnings("unchecked") static Object newInstance(Class c, Schema s); @Override Object createFixed(Object old, Schema schema); @Override Object newRecord(Object old, Schema schema); @SuppressWarnings("rawtypes") @Override /** * Create an InstanceSupplier that caches all information required for the * creation of a schema record instance rather than having to look them up for * each call (as newRecord would) */ InstanceSupplier getNewRecordSupplier(Schema schema); static BinaryDecoder getDecoder(ObjectInput in); static BinaryEncoder getEncoder(ObjectOutput out); @Override Object createString(Object value); static final String CLASS_PROP; static final String KEY_CLASS_PROP; static final String ELEMENT_PROP; static final Set<String> RESERVED_WORDS; }### Answer:
@Test public void testSpecificRecordBase() { final TestRecord record = new TestRecord(); record.put("x", 1); record.put("y", "str"); assertEquals(1, record.get("x")); assertEquals("str", record.get("y")); }
@Test public void testNonStringable() throws Exception { final Schema string = Schema.create(Type.STRING); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final Encoder encoder = EncoderFactory.get().directBinaryEncoder(baos, null); final DatumWriter<Object> writer = new SpecificDatumWriter<>(string); try { writer.write(new Object(), encoder); fail("Non stringable object should be rejected."); } catch (ClassCastException cce) { } }