From 1bcd74e8fa718dd5a852921dd107baf5e1bb642e Mon Sep 17 00:00:00 2001 From: Corey Daley Date: Thu, 13 Mar 2014 15:55:47 -0400 Subject: [PATCH] [OSJC-103] added ability to show test times --- .../AbstractOpenshiftConfiguration.java | 1 + .../configuration/DefaultConfiguration.java | 2 +- .../fakes/DefaultConfigurationFake.java | 29 +++++++++++++ .../fakes/OpenShiftConfigurationFake.java | 18 +++++++- .../client/APIResourceIntegrationTest.java | 2 +- .../internal/client/APIResourceTest.java | 2 +- .../ApplicationResourceIntegrationTest.java | 4 +- .../client/ApplicationResourceTest.java | 2 +- .../client/CertTrustIntegrationTest.java | 4 +- .../internal/client/ConfigurationTest.java | 2 +- .../client/DomainResourceIntegrationTest.java | 4 +- .../internal/client/DomainResourceTest.java | 2 +- .../client/EmbeddableCartridgeTest.java | 2 +- ...eddedCartridgeResourceIntegrationTest.java | 2 +- .../client/EmbeddedCartridgeResourceTest.java | 2 +- ...onmentVariableResourceIntegrationTest.java | 6 +-- .../EnvironmentVariableResourceTest.java | 2 +- .../client/GearGroupsResourceTest.java | 2 +- .../openshift/internal/client/GearTest.java | 2 +- .../LatestVersionQueryIntegrationTest.java | 4 +- .../client/OpenShiftExceptionTest.java | 2 +- .../internal/client/OpenShiftTestSuite.java | 2 +- .../openshift/internal/client/QueryTest.java | 2 +- .../client/RestServicePropertiesTest.java | 2 +- .../internal/client/RestServiceTest.java | 2 +- .../client/SSHKeyIntegrationTest.java | 4 +- .../openshift/internal/client/SSHKeyTest.java | 2 +- .../client/StandaloneCartridgeTest.java | 2 +- .../StandaloneCartridgesIntegrationTest.java | 2 +- .../openshift/internal/client/TestTimer.java | 42 +++++++++++++++++++ .../client/UserResourceIntegrationTest.java | 2 +- .../openshift/internal/client/UserTest.java | 2 +- .../client/httpclient/HttpClientTest.java | 17 ++++---- 33 files changed, 132 insertions(+), 45 deletions(-) create mode 100644 src/test/java/com/openshift/client/fakes/DefaultConfigurationFake.java create mode 100644 src/test/java/com/openshift/internal/client/TestTimer.java diff --git a/src/main/java/com/openshift/client/configuration/AbstractOpenshiftConfiguration.java b/src/main/java/com/openshift/client/configuration/AbstractOpenshiftConfiguration.java index 761e789a..bd0fe743 100755 --- a/src/main/java/com/openshift/client/configuration/AbstractOpenshiftConfiguration.java +++ b/src/main/java/com/openshift/client/configuration/AbstractOpenshiftConfiguration.java @@ -38,6 +38,7 @@ public abstract class AbstractOpenshiftConfiguration implements IOpenShiftConfig protected static final String KEY_CLIENT_ID = "client_id"; protected static final String KEY_TIMEOUT = "timeout"; + protected static final String DEFAULT_OPENSHIFT_TIMEOUT = "180000"; //3 minutes private static final Pattern QUOTED_REGEX = Pattern.compile("['\"]*([^'\"]+)['\"]*"); private static final char SINGLEQUOTE = '\''; diff --git a/src/main/java/com/openshift/client/configuration/DefaultConfiguration.java b/src/main/java/com/openshift/client/configuration/DefaultConfiguration.java index d6dede07..693b9189 100755 --- a/src/main/java/com/openshift/client/configuration/DefaultConfiguration.java +++ b/src/main/java/com/openshift/client/configuration/DefaultConfiguration.java @@ -35,7 +35,7 @@ protected Properties getProperties(File file, Properties defaultProperties) { Properties properties = new Properties(); properties.put(KEY_LIBRA_SERVER, LIBRA_SERVER); properties.put(KEY_LIBRA_DOMAIN, LIBRA_DOMAIN); - properties.put(KEY_TIMEOUT, "180000"); + properties.put(KEY_TIMEOUT, DEFAULT_OPENSHIFT_TIMEOUT); return properties; } } diff --git a/src/test/java/com/openshift/client/fakes/DefaultConfigurationFake.java b/src/test/java/com/openshift/client/fakes/DefaultConfigurationFake.java new file mode 100644 index 00000000..d744e0c8 --- /dev/null +++ b/src/test/java/com/openshift/client/fakes/DefaultConfigurationFake.java @@ -0,0 +1,29 @@ +package com.openshift.client.fakes; + +import com.openshift.client.OpenShiftException; +import com.openshift.client.configuration.DefaultConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.Properties; + +/** + * Created by cdaley on 3/13/14. + */ +public class DefaultConfigurationFake extends DefaultConfiguration { + public static final String LIBRA_SERVER = "openshift.redhat.com"; + public static final String LIBRA_DOMAIN = "rhcloud.com"; + + public DefaultConfigurationFake() throws OpenShiftException, IOException { + super(); + } + + @Override + protected Properties getProperties(File file, Properties defaultProperties) { + Properties properties = new Properties(); + properties.put(KEY_LIBRA_SERVER, LIBRA_SERVER); + properties.put(KEY_LIBRA_DOMAIN, LIBRA_DOMAIN); + properties.put(KEY_TIMEOUT, DEFAULT_OPENSHIFT_TIMEOUT); + return properties; + } +} diff --git a/src/test/java/com/openshift/client/fakes/OpenShiftConfigurationFake.java b/src/test/java/com/openshift/client/fakes/OpenShiftConfigurationFake.java index 72f48bb6..1569972f 100644 --- a/src/test/java/com/openshift/client/fakes/OpenShiftConfigurationFake.java +++ b/src/test/java/com/openshift/client/fakes/OpenShiftConfigurationFake.java @@ -13,11 +13,25 @@ * @author Corey Daley */ public class OpenShiftConfigurationFake extends AbstractOpenshiftConfiguration { - public OpenShiftConfigurationFake(final String systemConfigurationTimeout, final String userConfigurationTimeout, final String systemPropertiesTimeout) throws FileNotFoundException, IOException, OpenShiftException { + public OpenShiftConfigurationFake(final String systemConfigurationTimeout, final String userConfigurationTimeout, final String systemPropertiesTimeout, final String defaultConfigurationTimeout) throws FileNotFoundException, IOException, OpenShiftException { super(new SystemPropertiesFake( new UserConfigurationFake( new SystemConfigurationFake( - new DefaultConfiguration()){ + new DefaultConfigurationFake(){ + @Override + protected Properties getProperties(File file, Properties defaultProperties) { + Properties properties = new Properties(); + properties.put(KEY_LIBRA_SERVER, LIBRA_SERVER); + properties.put(KEY_LIBRA_DOMAIN, LIBRA_DOMAIN); + if (defaultConfigurationTimeout != null) { + properties.put(KEY_TIMEOUT, defaultConfigurationTimeout); + } else { + properties.put(KEY_TIMEOUT, DEFAULT_OPENSHIFT_TIMEOUT); + } + + return properties; + } + }){ //SystemConfigurationFake protected void init(Properties properties) { if (systemConfigurationTimeout != null) { diff --git a/src/test/java/com/openshift/internal/client/APIResourceIntegrationTest.java b/src/test/java/com/openshift/internal/client/APIResourceIntegrationTest.java index 81db792f..0a723de3 100644 --- a/src/test/java/com/openshift/internal/client/APIResourceIntegrationTest.java +++ b/src/test/java/com/openshift/internal/client/APIResourceIntegrationTest.java @@ -30,7 +30,7 @@ /** * @author André Dietisheim */ -public class APIResourceIntegrationTest { +public class APIResourceIntegrationTest extends TestTimer { private IOpenShiftConnection connection; diff --git a/src/test/java/com/openshift/internal/client/APIResourceTest.java b/src/test/java/com/openshift/internal/client/APIResourceTest.java index 582eb434..43ddefed 100644 --- a/src/test/java/com/openshift/internal/client/APIResourceTest.java +++ b/src/test/java/com/openshift/internal/client/APIResourceTest.java @@ -27,7 +27,7 @@ * @author Xavier Coulon * @author Andre Dietisheim */ -public class APIResourceTest { +public class APIResourceTest extends TestTimer { private IOpenShiftConnection connection; diff --git a/src/test/java/com/openshift/internal/client/ApplicationResourceIntegrationTest.java b/src/test/java/com/openshift/internal/client/ApplicationResourceIntegrationTest.java index 2b1615e9..e7af75b1 100755 --- a/src/test/java/com/openshift/internal/client/ApplicationResourceIntegrationTest.java +++ b/src/test/java/com/openshift/internal/client/ApplicationResourceIntegrationTest.java @@ -46,13 +46,13 @@ * @author Syed Iqbal * @author Martes G Wigglesworth */ -public class ApplicationResourceIntegrationTest { +public class ApplicationResourceIntegrationTest extends TestTimer { private static final long WAIT_TIMEOUT = 3 * 60 * 1000; private IUser user; private IDomain domain; - + @Before public void setUp() throws Exception { IOpenShiftConnection connection = new TestConnectionFactory().getConnection(); diff --git a/src/test/java/com/openshift/internal/client/ApplicationResourceTest.java b/src/test/java/com/openshift/internal/client/ApplicationResourceTest.java index 05f8c145..64539ff3 100644 --- a/src/test/java/com/openshift/internal/client/ApplicationResourceTest.java +++ b/src/test/java/com/openshift/internal/client/ApplicationResourceTest.java @@ -55,7 +55,7 @@ * @author Nicolas Spano * @author Syed Iqbal */ -public class ApplicationResourceTest { +public class ApplicationResourceTest extends TestTimer { private IDomain domain; private HttpClientMockDirector mockDirector; diff --git a/src/test/java/com/openshift/internal/client/CertTrustIntegrationTest.java b/src/test/java/com/openshift/internal/client/CertTrustIntegrationTest.java index 38345587..7a888a9a 100755 --- a/src/test/java/com/openshift/internal/client/CertTrustIntegrationTest.java +++ b/src/test/java/com/openshift/internal/client/CertTrustIntegrationTest.java @@ -22,10 +22,10 @@ /** * @author William DeCoste */ -public class CertTrustIntegrationTest { +public class CertTrustIntegrationTest extends TestTimer { private IUser user; - + @Before public void setUp() throws OpenShiftException, IOException { // service = new OpenShiftService(TestUser.ID, new OpenShiftConfiguration().getLibraServer()); diff --git a/src/test/java/com/openshift/internal/client/ConfigurationTest.java b/src/test/java/com/openshift/internal/client/ConfigurationTest.java index 85e9e476..7f0e799a 100644 --- a/src/test/java/com/openshift/internal/client/ConfigurationTest.java +++ b/src/test/java/com/openshift/internal/client/ConfigurationTest.java @@ -39,7 +39,7 @@ /** * @author André Dietisheim */ -public class ConfigurationTest { +public class ConfigurationTest extends TestTimer { private static final String USERNAME_REGEX = "[^=]+=(.+)"; private static final String USERNAME = "dummyUser"; diff --git a/src/test/java/com/openshift/internal/client/DomainResourceIntegrationTest.java b/src/test/java/com/openshift/internal/client/DomainResourceIntegrationTest.java index 99ea85dd..63ec9c38 100755 --- a/src/test/java/com/openshift/internal/client/DomainResourceIntegrationTest.java +++ b/src/test/java/com/openshift/internal/client/DomainResourceIntegrationTest.java @@ -40,7 +40,7 @@ /** * @author Andre Dietisheim */ -public class DomainResourceIntegrationTest { +public class DomainResourceIntegrationTest extends TestTimer { private static final String QUICKSTART_REVEALJS_GITURL = "git://github.com/openshift-quickstart/reveal.js-openshift-quickstart.git"; private static final String REVEALJS_INDEX = "revealjs.html"; @@ -55,7 +55,7 @@ public void setUp() throws OpenShiftException, IOException { this.user = new TestConnectionFactory().getConnection().getUser(); this.domain = DomainTestUtils.ensureHasDomain(user); } - + @Test public void shouldSetNamespace() throws Exception { // pre-condition diff --git a/src/test/java/com/openshift/internal/client/DomainResourceTest.java b/src/test/java/com/openshift/internal/client/DomainResourceTest.java index b8ed61bd..074c8214 100644 --- a/src/test/java/com/openshift/internal/client/DomainResourceTest.java +++ b/src/test/java/com/openshift/internal/client/DomainResourceTest.java @@ -65,7 +65,7 @@ * @author Xavier Coulon * @author Andre Dietisheim */ -public class DomainResourceTest { +public class DomainResourceTest extends TestTimer { private IUser user; private IDomain domain; diff --git a/src/test/java/com/openshift/internal/client/EmbeddableCartridgeTest.java b/src/test/java/com/openshift/internal/client/EmbeddableCartridgeTest.java index ed7d72d1..5443431d 100644 --- a/src/test/java/com/openshift/internal/client/EmbeddableCartridgeTest.java +++ b/src/test/java/com/openshift/internal/client/EmbeddableCartridgeTest.java @@ -31,7 +31,7 @@ /** * @author Andre Dietisheim */ -public class EmbeddableCartridgeTest { +public class EmbeddableCartridgeTest extends TestTimer { private IOpenShiftConnection connection; diff --git a/src/test/java/com/openshift/internal/client/EmbeddedCartridgeResourceIntegrationTest.java b/src/test/java/com/openshift/internal/client/EmbeddedCartridgeResourceIntegrationTest.java index 34872ac3..c2e7719c 100755 --- a/src/test/java/com/openshift/internal/client/EmbeddedCartridgeResourceIntegrationTest.java +++ b/src/test/java/com/openshift/internal/client/EmbeddedCartridgeResourceIntegrationTest.java @@ -45,7 +45,7 @@ /** * @author André Dietisheim */ -public class EmbeddedCartridgeResourceIntegrationTest { +public class EmbeddedCartridgeResourceIntegrationTest extends TestTimer { private IDomain domain; private IUser user; diff --git a/src/test/java/com/openshift/internal/client/EmbeddedCartridgeResourceTest.java b/src/test/java/com/openshift/internal/client/EmbeddedCartridgeResourceTest.java index b88cea8c..bb26fcb7 100644 --- a/src/test/java/com/openshift/internal/client/EmbeddedCartridgeResourceTest.java +++ b/src/test/java/com/openshift/internal/client/EmbeddedCartridgeResourceTest.java @@ -54,7 +54,7 @@ /** * @author Andre Dietisheim */ -public class EmbeddedCartridgeResourceTest { +public class EmbeddedCartridgeResourceTest extends TestTimer { private IApplication application; private HttpClientMockDirector mockDirector; diff --git a/src/test/java/com/openshift/internal/client/EnvironmentVariableResourceIntegrationTest.java b/src/test/java/com/openshift/internal/client/EnvironmentVariableResourceIntegrationTest.java index e8aaf11d..7b86c79f 100644 --- a/src/test/java/com/openshift/internal/client/EnvironmentVariableResourceIntegrationTest.java +++ b/src/test/java/com/openshift/internal/client/EnvironmentVariableResourceIntegrationTest.java @@ -27,12 +27,12 @@ /** * @author Syed Iqbal */ -public class EnvironmentVariableResourceIntegrationTest { +public class EnvironmentVariableResourceIntegrationTest extends TestTimer { private IUser user; private IDomain domain; private IApplication application; - + @Before public void setUp() throws Exception { IOpenShiftConnection connection = new TestConnectionFactory().getConnection(); @@ -41,7 +41,7 @@ public void setUp() throws Exception { ApplicationTestUtils.silentlyDestroyAllApplications(domain); this.application = ApplicationTestUtils.getOrCreateApplication(domain); } - + @Test public void shouldGetEnvironmentVariableNameAndValue() throws Throwable { // operation diff --git a/src/test/java/com/openshift/internal/client/EnvironmentVariableResourceTest.java b/src/test/java/com/openshift/internal/client/EnvironmentVariableResourceTest.java index 6f62e46f..ddda1305 100644 --- a/src/test/java/com/openshift/internal/client/EnvironmentVariableResourceTest.java +++ b/src/test/java/com/openshift/internal/client/EnvironmentVariableResourceTest.java @@ -28,7 +28,7 @@ * @author Syed Iqbal * @author Martes G Wigglesworth */ -public class EnvironmentVariableResourceTest { +public class EnvironmentVariableResourceTest extends TestTimer { private IApplication application; private HttpClientMockDirector mockDirector; diff --git a/src/test/java/com/openshift/internal/client/GearGroupsResourceTest.java b/src/test/java/com/openshift/internal/client/GearGroupsResourceTest.java index 32f74390..76f0c100 100644 --- a/src/test/java/com/openshift/internal/client/GearGroupsResourceTest.java +++ b/src/test/java/com/openshift/internal/client/GearGroupsResourceTest.java @@ -34,7 +34,7 @@ * @author Xavier Coulon * @author Andre Dietisheim */ -public class GearGroupsResourceTest { +public class GearGroupsResourceTest extends TestTimer { private IDomain domain; diff --git a/src/test/java/com/openshift/internal/client/GearTest.java b/src/test/java/com/openshift/internal/client/GearTest.java index dd2ea4ee..63a755ee 100644 --- a/src/test/java/com/openshift/internal/client/GearTest.java +++ b/src/test/java/com/openshift/internal/client/GearTest.java @@ -20,7 +20,7 @@ * @author Xavier Coulon * @author Andre Dietisheim */ -public class GearTest { +public class GearTest extends TestTimer { @Test public void nullShouldCreateUnknownGearState() { diff --git a/src/test/java/com/openshift/internal/client/LatestVersionQueryIntegrationTest.java b/src/test/java/com/openshift/internal/client/LatestVersionQueryIntegrationTest.java index d0393070..7ade661b 100644 --- a/src/test/java/com/openshift/internal/client/LatestVersionQueryIntegrationTest.java +++ b/src/test/java/com/openshift/internal/client/LatestVersionQueryIntegrationTest.java @@ -28,7 +28,7 @@ /** * @author Andre Dietisheim */ -public class LatestVersionQueryIntegrationTest { +public class LatestVersionQueryIntegrationTest extends TestTimer { private IUser user; @@ -36,7 +36,7 @@ public class LatestVersionQueryIntegrationTest { public void setUp() throws OpenShiftException, FileNotFoundException, IOException { this.user = new TestConnectionFactory().getConnection().getUser(); } - + @Test public void shouldSelectJBossAs() { // pre-coniditions diff --git a/src/test/java/com/openshift/internal/client/OpenShiftExceptionTest.java b/src/test/java/com/openshift/internal/client/OpenShiftExceptionTest.java index 156c2489..b3c7342c 100644 --- a/src/test/java/com/openshift/internal/client/OpenShiftExceptionTest.java +++ b/src/test/java/com/openshift/internal/client/OpenShiftExceptionTest.java @@ -41,7 +41,7 @@ /** * @author Andre Dietisheim */ -public class OpenShiftExceptionTest { +public class OpenShiftExceptionTest extends TestTimer { private IUser user; private IHttpClient clientMock; diff --git a/src/test/java/com/openshift/internal/client/OpenShiftTestSuite.java b/src/test/java/com/openshift/internal/client/OpenShiftTestSuite.java index 76c2cce6..53564f8a 100755 --- a/src/test/java/com/openshift/internal/client/OpenShiftTestSuite.java +++ b/src/test/java/com/openshift/internal/client/OpenShiftTestSuite.java @@ -47,5 +47,5 @@ * @author André Dietisheim */ public class OpenShiftTestSuite { - + } diff --git a/src/test/java/com/openshift/internal/client/QueryTest.java b/src/test/java/com/openshift/internal/client/QueryTest.java index 9d301913..2ac7260f 100644 --- a/src/test/java/com/openshift/internal/client/QueryTest.java +++ b/src/test/java/com/openshift/internal/client/QueryTest.java @@ -48,7 +48,7 @@ /** * @author Andre Dietisheim */ -public class QueryTest { +public class QueryTest extends TestTimer { private IOpenShiftConnection connection; diff --git a/src/test/java/com/openshift/internal/client/RestServicePropertiesTest.java b/src/test/java/com/openshift/internal/client/RestServicePropertiesTest.java index dcde1a5f..07308d5b 100644 --- a/src/test/java/com/openshift/internal/client/RestServicePropertiesTest.java +++ b/src/test/java/com/openshift/internal/client/RestServicePropertiesTest.java @@ -25,7 +25,7 @@ /** * @author Andre Dietisheim */ -public class RestServicePropertiesTest { +public class RestServicePropertiesTest extends TestTimer { private static final String VERSION = "0.0.1"; private RestServiceProperties serviceProperties; diff --git a/src/test/java/com/openshift/internal/client/RestServiceTest.java b/src/test/java/com/openshift/internal/client/RestServiceTest.java index 66f6cd69..51ff6601 100644 --- a/src/test/java/com/openshift/internal/client/RestServiceTest.java +++ b/src/test/java/com/openshift/internal/client/RestServiceTest.java @@ -46,7 +46,7 @@ /** * @author Andre Dietisheim */ -public class RestServiceTest { +public class RestServiceTest extends TestTimer { protected static final String KEY_PROTOCOL_VERSION = "protocol_version"; private IRestService service; diff --git a/src/test/java/com/openshift/internal/client/SSHKeyIntegrationTest.java b/src/test/java/com/openshift/internal/client/SSHKeyIntegrationTest.java index 2901b38b..d0859b0c 100644 --- a/src/test/java/com/openshift/internal/client/SSHKeyIntegrationTest.java +++ b/src/test/java/com/openshift/internal/client/SSHKeyIntegrationTest.java @@ -36,10 +36,10 @@ /** * @author Andre Dietisheim */ -public class SSHKeyIntegrationTest { +public class SSHKeyIntegrationTest extends TestTimer { private IUser user; - + @Before public void setUp() throws FileNotFoundException, IOException, OpenShiftException { this.user = new TestConnectionFactory().getConnection().getUser(); diff --git a/src/test/java/com/openshift/internal/client/SSHKeyTest.java b/src/test/java/com/openshift/internal/client/SSHKeyTest.java index d9f224cb..226e13aa 100644 --- a/src/test/java/com/openshift/internal/client/SSHKeyTest.java +++ b/src/test/java/com/openshift/internal/client/SSHKeyTest.java @@ -43,7 +43,7 @@ /** * @author Andre Dietisheim */ -public class SSHKeyTest { +public class SSHKeyTest extends TestTimer { private IUser user; private HttpClientMockDirector mockDirector; diff --git a/src/test/java/com/openshift/internal/client/StandaloneCartridgeTest.java b/src/test/java/com/openshift/internal/client/StandaloneCartridgeTest.java index a7d12d10..e90c49ed 100644 --- a/src/test/java/com/openshift/internal/client/StandaloneCartridgeTest.java +++ b/src/test/java/com/openshift/internal/client/StandaloneCartridgeTest.java @@ -31,7 +31,7 @@ /** * @author Andre Dietisheim */ -public class StandaloneCartridgeTest { +public class StandaloneCartridgeTest extends TestTimer { private IOpenShiftConnection connection; diff --git a/src/test/java/com/openshift/internal/client/StandaloneCartridgesIntegrationTest.java b/src/test/java/com/openshift/internal/client/StandaloneCartridgesIntegrationTest.java index 0779b070..150fef92 100755 --- a/src/test/java/com/openshift/internal/client/StandaloneCartridgesIntegrationTest.java +++ b/src/test/java/com/openshift/internal/client/StandaloneCartridgesIntegrationTest.java @@ -31,7 +31,7 @@ /** * @author André Dietisheim */ -public class StandaloneCartridgesIntegrationTest { +public class StandaloneCartridgesIntegrationTest extends TestTimer { private IUser user; private IDomain domain; diff --git a/src/test/java/com/openshift/internal/client/TestTimer.java b/src/test/java/com/openshift/internal/client/TestTimer.java new file mode 100644 index 00000000..769c87a5 --- /dev/null +++ b/src/test/java/com/openshift/internal/client/TestTimer.java @@ -0,0 +1,42 @@ +package com.openshift.internal.client; + +import com.openshift.client.OpenShiftException; +import com.openshift.client.utils.TestConnectionFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.rules.TestName; + +import java.io.IOException; + +/** + * Created by cdaley on 3/13/14. + */ +public class TestTimer { + protected long startTime; + protected long endTime; + + @Rule + public TestName name = new TestName(); + + @Before + public void startTimer() throws OpenShiftException, IOException { + this.startTime = 0; + this.startTime = System.currentTimeMillis(); + } + + @After + public void endTimer() { + this.endTime = 0; + this.endTime = System.currentTimeMillis(); + calcExecTime(); + + + } + + public void calcExecTime() { + if (System.getProperty("showTestTimes") != null) { + System.out.println(this.getClass() +"#"+name.getMethodName() + " : " + (this.endTime - this.startTime)); + } + } +} diff --git a/src/test/java/com/openshift/internal/client/UserResourceIntegrationTest.java b/src/test/java/com/openshift/internal/client/UserResourceIntegrationTest.java index e7febcea..c3c8665f 100755 --- a/src/test/java/com/openshift/internal/client/UserResourceIntegrationTest.java +++ b/src/test/java/com/openshift/internal/client/UserResourceIntegrationTest.java @@ -37,7 +37,7 @@ /** * @author André Dietisheim */ -public class UserResourceIntegrationTest { +public class UserResourceIntegrationTest extends TestTimer { private IUser user; diff --git a/src/test/java/com/openshift/internal/client/UserTest.java b/src/test/java/com/openshift/internal/client/UserTest.java index 735d08f4..532b2950 100644 --- a/src/test/java/com/openshift/internal/client/UserTest.java +++ b/src/test/java/com/openshift/internal/client/UserTest.java @@ -26,7 +26,7 @@ * @author Xavier Coulon * @author Andre Dietisheim */ -public class UserTest { +public class UserTest extends TestTimer { private IUser user; private static final String PASSWORD = "123490"; diff --git a/src/test/java/com/openshift/internal/client/httpclient/HttpClientTest.java b/src/test/java/com/openshift/internal/client/httpclient/HttpClientTest.java index edc35de0..219d6ac2 100755 --- a/src/test/java/com/openshift/internal/client/httpclient/HttpClientTest.java +++ b/src/test/java/com/openshift/internal/client/httpclient/HttpClientTest.java @@ -42,6 +42,7 @@ import com.openshift.client.configuration.*; import com.openshift.client.fakes.*; +import com.openshift.internal.client.TestTimer; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -62,7 +63,7 @@ * @author Nicolas Spano * @author Corey Daley */ -public class HttpClientTest { +public class HttpClientTest extends TestTimer { private static final String ACCEPT_APPLICATION_JSON = "Accept: application/json"; private static final Pattern AUTHORIZATION_PATTERN = Pattern.compile("Authorization: Basic ([^\n]*)"); @@ -74,12 +75,12 @@ public class HttpClientTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - + @Before public void setUp() throws Exception { this.serverFake = startHttpServerFake(null); this.httpsServerFake = startHttpsServerFake(null); - this.configuration = new OpenShiftConfigurationFake("10000","10000","10000"); + this.configuration = new OpenShiftConfigurationFake("10000","10000","10000",null); this.httpClient = new UrlConnectionHttpClientBuilder() .setAcceptMediaType(ACCEPT_APPLICATION_JSON) .setUserAgent("com.openshift.client.test") @@ -455,8 +456,8 @@ public void shouldFallbackToOpenShiftTimeout() throws Throwable { public void shouldRespectDefaultTimeout() throws Throwable { // pre-conditions final int timeout = 1000; - final int serverDelay = timeout * 190; - IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake(null,null,null); + final int serverDelay = timeout * 10000; + IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake(null,null,null,"5000"); IHttpClient httpClient = new UrlConnectionHttpClientBuilder() .setAcceptMediaType(ACCEPT_APPLICATION_JSON) .setUserAgent("com.openshift.client.test") @@ -483,7 +484,7 @@ public void shouldRespectSystemConfigurationTimeoutOverridingDefaultTimeout() th // pre-conditions final int timeout = 1000; final int serverDelay = timeout * 15; - IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake(null,null,"11000"); + IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake(null,null,"2000","1000"); IHttpClient httpClient = new UrlConnectionHttpClientBuilder() .setAcceptMediaType(ACCEPT_APPLICATION_JSON) .setUserAgent("com.openshift.client.test") @@ -510,7 +511,7 @@ public void shouldRespectUserConfigurationTimeoutOverridingSystemConfigurationTi // pre-conditions final int timeout = 1000; final int serverDelay = timeout * 15; - IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake(null,"12000","11000"); + IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake(null,"3000","2000","1000"); IHttpClient httpClient = new UrlConnectionHttpClientBuilder() .setAcceptMediaType(ACCEPT_APPLICATION_JSON) .setUserAgent("com.openshift.client.test") @@ -537,7 +538,7 @@ public void shouldRespectSystemPropertiesTimeoutOverridingUserConfigurationTimeo // pre-conditions final int timeout = 1000; final int serverDelay = timeout * 15; - IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake("13000","12000","11000"); + IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake("4000","3000","2000","1000"); IHttpClient httpClient = new UrlConnectionHttpClientBuilder() .setAcceptMediaType(ACCEPT_APPLICATION_JSON) .setUserAgent("com.openshift.client.test")