Repository: ctripcorp/apollo
Pull request #1005 (2018-03-17 16:27:02)

abandon AllTests.java and fix some potential test issues


Patch:
diff --git a/pom.xml b/pom.xml
index a86ce80eb..8ff1e5087 100644
--- a/pom.xml
+++ b/pom.xml
@@ -329,11 +329,6 @@
 					<groupId>org.apache.maven.plugins</groupId>
 					<artifactId>maven-surefire-plugin</artifactId>
 					<version>${maven-surefire-plugin.version}</version>
-					<configuration>
-						<includes>
-							<include>**/AllTests.java</include>
-						</includes>
-					</configuration>
 				</plugin>
 				<plugin>
 					<groupId>org.apache.maven.plugins</groupId>


Test patch:
diff --git a/apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/AllTests.java b/apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/AllTests.java
deleted file mode 100644
index 2122236ea..000000000
--- a/apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/AllTests.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.ctrip.framework.apollo.adminservice;
-
-import com.ctrip.framework.apollo.adminservice.aop.NamespaceLockTest;
-import com.ctrip.framework.apollo.adminservice.aop.NamespaceUnlockAspectTest;
-import com.ctrip.framework.apollo.adminservice.controller.AppControllerTest;
-import com.ctrip.framework.apollo.adminservice.controller.AppNamespaceControllerTest;
-import com.ctrip.framework.apollo.adminservice.controller.ControllerExceptionTest;
-import com.ctrip.framework.apollo.adminservice.controller.ControllerIntegrationExceptionTest;
-import com.ctrip.framework.apollo.adminservice.controller.InstanceConfigControllerTest;
-import com.ctrip.framework.apollo.adminservice.controller.ItemSetControllerTest;
-import com.ctrip.framework.apollo.adminservice.controller.ReleaseControllerTest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses({
-    AppControllerTest.class, ReleaseControllerTest.class, ItemSetControllerTest.class,
-    ControllerExceptionTest.class, ControllerIntegrationExceptionTest.class,
-    NamespaceLockTest.class, InstanceConfigControllerTest.class, AppNamespaceControllerTest.class,
-    NamespaceUnlockAspectTest.class
-})
-public class AllTests {
-
-}
diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java
index d15760aba..0f5ee2bab 100644
--- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java
+++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java
@@ -12,6 +12,6 @@ import org.springframework.transaction.annotation.Transactional;
 @Transactional
 @WebIntegrationTest(randomPort = true)
 @SpringApplicationConfiguration(classes = BizTestConfiguration.class)
