forked from apache/ozhera
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: modify the verification method of es address apache#416
- Loading branch information
1 parent
a27b435
commit d1becbc
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...t/java/com/xiaomi/mone/log/manager/service/impl/MilogMiddlewareConfigServiceImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.xiaomi.mone.log.manager.service.impl; | ||
|
||
import com.xiaomi.mone.log.api.model.bo.MiLogResource; | ||
import static com.xiaomi.mone.log.manager.common.utils.ManagerUtil.getConfigFromNanos; | ||
import com.xiaomi.youpin.docean.Ioc; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
|
||
/** | ||
* @author: songyutong1 | ||
* @date: 2024/08/22/15:15 | ||
*/ | ||
public class MilogMiddlewareConfigServiceImplTest { | ||
|
||
@Test | ||
public void testCheckEsAddressPortOperate() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { | ||
getConfigFromNanos(); | ||
Ioc.ins().init("com.xiaomi"); | ||
MilogMiddlewareConfigServiceImpl milogMiddlewareConfigService = Ioc.ins().getBean(MilogMiddlewareConfigServiceImpl.class); | ||
Method method = milogMiddlewareConfigService.getClass().getDeclaredMethod("checkEsAddressPortOperate", MiLogResource.class); | ||
method.setAccessible(true); | ||
|
||
MiLogResource miLogResource = new MiLogResource(); | ||
miLogResource.setServiceUrl("zjynewretail.api.es.srv"); | ||
method.invoke(milogMiddlewareConfigService, miLogResource); | ||
Assert.assertEquals("zjynewretail.api.es.srv:80", miLogResource.getServiceUrl()); | ||
|
||
miLogResource.setServiceUrl("zjynewretail.api.es.srv:80"); | ||
method.invoke(milogMiddlewareConfigService, miLogResource); | ||
Assert.assertEquals("zjynewretail.api.es.srv:80", miLogResource.getServiceUrl()); | ||
|
||
miLogResource.setServiceUrl("zjynewretail.api.es.srv:"); | ||
method.invoke(milogMiddlewareConfigService, miLogResource); | ||
Assert.assertEquals("zjynewretail.api.es.srv:80", miLogResource.getServiceUrl()); | ||
} | ||
|
||
} |