Closed tvd12 closed 3 years ago
beanContextBuilder.addAllClasses(reflection);
beanContextBuilder.scan(scanablePackages);
com.tvd12.ezyfoxserver.support.v120.test.entry
<package name="com.tvd12.ezyfoxserver.support.v120.test.entry"/>
EzySimpleAppEntryTest
package com.tvd12.ezyfoxserver.support.v120.test.entry; import java.util.Set; import org.testng.annotations.Test; import com.tvd12.ezyfox.bean.EzyBeanContext; import com.tvd12.ezyfox.bean.EzyPackagesToScanAware; import com.tvd12.ezyfox.bean.annotation.EzySingleton; import com.tvd12.ezyfox.collect.Sets; import com.tvd12.ezyfoxserver.context.EzyAppContext; import com.tvd12.ezyfoxserver.support.entry.EzySimpleAppEntry; import com.tvd12.test.assertion.Asserts; import static org.mockito.Mockito.*; import lombok.Setter; public class EzySimpleAppEntryTest { @Test public void scanPacakges() { // given EzyAppContext appContext = mock(EzyAppContext.class); InternalAppEntry sut = new InternalAppEntry(); // when sut.config(appContext); // then EzyBeanContext beanContext = sut.beanContext; MongoConfig mongoConfig = beanContext.getBeanCast(MongoConfig.class); Set<String> expectedPackages = Sets.newHashSet( "com.tvd12.ezyfoxserver.support.v120.test.entry" ); Asserts.assertEquals(expectedPackages, mongoConfig.packagesToScan); Singleton singleton = beanContext.getBeanCast(Singleton.class); Asserts.assertNotNull(singleton); } @EzySingleton public static class Singleton { } @Setter public static class MongoConfig implements EzyPackagesToScanAware { public Set<String> packagesToScan; } private static class InternalAppEntry extends EzySimpleAppEntry { public EzyBeanContext beanContext; @Override protected String[] getScanablePackages() { return new String[] {"com.tvd12.ezyfoxserver.support.v120.test.entry"}; } @Override protected void postConfig(EzyAppContext context, EzyBeanContext beanContext) { this.beanContext = beanContext; } } }
EzySimplePluginEntryTest
dev
Nguyên nhân
Các file bị ảnh hưởng
Cách fix
beanContextBuilder.addAllClasses(reflection);
bằngbeanContextBuilder.scan(scanablePackages);
com.tvd12.ezyfoxserver.support.v120.test.entry
trong thư mục ezyfox-server-support/src/test<package name="com.tvd12.ezyfoxserver.support.v120.test.entry"/>
vào AllTests.tng.xmlEzySimpleAppEntryTest
với nội dung kiểu này:EzySimplePluginEntryTest
với nội dung kiểu trênQuy trình
dev