Skip to content

Commit

Permalink
[ISSUE alibaba#5092] add unit tests for constant in nacos-config
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorHe1 committed Oct 27, 2021
1 parent ea2a106 commit b5511e5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public enum CounterMode {
/**
* Reverse the two mode value.
*
* @return
* @return CounterMode
*/
public CounterMode reverse() {
if (INCREMENT == this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,30 @@
import static com.alibaba.nacos.config.server.constant.Constants.HEALTH_CONTROLLER_PATH;
import static com.alibaba.nacos.config.server.constant.Constants.HISTORY_CONTROLLER_PATH;
import static com.alibaba.nacos.config.server.constant.Constants.LISTENER_CONTROLLER_PATH;
import static com.alibaba.nacos.config.server.constant.Constants.METRICS_CONTROLLER_PATH;
import static com.alibaba.nacos.config.server.constant.Constants.NAMESPACE_CONTROLLER_PATH;
import static com.alibaba.nacos.config.server.constant.Constants.OPS_CONTROLLER_PATH;
import static com.alibaba.nacos.config.server.constant.Constants.RECV_WAIT_TIMEOUT;

public class ConstantsTest {

@Test
public void testControllerPathsDefaultValues() {

Assert.assertEquals("/v1/cs/ops", OPS_CONTROLLER_PATH);
Assert.assertEquals("/v1/cs/capacity", CAPACITY_CONTROLLER_PATH);
Assert.assertEquals("/v1/cs/communication", COMMUNICATION_CONTROLLER_PATH);
Assert.assertEquals("/v1/cs/configs", CONFIG_CONTROLLER_PATH);
Assert.assertEquals("/v1/cs/health", HEALTH_CONTROLLER_PATH);
Assert.assertEquals("/v1/cs/history", HISTORY_CONTROLLER_PATH);
Assert.assertEquals("/v1/cs/listener", LISTENER_CONTROLLER_PATH);
Assert.assertEquals("/v1/cs/namespaces", NAMESPACE_CONTROLLER_PATH);
Assert.assertEquals("/v1/cs/metrics", METRICS_CONTROLLER_PATH);
}

@Test
public void testRecvWaitTimeoutDefaultValue() {

Assert.assertEquals(10000, RECV_WAIT_TIMEOUT);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.alibaba.nacos.config.server.constant;

import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mock;

public class CounterModeTest {

@Mock
CounterMode counterMode;

@Test
public void testReverse() {
counterMode = CounterMode.INCREMENT;
Assert.assertEquals(CounterMode.DECREMENT, counterMode.reverse());
counterMode = CounterMode.DECREMENT;
Assert.assertEquals(CounterMode.INCREMENT, counterMode.reverse());
}

}

0 comments on commit b5511e5

Please sign in to comment.