1 /* 2 * Zed Attack Proxy (ZAP) and its related class files. 3 * 4 * ZAP is an HTTP/HTTPS proxy for assessing web application security. 5 * 6 * Copyright 2012 The ZAP Development Team 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 package org.parosproxy.paros.core.scanner; 21 22 import static org.hamcrest.MatcherAssert.assertThat; 23 import static org.hamcrest.Matchers.closeTo; 24 import static org.hamcrest.Matchers.is; 25 26 import org.junit.jupiter.api.Test; 27 28 class UtilUnitTest { 29 30 @Test shouldPauseForGivenDuration()31 void shouldPauseForGivenDuration() { 32 // Given 33 int intendedPause = 500; 34 // When 35 long startTime = System.currentTimeMillis(); 36 Util.sleep(intendedPause); 37 long endTime = System.currentTimeMillis(); 38 double pause = endTime - startTime; 39 // Then 40 assertThat(pause, is(closeTo(intendedPause, 100d))); // allow 20% variance 41 } 42 } 43