Search in sources :

Example 56 with MultiMap

use of io.vertx.core.MultiMap in project vert.x by eclipse.

the class CaseInsensitiveHeadersTest method testGetAllHashColl.

@Test
public void testGetAllHashColl() {
    MultiMap mm = new CaseInsensitiveHeaders();
    String name1 = "AZ";
    String name2 = "€Y";
    assertTrue("hash error", hash(name1) == hash(name2));
    mm.add(name1, "value1");
    mm.add(name2, "value2");
    assertEquals(2, mm.size());
    assertEquals("[value1]", mm.getAll(name1).toString());
    assertEquals("[value2]", mm.getAll(name2).toString());
    mm = new CaseInsensitiveHeaders();
    name1 = "A";
    name2 = "R";
    assertTrue("hash error", index(hash(name1)) == index(hash(name2)));
    mm.add(name1, "value1");
    mm.add(name2, "value2");
    assertEquals(2, mm.size());
    assertEquals("[value1]", mm.getAll(name1).toString());
    assertEquals("[value2]", mm.getAll(name2).toString());
}
Also used : MultiMap(io.vertx.core.MultiMap) CaseInsensitiveHeaders(io.vertx.core.http.CaseInsensitiveHeaders) Test(org.junit.Test)

Example 57 with MultiMap

use of io.vertx.core.MultiMap in project vert.x by eclipse.

the class CaseInsensitiveHeadersTest method testAddTest2.

@Test
public void testAddTest2() throws Exception {
    MultiMap mmap = new CaseInsensitiveHeaders();
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("a", "b");
    map.put("c", "d");
    assertEquals("a: b\nc: d\n", mmap.addAll(map).toString());
}
Also used : MultiMap(io.vertx.core.MultiMap) CaseInsensitiveHeaders(io.vertx.core.http.CaseInsensitiveHeaders) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 58 with MultiMap

use of io.vertx.core.MultiMap in project vert.x by eclipse.

the class CaseInsensitiveHeadersTest method testAddIterable.

@Test
public void testAddIterable() throws Exception {
    MultiMap mmap = new CaseInsensitiveHeaders();
    String name = "name";
    List<String> values = new ArrayList<String>();
    values.add("value1");
    values.add("value2");
    MultiMap result = mmap.add(name, values);
    assertEquals(1, result.size());
    assertEquals("name: value1\nname: value2\n", result.toString());
}
Also used : MultiMap(io.vertx.core.MultiMap) CaseInsensitiveHeaders(io.vertx.core.http.CaseInsensitiveHeaders) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 59 with MultiMap

use of io.vertx.core.MultiMap in project vert.x by eclipse.

the class CaseInsensitiveHeadersTest method testSetTest14.

@Test
public void testSetTest14() throws Exception {
    MultiMap mmap = new CaseInsensitiveHeaders();
    String name = "";
    String strVal = "bbb";
    MultiMap result = mmap.set(name, strVal);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    assertEquals(1, result.size());
    assertEquals(": bbb\n", result.toString());
}
Also used : MultiMap(io.vertx.core.MultiMap) CaseInsensitiveHeaders(io.vertx.core.http.CaseInsensitiveHeaders) Test(org.junit.Test)

Example 60 with MultiMap

use of io.vertx.core.MultiMap in project vert.x by eclipse.

the class CaseInsensitiveHeadersTest method testGetAllTest1.

@Test
public void testGetAllTest1() throws Exception {
    MultiMap mmap = new CaseInsensitiveHeaders();
    CharSequence name = String.valueOf(new Object());
    List<String> result = mmap.getAll(name);
    assertNotNull(result);
    assertEquals(0, result.size());
}
Also used : MultiMap(io.vertx.core.MultiMap) CaseInsensitiveHeaders(io.vertx.core.http.CaseInsensitiveHeaders) Test(org.junit.Test)

Aggregations

MultiMap (io.vertx.core.MultiMap)89 Test (org.junit.Test)77 CaseInsensitiveHeaders (io.vertx.core.http.CaseInsensitiveHeaders)61 HashMap (java.util.HashMap)21 ArrayList (java.util.ArrayList)19 Map (java.util.Map)12 Buffer (io.vertx.core.buffer.Buffer)9 DefaultHttpHeaders (io.netty.handler.codec.http.DefaultHttpHeaders)8 Handler (io.vertx.core.Handler)8 VertxException (io.vertx.core.VertxException)8 HttpClientRequest (io.vertx.core.http.HttpClientRequest)8 HttpMethod (io.vertx.core.http.HttpMethod)8 HttpServerResponse (io.vertx.core.http.HttpServerResponse)8 HeadersAdaptor (io.vertx.core.http.impl.HeadersAdaptor)8 HttpResponseStatus (io.netty.handler.codec.http.HttpResponseStatus)7 InternalLoggerFactory (io.netty.util.internal.logging.InternalLoggerFactory)7 Nullable (io.vertx.codegen.annotations.Nullable)7 AbstractVerticle (io.vertx.core.AbstractVerticle)7 AsyncResult (io.vertx.core.AsyncResult)7 Context (io.vertx.core.Context)7