use of com.alibaba.nacos.config.server.utils.MD5Util in project nacos by alibaba.
the class ConfigServletInnerTest method testDoPollingConfig.
@Test
public void testDoPollingConfig() throws Exception {
final MockedStatic<MD5Util> md5Util = Mockito.mockStatic(MD5Util.class);
Map<String, String> clientMd5Map = new HashMap<>();
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
List<String> changedGroups = new ArrayList<>();
changedGroups.add("1");
changedGroups.add("2");
when(MD5Util.compareMd5(request, response, clientMd5Map)).thenReturn(changedGroups);
when(MD5Util.compareMd5OldResult(changedGroups)).thenReturn("test-old");
when(MD5Util.compareMd5ResultString(changedGroups)).thenReturn("test-new");
String actualValue = configServletInner.doPollingConfig(request, response, clientMd5Map, 1);
Assert.assertEquals(HttpServletResponse.SC_OK + "", actualValue);
Assert.assertEquals("test-old", response.getHeader(Constants.PROBE_MODIFY_RESPONSE));
Assert.assertEquals("test-new", response.getHeader(Constants.PROBE_MODIFY_RESPONSE_NEW));
Assert.assertEquals("no-cache,no-store", response.getHeader("Cache-Control"));
md5Util.close();
}
Aggregations