Repository: ambari
Updated Branches:
  refs/heads/branch-dev-logsearch a565ead6f -> ffcf5328e


http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/StringUtil.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/StringUtil.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/StringUtil.java
deleted file mode 100644
index de83e7e..0000000
--- 
a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/StringUtil.java
+++ /dev/null
@@ -1,33 +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.ambari.logsearch.util;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-@Component
-public class StringUtil {
-  
-  private static  Logger logger = Logger.getLogger(StringUtil.class);
-  
-  public boolean isEmpty(String str) {
-    return str == null || str.trim().length() == 0;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
index 69132e8..9fb285e 100644
--- 
a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
@@ -29,12 +29,10 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
-import org.apache.ambari.logsearch.common.RequestContext;
-import org.apache.ambari.logsearch.common.UserSessionInfo;
+import org.apache.ambari.logsearch.common.LogSearchContext;
 import org.apache.ambari.logsearch.manager.SessionMgr;
-import org.apache.ambari.logsearch.security.context.LogsearchContextHolder;
-import org.apache.ambari.logsearch.security.context.LogsearchSecurityContext;
 import org.apache.ambari.logsearch.util.CommonUtil;
+import org.apache.ambari.logsearch.web.model.User;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import 
org.springframework.security.authentication.AnonymousAuthenticationToken;
@@ -89,31 +87,21 @@ public class LogsearchSecurityContextFormationFilter 
extends GenericFilterBean {
           httpResponse.addCookie(cookie);
         }
         // [1]get the context from session
-        LogsearchSecurityContext context = (LogsearchSecurityContext) 
httpSession
+        LogSearchContext context = (LogSearchContext) httpSession
           .getAttribute(LOGSEARCH_SC_SESSION_KEY);
         if (context == null) {
-          context = new LogsearchSecurityContext();
+          context = new LogSearchContext();
           httpSession.setAttribute(LOGSEARCH_SC_SESSION_KEY, context);
         }
-        String userAgent = httpRequest.getHeader(USER_AGENT);
-        // Get the request specific info
-        RequestContext requestContext = new RequestContext();
-        String reqIP = httpRequest.getRemoteAddr();
-        requestContext.setIpAddress(reqIP);
-        requestContext.setMsaCookie(msaCookie);
-        requestContext.setUserAgent(userAgent);
-        requestContext.setServerRequestId(CommonUtil.genGUI());
-        requestContext.setRequestURL(httpRequest.getRequestURI());
-        context.setRequestContext(requestContext);
-        LogsearchContextHolder.setSecurityContext(context);
-        UserSessionInfo userSession = sessionMgr.processSuccessLogin(0, 
userAgent);
-        context.setUserSession(userSession);
+        LogSearchContext.setContext(context);
+        User user = sessionMgr.processSuccessLogin();
+        context.setUser(user);
       }
       chain.doFilter(request, response);
 
     } finally {
       // [4]remove context from thread-local
-      LogsearchContextHolder.resetSecurityContext();
+      LogSearchContext.resetContext();
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
index f1f2e31..72ee60f 100644
--- 
a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
@@ -26,8 +26,8 @@ import javax.annotation.PostConstruct;
 import org.apache.ambari.logsearch.util.ExternalServerClient;
 import org.apache.ambari.logsearch.util.JSONUtil;
 import org.apache.ambari.logsearch.util.PropertiesUtil;
-import org.apache.ambari.logsearch.util.StringUtil;
 import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.BadCredentialsException;
@@ -99,9 +99,6 @@ public class LogsearchExternalServerAuthenticationProvider 
extends
   ExternalServerClient externalServerClient;
 
   @Autowired
-  StringUtil stringUtil;
-
-  @Autowired
   JSONUtil jsonUtil;
 
   private String loginAPIURL = 
"/api/v1/users/$USERNAME/privileges?fields=*";// default
@@ -130,10 +127,10 @@ public class 
LogsearchExternalServerAuthenticationProvider extends
     }
     String username = authentication.getName();
     String password = (String) authentication.getCredentials();
