WebXml { public boolean setServletMapping( String name, String value ) { String xPath = MessageFormat.format( SERVLET_NAME_TEMPLATE_XPATH, name ); Node node = document.selectSingleNode( xPath ); if ( node != null ) { node = node.selectSingleNode( "../jsp-file" ); } if ( node != null ) { node.setText( value ); return true; } return false; } WebXml( File pentahoXmlFile );  WebXml( String xml );  WebXml( Document doc );  WebXml(); String getContextConfigFileName(); @Deprecated String getBaseUrl(); String getFullyQualifiedServerUrl(); String getSolutionPath(); String getLocaleLanguage(); String getLocaleCountry(); String getEncoding(); String getHomePage(); void setContextConfigFileName( String fileName ); void setBaseUrl( String baseUrl ); void setFullyQualifiedServerUrl( String fullyQualifiedServerUrl ); void setSolutionPath( String solutionPath ); void setLocaleLanguage( String language ); void setLocaleCountry( String country ); void setEncoding( String encoding ); void setHomePage( String homePage ); Document getDocument(); String getContextParamValue( String name ); void setContextParamValue( String name, String value ); boolean setServletMapping( String name, String value ); String getServletMapping( String name );  }
@Test public void testSetServletMapping_noMatch() throws Exception { webXml = new WebXml( document ); when( document.selectSingleNode( anyString() ) ).thenReturn( null ); assertFalse( webXml.setServletMapping( "key", value ) ); }
@Test public void testSetServletMapping_noJspFileNode() throws Exception { webXml = new WebXml( document ); Element node = mock( Element.class ); Element jspNode = mock( Element.class ); when( document.selectSingleNode( anyString() ) ).thenReturn( node ); when( node.selectSingleNode( "../jsp-file" ) ).thenReturn( jspNode ); assertTrue( webXml.setServletMapping( "key", value ) ); verify( jspNode ).setText( value ); }