Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '\'';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* @author André Dietisheim
*/
public class APIResourceIntegrationTest {
public class APIResourceIntegrationTest extends TestTimer {

private IOpenShiftConnection connection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @author Xavier Coulon
* @author Andre Dietisheim
*/
public class APIResourceTest {
public class APIResourceTest extends TestTimer {

private IOpenShiftConnection connection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* @author Nicolas Spano
* @author Syed Iqbal
*/
public class ApplicationResourceTest {
public class ApplicationResourceTest extends TestTimer {

private IDomain domain;
private HttpClientMockDirector mockDirector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
* @author Xavier Coulon
* @author Andre Dietisheim
*/
public class DomainResourceTest {
public class DomainResourceTest extends TestTimer {

private IUser user;
private IDomain domain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* @author Andre Dietisheim
*/
public class EmbeddableCartridgeTest {
public class EmbeddableCartridgeTest extends TestTimer {

private IOpenShiftConnection connection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/**
* @author André Dietisheim
*/
public class EmbeddedCartridgeResourceIntegrationTest {
public class EmbeddedCartridgeResourceIntegrationTest extends TestTimer {

private IDomain domain;
private IUser user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
/**
* @author Andre Dietisheim
*/
public class EmbeddedCartridgeResourceTest {
public class EmbeddedCartridgeResourceTest extends TestTimer {

private IApplication application;
private HttpClientMockDirector mockDirector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -41,7 +41,7 @@ public void setUp() throws Exception {
ApplicationTestUtils.silentlyDestroyAllApplications(domain);
this.application = ApplicationTestUtils.getOrCreateApplication(domain);
}

@Test
public void shouldGetEnvironmentVariableNameAndValue() throws Throwable {
// operation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Xavier Coulon
* @author Andre Dietisheim
*/
public class GearGroupsResourceTest {
public class GearGroupsResourceTest extends TestTimer {

private IDomain domain;

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/openshift/internal/client/GearTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @author Xavier Coulon
* @author Andre Dietisheim
*/
public class GearTest {
public class GearTest extends TestTimer {

@Test
public void nullShouldCreateUnknownGearState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
/**
* @author Andre Dietisheim
*/
public class LatestVersionQueryIntegrationTest {
public class LatestVersionQueryIntegrationTest extends TestTimer {

private IUser user;

@Before
public void setUp() throws OpenShiftException, FileNotFoundException, IOException {
this.user = new TestConnectionFactory().getConnection().getUser();
}

@Test
public void shouldSelectJBossAs() {
// pre-coniditions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/**
* @author Andre Dietisheim
*/
public class OpenShiftExceptionTest {
public class OpenShiftExceptionTest extends TestTimer {

private IUser user;
private IHttpClient clientMock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@
* @author André Dietisheim
*/
public class OpenShiftTestSuite {

}
2 changes: 1 addition & 1 deletion src/test/java/com/openshift/internal/client/QueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
/**
* @author Andre Dietisheim
*/
public class QueryTest {
public class QueryTest extends TestTimer {

private IOpenShiftConnection connection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
/**
* @author Andre Dietisheim
*/
public class SSHKeyTest {
public class SSHKeyTest extends TestTimer {

private IUser user;
private HttpClientMockDirector mockDirector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* @author Andre Dietisheim
*/
public class StandaloneCartridgeTest {
public class StandaloneCartridgeTest extends TestTimer {

private IOpenShiftConnection connection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* @author André Dietisheim
*/
public class StandaloneCartridgesIntegrationTest {
public class StandaloneCartridgesIntegrationTest extends TestTimer {

private IUser user;
private IDomain domain;
Expand Down
42 changes: 42 additions & 0 deletions src/test/java/com/openshift/internal/client/TestTimer.java
Original file line number Diff line number Diff line change
@@ -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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/**
* @author André Dietisheim
*/
public class UserResourceIntegrationTest {
public class UserResourceIntegrationTest extends TestTimer {

private IUser user;

Expand Down
Loading