Browse Source

abandon AllTests.java and fix some potential test issues

nobodyiam 7 years ago
parent
commit
f754dc26aa

+ 0 - 26
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/AllTests.java

@@ -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 {
-
-}

+ 1 - 1
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 {
 
 }

+ 1 - 1
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 {
 
 }

+ 0 - 49
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AllTests.java

@@ -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 {
-
-}

+ 0 - 48
apollo-client/src/test/java/com/ctrip/framework/apollo/AllTests.java

@@ -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 {
-
-}

+ 0 - 16
apollo-common/src/test/java/com/ctrip/framework/apollo/common/AllTests.java

@@ -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 {
-
-}

+ 0 - 36
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/AllTests.java

@@ -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 {
-
-}

+ 5 - 2
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(

+ 2 - 1
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

+ 0 - 24
apollo-core/src/test/java/com/ctrip/framework/apollo/AllTests.java

@@ -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 {
-
-}

+ 0 - 37
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/AllTests.java

@@ -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 {
-
-}

+ 0 - 5
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>