1 38 package com.gargoylesoftware.htmlunit.jelly; 39 40 import org.apache.commons.jelly.JellyTagException; 41 import org.apache.commons.jelly.XMLOutput; 42 43 49 public class AssertContentTypeTag extends HtmlUnitTagSupport { 50 private String contentType_; 51 52 53 58 public void doTag(final XMLOutput xmlOutput) throws JellyTagException { 59 invokeBody(xmlOutput); 60 61 if( contentType_ == null ) { 62 throw new JellyTagException("contentType is a mandatory attribute"); 63 } 64 65 final String actualContentType = getHtmlPage().getWebResponse().getContentType(); 66 67 if( actualContentType.equals(contentType_) == false ) { 68 throw new JellyTagException("Expected content-type "+contentType_+" but got "+actualContentType+" instead"); 69 } 70 } 71 72 73 77 public void setContentType( final String contentType ) { 78 contentType_ = contentType; 79 } 80 } 81 82 | Popular Tags |