本文整理匯總了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);
}