-    if (stringUtil.isEmpty(username)) {
+    if (StringUtils.isBlank(username)) {
       throw new BadCredentialsException("Username can't be null or empty.");
     }
-    if (stringUtil.isEmpty(password)) {
+    if (StringUtils.isBlank(password)) {
       throw new BadCredentialsException("Password can't be null or empty.");
     }
     // html unescape

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
index a5ff295..44c31c5 100644
--- 
a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
@@ -20,9 +20,9 @@ package org.apache.ambari.logsearch.web.security;
 
 import java.util.Collection;
 
-import org.apache.ambari.logsearch.dao.UserDao;
-import org.apache.ambari.logsearch.util.StringUtil;
+import org.apache.ambari.logsearch.util.CommonUtil;
 import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.BadCredentialsException;
@@ -40,12 +40,6 @@ public class LogsearchFileAuthenticationProvider extends 
LogsearchAbstractAuthen
   private static Logger logger = 
Logger.getLogger(LogsearchFileAuthenticationProvider.class);
 
   @Autowired
-  UserDao userDao;
-
-  @Autowired
-  StringUtil stringUtil;
-
-  @Autowired
   private UserDetailsService userDetailsService;
 
   @Override
@@ -56,10 +50,10 @@ public class LogsearchFileAuthenticationProvider extends 
LogsearchAbstractAuthen
     }
     String username = authentication.getName();
     String password = (String) authentication.getCredentials();
-    if (stringUtil.isEmpty(username)) {
+    if (StringUtils.isBlank(username)) {
       throw new BadCredentialsException("Username can't be null or empty.");
     }
-    if (stringUtil.isEmpty(password)) {
+    if (StringUtils.isBlank(password)) {
       throw new BadCredentialsException("Password can't be null or empty.");
     }
     // html unescape
@@ -76,7 +70,7 @@ public class LogsearchFileAuthenticationProvider extends 
LogsearchAbstractAuthen
       throw new BadCredentialsException("Password can't be null or empty.");
     }
 
-    String encPassword = userDao.encryptPassword(username, password);
+    String encPassword = CommonUtil.encryptPassword(username, password);
     if (!encPassword.equals(user.getPassword())) {
       logger.error("Wrong password for user=" + username);
       throw new BadCredentialsException("Wrong password");

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
index 7e0546e..ec2516c 100644
--- 
a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
@@ -18,11 +18,10 @@
  */
 package org.apache.ambari.logsearch.web.security;
 
-import org.apache.ambari.logsearch.util.StringUtil;
 import org.apache.ambari.logsearch.web.model.User;
 import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.BadCredentialsException;
 import 
org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
@@ -34,9 +33,6 @@ public class LogsearchSimpleAuthenticationProvider extends 
LogsearchAbstractAuth
 
   private static Logger logger = 
Logger.getLogger(LogsearchSimpleAuthenticationProvider.class);
 
-  @Autowired
-  StringUtil stringUtil;
-
   @Override
   public Authentication authenticate(Authentication authentication) throws 
AuthenticationException {
     if (!this.isEnable()) {
@@ -46,7 +42,7 @@ public class LogsearchSimpleAuthenticationProvider extends 
LogsearchAbstractAuth
     String username = authentication.getName();
     String password = (String) authentication.getCredentials();
     username = StringEscapeUtils.unescapeHtml(username);
-    if (stringUtil.isEmpty(username)) {
+    if (StringUtils.isBlank(username)) {
       throw new BadCredentialsException("Username can't be null or empty.");
     }
     User user = new User();

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/LogSearchContextUtilTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/LogSearchContextUtilTest.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/LogSearchContextUtilTest.java
new file mode 100644
index 0000000..cd33741
--- /dev/null
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/LogSearchContextUtilTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.ambari.logsearch.common;
+
+import org.apache.ambari.logsearch.web.model.User;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+public class LogSearchContextUtilTest {
+
+  @Before
+  public void resetContext() {
+    LogSearchContext.resetContext();
+  }
+  
+  @Test
+  public void testNoContext() {
+    Assert.assertNull(LogSearchContext.getCurrentUsername());
+  }
+  
+  @Test
+  public void testUserSession() {
+    User user = new User("UserName", "Password", null);
+    
+    LogSearchContext context = new LogSearchContext();
+    context.setUser(user);
+    
+    LogSearchContext.setContext(context);
+    
+    Assert.assertEquals(LogSearchContext.getCurrentUsername(), "UserName");
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/ManageStartEndTimeTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/ManageStartEndTimeTest.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/ManageStartEndTimeTest.java
new file mode 100644
index 0000000..6b75d87
--- /dev/null
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/ManageStartEndTimeTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.ambari.logsearch.common;
+
+import java.util.Date;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ManageStartEndTimeTest {
+
+  @Test
+  public void testManageStartEndTime() {
+    ManageStartEndTime.manage();
+    Date[] range = ManageStartEndTime.getStartEndTime();
+    Assert.assertEquals(range[1].getTime() - range[0].getTime(), 60*60*1000);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
new file mode 100644
index 0000000..0b94b60
--- /dev/null
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.ambari.logsearch.dao;
+
+import java.util.ArrayList;
+
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.common.util.NamedList;
+import org.easymock.Capture;
+import org.easymock.CaptureType;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+public class AuditSolrDaoTest {
+
+  @Test
+  public void testAuditSolrDaoPostConstructor() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    
+    NamedList<Object> response = new NamedList<Object>();
+    NamedList<Object> header = new NamedList<Object>();
+    header.add("status", 0);
+    response.add("responseHeader", header);
+    response.add("collections", new ArrayList<String>());
+    
+    Capture<CollectionAdminRequest.Create> captureCreateRequest = 
EasyMock.newCapture(CaptureType.LAST);
+    
+    
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class),
 EasyMock.anyString())).andReturn(response);
+    
+    mockSolrClient.request(EasyMock.capture(captureCreateRequest), 
EasyMock.anyString());
+    EasyMock.expectLastCall().andReturn(response);
+    
+    EasyMock.replay(mockSolrClient);
+    
+    AuditSolrDao dao = new AuditSolrDao();
+    dao.solrClient = mockSolrClient;
+    dao.isZkConnectString = true;
+    
+    dao.postConstructor();
+    EasyMock.verify(mockSolrClient);
+    
+    CollectionAdminRequest.Create createRequest = 
captureCreateRequest.getValue();
+    Assert.assertEquals(createRequest.getConfigName(), 
"test_audit_logs_config_name");
+    Assert.assertEquals(createRequest.getNumShards().intValue(), 123);
+    Assert.assertEquals(createRequest.getReplicationFactor().intValue(), 456);
+    Assert.assertEquals(createRequest.getCollectionName(), 
"test_audit_logs_collection");
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
new file mode 100644
index 0000000..2985a62
--- /dev/null
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.ambari.logsearch.dao;
+
+import java.util.ArrayList;
+
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.common.util.NamedList;
+import org.easymock.Capture;
+import org.easymock.CaptureType;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+public class ServiceLogsSolrDaoTest {
+
+  @Test
+  public void testServiceLogsSolrDaoPostConstructor() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    
+    NamedList<Object> response = new NamedList<Object>();
+    NamedList<Object> header = new NamedList<Object>();
+    header.add("status", 0);
+    response.add("responseHeader", header);
+    response.add("collections", new ArrayList<String>());
+    
+    Capture<CollectionAdminRequest.Create> captureCreateRequest = 
EasyMock.newCapture(CaptureType.LAST);
+    
+    
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class),
 EasyMock.anyString())).andReturn(response);
+    mockSolrClient.request(EasyMock.capture(captureCreateRequest), 
EasyMock.anyString()); EasyMock.expectLastCall().andReturn(response);
+    
+    EasyMock.replay(mockSolrClient);
+    
+    ServiceLogsSolrDao dao = new ServiceLogsSolrDao();
+    dao.solrClient = mockSolrClient;
+    dao.isZkConnectString = true;
+    
+    dao.postConstructor();
+    EasyMock.verify(mockSolrClient);
+    
+    CollectionAdminRequest.Create createRequest = 
captureCreateRequest.getValue();
+    Assert.assertEquals(createRequest.getConfigName(), 
"test_service_logs_config_name");
+    Assert.assertEquals(createRequest.getNumShards().intValue(), 789);
+    Assert.assertEquals(createRequest.getReplicationFactor().intValue(), 987);
+    Assert.assertEquals(createRequest.getCollectionName(), 
"test_service_logs_collection");
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
new file mode 100644
index 0000000..0ded95d
--- /dev/null
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
@@ -0,0 +1,286 @@
+/*
+ * 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.ambari.logsearch.dao;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import javax.ws.rs.WebApplicationException;
+
+import org.apache.ambari.logsearch.manager.MgrBase.LogType;
+import org.apache.ambari.logsearch.util.RESTErrorUtil;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.SolrRequest.METHOD;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.client.solrj.response.UpdateResponse;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.util.NamedList;
+import org.easymock.EasyMock;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import junit.framework.Assert;
+
+public class SolrDaoBaseTest {
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+  
+  // ----------------------------------------------------------- connectToSolr 
-----------------------------------------------------------
+  
+  @Test
+  public void testConnectToSolrWithConnectString() throws Exception {
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    SolrClient solrClient = dao.connectToSolr(null, "zk_connect_string", 
"collection");
+    
+    Assert.assertEquals(solrClient.getClass(), CloudSolrClient.class);
+  }
+  
+  @Test
+  public void testConnectToSolrWithUrl() throws Exception {
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    SolrClient solrClient = dao.connectToSolr("url", null, "collection");
+    
+    Assert.assertEquals(solrClient.getClass(), HttpSolrClient.class);
+  }
+  
+  @Test
+  public void testConnectToSolrWithBoth() throws Exception {
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    SolrClient solrClient = dao.connectToSolr("url", "zk_connect_string", 
"collection");
+    
+    Assert.assertEquals(solrClient.getClass(), CloudSolrClient.class);
+  }
+  
+  @Test
+  public void testConnectToSolrWithNeither() throws Exception {
+    expectedException.expect(Exception.class);
+    expectedException.expectMessage("Both zkConnectString and URL are empty. 
zkConnectString=null, collection=collection, url=null");
+
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    dao.connectToSolr(null, null, "collection");
+  }
+  
+  @Test
+  public void testConnectToSolrWithoutCollection() throws Exception {
+    expectedException.expect(Exception.class);
+    expectedException.expectMessage("For solr, collection name is mandatory. 
zkConnectString=zk_connect_string, collection=null, url=url");
+
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    dao.connectToSolr("url", "zk_connect_string", null);
+  }
+  
+  // ---------------------------------------------------------- 
checkSolrStatus ----------------------------------------------------------
+  
+  @Test
+  public void testCheckSolrStatus() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    
+    NamedList<Object> response = new NamedList<Object>();
+    NamedList<Object> header = new NamedList<Object>();
+    header.add("status", 0);
+    response.add("responseHeader", header);
+    response.add("collections", new ArrayList<String>());
+    
+    
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class),
 EasyMock.anyString())).andReturn(response);
+    EasyMock.replay(mockSolrClient);
+    
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    dao.solrClient = mockSolrClient;
+    
+    boolean status = dao.checkSolrStatus(10000);
+    Assert.assertTrue(status);
+    
+    EasyMock.verify(mockSolrClient);
+  }
+  
+  @Test
+  public void testCheckSolrStatusNotSuccessful() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    EasyMock.replay(mockSolrClient);
+    
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    dao.solrClient = mockSolrClient;
+    
+    boolean status = dao.checkSolrStatus(10000);
+    Assert.assertFalse(status);
+    
+    EasyMock.verify(mockSolrClient);
+  }
+  
+  // ------------------------------------------------------------- setupAlias 
------------------------------------------------------------
+  
+  @Test
+  public void testSetupAlias() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    CloudSolrClient mockSolrClouldClient = 
EasyMock.strictMock(CloudSolrClient.class);
+    
+    NamedList<Object> response = new NamedList<Object>();
+    NamedList<Object> header = new NamedList<Object>();
+    header.add("status", 0);
+    response.add("responseHeader", header);
+    response.add("collections", Arrays.asList("collection1", "collection2"));
+    
+    
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class),
 EasyMock.anyString())).andReturn(response);
+    
EasyMock.expect(mockSolrClouldClient.request(EasyMock.anyObject(CollectionAdminRequest.CreateAlias.class),
 EasyMock.anyString())).andReturn(response);
+    mockSolrClouldClient.setDefaultCollection("alias_name"); 
EasyMock.expectLastCall();
+    
+    EasyMock.replay(mockSolrClient, mockSolrClouldClient);
+    
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    dao.isZkConnectString = true;
+    dao.solrClient = mockSolrClient;
+    dao.solrClouldClient = mockSolrClouldClient;
+    dao.collectionName = "test_collection";
+    
+    dao.setupAlias("alias_name", Arrays.asList("collection1", "collection2"));
+    
+    Thread.sleep(1000);
+    
+    EasyMock.verify(mockSolrClient, mockSolrClouldClient);
+  }
+  
+  // ---------------------------------------------------------- 
setupCollections ---------------------------------------------------------
+  
+  @Test
+  public void testCreateCollectionsDontSplitPopulate() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    
+    NamedList<Object> response = new NamedList<Object>();
+    NamedList<Object> header = new NamedList<Object>();
+    header.add("status", 0);
+    response.add("responseHeader", header);
+    response.add("collections", new ArrayList<String>());
+    
+    
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class),
 EasyMock.anyString())).andReturn(response);
+    
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.Create.class),
 EasyMock.anyString())).andReturn(response);
+    EasyMock.replay(mockSolrClient);
+    
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    dao.isZkConnectString = true;
+    dao.solrClient = mockSolrClient;
+    dao.collectionName = "test_collection";
+    
+    dao.setupCollections("none", "configName", 1, 1, true);
+    
+    EasyMock.verify(mockSolrClient);
+  }
+  
+  @Test
+  public void testCreateCollectionsSplitDontPopulate() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    
+    NamedList<Object> response = new NamedList<Object>();
+    NamedList<Object> header = new NamedList<Object>();
+    header.add("status", 0);
+    response.add("responseHeader", header);
+    response.add("collections", new ArrayList<String>());
+    
+    
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class),
 EasyMock.anyString())).andReturn(response);
+    
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.Create.class),
 EasyMock.anyString())).andReturn(response);
+    EasyMock.replay(mockSolrClient);
+    
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    dao.isZkConnectString = true;
+    dao.solrClient = mockSolrClient;
+    
+    dao.setupCollections("1", "configName", 3, 1, false);
+    
+    EasyMock.verify(mockSolrClient);
+  }
+  
+  // -------------------------------------------------------------- process 
--------------------------------------------------------------
+  
+  @Test
+  public void testProcess() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    EasyMock.expect(mockSolrClient.query(EasyMock.anyObject(SolrQuery.class), 
EasyMock.eq(METHOD.POST))).andReturn(new QueryResponse());
+    EasyMock.replay(mockSolrClient);
+    
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    dao.solrClient = mockSolrClient;
+    
+    dao.process(new SolrQuery());
+    
+    EasyMock.verify(mockSolrClient);
+  }
+  
+  @Test
+  public void testProcessNoConnection() throws Exception {
+    expectedException.expect(WebApplicationException.class);
+    
+    SolrDaoBase dao = new SolrDaoBase(LogType.SERVICE) {};
+    dao.restErrorUtil = new RESTErrorUtil();
+    dao.process(new SolrQuery());
+  }
+  
+  // ----------------------------------------------------------- add/removeDoc 
-----------------------------------------------------------
+  
+  @Test
+  public void testAddDoc() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    
+    UpdateResponse updateResponse = new UpdateResponse();
+    NamedList<Object> response = new NamedList<Object>();
+    NamedList<Object> header = new NamedList<Object>();
+    header.add("QTime", 1);
+    response.add("responseHeader", header);
+    updateResponse.setResponse(response);
+    
+    
EasyMock.expect(mockSolrClient.add(EasyMock.anyObject(SolrInputDocument.class))).andReturn(updateResponse);
+    EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
+    EasyMock.replay(mockSolrClient);
+    
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    dao.solrClient = mockSolrClient;
+    
+    dao.addDocs(new SolrInputDocument());
+    
+    EasyMock.verify(mockSolrClient);
+  }
+  
+  @Test
+  public void testRemoveDoc() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    
+    UpdateResponse updateResponse = new UpdateResponse();
+    NamedList<Object> response = new NamedList<Object>();
+    NamedList<Object> header = new NamedList<Object>();
+    header.add("QTime", 1);
+    response.add("responseHeader", header);
+    updateResponse.setResponse(response);
+    
+    
EasyMock.expect(mockSolrClient.deleteByQuery(EasyMock.anyString())).andReturn(updateResponse);
+    EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
+    EasyMock.replay(mockSolrClient);
+    
+    SolrDaoBase dao = new SolrDaoBase(null) {};
+    dao.solrClient = mockSolrClient;
+    
+    dao.removeDoc("query");
+    
+    EasyMock.verify(mockSolrClient);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
new file mode 100644
index 0000000..5ef286f
--- /dev/null
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
@@ -0,0 +1,129 @@
+/*
+ * 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.ambari.logsearch.dao;
+
+import java.util.ArrayList;
+
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrRequest.METHOD;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.client.solrj.response.UpdateResponse;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.easymock.Capture;
+import org.easymock.CaptureType;
+import org.easymock.EasyMock;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import junit.framework.Assert;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "/applicationContext.xml" })
+public class UserConfigSolrDaoTest {
+  
+  @Autowired
+  private UserConfigSolrDao dao;
+  
+  @Test
+  public void testUserConfigDaoPostConstructor() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    
+    NamedList<Object> requestResponse = new NamedList<Object>();
+    NamedList<Object> requestResponseHeader = new NamedList<Object>();
+    requestResponseHeader.add("status", 0);
+    requestResponse.add("responseHeader", requestResponseHeader);
+    requestResponse.add("collections", new ArrayList<String>());
+    
+    QueryResponse queryResponse = new QueryResponse();
+    
+    UpdateResponse updateResponse = new UpdateResponse();
+    NamedList<Object> updateResponseContent = new NamedList<Object>();
+    NamedList<Object> updateResponseHeader = new NamedList<Object>();
+    updateResponseHeader.add("QTime", 1);
+    updateResponseContent.add("responseHeader", updateResponseHeader);
+    updateResponse.setResponse(updateResponseContent);
+    
+    Capture<CollectionAdminRequest.Create> captureCreateRequest = 
EasyMock.newCapture(CaptureType.LAST);
+    Capture<SolrParams> captureSolrParams = 
EasyMock.newCapture(CaptureType.LAST);
+    Capture<METHOD> captureMethod = EasyMock.newCapture(CaptureType.LAST);
+    Capture<SolrInputDocument> captureSolrInputDocument = 
EasyMock.newCapture(CaptureType.LAST);
+    
+    
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class),
 EasyMock.anyString())).andReturn(requestResponse);
+    mockSolrClient.request(EasyMock.capture(captureCreateRequest), 
EasyMock.anyString()); EasyMock.expectLastCall().andReturn(requestResponse);
+    mockSolrClient.query(EasyMock.capture(captureSolrParams), 
EasyMock.capture(captureMethod)); 
EasyMock.expectLastCall().andReturn(queryResponse);
+    mockSolrClient.add(EasyMock.capture(captureSolrInputDocument)); 
EasyMock.expectLastCall().andReturn(updateResponse);
+    EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
+    EasyMock.replay(mockSolrClient);
+    
+    dao.solrClient = mockSolrClient;
+    dao.isZkConnectString = true;
+    
+    dao.postConstructor();
+    EasyMock.verify(mockSolrClient);
+    
+    CollectionAdminRequest.Create createRequest = 
captureCreateRequest.getValue();
+    Assert.assertEquals(createRequest.getConfigName(), 
"test_history_logs_config_name");
+    Assert.assertEquals(createRequest.getReplicationFactor().intValue(), 234);
+    Assert.assertEquals(createRequest.getCollectionName(), 
"test_history_logs_collection");
+    
+    SolrParams solrParams = captureSolrParams.getValue();
+    Assert.assertEquals(solrParams.get("q"), "*:*");
+    Assert.assertEquals(solrParams.get("fq"), "rowtype:log_feeder_config");
+    
+    METHOD method = captureMethod.getValue();
+    Assert.assertEquals(method, METHOD.POST);
+    
+    SolrInputDocument solrInputDocument = captureSolrInputDocument.getValue();
+    Assert.assertNotNull(solrInputDocument.getFieldValue("id"));
+    Assert.assertEquals(solrInputDocument.getFieldValue("rowtype"), 
"log_feeder_config");
+    Assert.assertEquals(solrInputDocument.getFieldValue("jsons"), 
"{\"filter\":{\"test_component2\":{\"label\":\"test_component2\",\"hosts\":[],\"defaultLevels\":[\"FATAL\",\"ERROR\",\"WARN\",\"INFO\",\"DEBUG\",\"TRACE\"],\"overrideLevels\":[]},\"test_component1\":{\"label\":\"test_component1\",\"hosts\":[],\"defaultLevels\":[\"FATAL\",\"ERROR\",\"WARN\",\"INFO\",\"DEBUG\",\"TRACE\"],\"overrideLevels\":[]}},\"id\":\""
 + solrInputDocument.getFieldValue("id") + "\"}");
+    Assert.assertEquals(solrInputDocument.getFieldValue("username"), 
"log_feeder_config");
+    Assert.assertEquals(solrInputDocument.getFieldValue("filtername"), 
"log_feeder_config");
+  }
+  
+  @Test
+  public void testDeleteUserConfig() throws Exception {
+    SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
+    
+    UpdateResponse updateResponse = new UpdateResponse();
+    NamedList<Object> response = new NamedList<Object>();
+    NamedList<Object> header = new NamedList<Object>();
+    header.add("QTime", 1);
+    response.add("responseHeader", header);
+    updateResponse.setResponse(response);
+    
+    
EasyMock.expect(mockSolrClient.deleteByQuery("id:test_id")).andReturn(updateResponse);
+    EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
+    EasyMock.replay(mockSolrClient);
+    
+    dao.solrClient = mockSolrClient;
+    dao.isZkConnectString = true;
+    
+    dao.deleteUserConfig("test_id");
+    
+    EasyMock.verify(mockSolrClient);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserDaoTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserDaoTest.java
 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserDaoTest.java
new file mode 100644
index 0000000..703d877
--- /dev/null
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserDaoTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.ambari.logsearch.dao;
+
+import java.util.Collection;
+
+import org.apache.ambari.logsearch.web.model.Role;
+import org.apache.ambari.logsearch.web.model.User;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "/applicationContext.xml" })
+public class UserDaoTest {
+
+  @Autowired
+  private UserDao dao;
+  
+  @Test
+  public void testUserDaoInitAndFindUser() throws Exception {
+    User user = dao.loadUserByUsername("testUserName");
+    assertEquals(user.getUsername(), "testUserName");
+    assertEquals(user.getFirstName(), "Test User Name");
+    assertEquals(user.getLastName(), "Test User Name");
+    
+    Collection<? extends GrantedAuthority> authorities = user.getAuthorities();
+    assertTrue(authorities.size() == 1);
+    
+    Role authority = (Role)authorities.iterator().next();
+    assertEquals(authority.getName(), "ROLE_USER");
+    assertTrue(authority.getPrivileges().size() == 1);
+    assertEquals(authority.getPrivileges().get(0).getName(), "READ_PRIVILEGE");
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/resources/HadoopServiceConfig.json
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/resources/HadoopServiceConfig.json
 
b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/HadoopServiceConfig.json
new file mode 100644
index 0000000..344dc3d
--- /dev/null
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/HadoopServiceConfig.json
@@ -0,0 +1,17 @@
+{
+  "service": {
+    "accumulo": {
+      "label": "TestService",
+      "components": [
+        {
+          "name": "test_component1"
+        },
+        {
+          "name": "test_component2"
+        }
+      ],
+      "dependencies": [
+      ]
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml
 
b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml
new file mode 100644
index 0000000..5e24d88
--- /dev/null
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+xmlns:aop="http://www.springframework.org/schema/aop"; 
xmlns:jee="http://www.springframework.org/schema/jee";
+xmlns:tx="http://www.springframework.org/schema/tx"; 
xmlns:context="http://www.springframework.org/schema/context";
+xmlns:task="http://www.springframework.org/schema/task"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+xmlns:util="http://www.springframework.org/schema/util";
+xsi:schemaLocation="http://www.springframework.org/schema/aop
+http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
+http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
+http://www.springframework.org/schema/context
+http://www.springframework.org/schema/context/spring-context-4.2.xsd
+http://www.springframework.org/schema/jee
+http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
+http://www.springframework.org/schema/tx
+http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
+http://www.springframework.org/schema/task
+http://www.springframework.org/schema/task/spring-task-4.2.xsd
+http://www.springframework.org/schema/util
+http://www.springframework.org/schema/util/spring-util.xsd";>
+
+       <context:component-scan base-package="org.apache.ambari.logsearch" />
+       <task:annotation-driven />
+       <bean id="xmlPropertyConfigurer" 
class="org.apache.ambari.logsearch.util.XMLPropertiesUtil" />
+       
+       <bean id="propertyConfigurer" 
class="org.apache.ambari.logsearch.util.PropertiesUtil">
+               <property name="locations">
+                       <list>
+                               <value>classpath:default.properties</value>
+                               <value>classpath:logsearch.properties</value>
+                               
<value>classpath:logsearch-admin-site.xml</value>
+                       </list>
+               </property>
+               <property name="propertiesPersister" 
ref="xmlPropertyConfigurer" />
+       </bean>
+       
+</beans>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext_testManagers.xml
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext_testManagers.xml
 
b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext_testManagers.xml
new file mode 100644
index 0000000..f1d1dbe
--- /dev/null
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext_testManagers.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+xmlns:aop="http://www.springframework.org/schema/aop"; 
xmlns:jee="http://www.springframework.org/schema/jee";
+xmlns:tx="http://www.springframework.org/schema/tx"; 
xmlns:context="http://www.springframework.org/schema/context";
+xmlns:task="http://www.springframework.org/schema/task"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+xmlns:util="http://www.springframework.org/schema/util";
+xsi:schemaLocation="http://www.springframework.org/schema/aop
+http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
+http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
+http://www.springframework.org/schema/context
+http://www.springframework.org/schema/context/spring-context-4.2.xsd
+http://www.springframework.org/schema/jee
+http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
+http://www.springframework.org/schema/tx
+http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
+http://www.springframework.org/schema/task
+http://www.springframework.org/schema/task/spring-task-4.2.xsd
+http://www.springframework.org/schema/util
+http://www.springframework.org/schema/util/spring-util.xsd";>
+
+       <context:component-scan 
base-package="org.apache.ambari.logsearch.manager.dao, 
org.apache.ambari.logsearch.util" />
+       <task:annotation-driven />
+       <bean id="xmlPropertyConfigurer" 
class="org.apache.ambari.logsearch.util.XMLPropertiesUtil" />
+       
+       <bean id="propertyConfigurer" 
class="org.apache.ambari.logsearch.util.PropertiesUtil">
+               <property name="locations">
+                       <list>
+                               <value>classpath:default.properties</value>
+                               <value>classpath:logsearch.properties</value>
+                               
<value>classpath:logsearch-admin-site.xml</value>
+                       </list>
+               </property>
+               <property name="propertiesPersister" 
ref="xmlPropertyConfigurer" />
+       </bean>
+       
+</beans>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/resources/logsearch.properties
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/resources/logsearch.properties
 
b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/logsearch.properties
new file mode 100755
index 0000000..fa3efb8
--- /dev/null
+++ 
b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/logsearch.properties
@@ -0,0 +1,32 @@
+# 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.
+
+logsearch.solr.audit.logs.config.name=test_audit_logs_config_name
+logsearch.collection.audit.logs.numshards=123
+logsearch.collection.audit.logs.replication.factor=456
+logsearch.solr.collection.audit.logs=test_audit_logs_collection
+
+logsearch.solr.service.logs.config.name=test_service_logs_config_name
+logsearch.collection.service.logs.numshards=789
+logsearch.collection.service.logs.replication.factor=987
+logsearch.solr.collection.service.logs=test_service_logs_collection
+logsearch.service.logs.split.interval.mins=1
+
+logsearch.solr.history.config.name=test_history_logs_config_name
+logsearch.collection.history.replication.factor=234
+logsearch.solr.collection.history=test_history_logs_collection
+
+logsearch.auth.file.enable=true
+logsearch.login.credentials.file=user_pass.json
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/test/resources/user_pass.json
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-portal/src/test/resources/user_pass.json 
b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/user_pass.json
new file mode 100644
index 0000000..0a04afe
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/user_pass.json
@@ -0,0 +1,8 @@
+{
+  "users": [{
+    "name": "Test User Name",
+    "username": "testUserName",
+    "password": "testUserPassword",
+    "en_password": ""
+  }]
+}
\ No newline at end of file

Reply via email to