private void switchToJson() throws PropertyException {
   marshallerValidOn.setProperty(JAXBContextProperties.MEDIA_TYPE, "application/json");
   marshallerValidOn.setProperty(JAXBContextProperties.JSON_INCLUDE_ROOT, true);
   unmarshallerValidOn.setProperty(JAXBContextProperties.MEDIA_TYPE, "application/json");
   unmarshallerValidOn.setProperty(JAXBContextProperties.JSON_INCLUDE_ROOT, true);
   marshallerValidOff.setProperty(JAXBContextProperties.MEDIA_TYPE, "application/json");
   marshallerValidOff.setProperty(JAXBContextProperties.JSON_INCLUDE_ROOT, true);
   unmarshallerValidOff.setProperty(JAXBContextProperties.MEDIA_TYPE, "application/json");
   unmarshallerValidOff.setProperty(JAXBContextProperties.JSON_INCLUDE_ROOT, true);
 }
 private void toggleDriversGroupOnOff() throws PropertyException {
   if (toggle ^= true) {
     marshallerValidOn.setProperty(
         MarshallerProperties.BEAN_VALIDATION_GROUPS, new Class[] {Default.class, Drivers.class});
     unmarshallerValidOn.setProperty(
         MarshallerProperties.BEAN_VALIDATION_GROUPS, new Class[] {Default.class, Drivers.class});
   } else {
     marshallerValidOn.setProperty(MarshallerProperties.BEAN_VALIDATION_GROUPS, new Class[0]);
     unmarshallerValidOn.setProperty(MarshallerProperties.BEAN_VALIDATION_GROUPS, new Class[0]);
   }
 }
  @Before
  public void setUp() throws Exception {
    preferredValidatorFactory = Validation.buildDefaultValidatorFactory();

    JAXBContext ctx = JAXBContextFactory.createContext(EMPLOYEE, null);
    marshallerValidOn = (JAXBMarshaller) ctx.createMarshaller();
    marshallerValidOn.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    marshallerValidOff = (JAXBMarshaller) ctx.createMarshaller();
    /* tests setting the property through marshaller */
    marshallerValidOff.setProperty(
        MarshallerProperties.BEAN_VALIDATION_MODE, BeanValidationMode.NONE);
    marshallerValidOff.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

    JAXBContext ctxValidationOff =
        JAXBContextFactory.createContext(
            EMPLOYEE,
            new HashMap<String, Object>() {
              {
                put(JAXBContextProperties.BEAN_VALIDATION_MODE, BeanValidationMode.NONE);
                put(JAXBContextProperties.BEAN_VALIDATION_FACTORY, preferredValidatorFactory);
              }
            });
    unmarshallerValidOn = (JAXBUnmarshaller) ctxValidationOff.createUnmarshaller();
    /* tests setting the property through unmarshaller */
    unmarshallerValidOn.setProperty(
        UnmarshallerProperties.BEAN_VALIDATION_MODE, BeanValidationMode.CALLBACK);
    unmarshallerValidOff = (JAXBUnmarshaller) ctxValidationOff.createUnmarshaller();
  }