// [JACKSON-684]
  public void testAsIndex() throws Exception {
    // By default, serialize using name
    ObjectMapper m = new ObjectMapper();
    assertFalse(m.isEnabled(SerializationFeature.WRITE_ENUMS_USING_INDEX));
    assertEquals(quote("B"), m.writeValueAsString(TestEnum.B));

    // but we can change (dynamically, too!) it to be number-based
    m.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX);
    assertEquals("1", m.writeValueAsString(TestEnum.B));
  }
  // Test to ensure that we can check property ordering defaults...
  public void testConfigForPropertySorting() throws Exception {
    ObjectMapper m = new ObjectMapper();

    // sort-alphabetically is disabled by default:
    assertFalse(m.isEnabled(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY));
    SerializationConfig sc = m.getSerializationConfig();
    assertFalse(sc.isEnabled(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY));
    assertFalse(sc.shouldSortPropertiesAlphabetically());
    DeserializationConfig dc = m.getDeserializationConfig();
    assertFalse(dc.shouldSortPropertiesAlphabetically());

    // but when enabled, should be visible:
    m.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
    sc = m.getSerializationConfig();
    assertTrue(sc.isEnabled(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY));
    assertTrue(sc.shouldSortPropertiesAlphabetically());
    dc = m.getDeserializationConfig();
    // and not just via SerializationConfig, but also via DeserializationConfig
    assertTrue(dc.isEnabled(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY));
    assertTrue(dc.shouldSortPropertiesAlphabetically());
  }
  // [Issue#28]: ObjectMapper.copy()
  public void testCopy() throws Exception {
    ObjectMapper m = new ObjectMapper();
    assertTrue(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
    m.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    assertFalse(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
    InjectableValues inj = new InjectableValues.Std();
    m.setInjectableValues(inj);
    assertFalse(m.isEnabled(JsonParser.Feature.ALLOW_COMMENTS));
    m.enable(JsonParser.Feature.ALLOW_COMMENTS);
    assertTrue(m.isEnabled(JsonParser.Feature.ALLOW_COMMENTS));

    // // First: verify that handling of features is decoupled:

    ObjectMapper m2 = m.copy();
    assertFalse(m2.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
    m2.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    assertTrue(m2.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
    assertSame(inj, m2.getInjectableValues());

    // but should NOT change the original
    assertFalse(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));

    // nor vice versa:
    assertFalse(m.isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE));
    assertFalse(m2.isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE));
    m.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
    assertTrue(m.isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE));
    assertFalse(m2.isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE));

    // // Also, underlying JsonFactory instances should be distinct

    assertNotSame(m.getFactory(), m2.getFactory());

    // [Issue#122]: Need to ensure mix-ins are not shared
    assertEquals(0, m.getSerializationConfig().mixInCount());
    assertEquals(0, m2.getSerializationConfig().mixInCount());
    assertEquals(0, m.getDeserializationConfig().mixInCount());
    assertEquals(0, m2.getDeserializationConfig().mixInCount());

    m.addMixIn(String.class, Integer.class);
    assertEquals(1, m.getSerializationConfig().mixInCount());
    assertEquals(0, m2.getSerializationConfig().mixInCount());
    assertEquals(1, m.getDeserializationConfig().mixInCount());
    assertEquals(0, m2.getDeserializationConfig().mixInCount());

    // [Issue#913]: Ensure JsonFactory Features copied
    assertTrue(m2.isEnabled(JsonParser.Feature.ALLOW_COMMENTS));
  }