Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.server;
import static com.facebook.presto.client.PrestoHeaders.PRESTO_CATALOG;
import static com.facebook.presto.client.PrestoHeaders.PRESTO_LANGUAGE;
import static com.facebook.presto.client.PrestoHeaders.PRESTO_SCHEMA;
import static com.facebook.presto.client.PrestoHeaders.PRESTO_SESSION;
import static com.facebook.presto.client.PrestoHeaders.PRESTO_SOURCE;
import static com.facebook.presto.client.PrestoHeaders.PRESTO_TIME_ZONE;
import static com.facebook.presto.client.PrestoHeaders.PRESTO_USER;
import static com.facebook.presto.server.ResourceUtil.createSessionForRequest;
import static com.facebook.presto.spi.type.TimeZoneKey.getTimeZoneKey;
import static org.testng.Assert.assertEquals;
public class TestResourceUtil
    @Test
    public void testCreateSession()
            throws Exception
    {
        HttpServletRequest request = new MockHttpServletRequest(
                ImmutableListMultimap.<StringString>builder()
                        .put("testUser")
                        .put("testSource")
                        .put("testCatalog")
                        .put("testSchema")
                        .put("zh-TW")
                        .put("Asia/Taipei")
                        .put("first=abc")
                        .put("second=mno,third=xyz")
                        .build(),
                "testRemote");
        Session session = createSessionForRequest(request);
        assertEquals(session.getUser(), "testUser");
        assertEquals(session.getSource(), "testSource");
        assertEquals(session.getCatalog(), "testCatalog");
        assertEquals(session.getSchema(), "testSchema");
        assertEquals(session.getLocale(), .);
        assertEquals(session.getTimeZoneKey(), getTimeZoneKey("Asia/Taipei"));
        assertEquals(session.getRemoteUserAddress(), "testRemote");
        assertEquals(session.getSystemProperties(), ImmutableMap.<StringString>builder()
                .put("first""abc")
                .put("second""mno")
                .put("third""xyz")
                .build());
    }
New to GrepCode? Check out our FAQ X