public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases )
    throws KettleException {
    try {
      encoding = rep.getStepAttributeString( id_step, "encoding" );
      nameSpace = rep.getStepAttributeString( id_step, "name_space" );
      mainElement = rep.getStepAttributeString( id_step, "xml_main_element" );
      repeatElement = rep.getStepAttributeString( id_step, "xml_repeat_element" );

      fileName = rep.getStepAttributeString( id_step, "file_name" );
      extension = rep.getStepAttributeString( id_step, "file_extention" );
      servletOutput = rep.getStepAttributeBoolean( id_step, "file_servlet_output" );

      doNotOpenNewFileInit = rep.getStepAttributeBoolean( id_step, "do_not_open_newfile_init" );
      splitEvery = (int) rep.getStepAttributeInteger( id_step, "file_split" );
      stepNrInFilename = rep.getStepAttributeBoolean( id_step, "file_add_stepnr" );
      dateInFilename = rep.getStepAttributeBoolean( id_step, "file_add_date" );
      timeInFilename = rep.getStepAttributeBoolean( id_step, "file_add_time" );
      SpecifyFormat = rep.getStepAttributeBoolean( id_step, "SpecifyFormat" );
      omitNullValues = rep.getStepAttributeBoolean( id_step, "omit_null_values" );
      date_time_format = rep.getStepAttributeString( id_step, "date_time_format" );

      addToResultFilenames = rep.getStepAttributeBoolean( id_step, "add_to_result_filenames" );
      zipped = rep.getStepAttributeBoolean( id_step, "file_zipped" );

      int nrfields = rep.countNrStepAttributes( id_step, "field_name" );

      allocate( nrfields );

      for ( int i = 0; i < nrfields; i++ ) {
        outputFields[i] = new XMLField();

        outputFields[i].setContentType( ContentType.valueOf( Const.NVL( rep.getStepAttributeString( id_step, i,
            "field_content_type" ), ContentType.Element.name() ) ) );
        outputFields[i].setFieldName( rep.getStepAttributeString( id_step, i, "field_name" ) );
        outputFields[i].setElementName( rep.getStepAttributeString( id_step, i, "field_element" ) );
        outputFields[i].setType( rep.getStepAttributeString( id_step, i, "field_type" ) );
        outputFields[i].setFormat( rep.getStepAttributeString( id_step, i, "field_format" ) );
        outputFields[i].setCurrencySymbol( rep.getStepAttributeString( id_step, i, "field_currency" ) );
        outputFields[i].setDecimalSymbol( rep.getStepAttributeString( id_step, i, "field_decimal" ) );
        outputFields[i].setGroupingSymbol( rep.getStepAttributeString( id_step, i, "field_group" ) );
        outputFields[i].setNullString( rep.getStepAttributeString( id_step, i, "field_nullif" ) );
        outputFields[i].setLength( (int) rep.getStepAttributeInteger( id_step, i, "field_length" ) );
        outputFields[i].setPrecision( (int) rep.getStepAttributeInteger( id_step, i, "field_precision" ) );
      }
    } catch ( Exception e ) {
      throw new KettleException( "Unexpected error reading step information from the repository", e );
    }
  }
@Test
  public void testReadRepException() throws Exception {
    XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
    Repository rep = mock( Repository.class );
    IMetaStore metastore = mock( IMetaStore.class );
    DatabaseMeta dbMeta = mock( DatabaseMeta.class );
    ObjectId oid = new StringObjectId( "oid" );
    when( rep.getStepAttributeString( oid, "encoding" ) ).thenThrow( new RuntimeException( "encoding exception" ) );
    try {
      xmlOutputMeta.readRep( rep, metastore, oid, Collections.singletonList( dbMeta ) );
    } catch ( KettleException e ) {
      assertEquals( "encoding exception", e.getCause().getMessage() );
    }
  }