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

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.tests;
import static org.junit.Assert.assertNotNull;
@@ -54,12 +54,12 @@ public abstract class AbstractTestFixture implements TestFixture
protected TreeMap<String, TestNetwork> networks = new TreeMap<String, TestNetwork>();
protected TreeMap<String, SiteInformation> sites = new TreeMap<String, SiteInformation>();
protected String[] configLocations;
protected final String[] classLocations;
protected int port = 8081;
protected String contextPath = "/alfresco";
protected String servletName = "api";
protected String hostname = "localhost";
private String[] configLocations;
private final String[] classLocations;
private int port = PORT;
private String contextPath = CONTEXT_PATH;
private String servletName = PUBLIC_API_SERVLET_NAME;
protected JettyComponent jetty;
protected boolean cleanup;
protected Random random = new Random();
@@ -94,29 +94,49 @@ public abstract class AbstractTestFixture implements TestFixture
{
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 void populateTestData();
protected abstract RepoService makeRepoService() throws Exception;
public void setup() throws Exception
{
setup(true);
}
public void setup(boolean createTestData) throws Exception
{
setup(true);
}
public void setup(boolean createTestData) throws Exception
{
this.jetty = makeJettyComponent();
this.jetty.start();
this.applicationContext = jetty.getApplicationContext();
this.repoService = makeRepoService();
this.transactionHelper = (RetryingTransactionHelper)repoService.getApplicationContext().getBean("retryingTransactionHelper");
if (createTestData)
{
populateTestData();
createTestData();
}
if (createTestData)
{
populateTestData();
createTestData();
}
}
public RepoService getRepoService()
@@ -146,11 +166,11 @@ public abstract class AbstractTestFixture implements TestFixture
public TestNetwork getRandomNetwork()
{
if (networks.isEmpty())
{
populateTestData();
createTestData();
}
if (networks.isEmpty())
{
populateTestData();
createTestData();
}
int r = random.nextInt(networks.size());
List<TestNetwork> a = new ArrayList<TestNetwork>();
a.addAll(networks.values());