Repository: hadoop
Updated Branches:
  refs/heads/branch-2 217c0405d -> f11c8eb09


http://git-wip-us.apache.org/repos/asf/hadoop/blob/f11c8eb0/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfsnodelist.jsp
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfsnodelist.jsp 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfsnodelist.jsp
deleted file mode 100644
index 3bb3498..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfsnodelist.jsp
+++ /dev/null
@@ -1,59 +0,0 @@
-<%
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file 
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-%>
-<%@ page
-  contentType="text/html; charset=UTF-8"
-  import="org.apache.hadoop.util.ServletUtil"
-  import="org.apache.hadoop.ha.HAServiceProtocol.HAServiceState"
-%>
-<%!
-  //for java.io.Serializable
-  private static final long serialVersionUID = 1L;
-%>
-<%
-final NamenodeJspHelper.NodeListJsp nodelistjsp = new 
NamenodeJspHelper.NodeListJsp();
-NameNode nn = NameNodeHttpServer.getNameNodeFromContext(application);
-String namenodeRole = nn.getRole().toString();
-FSNamesystem fsn = nn.getNamesystem();
-HAServiceState nnHAState = nn.getServiceState();
-boolean isActive = (nnHAState == HAServiceState.ACTIVE);
-String namenodeLabel = NamenodeJspHelper.getNameNodeLabel(nn);
-%>
-
-<!DOCTYPE html>
-<html>
-
-<link rel="stylesheet" type="text/css" href="/static/hadoop.css">
-<title>Hadoop <%=namenodeRole%>&nbsp;<%=namenodeLabel%></title>
-  
-<body>
-<h1><%=namenodeRole%> '<%=namenodeLabel%>'</h1>
-<%= NamenodeJspHelper.getVersionTable(fsn) %>
-<br />
-<% if (isActive && fsn != null) { %> 
-  <b><a href="/nn_browsedfscontent.jsp">Browse the filesystem</a></b><br>
-<% } %> 
-<b><a href="/logs/"><%=namenodeRole%> Logs</a></b><br>
-<b><a href=/dfshealth.jsp> Go back to DFS home</a></b>
-<hr>
-<% nodelistjsp.generateNodesList(application, out, request); %>
-
-<%
-out.println(ServletUtil.htmlFooter());
-%>

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f11c8eb0/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/nn_browsedfscontent.jsp
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/nn_browsedfscontent.jsp 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/nn_browsedfscontent.jsp
deleted file mode 100644
index 4a75f6d..0000000
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/nn_browsedfscontent.jsp
+++ /dev/null
@@ -1,46 +0,0 @@
-<%
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file 
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-%>
-<%@ page
-  contentType="text/html; charset=UTF-8"
-  import="org.apache.hadoop.conf.Configuration"
-  import="org.apache.hadoop.util.ServletUtil"
-  import="org.apache.hadoop.hdfs.server.common.JspHelper"
-%>
-<%!
-  //for java.io.Serializable
-  private static final long serialVersionUID = 1L;
-%>
-<!DOCTYPE html>
-<html>
-
-<title></title>
-
-<body>
-<% 
-  NamenodeJspHelper.redirectToRandomDataNode(application, request, response); 
-%>
-<hr>
-
-<h2>Local logs</h2>
-<a href="/logs/">Log</a> directory
-
-<%
-out.println(ServletUtil.htmlFooter());
-%>

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f11c8eb0/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/journal/journalstatus.jsp
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/journal/journalstatus.jsp 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/journal/journalstatus.jsp
deleted file mode 100644
index 2c6e5a3..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/journal/journalstatus.jsp
+++ /dev/null
@@ -1,42 +0,0 @@
-<%
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file 
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-%>
-<%@ page
-  contentType="text/html; charset=UTF-8"
-  import="org.apache.hadoop.hdfs.server.common.JspHelper"
-  import="org.apache.hadoop.util.ServletUtil"
-%>
-<%!
-  //for java.io.Serializable
-  private static final long serialVersionUID = 1L;
-%>
-
-<!DOCTYPE html>
-<html>
-<link rel="stylesheet" type="text/css" href="/static/hadoop.css">
-<title>Hadoop JournalNode</title>
-    
-<body>
-<h1>JournalNode</h1>
-<%= JspHelper.getVersionTable() %>
-<hr />
-
-<br />
-<b><a href="/logs/">Logs</a></b>
-<%= ServletUtil.htmlFooter() %>

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f11c8eb0/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/status.jsp
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/status.jsp 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/status.jsp
deleted file mode 100644
index bb9667b..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/status.jsp
+++ /dev/null
@@ -1,45 +0,0 @@
-<%
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file 
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-%>
-<%@ page
-  contentType="text/html; charset=UTF-8"
-  import="org.apache.hadoop.hdfs.server.common.JspHelper"
-  import="org.apache.hadoop.util.ServletUtil"
-%>
-<%!
-  //for java.io.Serializable
-  private static final long serialVersionUID = 1L;
-%>
-
-<!DOCTYPE html>
-<html>
-<link rel="stylesheet" type="text/css" href="/static/hadoop.css">
-<title>Hadoop SecondaryNameNode</title>
-    
-<body>
-<h1>SecondaryNameNode</h1>
-<%= JspHelper.getVersionTable() %>
-<hr />
-<pre>
-<%= application.getAttribute("secondary.name.node").toString() %>
-</pre>
-
-<br />
-<b><a href="/logs/">Logs</a></b>
-<%= ServletUtil.htmlFooter() %>

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f11c8eb0/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/common/TestJspHelper.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/common/TestJspHelper.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/common/TestJspHelper.java
index 873bc88..b5d23c8 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/common/TestJspHelper.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/common/TestJspHelper.java
@@ -17,39 +17,12 @@
  */
 package org.apache.hadoop.hdfs.server.common;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.*;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.jsp.JspWriter;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-
