Skip to content

Package: ReferencedXmlResource

ReferencedXmlResource

nameinstructionbranchcomplexitylinemethod
ReferencedXmlResource(File)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
asStreamSource()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
asString()
M: 34 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: package com.sun.xml.ws.test.client;
12:
13: import javax.xml.transform.stream.StreamSource;
14: import java.io.File;
15: import java.io.InputStreamReader;
16: import java.io.Reader;
17: import java.io.StringWriter;
18: import java.io.FileInputStream;
19:
20: /**
21: * Resource XML defined as a reference.
22: *
23: * @author Kohsuke Kawaguchi
24: */
25: public class ReferencedXmlResource extends AbstractXmlResource {
26: private final File xml;
27:
28: public ReferencedXmlResource(File xml) {
29: this.xml = xml;
30: }
31:
32: public String asString() throws Exception {
33: StringWriter sw = new StringWriter();
34: Reader r = new InputStreamReader(new FileInputStream(xml),"UTF-8");
35: char[] buf = new char[1024];
36:
37: int len;
38:• while((len=r.read(buf))>=0)
39: sw.write(buf,0,len);
40:
41: r.close();
42:
43: return sw.toString();
44: }
45:
46: public StreamSource asStreamSource() throws Exception {
47: return new StreamSource(xml);
48: }
49: }