# PageContextTest

### Summary

A PageContext instance provides access to all the namespaces associated with a JSP page, provides to several page attributes as well as a layer above the implementation details.

### Positive Tests

positiveForward:The forward method is used to re-direct the current ServletRequest and ServletResponse to another active component in the application.Here, we are forwarding to a jsp page named forward.jsp.

title | PageContextTest
source | PageContextTest.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID positiveForward -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

positiveGetAttributeAvbl:Here,the method getAttribute(java.lang.String name) is tested.This returns an java.lang.Object. In the test, we are declaring a useBean action tag ,and the same is testsd.

title | PageContextTest
source | PageContextTest.java TestBean.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID positiveGetAttributeAvbl -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

positiveGetAttributeNotAvbl:Here,the method getAttribute(java.lang.String name) is tested.This returns an java.lang.Object. It returns null if the attribute specified is not available.We are testing for this.

title | PageContextTest
source | PageContextTest.java TestBean.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID positiveGetAttributeNotAvbl -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

positiveGetAttributeNamesInScope:Here,the method getAttributeNameInScope(int scope).This returns an java.util.Enumeration.

title | PageContextTest
source | PageContextTest.java TestBean.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID positiveGetAttributeNamesInScope -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

positiveGetAttributeScope:Here,the method getAttributesScope().An integer value of the scope is returned.

title | PageContextTest
source | PageContextTest.java TestBean.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID positiveGetAttributeScope -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

checkGetException:This method tests for the method getException() of the PageContext class. It is expected to return an object of type java.lang.Exception.This test is testing for the return type.

title | PageContextTest
source | PageContextTest.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID checkGetException -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

checkGetOut:This method tests for the method getOut() of the PageContext class.This is expected to return an object of type javax.servlet.jsp.JspWriter.This test tests for this return type.

title | PageContextTest
source | PageContextTest.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID checkGetOut -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

checkGetServletConfig:This method tests for the method getServletConfig() of the PageContext class.This is expected to return an object of type javax.servlet.ServletConfig.This test tests for this return type.

title | PageContextTest
source | PageContextTest.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID checkGetServletConfig -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

checkGetServletContext:This method tests for the method getServletContext() of the PageContext class.This is expected to return an object of type javax.servlet.ServletContext.This test tests for this return type.

title | PageContextTest
source | PageContextTest.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID checkGetServletContext -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

checkGetRequest:This method tests for the method getRequest() of the PageContext class.This is expected to return an object of type javax.servlet.ServletRequest.This test tests for this return type.

title | PageContextTest
source | PageContextTest.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID checkGetRequest -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

checkGetResponse:This method tests for the method getResponse() of the PageContext class.This is expected to return an object of type javax.servlet.ServletResponse.This test tests for this return type.

title | PageContextTest
source | PageContextTest.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID checkGetResponse -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

checkGetSession:This method tests for the method getSession() of the PageContext class.This is expected to return an object of type javax.servlet.http.HttpSession.This test tests for this return type.

title | PageContextTest
source | PageContextTest.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID checkGetSession -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

positiveInclude: This method test for the include() method. This causes the resource specified to be processed as part the current ServletRequest and ServletResponse being processed by the calling thread.

title | PageContextTest
source | PageContextTest.java TestBean.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID positiveInclude -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

positiveRemoveAttribute:This tests for the removeAttribute method of the PageContext class. It removes the object reference associated with the specified name.

title | PageContextTest
source | PageContextTest.java TestBean.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID positiveRemoveAttribute -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

positiveSetAttribute: This method registers the name and object specified with page scope

title | PageContextTest
source | PageContextTest.java TestBean.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID positiveSetAttribute -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

positiveSetAttributeInScope:This method registers the name and object specified with appropriate scope

title | PageContextTest
source | PageContextTest.java TestBean.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID positiveSetAttributeInScope -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

### Negative Tests

negativeForwardIllegalState:Here the forward method is tested for IllegalStateException.

title | PageContextTest
source | PageContextTest.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID negativeForwardIllegalState -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

negativeForwardIllegalArg:Here the forward method is tested for IllegalArgumentException

title | PageContextTest
source | PageContextTest.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID negativeForwardIllegalArg -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

negativeInclude:The method tests for include() method. we are passing an unavailable JSP page as an parameter.

title | PageContextTest
source | PageContextTest.java TestBean.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID negativeInclude -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI

negativeRemoveAttribute:This tests for the removeAttribute method of the PageContext class.It trys to remove unavailable the attribute.

title | PageContextTest
source | PageContextTest.java TestBean.java
executeClass | engine.PageContext.PageContextTest
executeArgs | -TestCaseID negativeRemoveAttribute -ServerHost $servletServerHost -ServerPort $servletServerPort -UrlMaps $servletMaps
keywords | positive JSP extensionAPI