@Test( expected = ParseException.class ) public void testParsingIncorrectResource() throws Exception { XMLAttributesImpl attrs = new XMLAttributesImpl(); attrs.addAttribute( new QName( null, "target-type", null, URI ), ATTR_TYPE, TARGET ); attrs.addAttribute( new QName( null, "href", null, URI ), ATTR_TYPE, "test-href" ); AttributesProxy fAttributesProxy = new AttributesProxy( attrs ); doThrow( ResourceException.class ).when( resource ).getResource(); handler.startParsing( fAttributesProxy ); }
protected void startParsing( final Attributes attrs ) throws SAXException { targetType = attrs.getValue( getUri(), "target-type" ); if ( targetType == null ) { throw new ParseException( "Mandatory attribute 'target-type' is missing.", getLocator() ); } final String href = attrs.getValue( getUri(), "href" ); if ( href == null ) { throw new ParseException( "Mandatory attribute 'href' is missing.", getLocator() ); } try { final ResourceManager resourceManager = getRootHandler().getResourceManager(); final ResourceKey key = resourceManager.deriveKey( getRootHandler().getSource(), href ); final Resource resource = resourceManager.create( key, null, MasterReport.class ); report = (MasterReport) resource.getResource(); } catch ( ResourceException re ) { throw new ParseException( "Mandatory attribute 'href' is not pointing to a valid report.", re, getLocator() ); } }
ReportReadHandler extends AbstractXmlReadHandler { protected void startParsing( final Attributes attrs ) throws SAXException { targetType = attrs.getValue( getUri(), "target-type" ); if ( targetType == null ) { throw new ParseException( "Mandatory attribute 'target-type' is missing.", getLocator() ); } final String href = attrs.getValue( getUri(), "href" ); if ( href == null ) { throw new ParseException( "Mandatory attribute 'href' is missing.", getLocator() ); } try { final ResourceManager resourceManager = getRootHandler().getResourceManager(); final ResourceKey key = resourceManager.deriveKey( getRootHandler().getSource(), href ); final Resource resource = resourceManager.create( key, null, MasterReport.class ); report = (MasterReport) resource.getResource(); } catch ( ResourceException re ) { throw new ParseException( "Mandatory attribute 'href' is not pointing to a valid report.", re, getLocator() ); } } }
ReportReadHandler extends AbstractXmlReadHandler { protected void startParsing( final Attributes attrs ) throws SAXException { targetType = attrs.getValue( getUri(), "target-type" ); if ( targetType == null ) { throw new ParseException( "Mandatory attribute 'target-type' is missing.", getLocator() ); } final String href = attrs.getValue( getUri(), "href" ); if ( href == null ) { throw new ParseException( "Mandatory attribute 'href' is missing.", getLocator() ); } try { final ResourceManager resourceManager = getRootHandler().getResourceManager(); final ResourceKey key = resourceManager.deriveKey( getRootHandler().getSource(), href ); final Resource resource = resourceManager.create( key, null, MasterReport.class ); report = (MasterReport) resource.getResource(); } catch ( ResourceException re ) { throw new ParseException( "Mandatory attribute 'href' is not pointing to a valid report.", re, getLocator() ); } } ReportReadHandler(); }
ReportReadHandler extends AbstractXmlReadHandler { protected void startParsing( final Attributes attrs ) throws SAXException { targetType = attrs.getValue( getUri(), "target-type" ); if ( targetType == null ) { throw new ParseException( "Mandatory attribute 'target-type' is missing.", getLocator() ); } final String href = attrs.getValue( getUri(), "href" ); if ( href == null ) { throw new ParseException( "Mandatory attribute 'href' is missing.", getLocator() ); } try { final ResourceManager resourceManager = getRootHandler().getResourceManager(); final ResourceKey key = resourceManager.deriveKey( getRootHandler().getSource(), href ); final Resource resource = resourceManager.create( key, null, MasterReport.class ); report = (MasterReport) resource.getResource(); } catch ( ResourceException re ) { throw new ParseException( "Mandatory attribute 'href' is not pointing to a valid report.", re, getLocator() ); } } ReportReadHandler(); String getTargetType(); MasterReport getReport(); Object getObject(); }
ReportReadHandler extends AbstractXmlReadHandler { protected void startParsing( final Attributes attrs ) throws SAXException { targetType = attrs.getValue( getUri(), "target-type" ); if ( targetType == null ) { throw new ParseException( "Mandatory attribute 'target-type' is missing.", getLocator() ); } final String href = attrs.getValue( getUri(), "href" ); if ( href == null ) { throw new ParseException( "Mandatory attribute 'href' is missing.", getLocator() ); } try { final ResourceManager resourceManager = getRootHandler().getResourceManager(); final ResourceKey key = resourceManager.deriveKey( getRootHandler().getSource(), href ); final Resource resource = resourceManager.create( key, null, MasterReport.class ); report = (MasterReport) resource.getResource(); } catch ( ResourceException re ) { throw new ParseException( "Mandatory attribute 'href' is not pointing to a valid report.", re, getLocator() ); } } ReportReadHandler(); String getTargetType(); MasterReport getReport(); Object getObject();  }