MockCookieHandler.java :  » MVC » jurfa » com » jurfa » test » Java Open Source

Java Open Source » MVC » jurfa 
jurfa » com » jurfa » test » MockCookieHandler.java
package com.jurfa.test;

import java.util.HashSet;
import java.util.Set;

import javax.servlet.http.Cookie;

public class MockCookieHandler 
{
  private static MockCookieHandler instance;
  
  public static MockCookieHandler getInstance() {
    if (instance == null) {
      synchronized (MockCookieHandler.class) {
        if (instance == null) {
          instance = new MockCookieHandler();
        }
      }
    }
    return instance;
  }
  private Set<Cookie> cookies;
  
  private MockCookieHandler() {
    cookies = new HashSet<Cookie>();
  }
  
  public void addCookie(Cookie cookie) {
    cookies.add(cookie);
  }
  
  public Cookie[] getCookies() {
    return cookies.toArray(new Cookie[cookies.size()]);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.