-public class AbstractIntegrationTest {
+public abstract class AbstractIntegrationTest {
 
 }
diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractUnitTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractUnitTest.java
index 318e5fe1c..672692ee7 100644
--- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractUnitTest.java
+++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractUnitTest.java
@@ -4,6 +4,6 @@ import org.junit.runner.RunWith;
 import org.mockito.runners.MockitoJUnitRunner;
 
 @RunWith(MockitoJUnitRunner.class)
-public class AbstractUnitTest {
+public abstract class AbstractUnitTest {
 
 }
diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AllTests.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AllTests.java
deleted file mode 100644
index ea90e8750..000000000
--- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AllTests.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.ctrip.framework.apollo.biz;
-
-import com.ctrip.framework.apollo.biz.config.BizConfigTest;
-import com.ctrip.framework.apollo.biz.grayReleaseRule.GrayReleaseRulesHolderTest;
-import com.ctrip.framework.apollo.biz.message.DatabaseMessageSenderTest;
-import com.ctrip.framework.apollo.biz.message.ReleaseMessageScannerTest;
-import com.ctrip.framework.apollo.biz.repository.AppNamespaceRepositoryTest;
-import com.ctrip.framework.apollo.biz.repository.AppRepositoryTest;
-import com.ctrip.framework.apollo.biz.service.AdminServiceTest;
-import com.ctrip.framework.apollo.biz.service.AdminServiceTransactionTest;
-import com.ctrip.framework.apollo.biz.service.ClusterServiceTest;
-import com.ctrip.framework.apollo.biz.service.InstanceServiceTest;
-import com.ctrip.framework.apollo.biz.service.NamespaceBranchServiceTest;
-import com.ctrip.framework.apollo.biz.service.NamespacePublishInfoTest;
-import com.ctrip.framework.apollo.biz.service.NamespaceServiceIntegrationTest;
-import com.ctrip.framework.apollo.biz.service.NamespaceServiceTest;
-import com.ctrip.framework.apollo.biz.service.ReleaseCreationTest;
-import com.ctrip.framework.apollo.biz.service.ReleaseServiceTest;
-import com.ctrip.framework.apollo.biz.service.BizDBPropertySourceTest;
-import com.ctrip.framework.apollo.biz.utils.ReleaseKeyGeneratorTest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses({
-    AppRepositoryTest.class,
-    AppNamespaceRepositoryTest.class,
-    AdminServiceTest.class,
-    AdminServiceTransactionTest.class,
-    DatabaseMessageSenderTest.class,
-    BizDBPropertySourceTest.class,
-    ReleaseServiceTest.class,
-    ReleaseMessageScannerTest.class,
-    ClusterServiceTest.class,
-    ReleaseKeyGeneratorTest.class,
-    InstanceServiceTest.class,
-    GrayReleaseRulesHolderTest.class,
-    NamespaceBranchServiceTest.class,
-    ReleaseCreationTest.class,
-    NamespacePublishInfoTest.class,
-    NamespaceServiceIntegrationTest.class,
-    BizConfigTest.class,
-    NamespaceServiceTest.class
-})
-public class AllTests {
-
-}
diff --git a/apollo-client/src/test/java/com/ctrip/framework/apollo/AllTests.java b/apollo-client/src/test/java/com/ctrip/framework/apollo/AllTests.java
deleted file mode 100644
index 4ec05b3d6..000000000
--- a/apollo-client/src/test/java/com/ctrip/framework/apollo/AllTests.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.ctrip.framework.apollo;
-
-import com.ctrip.framework.apollo.integration.ConfigIntegrationTest;
-import com.ctrip.framework.apollo.internals.DefaultConfigManagerTest;
-import com.ctrip.framework.apollo.internals.DefaultConfigTest;
-import com.ctrip.framework.apollo.internals.JsonConfigFileTest;
-import com.ctrip.framework.apollo.internals.LocalFileConfigRepositoryTest;
-import com.ctrip.framework.apollo.internals.PropertiesConfigFileTest;
-import com.ctrip.framework.apollo.internals.RemoteConfigLongPollServiceTest;
-import com.ctrip.framework.apollo.internals.RemoteConfigRepositoryTest;
-import com.ctrip.framework.apollo.internals.SimpleConfigTest;
-import com.ctrip.framework.apollo.internals.XmlConfigFileTest;
-import com.ctrip.framework.apollo.spi.DefaultConfigFactoryManagerTest;
-import com.ctrip.framework.apollo.spi.DefaultConfigFactoryTest;
-import com.ctrip.framework.apollo.spi.DefaultConfigRegistryTest;
-import com.ctrip.framework.apollo.spring.BootstrapConfigTest;
-import com.ctrip.framework.apollo.spring.JavaConfigAnnotationTest;
-import com.ctrip.framework.apollo.spring.JavaConfigPlaceholderAutoUpdateTest;
-import com.ctrip.framework.apollo.spring.JavaConfigPlaceholderTest;
-import com.ctrip.framework.apollo.spring.XMLConfigAnnotationTest;
-import com.ctrip.framework.apollo.spring.XmlConfigPlaceholderAutoUpdateTest;
-import com.ctrip.framework.apollo.spring.XmlConfigPlaceholderTest;
-import com.ctrip.framework.apollo.spring.config.ConfigPropertySourceTest;
-import com.ctrip.framework.apollo.spring.property.PlaceholderHelperTest;
-import com.ctrip.framework.apollo.util.ConfigUtilTest;
-import com.ctrip.framework.apollo.util.ExceptionUtilTest;
-import com.ctrip.framework.apollo.util.parser.DateParserTest;
-import com.ctrip.framework.apollo.util.parser.DurationParserTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses({
-    ConfigServiceTest.class, DefaultConfigRegistryTest.class, DefaultConfigFactoryManagerTest.class,
-    DefaultConfigManagerTest.class, DefaultConfigTest.class, LocalFileConfigRepositoryTest.class,
-    RemoteConfigRepositoryTest.class, SimpleConfigTest.class, DefaultConfigFactoryTest.class,
-    ConfigIntegrationTest.class, ExceptionUtilTest.class, XmlConfigFileTest.class,
-    PropertiesConfigFileTest.class, RemoteConfigLongPollServiceTest.class, DateParserTest.class,
-    DurationParserTest.class, JsonConfigFileTest.class, XmlConfigPlaceholderTest.class,
-    JavaConfigPlaceholderTest.class, XMLConfigAnnotationTest.class, JavaConfigAnnotationTest.class,
-    ConfigUtilTest.class, BootstrapConfigTest.class, JavaConfigPlaceholderAutoUpdateTest.class,
-    XmlConfigPlaceholderAutoUpdateTest.class, ConfigPropertySourceTest.class,
-    PlaceholderHelperTest.class
-})
-public class AllTests {
-
-}
diff --git a/apollo-common/src/test/java/com/ctrip/framework/apollo/common/AllTests.java b/apollo-common/src/test/java/com/ctrip/framework/apollo/common/AllTests.java
deleted file mode 100644
index 15a2b95c3..000000000
--- a/apollo-common/src/test/java/com/ctrip/framework/apollo/common/AllTests.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.ctrip.framework.apollo.common;
-
-import com.ctrip.framework.apollo.common.conditional.ConditionalOnProfileTest;
-import com.ctrip.framework.apollo.common.utils.InputValidatorTest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses({
-    InputValidatorTest.class, ConditionalOnProfileTest.class
-})
-public class AllTests {
-
-}
diff --git a/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/AllTests.java b/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/AllTests.java
deleted file mode 100644
index c45b57ca5..000000000
--- a/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/AllTests.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.ctrip.framework.apollo.configservice;
-
-import com.ctrip.framework.apollo.configservice.controller.ConfigControllerTest;
-import com.ctrip.framework.apollo.configservice.controller.ConfigFileControllerTest;
-import com.ctrip.framework.apollo.configservice.controller.NotificationControllerTest;
-import com.ctrip.framework.apollo.configservice.controller.NotificationControllerV2Test;
-import com.ctrip.framework.apollo.configservice.integration.ConfigControllerIntegrationTest;
-import com.ctrip.framework.apollo.configservice.integration.ConfigFileControllerIntegrationTest;
-import com.ctrip.framework.apollo.configservice.integration.NotificationControllerIntegrationTest;
-import com.ctrip.framework.apollo.configservice.integration.NotificationControllerV2IntegrationTest;
-import com.ctrip.framework.apollo.configservice.service.AppNamespaceServiceWithCacheTest;
-import com.ctrip.framework.apollo.configservice.service.ReleaseMessageServiceWithCacheTest;
-import com.ctrip.framework.apollo.configservice.service.config.ConfigServiceWithCacheTest;
-import com.ctrip.framework.apollo.configservice.service.config.DefaultConfigServiceTest;
-import com.ctrip.framework.apollo.configservice.util.InstanceConfigAuditUtilTest;
-import com.ctrip.framework.apollo.configservice.util.NamespaceUtilTest;
-import com.ctrip.framework.apollo.configservice.util.WatchKeysUtilTest;
-import com.ctrip.framework.apollo.configservice.wrapper.CaseInsensitiveMapWrapperTest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses({ConfigControllerTest.class, NotificationControllerTest.class,
-    ConfigControllerIntegrationTest.class, NotificationControllerIntegrationTest.class,
-    NamespaceUtilTest.class, ConfigFileControllerTest.class,
-    ConfigFileControllerIntegrationTest.class, WatchKeysUtilTest.class,
-    NotificationControllerV2Test.class, NotificationControllerV2IntegrationTest.class,
-    InstanceConfigAuditUtilTest.class, AppNamespaceServiceWithCacheTest.class,
-    ReleaseMessageServiceWithCacheTest.class, DefaultConfigServiceTest.class, ConfigServiceWithCacheTest.class,
-    CaseInsensitiveMapWrapperTest.class
-})
-public class AllTests {
-
-}
diff --git a/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2Test.java b/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2Test.java
index 602c66709..10b1cd444 100644
--- a/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2Test.java
+++ b/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2Test.java
@@ -35,6 +35,7 @@ import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
@@ -342,11 +343,13 @@ public class NotificationControllerV2Test {
 
     controller.handleMessage(someReleaseMessage, Topics.APOLLO_RELEASE_TOPIC);
 
-    assertTrue(!anotherDeferredResult.hasResult());
+    //in batch mode, at most one of them should have result
+    assertFalse(deferredResult.hasResult() && anotherDeferredResult.hasResult());
 
     TimeUnit.MILLISECONDS.sleep(someBatchInterval * 10);
 
-    assertTrue(anotherDeferredResult.hasResult());
+    //now both of them should have result
+    assertTrue(deferredResult.hasResult() && anotherDeferredResult.hasResult());
   }
 
   private String transformApolloConfigNotificationsToString(
diff --git a/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/AbstractBaseIntegrationTest.java b/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/AbstractBaseIntegrationTest.java
index 688f28e0c..e1a322e65 100644
--- a/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/AbstractBaseIntegrationTest.java
+++ b/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/AbstractBaseIntegrationTest.java
@@ -114,7 +114,8 @@ public abstract class AbstractBaseIntegrationTest {
   private static class TestBizConfig extends BizConfig {
     @Override
     public int appNamespaceCacheScanInterval() {
-      return 50;
+      //should be short enough to update the AppNamespace cache in time
+      return 1;
     }
 
     @Override
diff --git a/apollo-core/src/test/java/com/ctrip/framework/apollo/AllTests.java b/apollo-core/src/test/java/com/ctrip/framework/apollo/AllTests.java
deleted file mode 100644
index 878c12cf8..000000000
--- a/apollo-core/src/test/java/com/ctrip/framework/apollo/AllTests.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.ctrip.framework.apollo;
-
-import com.ctrip.framework.apollo.foundation.FoundationTest;
-import com.ctrip.framework.apollo.foundation.internals.ServiceBootstrapTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-import com.ctrip.framework.apollo.core.MetaDomainTest;
-import com.ctrip.framework.apollo.foundation.internals.provider.DefaultApplicationProviderTest;
-import com.ctrip.framework.apollo.foundation.internals.provider.DefaultServerProviderTest;
-import com.ctrip.framework.apollo.tracer.TracerTest;
-import com.ctrip.framework.apollo.tracer.internals.DefaultMessageProducerManagerTest;
-import com.ctrip.framework.apollo.tracer.internals.NullMessageProducerManagerTest;
-import com.ctrip.framework.apollo.tracer.internals.NullMessageProducerTest;
-
-@RunWith(Suite.class)
-@SuiteClasses({
-    MetaDomainTest.class, ServiceBootstrapTest.class, NullMessageProducerManagerTest.class,
-    NullMessageProducerTest.class, DefaultMessageProducerManagerTest.class, TracerTest.class,
-    DefaultApplicationProviderTest.class, DefaultServerProviderTest.class, FoundationTest.class})
-public class AllTests {
-
-}
diff --git a/apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/AllTests.java b/apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/AllTests.java
deleted file mode 100644
index 063230969..000000000
--- a/apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/AllTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.ctrip.framework.apollo.portal;
-
-
-import com.ctrip.framework.apollo.openapi.filter.ConsumerAuthenticationFilterTest;
-import com.ctrip.framework.apollo.openapi.service.ConsumerRolePermissionServiceTest;
-import com.ctrip.framework.apollo.openapi.service.ConsumerServiceTest;
-import com.ctrip.framework.apollo.openapi.util.ConsumerAuditUtilTest;
-import com.ctrip.framework.apollo.openapi.util.ConsumerAuthUtilTest;
-import com.ctrip.framework.apollo.portal.component.txtresolver.FileTextResolverTest;
-import com.ctrip.framework.apollo.portal.component.txtresolver.PropertyResolverTest;
-import com.ctrip.framework.apollo.portal.config.ConfigTest;
-import com.ctrip.framework.apollo.portal.service.AppNamespaceServiceTest;
-import com.ctrip.framework.apollo.portal.service.ConfigServiceTest;
-import com.ctrip.framework.apollo.portal.service.FavoriteServiceTest;
-import com.ctrip.framework.apollo.portal.service.NamespaceServiceTest;
-import com.ctrip.framework.apollo.portal.spi.defaultImpl.RoleInitializationServiceTest;
-import com.ctrip.framework.apollo.portal.spi.defaultImpl.RolePermissionServiceTest;
-import com.ctrip.framework.apollo.portal.spi.ctrip.CtripUserServiceTest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses({
-    ConfigServiceTest.class, PropertyResolverTest.class,
-    NamespaceServiceTest.class, ServiceExceptionTest.class, RolePermissionServiceTest.class,
-    AppNamespaceServiceTest.class, RoleInitializationServiceTest.class, FileTextResolverTest.class,
-    RetryableRestTemplateTest.class, ConsumerRolePermissionServiceTest.class,
-    ConsumerAuthenticationFilterTest.class, ConsumerAuthUtilTest.class, ConsumerServiceTest.class,
-    ConsumerAuditUtilTest.class, ConfigTest.class, FavoriteServiceTest.class,
-    CtripUserServiceTest.class
-
-})
-public class AllTests {
-
-}