本文整理汇总了Java中javax.ws.rs.core.Cookie.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java Cookie.valueOf方法的具体用法?Java Cookie.valueOf怎么用?Java Cookie.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.Cookie
的用法示例。
在下文中一共展示了Cookie.valueOf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFromStringWithExtendedParameters
import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Test
public void testFromStringWithExtendedParameters() {
String cookieString = "Version=1; Application=msf4j; Path=/carbon; Domain=wso2; Expires=Sun, 06 Nov 1994 " +
"08:49:37 GMT; Secure; HttpOnly; MaxAge=50; Comment=TestOnly";
String name = "Application";
String value = "msf4j";
String path = "/carbon";
String domain = "wso2";
long dateTime = 784111777000L;
NewCookie cookie = (NewCookie) Cookie.valueOf(cookieString);
assertEquals(cookie.getName(), name);
assertEquals(cookie.getValue(), value);
assertEquals(cookie.getPath(), path);
assertEquals(cookie.getVersion(), 1);
assertEquals(cookie.getDomain(), domain);
assertEquals(cookie.getComment(), "TestOnly");
assertEquals(cookie.getExpiry().getTime(), dateTime);
assertEquals(cookie.getMaxAge(), 50);
assertEquals(cookie.isSecure(), true);
assertEquals(cookie.isHttpOnly(), true);
}
示例2: getCookies
import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Override
public Map<String, Cookie> getCookies() {
List<String> values = nettyHttpHeaders.getAll(HttpHeaders.COOKIE);
if (values == null || values.isEmpty()) {
return Collections.emptyMap();
}
Map<String, Cookie> cookieMap = new HashMap<>();
for (String value : values) {
if (value == null) {
continue;
}
Cookie cookie = Cookie.valueOf(value);
cookieMap.put(cookie.getName(), cookie);
}
return cookieMap;
}
示例3: testFromString
import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Test
public void testFromString() throws Exception {
Cookie cookie = Cookie.valueOf("JSESSIONID=3508015E4EF0ECA8C4B761FCC4BC1718");
assertEquals(cookie.getName(), "JSESSIONID");
assertEquals(cookie.getValue(), "3508015E4EF0ECA8C4B761FCC4BC1718");
}
示例4: testFromStringWithoutCookieString
import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Cookie value can " +
"not be null")
public void testFromStringWithoutCookieString() {
Cookie.valueOf(null);
}
示例5: testFromStringWithoutName
import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void testFromStringWithoutName() {
String cookieString = "Version=1; Path=/carbon; Domain=wso2";
Cookie.valueOf(cookieString);
}
示例6: testFromStringWithoutValue
import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void testFromStringWithoutValue() {
String cookieString = "Version=1; Application; Path=/carbon; Domain=wso2";
Cookie.valueOf(cookieString);
}