1 package com.squareup.okhttp; 2 3 import com.squareup.okhttp.internal.framed.Header; 4 import java.util.ArrayList; 5 import java.util.Arrays; 6 import java.util.Collection; 7 import java.util.LinkedHashSet; 8 import java.util.List; 9 import java.util.Set; 10 11 public final class TestUtil { TestUtil()12 private TestUtil() { 13 } 14 headerEntries(String... elements)15 public static List<Header> headerEntries(String... elements) { 16 List<Header> result = new ArrayList<>(elements.length / 2); 17 for (int i = 0; i < elements.length; i += 2) { 18 result.add(new Header(elements[i], elements[i + 1])); 19 } 20 return result; 21 } 22 setOf(T... elements)23 public static <T> Set<T> setOf(T... elements) { 24 return setOf(Arrays.asList(elements)); 25 } 26 setOf(Collection<T> elements)27 public static <T> Set<T> setOf(Collection<T> elements) { 28 return new LinkedHashSet<>(elements); 29 } 30 repeat(char c, int count)31 public static String repeat(char c, int count) { 32 char[] array = new char[count]; 33 Arrays.fill(array, c); 34 return new String(array); 35 } 36 } 37