hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [1/4] hbase-site git commit: Published site at .
Date Thu, 19 Oct 2017 15:24:42 GMT
Repository: hbase-site
Updated Branches:
  refs/heads/asf-site b7daf3658 -> a823fbb9d


http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a823fbb9/testdevapidocs/src-html/org/apache/hadoop/hbase/rest/client/TestXmlParsing.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/rest/client/TestXmlParsing.html
b/testdevapidocs/src-html/org/apache/hadoop/hbase/rest/client/TestXmlParsing.html
index 66a2c26..20a6e4f 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/rest/client/TestXmlParsing.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/rest/client/TestXmlParsing.html
@@ -31,57 +31,65 @@
 <span class="sourceLineNo">023</span>import static org.mockito.Mockito.when;<a
name="line.23"></a>
 <span class="sourceLineNo">024</span><a name="line.24"></a>
 <span class="sourceLineNo">025</span>import java.io.IOException;<a name="line.25"></a>
-<span class="sourceLineNo">026</span><a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.HBaseConfiguration;<a
name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.rest.Constants;<a
name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.rest.model.StorageClusterVersionModel;<a
name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.testclassification.SmallTests;<a
name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.util.StringUtils;<a
name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.junit.Test;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.junit.experimental.categories.Category;<a
name="line.33"></a>
-<span class="sourceLineNo">034</span><a name="line.34"></a>
-<span class="sourceLineNo">035</span>/**<a name="line.35"></a>
-<span class="sourceLineNo">036</span> * Test class for {@link RemoteAdmin} to
verify XML is parsed in a certain manner.<a name="line.36"></a>
-<span class="sourceLineNo">037</span> */<a name="line.37"></a>
-<span class="sourceLineNo">038</span>@Category(SmallTests.class)<a name="line.38"></a>
-<span class="sourceLineNo">039</span>public class TestXmlParsing {<a name="line.39"></a>
-<span class="sourceLineNo">040</span><a name="line.40"></a>
-<span class="sourceLineNo">041</span>  @Test<a name="line.41"></a>
-<span class="sourceLineNo">042</span>  public void testParsingClusterVersion()
throws Exception {<a name="line.42"></a>
-<span class="sourceLineNo">043</span>    final String xml = "&lt;?xml version=\"1.0\"
encoding=\"UTF-8\" standalone=\"yes\"?&gt;"<a name="line.43"></a>
-<span class="sourceLineNo">044</span>        + "&lt;ClusterVersion Version=\"2.0.0\"/&gt;";<a
name="line.44"></a>
-<span class="sourceLineNo">045</span>    Client client = mock(Client.class);<a
name="line.45"></a>
-<span class="sourceLineNo">046</span>    RemoteAdmin admin = new RemoteAdmin(client,
HBaseConfiguration.create(), null);<a name="line.46"></a>
-<span class="sourceLineNo">047</span>    Response resp = new Response(200, null,
xml.getBytes());<a name="line.47"></a>
-<span class="sourceLineNo">048</span><a name="line.48"></a>
-<span class="sourceLineNo">049</span>    when(client.get("/version/cluster",
Constants.MIMETYPE_XML)).thenReturn(resp);<a name="line.49"></a>
-<span class="sourceLineNo">050</span><a name="line.50"></a>
-<span class="sourceLineNo">051</span>    StorageClusterVersionModel cv = admin.getClusterVersion();<a
name="line.51"></a>
-<span class="sourceLineNo">052</span>    assertEquals("2.0.0", cv.getVersion());<a
name="line.52"></a>
-<span class="sourceLineNo">053</span>  }<a name="line.53"></a>
+<span class="sourceLineNo">026</span>import javax.xml.bind.UnmarshalException;<a
name="line.26"></a>
+<span class="sourceLineNo">027</span><a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.commons.logging.Log;<a
name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.commons.logging.LogFactory;<a
name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.HBaseConfiguration;<a
name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.rest.Constants;<a
name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.rest.model.StorageClusterVersionModel;<a
name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.testclassification.SmallTests;<a
name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.util.StringUtils;<a
name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.junit.Test;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.junit.experimental.categories.Category;<a
name="line.36"></a>
+<span class="sourceLineNo">037</span><a name="line.37"></a>
+<span class="sourceLineNo">038</span>/**<a name="line.38"></a>
+<span class="sourceLineNo">039</span> * Test class for {@link RemoteAdmin} to
verify XML is parsed in a certain manner.<a name="line.39"></a>
+<span class="sourceLineNo">040</span> */<a name="line.40"></a>
+<span class="sourceLineNo">041</span>@Category(SmallTests.class)<a name="line.41"></a>
+<span class="sourceLineNo">042</span>public class TestXmlParsing {<a name="line.42"></a>
+<span class="sourceLineNo">043</span>  private static final Log LOG = LogFactory.getLog(TestXmlParsing.class);<a
name="line.43"></a>
+<span class="sourceLineNo">044</span><a name="line.44"></a>
+<span class="sourceLineNo">045</span>  @Test<a name="line.45"></a>
+<span class="sourceLineNo">046</span>  public void testParsingClusterVersion()
throws Exception {<a name="line.46"></a>
+<span class="sourceLineNo">047</span>    final String xml = "&lt;?xml version=\"1.0\"
encoding=\"UTF-8\" standalone=\"yes\"?&gt;"<a name="line.47"></a>
+<span class="sourceLineNo">048</span>        + "&lt;ClusterVersion Version=\"2.0.0\"/&gt;";<a
name="line.48"></a>
+<span class="sourceLineNo">049</span>    Client client = mock(Client.class);<a
name="line.49"></a>
+<span class="sourceLineNo">050</span>    RemoteAdmin admin = new RemoteAdmin(client,
HBaseConfiguration.create(), null);<a name="line.50"></a>
+<span class="sourceLineNo">051</span>    Response resp = new Response(200, null,
xml.getBytes());<a name="line.51"></a>
+<span class="sourceLineNo">052</span><a name="line.52"></a>
+<span class="sourceLineNo">053</span>    when(client.get("/version/cluster",
Constants.MIMETYPE_XML)).thenReturn(resp);<a name="line.53"></a>
 <span class="sourceLineNo">054</span><a name="line.54"></a>
-<span class="sourceLineNo">055</span>  @Test<a name="line.55"></a>
-<span class="sourceLineNo">056</span>  public void testFailOnExternalEntities()
throws Exception {<a name="line.56"></a>
-<span class="sourceLineNo">057</span>    final String externalEntitiesXml =<a
name="line.57"></a>
-<span class="sourceLineNo">058</span>        "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;"<a
name="line.58"></a>
-<span class="sourceLineNo">059</span>        + " &lt;!DOCTYPE foo [ &lt;!ENTITY
xxe SYSTEM \"/tmp/foo\"&gt; ] &gt;"<a name="line.59"></a>
-<span class="sourceLineNo">060</span>        + " &lt;ClusterVersion&gt;&amp;xee;&lt;/ClusterVersion&gt;";<a
name="line.60"></a>
-<span class="sourceLineNo">061</span>    Client client = mock(Client.class);<a
name="line.61"></a>
-<span class="sourceLineNo">062</span>    RemoteAdmin admin = new RemoteAdmin(client,
HBaseConfiguration.create(), null);<a name="line.62"></a>
-<span class="sourceLineNo">063</span>    Response resp = new Response(200, null,
externalEntitiesXml.getBytes());<a name="line.63"></a>
-<span class="sourceLineNo">064</span><a name="line.64"></a>
-<span class="sourceLineNo">065</span>    when(client.get("/version/cluster",
Constants.MIMETYPE_XML)).thenReturn(resp);<a name="line.65"></a>
-<span class="sourceLineNo">066</span><a name="line.66"></a>
-<span class="sourceLineNo">067</span>    try {<a name="line.67"></a>
-<span class="sourceLineNo">068</span>      admin.getClusterVersion();<a name="line.68"></a>
-<span class="sourceLineNo">069</span>      fail("Expected getClusterVersion()
to throw an exception");<a name="line.69"></a>
-<span class="sourceLineNo">070</span>    } catch (IOException e) {<a name="line.70"></a>
-<span class="sourceLineNo">071</span>      final String exceptionText = StringUtils.stringifyException(e);<a
name="line.71"></a>
-<span class="sourceLineNo">072</span>      final String expectedText = "The entity
\"xee\" was referenced, but not declared.";<a name="line.72"></a>
-<span class="sourceLineNo">073</span>      assertTrue("Exception does not contain
expected text", exceptionText.contains(expectedText));<a name="line.73"></a>
-<span class="sourceLineNo">074</span>    }<a name="line.74"></a>
-<span class="sourceLineNo">075</span>  }<a name="line.75"></a>
-<span class="sourceLineNo">076</span>}<a name="line.76"></a>
+<span class="sourceLineNo">055</span>    StorageClusterVersionModel cv = admin.getClusterVersion();<a
name="line.55"></a>
+<span class="sourceLineNo">056</span>    assertEquals("2.0.0", cv.getVersion());<a
name="line.56"></a>
+<span class="sourceLineNo">057</span>  }<a name="line.57"></a>
+<span class="sourceLineNo">058</span><a name="line.58"></a>
+<span class="sourceLineNo">059</span>  @Test<a name="line.59"></a>
+<span class="sourceLineNo">060</span>  public void testFailOnExternalEntities()
throws Exception {<a name="line.60"></a>
+<span class="sourceLineNo">061</span>    final String externalEntitiesXml =<a
name="line.61"></a>
+<span class="sourceLineNo">062</span>        "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;"<a
name="line.62"></a>
+<span class="sourceLineNo">063</span>        + " &lt;!DOCTYPE foo [ &lt;!ENTITY
xxe SYSTEM \"/tmp/foo\"&gt; ] &gt;"<a name="line.63"></a>
+<span class="sourceLineNo">064</span>        + " &lt;ClusterVersion&gt;&amp;xee;&lt;/ClusterVersion&gt;";<a
name="line.64"></a>
+<span class="sourceLineNo">065</span>    Client client = mock(Client.class);<a
name="line.65"></a>
+<span class="sourceLineNo">066</span>    RemoteAdmin admin = new RemoteAdmin(client,
HBaseConfiguration.create(), null);<a name="line.66"></a>
+<span class="sourceLineNo">067</span>    Response resp = new Response(200, null,
externalEntitiesXml.getBytes());<a name="line.67"></a>
+<span class="sourceLineNo">068</span><a name="line.68"></a>
+<span class="sourceLineNo">069</span>    when(client.get("/version/cluster",
Constants.MIMETYPE_XML)).thenReturn(resp);<a name="line.69"></a>
+<span class="sourceLineNo">070</span><a name="line.70"></a>
+<span class="sourceLineNo">071</span>    try {<a name="line.71"></a>
+<span class="sourceLineNo">072</span>      admin.getClusterVersion();<a name="line.72"></a>
+<span class="sourceLineNo">073</span>      fail("Expected getClusterVersion()
to throw an exception");<a name="line.73"></a>
+<span class="sourceLineNo">074</span>    } catch (IOException e) {<a name="line.74"></a>
+<span class="sourceLineNo">075</span>      assertEquals("Cause of exception ought
to be a failure to parse the stream due to our " +<a name="line.75"></a>
+<span class="sourceLineNo">076</span>          "invalid external entity. Make
sure this isn't just a false positive due to " +<a name="line.76"></a>
+<span class="sourceLineNo">077</span>          "implementation. see HBASE-19020.",
UnmarshalException.class, e.getCause().getClass());<a name="line.77"></a>
+<span class="sourceLineNo">078</span>      final String exceptionText = StringUtils.stringifyException(e);<a
name="line.78"></a>
+<span class="sourceLineNo">079</span>      final String expectedText = "\"xee\"";<a
name="line.79"></a>
+<span class="sourceLineNo">080</span>      LOG.debug("exception text: '" + exceptionText
+ "'", e);<a name="line.80"></a>
+<span class="sourceLineNo">081</span>      assertTrue("Exception does not contain
expected text", exceptionText.contains(expectedText));<a name="line.81"></a>
+<span class="sourceLineNo">082</span>    }<a name="line.82"></a>
+<span class="sourceLineNo">083</span>  }<a name="line.83"></a>
+<span class="sourceLineNo">084</span>}<a name="line.84"></a>
 
 
 


Mime
View raw message