Files
alfresco-community-repo/source/test-java/org/alfresco/rest/AbstractSingleNetworkSiteTest.java
Martin Muller a65e2f48f1 Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1)
128640 jvonka: V1 REST API: cleanup and rationalise new api tests (re: remotable helpers & runAs user / admin) - round 5
   REPO-113 (also relates to REPO-28, REPO-114, REPO-825)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@129179 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2016-08-05 13:47:37 +00:00

97 lines
3.2 KiB
Java

/*
* #%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;
import org.alfresco.rest.api.tests.AbstractBaseApiTest;
import org.junit.After;
import org.junit.Before;
/**
* Overrides AbstractBaseApiTest so that only a single network & site is created per test
* (instead of pre-creating multiple networks & sites)
*
* Can also be optionally tweaked locally to:
*
* - use the default network (ie. super tenant) => instead of creating a new tenant
*
* - re-use a single setup across test methods => although this does mean that each individual test method must either rely on uniquely created test data and/or cleanup
*
* Note: For now, these can be explicitly tweaked by a dev (do not commit)
* but in the future we could consider making these runtime options.
*
* @author Gethin James
* @author janv
*/
public class AbstractSingleNetworkSiteTest extends AbstractBaseApiTest
{
// note: experimental - for local/dev-use only (YMMV) ;-)
// - setting both to true should make the related tests run faster
// - if singleSetupNoTearDown=true then each individual test method should create unique data (or cleanup) to avoid interdependent test/run failures
// - if useDefaultNetwork=true then no tenant will be created (ie. will use default/super tenant)
protected static boolean singleSetupNoTearDown = false;
protected static boolean useDefaultNetwork = false;
private static boolean isSetup = false;
@Override
public String getScope()
{
return "public";
}
@Override
@Before
public void setup() throws Exception
{
if ((! isSetup) || (! singleSetupNoTearDown))
{
if (! useDefaultNetwork)
{
networkOne = getRepoService().createNetwork(this.getClass().getName().toLowerCase(), true);
networkOne.create();
}
else
{
networkOne = getRepoService().getSystemNetwork();
}
super.setup();
isSetup = true;
}
}
@Override
@After
public void tearDown() throws Exception
{
if (! singleSetupNoTearDown)
{
super.tearDown();
}
}
}