"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core/src/test/java/hudson/util/ConsistentHashTest.java" between
jenkins-jenkins-2.302.tar.gz and jenkins-jenkins-2.303.tar.gz

About: Jenkins is a automation server (written in Java) which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software (for e.g. as Continuous Integration and Continuous Delivery server). Weekly release.

ConsistentHashTest.java  (jenkins-jenkins-2.302):ConsistentHashTest.java  (jenkins-jenkins-2.303)
skipping to change at line 30 skipping to change at line 30
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package hudson.util; package hudson.util;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import java.util.Random; import java.util.Random;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
skipping to change at line 173 skipping to change at line 173
assertEquals(7, hash.countAllPoints()); assertEquals(7, hash.countAllPoints());
} }
@Test @Test
public void usesCustomHash() { public void usesCustomHash() {
final RuntimeException exception = new RuntimeException(); final RuntimeException exception = new RuntimeException();
ConsistentHash.Hash<String> hashFunction = str -> { ConsistentHash.Hash<String> hashFunction = str -> {
throw exception; throw exception;
}; };
try { final RuntimeException e = assertThrows(RuntimeException.class, () -> {
ConsistentHash<String> hash = new ConsistentHash<>(hashFunction); ConsistentHash<String> hash = new ConsistentHash<>(hashFunction);
hash.add("foo"); hash.add("foo");
fail("Didn't use custom hash function"); });
} catch (RuntimeException e) { assertSame(exception, e);
assertSame(exception, e);
}
} }
/** /**
* This test doesn't fail but it's written to measure the performance of the consistent hash function with large data set. * This test doesn't fail but it's written to measure the performance of the consistent hash function with large data set.
*/ */
@Test @Test
@Ignore("Helper test for performance, no assertion") @Ignore("Helper test for performance, no assertion")
public void speed() { public void speed() {
Map<String,Integer> data = new CopyOnWriteMap.Hash<>(); Map<String,Integer> data = new CopyOnWriteMap.Hash<>();
for (int i = 0; i < 1000; i++) { for (int i = 0; i < 1000; i++) {
 End of changes. 4 change blocks. 
6 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)