Coverage Report - org.apache.tapestry5.internal.test.TestableResponseImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
TestableResponseImpl
59%
17/29
N/A
1.056
 
 1  
 // Copyright 2007, 2008, 2009 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry5.internal.test;
 16  
 
 17  
 import org.apache.tapestry5.Link;
 18  
 import org.apache.tapestry5.dom.Document;
 19  
 
 20  
 import java.io.ByteArrayOutputStream;
 21  
 import java.io.IOException;
 22  
 import java.io.OutputStream;
 23  
 import java.io.PrintWriter;
 24  
 
 25  46
 public class TestableResponseImpl implements TestableResponse
 26  
 {
 27  
     private Link link;
 28  
 
 29  
     private boolean committed;
 30  
 
 31  
     private Document renderedDocument;
 32  
 
 33  
     private void nyi(String methodName)
 34  
     {
 35  0
         throw new RuntimeException(String.format("TestableResponse: Method %s() not yet implemented.", methodName));
 36  
     }
 37  
 
 38  
     public OutputStream getOutputStream(String contentType) throws IOException
 39  
     {
 40  0
         nyi("getOutputStream");
 41  
 
 42  0
         return null;
 43  
     }
 44  
 
 45  
     public PrintWriter getPrintWriter(String contentType) throws IOException
 46  
     {
 47  60
         committed = true;
 48  
 
 49  
         // Well, the output isn't accessible, but I guess we see that it could be generated from
 50  
         // the DOM.
 51  60
         return new PrintWriter(new ByteArrayOutputStream());
 52  
     }
 53  
 
 54  
     public void sendError(int sc, String message) throws IOException
 55  
     {
 56  0
         nyi("sendError");
 57  0
     }
 58  
 
 59  
     public void sendRedirect(String URL) throws IOException
 60  
     {
 61  0
         nyi("sendRedirect");
 62  0
     }
 63  
 
 64  
     public void setContentLength(int length)
 65  
     {
 66  0
     }
 67  
 
 68  
     public void setDateHeader(String name, long date)
 69  
     {
 70  0
     }
 71  
 
 72  
     public void setHeader(String name, String value)
 73  
     {
 74  0
     }
 75  
 
 76  
     public void setIntHeader(String name, int value)
 77  
     {
 78  0
     }
 79  
 
 80  
     public void sendRedirect(Link link) throws IOException
 81  
     {
 82  12
         committed = true;
 83  
 
 84  12
         this.link = link;
 85  12
     }
 86  
 
 87  
     public void setStatus(int sc)
 88  
     {
 89  0
     }
 90  
 
 91  
     public String encodeRedirectURL(String URL)
 92  
     {
 93  12
         return URL;
 94  
     }
 95  
 
 96  
     public String encodeURL(String URL)
 97  
     {
 98  54
         return URL;
 99  
     }
 100  
 
 101  
     public Link getRedirectLink()
 102  
     {
 103  72
         return link;
 104  
     }
 105  
 
 106  
     public boolean isCommitted()
 107  
     {
 108  18
         return committed;
 109  
     }
 110  
 
 111  
     public void clear()
 112  
     {
 113  72
         committed = false;
 114  72
         link = null;
 115  
 
 116  72
         renderedDocument = null;
 117  72
     }
 118  
 
 119  
     public Document getRenderedDocument()
 120  
     {
 121  60
         return renderedDocument;
 122  
     }
 123  
 
 124  
     public void setRenderedDocument(Document document)
 125  
     {
 126  60
         renderedDocument = document;
 127  60
     }
 128  
 }