-import static com.google.common.base.Strings.*;
-
-import junit.framework.Assert;
+import org.junit.Assert;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hdfs.DFSConfigKeys;
 import org.apache.hadoop.hdfs.HdfsConfiguration;
-import org.apache.hadoop.hdfs.protocol.DatanodeID;
 import 
org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
-import org.apache.hadoop.hdfs.server.blockmanagement.BlockManagerTestUtil;
-import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
 import org.apache.hadoop.hdfs.server.namenode.NameNodeHttpServer;
-import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage;
-import org.apache.hadoop.hdfs.server.protocol.StorageReport;
 import org.apache.hadoop.hdfs.web.resources.DoAsParam;
 import org.apache.hadoop.hdfs.web.resources.UserParam;
 import org.apache.hadoop.io.DataInputBuffer;
@@ -66,17 +39,21 @@ import org.apache.hadoop.security.token.TokenIdentifier;
 import 
org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class TestJspHelper {
 
   private final Configuration conf = new HdfsConfiguration();
-  private String jspWriterOutput = "";
 
   // allow user with TGT to run tests
   @BeforeClass
@@ -405,32 +382,6 @@ public class TestJspHelper {
     }
   }
 
-  @Test
-  public void testPrintGotoFormWritesValidXML() throws IOException,
-         ParserConfigurationException, SAXException {
-    JspWriter mockJspWriter = mock(JspWriter.class);
-    ArgumentCaptor<String> arg = ArgumentCaptor.forClass(String.class);
-    doAnswer(new Answer<Object>() {
-      @Override
-      public Object answer(InvocationOnMock invok) {
-        Object[] args = invok.getArguments();
-        jspWriterOutput += (String) args[0];
-        return null;
-      }
-    }).when(mockJspWriter).print(arg.capture());
-
-    jspWriterOutput = "";
-
-    JspHelper.printGotoForm(mockJspWriter, 424242, "a token string",
-            "foobar/file", "0.0.0.0");
-
-    DocumentBuilder parser =
-        DocumentBuilderFactory.newInstance().newDocumentBuilder();
-    InputSource is = new InputSource();
-    is.setCharacterStream(new StringReader(jspWriterOutput));
-    parser.parse(is);
-  }
-
   private HttpServletRequest getMockRequest(String remoteUser, String user, 
String doAs) {
     HttpServletRequest request = mock(HttpServletRequest.class);
     when(request.getParameter(UserParam.NAME)).thenReturn(user);
@@ -464,119 +415,7 @@ public class TestJspHelper {
                           ugi.getAuthenticationMethod());
     }
   }
