|
What this is
Other links
The source code/* * Copyright 1999-2004 The Apache Sofware Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.util.test; import java.io.PrintWriter; import java.util.Enumeration; import java.util.Hashtable; public class Report { // Defaults static PrintWriter defaultOutput=new PrintWriter(System.out); static String defaultOutType="text"; PrintWriter out=null; String outType=null; HttpClient httpClient; HttpRequest httpRequest; String description; String failueMessage; public static void setDefaultWriter( PrintWriter pw ) { defaultOutput=pw; } public static void setDefaultOutput( String s ) { defaultOutType=s; } public void setWriter( PrintWriter pw ) { out=pw; } /** text, xml, html */ public void setOutput( String t ) { outType=t; } public void setDescription( String desc ) { description = desc; } public void setHttpClient( HttpClient client ) { httpClient = client; } public void setHttpRequest( HttpRequest req ) { httpRequest = req; } public void setFailureMsg( String msg ) { failueMessage = msg; } public void writeReport() { if( out==null) out=defaultOutput; if( outType==null) outType=defaultOutType; if( "text".equals(outType) ) textReport(); if( "html".equals(outType) ) htmlReport(); } private void textReport() { String msg=null; if( "".equals( httpClient.getComment() )) msg=" (" + httpRequest.getRequestLine() + ")"; else msg=httpClient.getComment() + " (" + httpRequest.getRequestLine() + ")"; if( httpClient.getResult() ) out.println("OK " + msg ); else { out.println("FAIL " + msg ); out.println("Message: " + httpClient.getFailureMessage()); } out.flush(); } private void htmlReport() { String uri=httpRequest.getURI(); boolean result=httpClient.getResult(); if( uri!=null ) out.println(""); if( result ) out.println( "OK " ); else out.println("FAIL "); if( uri!=null ) out.println(""); String msg=null; if( "".equals( httpClient.getComment() )) msg=" (" + httpRequest.getRequestLine() + ")"; else msg=httpClient.getComment() + " (" + httpRequest.getRequestLine() + ")"; out.println( msg ); if( ! result ) out.println(""); out.println(" |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.