// Path: src/main/java/com/sonatype/nexus/perftest/ClientSwarm.java
// public static interface ClientRequestInfo {
//   String getSwarmName();
// 
//   int getClientId();
// 
//   int getRequestId();
// 
//   <T> void setContextValue(String key, T value);
// 
//   <T> T getContextValue(String key);
// }


import java.net.MalformedURLException;
import java.util.HashSet;
import java.util.Set;
import com.sonatype.nexus.perftest.ClientSwarm.ClientRequestInfo;
import org.sonatype.nexus.client.core.NexusClient;
import org.sonatype.nexus.client.core.spi.SubsystemFactory;
import org.sonatype.nexus.client.core.spi.subsystem.repository.RepositoryFactory;
import org.sonatype.nexus.client.core.subsystem.repository.Repositories;
import org.sonatype.nexus.client.internal.rest.jersey.subsystem.repository.maven.JerseyMavenGroupRepositoryFactory;
import org.sonatype.nexus.client.internal.rest.jersey.subsystem.repository.maven.JerseyMavenHostedRepositoryFactory;
import org.sonatype.nexus.client.internal.rest.jersey.subsystem.repository.maven.JerseyMavenProxyRepositoryFactory;
import org.sonatype.nexus.client.rest.AuthenticationInfo;
import org.sonatype.nexus.client.rest.BaseUrl;
import org.sonatype.nexus.client.rest.ConnectionInfo;
import org.sonatype.nexus.client.rest.UsernamePasswordAuthenticationInfo;
import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
import org.sonatype.nexus.client.rest.jersey.JerseyNexusClientFactory;
import org.sonatype.nexus.client.rest.jersey.subsystem.JerseyRepositoriesFactory;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
/*
 * Copyright (c) 2007-2013 Sonatype, Inc. All rights reserved.
 *
 * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
 * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
 */

package com.sonatype.nexus.perftest;





public abstract class AbstractNexusOperation
{
  public static final int HTTP_TIMEOUT = Integer.parseInt(System.getProperty("perftest.http.timeout", "60000"));

  protected final String username;

  protected final String password;

  protected final String nexusBaseurl;

  public AbstractNexusOperation(Nexus nexus) {
    this.nexusBaseurl = sanitizeBaseurl(nexus.getBaseurl());
    this.username = nexus.getUsername();
    this.password = nexus.getPassword();
  }

  private static String sanitizeBaseurl(String nexusBaseurl) {
    if (nexusBaseurl == null || nexusBaseurl.trim().isEmpty()) {
      return null;
    }
    nexusBaseurl = nexusBaseurl.trim();
    return nexusBaseurl.endsWith("/") ? nexusBaseurl : (nexusBaseurl + "/");
  }

  protected DefaultHttpClient getHttpClient() {
// Path: src/main/java/com/sonatype/nexus/perftest/ClientSwarm.java
// public static interface ClientRequestInfo {
//   String getSwarmName();
// 
//   int getClientId();
// 
//   int getRequestId();
// 
//   <T> void setContextValue(String key, T value);
// 
//   <T> T getContextValue(String key);
// }


// Path: src/main/java/com/sonatype/nexus/perftest/AbstractNexusOperation.java
import java.net.MalformedURLException;
import java.util.HashSet;
import java.util.Set;
import com.sonatype.nexus.perftest.ClientSwarm.ClientRequestInfo;
import org.sonatype.nexus.client.core.NexusClient;
import org.sonatype.nexus.client.core.spi.SubsystemFactory;
import org.sonatype.nexus.client.core.spi.subsystem.repository.RepositoryFactory;
import org.sonatype.nexus.client.core.subsystem.repository.Repositories;
import org.sonatype.nexus.client.internal.rest.jersey.subsystem.repository.maven.JerseyMavenGroupRepositoryFactory;
import org.sonatype.nexus.client.internal.rest.jersey.subsystem.repository.maven.JerseyMavenHostedRepositoryFactory;
import org.sonatype.nexus.client.internal.rest.jersey.subsystem.repository.maven.JerseyMavenProxyRepositoryFactory;
import org.sonatype.nexus.client.rest.AuthenticationInfo;
import org.sonatype.nexus.client.rest.BaseUrl;
import org.sonatype.nexus.client.rest.ConnectionInfo;
import org.sonatype.nexus.client.rest.UsernamePasswordAuthenticationInfo;
import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
import org.sonatype.nexus.client.rest.jersey.JerseyNexusClientFactory;
import org.sonatype.nexus.client.rest.jersey.subsystem.JerseyRepositoriesFactory;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

/*
 * Copyright (c) 2007-2013 Sonatype, Inc. All rights reserved.
 *
 * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
 * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
 */

package com.sonatype.nexus.perftest;





public abstract class AbstractNexusOperation
{
  public static final int HTTP_TIMEOUT = Integer.parseInt(System.getProperty("perftest.http.timeout", "60000"));

  protected final String username;

  protected final String password;

  protected final String nexusBaseurl;

  public AbstractNexusOperation(Nexus nexus) {
    this.nexusBaseurl = sanitizeBaseurl(nexus.getBaseurl());
    this.username = nexus.getUsername();
    this.password = nexus.getPassword();
  }

  private static String sanitizeBaseurl(String nexusBaseurl) {
    if (nexusBaseurl == null || nexusBaseurl.trim().isEmpty()) {
      return null;
    }
    nexusBaseurl = nexusBaseurl.trim();
    return nexusBaseurl.endsWith("/") ? nexusBaseurl : (nexusBaseurl + "/");
  }

  protected DefaultHttpClient getHttpClient() {
    ClientRequestInfo info = ((ClientRequestInfo) Thread.currentThread());