-  
-  @Test
-  public void testSortNodeByFields() throws Exception {
-    DatanodeID dnId1 = new DatanodeID("127.0.0.1", "localhost1", "datanode1",
-        1234, 2345, 3456, 4567);
-    DatanodeID dnId2 = new DatanodeID("127.0.0.2", "localhost2", "datanode2",
-        1235, 2346, 3457, 4568);
-
-    // Setup DatanodeDescriptors with one storage each.
-    DatanodeDescriptor dnDesc1 = new DatanodeDescriptor(dnId1, "rack1");
-    DatanodeDescriptor dnDesc2 = new DatanodeDescriptor(dnId2, "rack2");
-
-    // Update the DatanodeDescriptors with their attached storages.
-    BlockManagerTestUtil.updateStorage(dnDesc1, new 
DatanodeStorage("dnStorage1"));
-    BlockManagerTestUtil.updateStorage(dnDesc2, new 
DatanodeStorage("dnStorage2"));
-
-    DatanodeStorage dns1 = new DatanodeStorage("dnStorage1");
-    DatanodeStorage dns2 = new DatanodeStorage("dnStorage2");
-
-    StorageReport[] report1 = new StorageReport[] {
-        new StorageReport(dns1, false, 1024, 100, 924, 100)
-    };
-    StorageReport[] report2 = new StorageReport[] {
-        new StorageReport(dns2, false, 2500, 200, 1848, 200)
-    };
-    dnDesc1.updateHeartbeat(report1, 5L, 3L, 10, 2);
-    dnDesc2.updateHeartbeat(report2, 10L, 2L, 20, 1);
-
-    ArrayList<DatanodeDescriptor> live = new ArrayList<DatanodeDescriptor>();
-    live.add(dnDesc1);
-    live.add(dnDesc2);
-      
-    JspHelper.sortNodeList(live, "unexists", "ASC");
-    Assert.assertEquals(dnDesc1, live.get(0));
-    Assert.assertEquals(dnDesc2, live.get(1));    
-    JspHelper.sortNodeList(live, "unexists", "DSC");
-    Assert.assertEquals(dnDesc2, live.get(0));
-    Assert.assertEquals(dnDesc1, live.get(1));  
-    
-    // test sorting by capacity
-    JspHelper.sortNodeList(live, "capacity", "ASC");
-    Assert.assertEquals(dnDesc1, live.get(0));
-    Assert.assertEquals(dnDesc2, live.get(1));    
-    JspHelper.sortNodeList(live, "capacity", "DSC");
-    Assert.assertEquals(dnDesc2, live.get(0));
-    Assert.assertEquals(dnDesc1, live.get(1));
 
-    // test sorting by used
-    JspHelper.sortNodeList(live, "used", "ASC");
-    Assert.assertEquals(dnDesc1, live.get(0));
-    Assert.assertEquals(dnDesc2, live.get(1));    
-    JspHelper.sortNodeList(live, "used", "DSC");
-    Assert.assertEquals(dnDesc2, live.get(0));
-    Assert.assertEquals(dnDesc1, live.get(1)); 
-    
-    // test sorting by nondfsused
-    JspHelper.sortNodeList(live, "nondfsused", "ASC");
-    Assert.assertEquals(dnDesc1, live.get(0));
-    Assert.assertEquals(dnDesc2, live.get(1));
-    
-    JspHelper.sortNodeList(live, "nondfsused", "DSC");
-    Assert.assertEquals(dnDesc2, live.get(0));
-    Assert.assertEquals(dnDesc1, live.get(1));
-   
-    // test sorting by remaining
-    JspHelper.sortNodeList(live, "remaining", "ASC");
-    Assert.assertEquals(dnDesc1, live.get(0));
-    Assert.assertEquals(dnDesc2, live.get(1));
-    
-    JspHelper.sortNodeList(live, "remaining", "DSC");
-    Assert.assertEquals(dnDesc2, live.get(0));
-    Assert.assertEquals(dnDesc1, live.get(1));
-  }
-  
-  @Test
-  public void testPrintMethods() throws IOException {
-    JspWriter out = mock(JspWriter.class);      
-    HttpServletRequest req = mock(HttpServletRequest.class);
-    
-    final StringBuffer buffer = new StringBuffer();
-    
-    ArgumentCaptor<String> arg = ArgumentCaptor.forClass(String.class);
-    doAnswer(new Answer<String>() {      
-      @Override
-      public String answer(InvocationOnMock invok) {
-        Object[] args = invok.getArguments();
-        buffer.append(args[0]);
-        return null;
-      }
-    }).when(out).print(arg.capture());
-    
-    
-    JspHelper.createTitle(out, req, "testfile.txt");
-    verify(out, times(1)).print(Mockito.anyString());
-    
-    JspHelper.addTableHeader(out);
-    verify(out, times(1 + 2)).print(anyString());                  
-     
-    JspHelper.addTableRow(out, new String[] {" row11", "row12 "});
-    verify(out, times(1 + 2 + 4)).print(anyString());      
-    
-    JspHelper.addTableRow(out, new String[] {" row11", "row12 "}, 3);
-    verify(out, times(1 + 2 + 4 + 4)).print(Mockito.anyString());
-      
-    JspHelper.addTableRow(out, new String[] {" row21", "row22"});
-    verify(out, times(1 + 2 + 4 + 4 + 4)).print(anyString());      
-      
-    JspHelper.addTableFooter(out);
-    verify(out, times(1 + 2 + 4 + 4 + 4 + 1)).print(anyString());
-    
-    assertFalse(isNullOrEmpty(buffer.toString()));               
-  }
-  
   @Test
   public void testReadWriteReplicaState() {
     try {
@@ -596,21 +435,6 @@ public class TestJspHelper {
       fail("testReadWrite ex error ReplicaState");
     }
   }
-
-  @Test 
-  public void testAuthority(){
-    DatanodeID dnWithIp = new DatanodeID("127.0.0.1", "hostName", null,
-        50020, 50075, 50076, 50010);
-    assertNotNull(JspHelper.Url.authority("http", dnWithIp));
-
-    DatanodeID dnWithNullIp = new DatanodeID(null, "hostName", null,
-        50020, 50075, 50076, 50010);
-    assertNotNull(JspHelper.Url.authority("http", dnWithNullIp));
-
-    DatanodeID dnWithEmptyIp = new DatanodeID("", "hostName", null,
-        50020, 50075, 50076, 50010);
-    assertNotNull(JspHelper.Url.authority("http", dnWithEmptyIp));
-  }
  
   private static String clientAddr = "1.1.1.1";
   private static String chainedClientAddr = clientAddr+", 2.2.2.2";

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f11c8eb0/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
deleted file mode 100644
index 0d1c441..0000000
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.hadoop.hdfs.server.datanode;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.jsp.JspWriter;
-
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hdfs.DFSTestUtil;
-import org.apache.hadoop.hdfs.HdfsConfiguration;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.apache.hadoop.hdfs.server.common.JspHelper;
-import org.apache.hadoop.hdfs.server.namenode.NameNode;
-import org.apache.hadoop.net.NetUtils;
-import org.apache.hadoop.util.ServletUtil;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-public class TestDatanodeJsp {
-  
-  private static final String FILE_DATA = "foo bar baz biz buz";
-  private static final HdfsConfiguration CONF = new HdfsConfiguration();
-  private static String viewFilePage;
-  
-  private static void testViewingFile(MiniDFSCluster cluster, String filePath)
-      throws IOException {
-    FileSystem fs = cluster.getFileSystem();
-    
-    Path testPath = new Path(filePath);
-    if (!fs.exists(testPath)) {
-      DFSTestUtil.writeFile(fs, testPath, FILE_DATA);
-    }
-    
-    InetSocketAddress nnIpcAddress = 
cluster.getNameNode().getNameNodeAddress();
-    InetSocketAddress nnHttpAddress = cluster.getNameNode().getHttpAddress();
-    String base = JspHelper.Url.url("http", cluster.getDataNodes().get(0)
-        .getDatanodeId());
-
-    URL url = new URL(base + "/"
-        + "browseDirectory.jsp" + JspHelper.getUrlParam("dir", 
-            URLEncoder.encode(testPath.toString(), "UTF-8"), true)
-        + JspHelper.getUrlParam("namenodeInfoPort", Integer
-            .toString(nnHttpAddress.getPort())) + JspHelper
-            .getUrlParam("nnaddr", "localhost:" + nnIpcAddress.getPort()));
-    
-    viewFilePage = StringEscapeUtils.unescapeHtml(DFSTestUtil.urlGet(url));
-    
-    assertTrue("page should show preview of file contents, got: " + 
viewFilePage,
-        viewFilePage.contains(FILE_DATA));
-    
-    assertTrue("page should show link to download file", viewFilePage
-        .contains("/streamFile" + ServletUtil.encodePath(filePath)
-            + "?nnaddr=localhost:" + nnIpcAddress.getPort()));
-    
-    // check whether able to tail the file
-    String regex = "<a.+href=\"(.+?)\">Tail\\s*this\\s*file\\<\\/a\\>";
-    assertFileContents(regex, "Tail this File");
-    
-    // check whether able to 'Go Back to File View' after tailing the file
-    regex = "<a.+href=\"(.+?)\">Go\\s*Back\\s*to\\s*File\\s*View\\<\\/a\\>";
-    assertFileContents(regex, "Go Back to File View");
-
-    regex = "<a href=\"///" + nnHttpAddress.getHostName() + ":" +
-      nnHttpAddress.getPort() + "/dfshealth.jsp\">Go back to DFS home</a>";
-    assertTrue("page should generate DFS home scheme without explicit scheme", 
viewFilePage.contains(regex));
-  }
-  
-  private static void assertFileContents(String regex, String text)
-      throws IOException {
-    Pattern compile = Pattern.compile(regex);
-    Matcher matcher = compile.matcher(viewFilePage);
-    if (matcher.find()) {
-      // got hyperlink for Tail this file
-      String u = matcher.group(1);
-      String urlString = u.startsWith("///") ? ("http://"; + u.substring(3)) : 
u;
-      viewFilePage = StringEscapeUtils.unescapeHtml(DFSTestUtil
-          .urlGet(new URL(urlString)));
-      assertTrue("page should show preview of file contents", viewFilePage
-          .contains(FILE_DATA));
-    } else {
-      fail(text + " hyperlink should be there in the page content : "
-          + viewFilePage);
-    }
-  }
-  
-  @Test
-  public void testViewFileJsp() throws IOException {
-    MiniDFSCluster cluster = null;
-    try {
-      cluster = new MiniDFSCluster.Builder(CONF).build();
-      cluster.waitActive();
-      String paths[] = {
-        "/test-file",
-        "/tmp/test-file",
-        "/tmp/test-file%with goofy&characters",
-        "/foo bar/foo bar",
-        "/foo+bar/foo+bar",
-        "/foo;bar/foo;bar",
-        "/foo=bar/foo=bar",
-        "/foo,bar/foo,bar",
-        "/foo?bar/foo?bar",
-        "/foo\">bar/foo\">bar"
-      };
-      for (String p : paths) {
-        testViewingFile(cluster, p);
-        testViewingFile(cluster, p);
-      }
-    } finally {
-      if (cluster != null) {
-        cluster.shutdown();
-      }
-    }
-  }
-  
-  @Test
-  public void testGenStamp() throws Exception {
-    MiniDFSCluster cluster = new MiniDFSCluster.Builder(CONF).numDataNodes(1)
-        .build();
-    try {
-      FileSystem fs = cluster.getFileSystem();
-      Path testFile = new Path("/test/mkdirs/TestchunkSizeToView");
-      writeFile(fs, testFile);
-      JspWriter writerMock = Mockito.mock(JspWriter.class);
-      HttpServletRequest reqMock = Mockito.mock(HttpServletRequest.class);
-      setTheMockExpectationsFromReq(testFile, reqMock);
-      DatanodeJspHelper.generateFileDetails(writerMock, reqMock, CONF);
-      Mockito.verify(writerMock, Mockito.atLeastOnce()).print(
-          "<input type=\"hidden\" name=\"genstamp\" value=\"987654321\">");
-    } finally {
-      cluster.shutdown();
-    }
-  }
-
-  private void setTheMockExpectationsFromReq(Path testFile,
-      HttpServletRequest reqMock) {
-    Mockito.doReturn("987654321").when(reqMock).getParameter("genstamp");
-    Mockito.doReturn("1234").when(reqMock).getParameter("blockId");
-    Mockito.doReturn("8081").when(reqMock).getParameter("datanodePort");
-    Mockito.doReturn("8080").when(reqMock).getParameter("namenodeInfoPort");
-    Mockito.doReturn("100").when(reqMock).getParameter("chunkSizeToView");
-    Mockito.doReturn("1").when(reqMock).getParameter("startOffset");
-    Mockito.doReturn("1024").when(reqMock).getParameter("blockSize");
-    Mockito.doReturn(NetUtils.getHostPortString(NameNode.getAddress(CONF)))
-        .when(reqMock).getParameter("nnaddr");
-    Mockito.doReturn(testFile.toString()).when(reqMock).getPathInfo();
-    Mockito.doReturn("http").when(reqMock).getScheme();
-  }
-
-  static Path writeFile(FileSystem fs, Path f) throws IOException {
-    DataOutputStream out = fs.create(f);
-    try {
-      out.writeBytes("umamahesh: " + f);
-    } finally {
-      out.close();
-    }
-    assertTrue(fs.exists(f));
-    return f;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f11c8eb0/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeJspHelper.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeJspHelper.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeJspHelper.java
index 0cc92c3..b33ffa6 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeJspHelper.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeJspHelper.java
@@ -17,52 +17,24 @@
  */
 package org.apache.hadoop.hdfs.server.namenode;
 
-import static 
org.apache.hadoop.hdfs.server.namenode.startupprogress.Phase.LOADING_EDITS;
-import static 
org.apache.hadoop.hdfs.server.namenode.startupprogress.Phase.LOADING_FSIMAGE;
-import static 
org.apache.hadoop.hdfs.server.namenode.startupprogress.Phase.SAFEMODE;
-import static 
org.apache.hadoop.hdfs.server.namenode.startupprogress.Phase.SAVING_CHECKPOINT;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.jsp.JspWriter;
-
+import com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdfs.DFSConfigKeys;
 import org.apache.hadoop.hdfs.HdfsConfiguration;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
-import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeManager;
-import org.apache.hadoop.hdfs.server.common.JspHelper;
 import org.apache.hadoop.hdfs.server.datanode.DataNode;
-import org.apache.hadoop.hdfs.server.namenode.startupprogress.StartupProgress;
 import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
-import org.apache.hadoop.hdfs.web.resources.UserParam;
 import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.util.VersionInfo;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.znerd.xmlenc.XMLOutputter;
 
-import com.google.common.collect.ImmutableSet;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
 
 public class TestNameNodeJspHelper {
 
@@ -70,7 +42,6 @@ public class TestNameNodeJspHelper {
   
   private static MiniDFSCluster cluster;
   private static Configuration conf;
-  private static final String NAMENODE_ATTRIBUTE_KEY = "name.node";  
   
   @BeforeClass
   public static void setUp() throws Exception {
@@ -97,143 +68,14 @@ public class TestNameNodeJspHelper {
     Assert.assertEquals(null, tokenString);
   }
 
-  @Test
-  public void testSecurityModeText() {
-    conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
-    UserGroupInformation.setConfiguration(conf);
-    String securityOnOff = NamenodeJspHelper.getSecurityModeText();
-    Assert.assertTrue("security mode doesn't match. Should be ON",
-        securityOnOff.contains("ON"));
-    // Security is enabled
-    conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "simple");
-    UserGroupInformation.setConfiguration(conf);
-
-    securityOnOff = NamenodeJspHelper.getSecurityModeText();
-    Assert.assertTrue("security mode doesn't match. Should be OFF",
-        securityOnOff.contains("OFF"));
-  }
-
-  @Test
-  public void testGenerateStartupProgress() throws Exception {
-    cluster.waitClusterUp();
-    NamenodeJspHelper.HealthJsp jsp = new NamenodeJspHelper.HealthJsp();
-    StartupProgress prog = NameNode.getStartupProgress();
-    JspWriter out = mock(JspWriter.class);
-    jsp.generateStartupProgress(out, prog);
-    ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-    verify(out, atLeastOnce()).println(captor.capture());
-    List<String> contents = captor.getAllValues();
-
-    // Verify 100% overall completion and all phases mentioned in output.
-    Assert.assertTrue(containsMatch(contents, "Elapsed Time\\:"));
-    Assert.assertTrue(containsMatch(contents, "Percent 
Complete\\:.*?100\\.00%"));
-    Assert.assertTrue(containsMatch(contents, 
LOADING_FSIMAGE.getDescription()));
-    Assert.assertTrue(containsMatch(contents, LOADING_EDITS.getDescription()));
-    Assert.assertTrue(containsMatch(contents,
-      SAVING_CHECKPOINT.getDescription()));
-    Assert.assertTrue(containsMatch(contents, SAFEMODE.getDescription()));
-  }
-
-  @Test
-  public void testGetRollingUpgradeText() {
-    Assert.assertEquals("", NamenodeJspHelper.getRollingUpgradeText(null));
-  }
-
-  /**
-   * Tests for non-null, non-empty NameNode label.
-   */
-  @Test
-  public void testGetNameNodeLabel() {
-    String nameNodeLabel = NamenodeJspHelper.getNameNodeLabel(
-      cluster.getNameNode());
-    Assert.assertNotNull(nameNodeLabel);
-    Assert.assertFalse(nameNodeLabel.isEmpty());
-  }
-
-  /**
-   * Tests for non-null, non-empty NameNode label when called before
-   * initialization of the NameNode RPC server.
-   */
-  @Test
-  public void testGetNameNodeLabelNullRpcServer() {
-    NameNode nn = mock(NameNode.class);
-    when(nn.getRpcServer()).thenReturn(null);
-    String nameNodeLabel = NamenodeJspHelper.getNameNodeLabel(
-      cluster.getNameNode());
-    Assert.assertNotNull(nameNodeLabel);
-    Assert.assertFalse(nameNodeLabel.isEmpty());
-  }
-
-  /**
-   * Tests that passing a null FSNamesystem to generateSnapshotReport does not
-   * throw NullPointerException.
-   */
-  @Test
-  public void testGenerateSnapshotReportNullNamesystem() throws Exception {
-    NamenodeJspHelper.generateSnapshotReport(mock(JspWriter.class), null);
-  }
-
-  /**
-   * Tests that redirectToRandomDataNode does not throw NullPointerException if
-   * it finds a null FSNamesystem.
-   */
-  @Test(expected=IOException.class)
-  public void testRedirectToRandomDataNodeNullNamesystem() throws Exception {
-    NameNode nn = mock(NameNode.class);
-    when(nn.getNamesystem()).thenReturn(null);
-    ServletContext context = mock(ServletContext.class);
-    when(context.getAttribute("name.node")).thenReturn(nn);
-    NamenodeJspHelper.redirectToRandomDataNode(context,
-      mock(HttpServletRequest.class), mock(HttpServletResponse.class));
-  }
-
-  /**
-   * Tests that XMLBlockInfo does not throw NullPointerException if it finds a
-   * null FSNamesystem.
-   */
-  @Test
-  public void testXMLBlockInfoNullNamesystem() throws IOException {
-    XMLOutputter doc = new XMLOutputter(mock(JspWriter.class), "UTF-8");
-    new NamenodeJspHelper.XMLBlockInfo(null, 1L).toXML(doc);
-  }
-
-  /**
-   * Tests that XMLCorruptBlockInfo does not throw NullPointerException if it
-   * finds a null FSNamesystem.
-   */
-  @Test
-  public void testXMLCorruptBlockInfoNullNamesystem() throws IOException {
-    XMLOutputter doc = new XMLOutputter(mock(JspWriter.class), "UTF-8");
-    new NamenodeJspHelper.XMLCorruptBlockInfo(null, mock(Configuration.class),
-      10, 1L).toXML(doc);
-  }
-
-  /**
-   * Checks if the list contains any string that partially matches the regex.
-   *
-   * @param list List<String> containing strings to check
-   * @param regex String regex to check
-   * @return boolean true if some string in list partially matches regex
-   */
-  private static boolean containsMatch(List<String> list, String regex) {
-    Pattern pattern = Pattern.compile(regex);
-    for (String str: list) {
-      if (pattern.matcher(str).find()) {
-        return true;
-      }
-    }
-    return false;
-  }
-
   @Test(timeout = 15000)
   public void testGetRandomDatanode() {
-    ImmutableSet<String> set = ImmutableSet.of();
     NameNode nameNode = cluster.getNameNode();
     ImmutableSet.Builder<String> builder = ImmutableSet.builder();
     for (DataNode dataNode : cluster.getDataNodes()) {
       builder.add(dataNode.getDisplayName());
     }
-    set = builder.build();
+    ImmutableSet<String> set = builder.build();
 
     for (int i = 0; i < 10; i++) {
       DatanodeDescriptor dnDescriptor = NamenodeJspHelper
@@ -242,131 +84,4 @@ public class TestNameNodeJspHelper {
           set.contains(dnDescriptor.toString()));
     }
   }
-      
-  @Test(timeout = 15000)
-  public void testNamenodeJspHelperRedirectToRandomDataNode() throws 
IOException, InterruptedException {
-    final String urlPart = "browseDirectory.jsp?namenodeInfoPort=";            
         
-    
-    ServletContext context = mock(ServletContext.class);
-    HttpServletRequest request = mock(HttpServletRequest.class);
-    HttpServletResponse resp = mock(HttpServletResponse.class);          
-    
-    when(request.getScheme()).thenReturn("http");
-    when(request.getParameter(UserParam.NAME)).thenReturn("localuser");
-    when(context.getAttribute(NAMENODE_ATTRIBUTE_KEY)).thenReturn(
-        cluster.getNameNode());
-    when(context.getAttribute(JspHelper.CURRENT_CONF)).thenReturn(conf);    
-    ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-    doAnswer(new Answer<String>() {
-      @Override
-     public String answer(InvocationOnMock invocation) throws Throwable {
-        return null;
-        }
-    }).when(resp).sendRedirect(captor.capture());
-
-    NamenodeJspHelper.redirectToRandomDataNode(context, request, resp);    
-    assertTrue(captor.getValue().contains(urlPart));    
-  }
-  
-  private enum DataNodeStatus {
-    LIVE("[Live Datanodes(| +):(| +)]\\d"), 
-    DEAD("[Dead Datanodes(| +):(| +)]\\d");
-
-    private final Pattern pattern;
-
-    public Pattern getPattern() {
-      return pattern;
-    }
-
-    DataNodeStatus(String line) {
-      this.pattern = Pattern.compile(line);
-    }
-  }
-
-  private void checkDeadLiveNodes(NameNode nameNode, int deadCount,
-      int lifeCount) {
-    FSNamesystem ns = nameNode.getNamesystem();
-    DatanodeManager dm = ns.getBlockManager().getDatanodeManager();
-    List<DatanodeDescriptor> live = new ArrayList<DatanodeDescriptor>();
-    List<DatanodeDescriptor> dead = new ArrayList<DatanodeDescriptor>();
-    dm.fetchDatanodes(live, dead, true);
-    assertTrue("checkDeadLiveNodes error !!!", (live.size() == lifeCount)
-        && dead.size() == deadCount);
-  }
-
-  @Test(timeout = 15000)
-  public void testNodeListJspGenerateNodesList() throws IOException {
-    String output;
-    NameNode nameNode = cluster.getNameNode();
-    ServletContext context = mock(ServletContext.class);
-    when(context.getAttribute("name.node")).thenReturn(nameNode);
-    
when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
-        .thenReturn(cluster.getNameNode().getHttpAddress());    
-    checkDeadLiveNodes(nameNode, 0, DATA_NODES_AMOUNT);
-    output = getOutputFromGeneratedNodesList(context, DataNodeStatus.LIVE);
-    assertCounts(DataNodeStatus.LIVE, output, DATA_NODES_AMOUNT);
-    output = getOutputFromGeneratedNodesList(context, DataNodeStatus.DEAD);
-    assertCounts(DataNodeStatus.DEAD, output, 0);    
-  }
-
-  private void assertCounts(DataNodeStatus dataNodeStatus, String output,
-      int expectedCount) {
-    Matcher matcher = DataNodeStatus.LIVE.getPattern().matcher(output);
-    if (matcher.find()) {
-      String digitLine = output.substring(matcher.start(), matcher.end())
-          .trim();
-      assertTrue("assertCounts error. actual != expected",
-          Integer.parseInt(digitLine) == expectedCount);
-    } else {
-      fail("assertCount matcher error");
-    }
-  }
-
-  private String getOutputFromGeneratedNodesList(ServletContext context,
-      DataNodeStatus dnStatus) throws IOException {
-    JspWriter out = mock(JspWriter.class);
-    ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-    NamenodeJspHelper.NodeListJsp nodelistjsp = new 
NamenodeJspHelper.NodeListJsp();
-    final StringBuffer buffer = new StringBuffer();
-    doAnswer(new Answer<String>() {
-      @Override
-      public String answer(InvocationOnMock invok) {
-        Object[] args = invok.getArguments();
-        buffer.append((String) args[0]);
-        return null;
-      }
-    }).when(out).print(captor.capture());
-    HttpServletRequest request = mock(HttpServletRequest.class);
-    when(request.getScheme()).thenReturn("http");
-    when(request.getParameter("whatNodes")).thenReturn(dnStatus.name());
-    nodelistjsp.generateNodesList(context, out, request);
-    return buffer.toString();
-  }
-
-  @Test(timeout = 15000)
-  public void testGetInodeLimitText() {
-    NameNode nameNode = cluster.getNameNode();
-    FSNamesystem fsn = nameNode.getNamesystem();
-    ImmutableSet<String> patterns = 
-        ImmutableSet.of("files and directories", "Heap Memory used", "Non Heap 
Memory used");        
-    String line = NamenodeJspHelper.getInodeLimitText(fsn);    
-    for(String pattern: patterns) {
-      assertTrue("testInodeLimitText error " + pattern,
-          line.contains(pattern));
-    }    
-  }
-  
-  @Test(timeout = 15000)
-  public void testGetVersionTable() {
-    NameNode nameNode = cluster.getNameNode();
-    FSNamesystem fsn = nameNode.getNamesystem();
-    ImmutableSet<String> patterns = ImmutableSet.of(VersionInfo.getVersion(), 
-        VersionInfo.getRevision(), VersionInfo.getUser(), 
VersionInfo.getBranch(),
-        fsn.getClusterId(), fsn.getBlockPoolId());
-    String line = NamenodeJspHelper.getVersionTable(fsn);
-    for(String pattern: patterns) {
-       assertTrue("testGetVersionTable error " + pattern,
-           line.contains(pattern));
-    }
-  }  
 }

Reply via email to