@Test
public void testPrepareJrxmlAndReadInputParameters()
                        throws URISyntaxException, IOException, XMLStreamException, FactoryConfigurationError,
                        ProcessletException {

    DataTableContentProvider tableContentProvider = getProvider();
    List<CodeType> processedIds = new ArrayList<CodeType>();
    Pair<InputStream, Boolean> jrxml = new Pair<InputStream, Boolean>(
                                                                       TestDataTableContentProviderTest.class.getResourceAsStream( "../templateWithTable.jrxml" ),
                                                                       false );
    Map<String, Object> params = new HashMap<String, Object>();
    ProcessletInputs in = Utils.getInputs( "REPORT",
                                           DataTableContentProvider.MIME_TYPE,
                                           DataTableContentProvider.SCHEMA,
                                           TestDataTableContentProviderTest.class.getResourceAsStream( "complexInputTABLE" ) );
    tableContentProvider.setTableId( "REPORT" );
    jrxml = tableContentProvider.prepareJrxmlAndReadInputParameters( jrxml.first, params, in, processedIds,
                                                                     new HashMap<String, String>() );
    assertEquals( 1, params.size() );
    assertEquals( 1, processedIds.size() );
    XMLAdapter a = new XMLAdapter( jrxml.first );
    String[] fieldNames = a.getNodesAsStrings( a.getRootElement(),
                                               new XPath( "/jasper:jasperReport/jasper:field/@name", nsContext ) );
    List<String> detailFields = new ArrayList<String>();
    List<String> headerFields = new ArrayList<String>();
    for ( String field : fieldNames ) {
        if ( field.matches( TABLE_PREFIX + "[a-zA-Z0-9]*_(" + DETAIL_SUFFIX + ")[0-9]*" ) )
            detailFields.add( field );
        else if ( field.matches( TABLE_PREFIX + "[a-zA-Z0-9]*_(" + HEADER_SUFFIX + ")[0-9]*" ) )
            headerFields.add( field );
    }
    String[] textFieldNames = a.getNodesAsStrings( a.getRootElement(),
                                                   new XPath( ".//jasper:textField/jasper:textFieldExpression",
                                                              nsContext ) );
    List<String> detailTextFields = new ArrayList<String>();
    List<String> headerTextFields = new ArrayList<String>();
    for ( String field : textFieldNames ) {
        if ( field.matches( "\\$F\\{" + TABLE_PREFIX + "[a-zA-Z0-9]*_(" + DETAIL_SUFFIX + ")[0-9]*\\}" ) )
            detailTextFields.add( field );
        else if ( field.matches( "\\$F\\{" + TABLE_PREFIX + "[a-zA-Z0-9]*_(" + HEADER_SUFFIX + ")[0-9]*\\}" ) )
            headerTextFields.add( field );
    }
    assertEquals( 4, detailFields.size() );
    assertEquals( 4, headerFields.size() );
    assertEquals( 4, detailTextFields.size() );
    assertEquals( 4, headerTextFields.size() );
}