incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpapirkovs...@apache.org
Subject git commit: AMBARI-3503. AmbariLdapAuthenticationProviderForDNWithSpaceTest and JdbcPropertyTest fail sometimes due to order of tests execution. (mpapirkovskyy)
Date Fri, 11 Oct 2013 16:55:54 GMT
Updated Branches:
  refs/heads/trunk e964d3fd3 -> 4dd856eaa


AMBARI-3503. AmbariLdapAuthenticationProviderForDNWithSpaceTest and JdbcPropertyTest fail
sometimes due to order of tests execution. (mpapirkovskyy)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/4dd856ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/4dd856ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/4dd856ea

Branch: refs/heads/trunk
Commit: 4dd856eaa5efb324f7d5796dfea37b56fc3807ee
Parents: e964d3f
Author: Myroslav Papirkovskyy <mpapyrkovskyy@hortonworks.com>
Authored: Fri Oct 11 19:54:10 2013 +0300
Committer: Myroslav Papirkovskyy <mpapyrkovskyy@hortonworks.com>
Committed: Fri Oct 11 19:54:10 2013 +0300

----------------------------------------------------------------------
 .../apache/ambari/server/orm/JdbcPropertyTest.java  | 14 +++++++++++---
 ...dapAuthenticationProviderForDNWithSpaceTest.java | 16 +++++++++-------
 2 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4dd856ea/ambari-server/src/test/java/org/apache/ambari/server/orm/JdbcPropertyTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/JdbcPropertyTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/orm/JdbcPropertyTest.java
index c90fbbd..4a1f1fc 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/JdbcPropertyTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/JdbcPropertyTest.java
@@ -19,9 +19,11 @@ package org.apache.ambari.server.orm;
 
 import java.util.Properties;
 
+import com.google.inject.persist.PersistService;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.ControllerModule;
 import org.apache.ambari.server.state.Clusters;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -31,6 +33,7 @@ import com.google.inject.Injector;
 
 public class JdbcPropertyTest {
   Properties properties;
+  private Injector injector;
 
   @Before
   public void configure() {
@@ -40,10 +43,15 @@ public class JdbcPropertyTest {
     properties.setProperty(Configuration.SERVER_VERSION_FILE, "target/version");
     properties.setProperty(Configuration.OS_VERSION_KEY, "centos5");
   }
-  
+
+  @After
+  public void tearDown() throws Exception {
+    injector.getInstance(PersistService.class).stop();
+  }
+
   @Test
   public void testNormal() throws Exception {
-    Injector injector = Guice.createInjector(new ControllerModule(properties));
+    injector = Guice.createInjector(new ControllerModule(properties));
     injector.getInstance(GuiceJpaInitializer.class);
 
     injector.getInstance(Clusters.class);
@@ -52,7 +60,7 @@ public class JdbcPropertyTest {
   @Test
   public void testJdbcProperty() throws Exception {
     properties.setProperty(Configuration.SERVER_JDBC_PROPERTIES_PREFIX + "shutdown", "true");
-    Injector injector = Guice.createInjector(new ControllerModule(properties));
+    injector = Guice.createInjector(new ControllerModule(properties));
     injector.getInstance(GuiceJpaInitializer.class);
     try {
       injector.getInstance(Clusters.class);

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4dd856ea/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderForDNWithSpaceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderForDNWithSpaceTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderForDNWithSpaceTest.java
index b94758f..c904774 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderForDNWithSpaceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderForDNWithSpaceTest.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.security.authorization;
 import com.google.inject.Guice;
 import com.google.inject.Inject;
 import com.google.inject.Injector;
+import com.google.inject.persist.PersistService;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.dao.RoleDAO;
@@ -27,10 +28,7 @@ import org.apache.ambari.server.orm.dao.UserDAO;
 import org.apache.ambari.server.orm.entities.RoleEntity;
 import org.apache.ambari.server.orm.entities.UserEntity;
 import org.apache.ambari.server.security.ClientSecurityType;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.*;
 import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
@@ -53,9 +51,6 @@ public class AmbariLdapAuthenticationProviderForDNWithSpaceTest {
 
   @BeforeClass
   public static void beforeClass() throws Exception{
-    injector = Guice.createInjector(new AuthorizationTestModuleForLdapDNWithSpace());
-    injector.getInstance(GuiceJpaInitializer.class);
-
     apacheDSContainer = new ApacheDSContainer("dc=ambari,dc=the apache,dc=org", "classpath:/users_for_dn_with_space.ldif");
     apacheDSContainer.setPort(33389);
     apacheDSContainer.afterPropertiesSet();
@@ -63,10 +58,17 @@ public class AmbariLdapAuthenticationProviderForDNWithSpaceTest {
 
   @Before
   public void setUp() {
+    injector = Guice.createInjector(new AuthorizationTestModuleForLdapDNWithSpace());
     injector.injectMembers(this);
+    injector.getInstance(GuiceJpaInitializer.class);
     configuration.setClientSecurityType(ClientSecurityType.LDAP);
   }
 
+  @After
+  public void tearDown() throws Exception {
+    injector.getInstance(PersistService.class).stop();
+  }
+
   @Test(expected = BadCredentialsException.class)
   public void testBadCredential() throws Exception {
     Authentication authentication = new UsernamePasswordAuthenticationToken("notFound", "wrong");


Mime
View raw message