Clover icon

Magnolia REST Integration Tests 2.1.5

  1. Project Clover database Tue Jan 28 2020 16:43:22 CET
  2. Package info.magnolia.integrationtests.rest

File AbstractRestIntegrationTest.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
0% of files have more coverage

Code metrics

4
5
2
3
99
39
4
0.8
2.5
0.67
2
35.3% of code in this file is excluded from these metrics.

Classes

Class Line # Actions
AbstractRestIntegrationTest 41 0 - 0 0
-1.0 -
AbstractRestIntegrationTest.Instance 60 5 35.3% 4 11
0.00%
AbstractRestIntegrationTest.InstanceProperties 90 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /**
2    * This file Copyright (c) 2018 Magnolia International
3    * Ltd. (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10    * This file is distributed in the hope that it will be
11    * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12    * implied warranty of MERCHANTABILITY or FITNESS FOR A
13    * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14    * Redistribution, except as permitted by whichever of the GPL
15    * or MNA you select, is prohibited.
16    *
17    * 1. For the GPL license (GPL), you can redistribute and/or
18    * modify this file under the terms of the GNU General
19    * Public License, Version 3, as published by the Free Software
20    * Foundation. You should have received a copy of the GNU
21    * General Public License, Version 3 along with this program;
22    * if not, write to the Free Software Foundation, Inc., 51
23    * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24    *
25    * 2. For the Magnolia Network Agreement (MNA), this file
26    * and the accompanying materials are made available under the
27    * terms of the MNA which accompanies this distribution, and
28    * is available at http://www.magnolia-cms.com/mna.html
29    *
30    * Any modifications to this file must keep this entire header
31    * intact.
32    *
33    */
34    package info.magnolia.integrationtests.rest;
35   
36    import org.apache.commons.lang3.StringUtils;
37   
38    /**
39    * Abstract class for REST integration testing.
40    */
 
41    public abstract class AbstractRestIntegrationTest {
42    /**
43    * Name of the property that can be used to overwrite the context path for the author instance.
44    */
45    public static final String AUTHOR_CONTEXT_PATH_PROPERTY = "authorContextPath";
46   
47    /**
48    * Name of the property that can be used to overwrite the domain for the webapps.
49    */
50    public static final String DOMAIN_PROPERTY = "containerRootURL";
51   
52    /**
53    * Default domain, should never be used.
54    */
55    public static final String DEFAULT_DOMAIN = "http://localhost:8496/";
56   
57    /**
58    * A simple way of referring to one of the two test instances deployed during ITs.
59    */
 
60    public enum Instance implements InstanceProperties {
61    AUTHOR {
 
62  0 toggle @Override
63    public String getContextPath() {
64  0 final String authorContextPath = System.getProperty(AUTHOR_CONTEXT_PATH_PROPERTY);
65  0 return StringUtils.isEmpty(authorContextPath) ? "magnoliaTest/" : authorContextPath;
66    }
67    };
68   
 
69    toggle @Override
70    public String getDomain() {
71    final String domainFromProperty = System.getProperty(DOMAIN_PROPERTY);
72    final String domain = StringUtils.defaultIfEmpty(domainFromProperty, DEFAULT_DOMAIN);
73    return StringUtils.removeEnd(domain, "/");
74    }
75   
 
76    toggle @Override
77    public String getURL() {
78    return getDomain() + "/" + getContextPath();
79    }
80   
 
81  0 toggle @Override
82    public String getURL(String path) {
83  0 if (path.startsWith("/")) {
84  0 path = path.substring(1);
85    }
86  0 return getURL() + path;
87    }
88    }
89   
 
90    private interface InstanceProperties {
91    String getContextPath();
92   
93    String getDomain();
94   
95    String getURL();
96   
97    String getURL(String path);
98    }
99    }