io.netty.util.DefaultAttributeMap Java Examples
The following examples show how to use
io.netty.util.DefaultAttributeMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FutureCancelHandlerTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
@Before public void methodSetup() { requestContext = new RequestContext(channelPool, eventLoopGroup, AsyncExecuteRequest.builder().responseHandler(responseHandler).build(), null); DefaultAttributeMap attrMap = new DefaultAttributeMap(); attrMap.attr(EXECUTION_ID_KEY).set(1L); attrMap.attr(REQUEST_CONTEXT_KEY).set(requestContext); when(ctx.channel()).thenReturn(channel); when(channel.attr(EXECUTION_ID_KEY)).thenReturn(attrMap.attr(EXECUTION_ID_KEY)); when(channel.attr(REQUEST_CONTEXT_KEY)).thenReturn(attrMap.attr(REQUEST_CONTEXT_KEY)); }
Example #2
Source File: StripUntrustedProxyHeadersHandlerTest.java From zuul with Apache License 2.0 | 5 votes |
@Before public void before() { when(channelHandlerContext.channel()).thenReturn(channel); DefaultAttributeMap attributeMap = new DefaultAttributeMap(); attributeMap.attr(ATTR_SSL_INFO).set(sslHandshakeInfo); when(channel.attr(any())).thenAnswer(arg -> attributeMap.attr((AttributeKey) arg.getArguments()[0])); headers = new DefaultHttpHeaders(); when(msg.headers()).thenReturn(headers); headers.add(HttpHeaderNames.HOST, "netflix.com"); }
Example #3
Source File: TestShiroAuthenticatorWithCheckIp.java From arcusplatform with Apache License 2.0 | 4 votes |
private void doHandoff(String ip, String matchingIp, HttpResponseStatus responseStatus, boolean isSuccess) throws UnsupportedEncodingException { if(StringUtils.isBlank(ip)) { EasyMock.expect(channel.remoteAddress()).andReturn(null).anyTimes(); }else{ EasyMock.expect(channel.remoteAddress()).andReturn(new InetSocketAddress(ip, 33213)).anyTimes(); } SessionHandoff handoff = new SessionHandoff(); handoff.setPersonId(UUID.randomUUID()); handoff.setIp(matchingIp); Capture<Session> sessionRef = Capture.<Session>newInstance(); EasyMock .expect(appHandoffDao.validate("token")) .andReturn(Optional.of(handoff)); if(isSuccess) { EasyMock .expect(sessionDao.create(EasyMock.capture(sessionRef))) .andAnswer(() -> { SimpleSession value = (SimpleSession) sessionRef.getValue(); value.setId("session-id"); return "session-id"; }); sessionDao.update(EasyMock.capture(sessionRef)); EasyMock .expectLastCall() .times(3); } EasyMock .expect(sessionDao.readSession("session-id")) .andAnswer(() -> sessionRef.getValue()) .anyTimes() ; Attribute<Client> attribMap = new DefaultAttributeMap().attr(Client.ATTR_CLIENT); EasyMock.expect(channel.attr(Client.ATTR_CLIENT)).andReturn(attribMap).times(2); replay(); DefaultFullHttpRequest request = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost/client", Unpooled.wrappedBuffer("{token:\"token\"}".getBytes("UTF-8")) ); FullHttpResponse response = authenticator.authenticateRequest(channel, request); assertEquals(responseStatus, response.getStatus()); if(isSuccess) { assertCookieSet(response); }else{ assertCookieCleared(response); } verify(); }