Examples of CookieManager

The implementation conforms to RFC 2965, section 3.3. @version %I%, %E% @author Edward Wang @since 1.6

  • org.apache.jmeter.protocol.http.control.CookieManager
    This class provides an interface to the netscape cookies file to pass cookies along with a request. Now uses Commons HttpClient parsing and matching code (since 2.1.2)

  • Examples of org.apache.jmeter.protocol.http.control.CookieManager

       *
       * @see org.apache.jmeter.protocol.http.util.accesslog.Filter#isFiltered(java.lang.String)
       */
      public boolean isFiltered(String path,TestElement sampler) {
        String ipAddr = getIpAddress(path);
            CookieManager cm = getCookieManager(ipAddr);
            ((HTTPSampler)sampler).setCookieManager(cm);  
            return false;
      }
    View Full Code Here

    Examples of org.apache.jmeter.protocol.http.control.CookieManager

            return false;
      }
       
        protected CookieManager getCookieManager(String ipAddr)
        {
            CookieManager cm = null;
            // First have to release the cookie we were using so other
            // threads stuck in wait can move on
            synchronized(managersInUse)
            {
                if(lastUsed != null)
                {
                    managersInUse.remove(lastUsed);
                    managersInUse.notify();
                }
            }
            // let notified threads move on and get lock on managersInUse
            if(lastUsed != null)
            {
                Thread.yield();
            }
            // here is the core routine to find appropriate cookie manager and
            // check it's not being used.  If used, wait until whoever's using it gives
            // it up
            synchronized(managersInUse)
            {
                cm = (CookieManager)cookieManagers.get(ipAddr);
                if(cm == null)
                {
                    cm = new CookieManager();
                    cookieManagers.put(ipAddr,cm);
                }
                while(managersInUse.contains(cm))
                {
                    try {
    View Full Code Here

    Examples of org.apache.jmeter.protocol.http.control.CookieManager

              JMeterContextService.getContext().getThread().stop();
            }
            if (filter != null) {
              filter.reset();
            }
            CookieManager cm = getCookieManager();
            if (cm != null) {
              cm.clear();
            }
            count = 0;
            return errorResult(new Error("No entries found"), new HTTPSampleResult());
          }
          count = thisCount;
    View Full Code Here

    Examples of org.apache.jmeter.protocol.http.control.CookieManager

            setByte((byte)0xff); // Attributes not supported
        }

        private int getHeaderSize(String method, URL url) {
            HeaderManager headers = getHeaderManager();
            CookieManager cookies = getCookieManager();
            AuthManager auth = getAuthManager();
            int hsz = 1; // Host always
            if(method.equals(POST)) {
                String fn = getFilename();
                if(fn != null && fn.trim().length() > 0) {
                    hsz += 3;
                } else {
                    hsz += 2;
                }
            }
            if(headers != null) {
                hsz += headers.size();
            }
            if(cookies != null) {
                hsz += cookies.getCookieCount();
            }
            if(auth != null) {
                    String authHeader = auth.getAuthHeaderForURL(url);
                if(authHeader != null) {
                ++hsz;
    View Full Code Here

    Examples of org.apache.jmeter.protocol.http.control.CookieManager

                String value = getString();
                if(HEADER_CONTENT_TYPE.equalsIgnoreCase(name)) {
                    res.setContentType(value);
                    res.setEncodingAndType(value);
                } else if(HEADER_SET_COOKIE.equalsIgnoreCase(name)) {
                    CookieManager cookies = getCookieManager();
                    if(cookies != null) {
                        cookies.addCookieFromHeader(value, res.getURL());
                    }
                }
                sb.append(name).append(COLON_SPACE).append(value).append(NEWLINE);
            }
            res.setResponseHeaders(sb.toString());
    View Full Code Here

    Examples of org.apache.jmeter.protocol.http.control.CookieManager

      public HeaderManager getHeaderManager() {
        return (HeaderManager) getProperty(HEADER_MANAGER).getObjectValue();
      }

      public void setCookieManager(CookieManager value) {
        CookieManager mgr = getCookieManager();
        if (mgr != null) {
          log.warn("Existing Manager " + mgr.getName() + " superseded by " + value.getName());
        }
        setProperty(new TestElementProperty(COOKIE_MANAGER, value));
      }
    View Full Code Here

    Examples of org.apache.jmeter.protocol.http.control.CookieManager

        public HeaderManager getHeaderManager() {
            return (HeaderManager) getProperty(HEADER_MANAGER).getObjectValue();
        }

        public void setCookieManager(CookieManager value) {
            CookieManager mgr = getCookieManager();
            if (mgr != null) {
                log.warn("Existing CookieManager " + mgr.getName() + " superseded by " + value.getName());
            }
            setProperty(new TestElementProperty(COOKIE_MANAGER, value));
        }
    View Full Code Here

    Examples of org.apache.jmeter.protocol.http.control.CookieManager

                        final List<Future<AsynSamplerResultHolder>> retExec = exec.invokeAll(liste);
                        // call normal shutdown (wait ending all tasks)
                        exec.shutdown();
                        // put a timeout if tasks couldn't terminate
                        exec.awaitTermination(AWAIT_TERMINATION_TIMEOUT, TimeUnit.SECONDS);
                        CookieManager cookieManager = getCookieManager();
                        // add result to main sampleResult
                        for (Future<AsynSamplerResultHolder> future : retExec) {
                            AsynSamplerResultHolder binRes;
                            try {
                                binRes = future.get(1, TimeUnit.MILLISECONDS);
                                if(cookieManager != null) {
                                    CollectionProperty cookies = binRes.getCookies();
                                    PropertyIterator iter = cookies.iterator();
                                    while (iter.hasNext()) {
                                        Cookie cookie = (Cookie) iter.next().getObjectValue();
                                        cookieManager.add(cookie) ;
                                    }
                                }
                                res.addSubResult(binRes.getResult());
                                setParentSampleSuccess(res, res.isSuccessful() && binRes.getResult().isSuccessful());
                            } catch (TimeoutException e) {
    View Full Code Here

    Examples of org.apache.jmeter.protocol.http.control.CookieManager

                if (cacheManager != null) {
                    this.sampler.setCacheManager(cacheManager);
                }
               
                if(cookieManager != null) {
                    CookieManager clonedCookieManager = (CookieManager) cookieManager.clone();
                    this.sampler.setCookieManager(clonedCookieManager);
                }
                this.jmeterContextOfParentThread = JMeterContextService.getContext();
            }
    View Full Code Here

    Examples of org.apache.jmeter.protocol.http.control.CookieManager

            setByte((byte)0xff); // More general attributes not supported
        }

        private int getHeaderSize(String method, URL url) {
            HeaderManager headers = getHeaderManager();
            CookieManager cookies = getCookieManager();
            AuthManager auth = getAuthManager();
            int hsz = 1; // Host always
            if(method.equals(HTTPConstants.POST)) {
                HTTPFileArg[] hfa = getHTTPFiles();
                if(hfa.length > 0) {
                    hsz += 3;
                } else {
                    hsz += 2;
                }
            }
            if(headers != null) {
                hsz += headers.size();
            }
            if(cookies != null) {
                hsz += cookies.getCookieCount();
            }
            if(auth != null) {
                    String authHeader = auth.getAuthHeaderForURL(url);
                if(authHeader != null) {
                ++hsz;
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. All rights reserved.
    All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.