@Test public void testDefaultMethods() { List<String> methods = Arrays.asList( "connect", "DELEte", "geT", "HEAD", "OpTiOnS", "patch", "post", "pURGe", "put", "Trace"); Set<HTTPMethod> actual = new LinkedHashSet<HTTPMethod>(); for (String method : methods) { actual.add(HTTPMethod.valueOf(method)); } Assert.assertEquals(defaultMethods.size(), actual.size()); ArrayList<HTTPMethod> expected = new ArrayList<>(defaultMethods.values()); Collections.sort(expected); Iterator<HTTPMethod> defaultIterator = expected.iterator(); Iterator<HTTPMethod> actualIterator = actual.iterator(); while (actualIterator.hasNext()) { HTTPMethod m = defaultIterator.next(); HTTPMethod am = actualIterator.next(); Assert.assertSame(m, am); } }
@Test(expected = IllegalArgumentException.class) public void testEmpty() { HTTPMethod.valueOf(""); HTTPMethod.valueOf(" "); }
@Test(expected = IllegalArgumentException.class) public void testNull() { HTTPMethod.valueOf(null); }
@Test public void testUnknown() { Assert.assertFalse(defaultMethods.containsValue(HTTPMethod.valueOf("UNKNOWN"))); }