EMMA Coverage Report (generated Mon Nov 01 16:48:29 PDT 2010)
[all classes][com.google.caja.ancillary.servlet]

COVERAGE SUMMARY FOR SOURCE FILE [Result.java]

nameclass, %method, %block, %line, %
Result.java100% (1/1)100% (2/2)90%  (53/59)94%  (11.3/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Result100% (1/1)100% (2/2)90%  (53/59)94%  (11.3/12)
Result (int, Content, MessageQueue): void 100% (1/1)88%  (28/32)96%  (8.6/9)
getContentType (): String 100% (1/1)93%  (25/27)89%  (2.7/3)

1// Copyright (C) 2009 Google Inc.
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 
15package com.google.caja.ancillary.servlet;
16 
17import com.google.caja.reporting.MessageQueue;
18import com.google.caja.util.Lists;
19import com.google.caja.util.Pair;
20 
21import java.util.List;
22 
23/**
24 * Abstracts away a servlet response so the servlet can be easily tested.
25 *
26 * @author mikesamuel@gmail.com
27 */
28final class Result {
29  /** A response code, e.g. 200 for OK. */
30  final int status;
31  /** The response content. */
32  final Content content;
33  /** Any messages that should be reported to the user. */
34  final MessageQueue mq;
35  /** Extra response headers. */
36  final List<Pair<String, String>> headers = Lists.newArrayList();
37 
38  Result(int status, Content content, MessageQueue mq) {
39    if (content == null) { throw new NullPointerException(); }
40    this.status = status;
41    this.content = content;
42    this.mq = mq;
43    if (content.type != null) {
44      headers.add(Pair.pair("Content-type", getContentType()));
45    }
46  }
47 
48  String getContentType() {
49    if (content.type == null) { return null; }
50    String contentType = content.type.mimeType;
51    return content.type.isText ? contentType + "; charset=UTF-8" : contentType;
52  }
53}

[all classes][com.google.caja.ancillary.servlet]
EMMA 2.0.5312 (C) Vladimir Roubtsov