REPO-908: V1 REST API - minor test fwk improvement

- change default port from 8081 to 8765 (to avoid clash with Share, if already running in local dev env)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@133650 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2016-12-14 10:09:53 +00:00
parent 135d6696a0
commit cfdbdd6c29
5 changed files with 350 additions and 328 deletions

View File

@@ -95,7 +95,7 @@ public abstract class AbstractTestApi
}; };
AuthenticationDetailsProvider authenticationDetailsProvider = new UserAuthenticationDetailsProviderImpl(userDataService, "admin", "admin"); AuthenticationDetailsProvider authenticationDetailsProvider = new UserAuthenticationDetailsProviderImpl(userDataService, "admin", "admin");
AuthenticatedHttp authenticatedHttp = new AuthenticatedHttp(httpClientProvider, authenticationDetailsProvider); AuthenticatedHttp authenticatedHttp = new AuthenticatedHttp(httpClientProvider, authenticationDetailsProvider);
this.httpClient = new PublicApiHttpClient("localhost", TestFixture.PORT, TestFixture.CONTEXT_PATH, this.httpClient = new PublicApiHttpClient(TestFixture.HOST, TestFixture.PORT, TestFixture.CONTEXT_PATH,
TestFixture.PUBLIC_API_SERVLET_NAME, authenticatedHttp); TestFixture.PUBLIC_API_SERVLET_NAME, authenticatedHttp);
this.publicApiClient = new PublicApiClient(httpClient, userDataService); this.publicApiClient = new PublicApiClient(httpClient, userDataService);
} }

View File

@@ -54,12 +54,12 @@ public abstract class AbstractTestFixture implements TestFixture
protected TreeMap<String, TestNetwork> networks = new TreeMap<String, TestNetwork>(); protected TreeMap<String, TestNetwork> networks = new TreeMap<String, TestNetwork>();
protected TreeMap<String, SiteInformation> sites = new TreeMap<String, SiteInformation>(); protected TreeMap<String, SiteInformation> sites = new TreeMap<String, SiteInformation>();
protected String[] configLocations; private String[] configLocations;
protected final String[] classLocations; private final String[] classLocations;
protected int port = 8081; private int port = PORT;
protected String contextPath = "/alfresco"; private String contextPath = CONTEXT_PATH;
protected String servletName = "api"; private String servletName = PUBLIC_API_SERVLET_NAME;
protected String hostname = "localhost";
protected JettyComponent jetty; protected JettyComponent jetty;
protected boolean cleanup; protected boolean cleanup;
protected Random random = new Random(); protected Random random = new Random();
@@ -95,6 +95,26 @@ public abstract class AbstractTestFixture implements TestFixture
return port; return port;
} }
public String getContextPath()
{
return contextPath;
}
public String getServletName()
{
return servletName;
}
public String[] getConfigLocations()
{
return configLocations;
}
public String[] getClassLocations()
{
return classLocations;
}
protected abstract JettyComponent makeJettyComponent(); protected abstract JettyComponent makeJettyComponent();
protected abstract void populateTestData(); protected abstract void populateTestData();
protected abstract RepoService makeRepoService() throws Exception; protected abstract RepoService makeRepoService() throws Exception;

View File

@@ -68,7 +68,7 @@ public class EnterprisePublicApiTestFixture extends EnterpriseTestFixture
@Override @Override
protected JettyComponent makeJettyComponent() protected JettyComponent makeJettyComponent()
{ {
JettyComponent jettyComponent = new EnterpriseJettyComponent(port, contextPath, configLocations, classLocations); JettyComponent jettyComponent = new EnterpriseJettyComponent(getPort(), getContextPath(), getConfigLocations(), getClassLocations());
return jettyComponent; return jettyComponent;
} }

View File

@@ -33,7 +33,8 @@ import org.springframework.context.ApplicationContext;
public interface TestFixture public interface TestFixture
{ {
public final static int PORT = 8081; public final static String HOST = "localhost";
public final static int PORT = 8765;
public final static String CONTEXT_PATH = "/alfresco"; public final static String CONTEXT_PATH = "/alfresco";
public final static String PUBLIC_API_SERVLET_NAME = "api"; public final static String PUBLIC_API_SERVLET_NAME = "api";

View File

@@ -43,6 +43,7 @@ import org.alfresco.opencmis.CMISDispatcherRegistry.Binding;
import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.tenant.TenantUtil; import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.repo.web.scripts.BaseWebScriptTest.PatchMethod; import org.alfresco.repo.web.scripts.BaseWebScriptTest.PatchMethod;
import org.alfresco.rest.api.tests.TestFixture;
import org.alfresco.rest.api.tests.client.AuthenticatedHttp.HttpRequestCallback; import org.alfresco.rest.api.tests.client.AuthenticatedHttp.HttpRequestCallback;
import org.alfresco.rest.framework.Api; import org.alfresco.rest.framework.Api;
import org.alfresco.rest.framework.Api.SCOPE; import org.alfresco.rest.framework.Api.SCOPE;
@@ -95,8 +96,8 @@ public class PublicApiHttpClient
private static final String ATOM_PUB_URL = "{0}://{1}:{2}{3}cmisatom"; private static final String ATOM_PUB_URL = "{0}://{1}:{2}{3}cmisatom";
private String scheme = "http"; private String scheme = "http";
private String host = "localhost"; private String host = TestFixture.HOST;
private int port = 8081; private int port = TestFixture.PORT;
private String contextPath; private String contextPath;
private String servletName; private String servletName;