BasePentahoRequestContext implements IPentahoRequestContext { public BasePentahoRequestContext( String contextPath ) { super(); if ( contextPath != null ) { String draftPath = contextPath + ( contextPath.endsWith( SLASH ) ? EMPTY : SLASH ); this.contextPath = draftPath.replaceAll( "(?<!^http:|https:)(/){2,}", SLASH ); } else { String path = PentahoSystem.getApplicationContext().getFullyQualifiedServerURL(); this.contextPath = path + ( path != null && path.endsWith( SLASH ) ? EMPTY : SLASH ); } } BasePentahoRequestContext( String contextPath ); String getContextPath(); public String contextPath; static final String SLASH; static final String EMPTY; }
@Test public void basePentahoRequestContextTest() throws Exception { BasePentahoRequestContext basePentahoRequestContext = new BasePentahoRequestContext( input ); String actual = basePentahoRequestContext.getContextPath(); Assert.assertEquals( expected, actual ); }