@Test public void testCalculateDocumentBuilderFactory() throws ReportDataFactoryException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, ParserConfigurationException { Method method = LegacyXPathTableModel.class.getDeclaredMethod( "calculateDocumentBuilderFactory", Configuration.class ); method.setAccessible( true ); LegacyXPathTableModel legacyXPathTableModel = Mockito.mock( LegacyXPathTableModel.class ); ModifiableConfiguration disableDTDsPropertyConfig = ClassicEngineBoot.getInstance().getEditableConfig(); disableDTDsPropertyConfig.setConfigProperty( LegacyXPathTableModel.XPATH_ENABLE_DTDS, "false" ); DocumentBuilderFactory documentBuilderFactoryDisableDTDs = ( DocumentBuilderFactory ) method.invoke( legacyXPathTableModel, disableDTDsPropertyConfig ); Assert.assertTrue( documentBuilderFactoryDisableDTDs.getFeature( LegacyXPathTableModel.DISALLOW_DOCTYPE_DECL ) ); ModifiableConfiguration missingPropertyConfig = ClassicEngineBoot.getInstance().getEditableConfig(); DocumentBuilderFactory documentBuilderFactoryMissingProperty = ( DocumentBuilderFactory ) method.invoke( legacyXPathTableModel, missingPropertyConfig ); Assert.assertTrue( documentBuilderFactoryMissingProperty.getFeature( LegacyXPathTableModel.DISALLOW_DOCTYPE_DECL ) ); ModifiableConfiguration enableDTDsPropertyConfig = ClassicEngineBoot.getInstance().getEditableConfig(); enableDTDsPropertyConfig.setConfigProperty( LegacyXPathTableModel.XPATH_ENABLE_DTDS, "true" ); DocumentBuilderFactory documentBuilderFactoryEnableDTDs = ( DocumentBuilderFactory ) method.invoke( legacyXPathTableModel, enableDTDsPropertyConfig ); Assert.assertFalse( documentBuilderFactoryEnableDTDs.getFeature( LegacyXPathTableModel.DISALLOW_DOCTYPE_DECL ) ); }
private DocumentBuilderFactory calculateDocumentBuilderFactory( final Configuration configuration ) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setXIncludeAware( false ); if ( !"true".equals( configuration .getConfigProperty( XPATH_ENABLE_DTDS ) ) ) { dbf.setFeature( DISALLOW_DOCTYPE_DECL, true ); } return dbf; }
LegacyXPathTableModel extends AbstractTableModel { private DocumentBuilderFactory calculateDocumentBuilderFactory( final Configuration configuration ) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setXIncludeAware( false ); if ( !"true".equals( configuration .getConfigProperty( XPATH_ENABLE_DTDS ) ) ) { dbf.setFeature( DISALLOW_DOCTYPE_DECL, true ); } return dbf; } }
LegacyXPathTableModel extends AbstractTableModel { private DocumentBuilderFactory calculateDocumentBuilderFactory( final Configuration configuration ) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setXIncludeAware( false ); if ( !"true".equals( configuration .getConfigProperty( XPATH_ENABLE_DTDS ) ) ) { dbf.setFeature( DISALLOW_DOCTYPE_DECL, true ); } return dbf; } LegacyXPathTableModel( final ResourceData xmlResource,
                                final ResourceManager resourceManager,
                                final String xPathExpression,
                                final DataRow parameters,
                                final int maxRowsToProcess ); }
LegacyXPathTableModel extends AbstractTableModel { private DocumentBuilderFactory calculateDocumentBuilderFactory( final Configuration configuration ) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setXIncludeAware( false ); if ( !"true".equals( configuration .getConfigProperty( XPATH_ENABLE_DTDS ) ) ) { dbf.setFeature( DISALLOW_DOCTYPE_DECL, true ); } return dbf; } LegacyXPathTableModel( final ResourceData xmlResource,
                                final ResourceManager resourceManager,
                                final String xPathExpression,
                                final DataRow parameters,
                                final int maxRowsToProcess ); Class getColumnClass( final int columnIndex ); int getRowCount(); int getColumnCount(); String getColumnName( final int column ); Object getValueAt( final int rowIndex, final int columnIndex ); }
LegacyXPathTableModel extends AbstractTableModel { private DocumentBuilderFactory calculateDocumentBuilderFactory( final Configuration configuration ) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setXIncludeAware( false ); if ( !"true".equals( configuration .getConfigProperty( XPATH_ENABLE_DTDS ) ) ) { dbf.setFeature( DISALLOW_DOCTYPE_DECL, true ); } return dbf; } LegacyXPathTableModel( final ResourceData xmlResource,
                                final ResourceManager resourceManager,
                                final String xPathExpression,
                                final DataRow parameters,
                                final int maxRowsToProcess ); Class getColumnClass( final int columnIndex ); int getRowCount(); int getColumnCount(); String getColumnName( final int column ); Object getValueAt( final int rowIndex, final int columnIndex ); static final String DISALLOW_DOCTYPE_DECL; static final String XPATH_ENABLE_DTDS; }