Skip to content

Commit

Permalink
Death to statics in test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Oct 4, 2016
1 parent 49cc3ae commit 575507a
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.web.servlet.handler.RequestHandler;
Expand All @@ -38,21 +38,21 @@
*/
public class AddingProxyAgainFreesResources {

private static Registry registry;
private Registry registry;

private static Map<String, Object> ff = new HashMap<>();
private static RemoteProxy p1;
private static RequestHandler handler;
private static RequestHandler handler2;
private static TestSession session = null;
private Map<String, Object> ff = new HashMap<>();
private RemoteProxy p1;
private RequestHandler handler;
private RequestHandler handler2;
private TestSession session = null;

/**
* create a hub with 1 node accepting 1 FF
*
* @throws InterruptedException
*/
@BeforeClass
public static void setup() throws Exception {
@Before
public void setup() throws Exception {
registry = Registry.newInstance();
ff.put(CapabilityType.APPLICATION_NAME, "FF");
p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine1:4444", registry);
Expand Down Expand Up @@ -93,8 +93,8 @@ public void validateRequest2isNowRunningOnTheNode() throws InterruptedException
assertNotNull(handler2.getSession());
}

@AfterClass
public static void teardown() {
@After
public void teardown() {
registry.stop();
}
}
23 changes: 11 additions & 12 deletions java/server/test/org/openqa/grid/internal/BaseRemoteProxyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

import com.beust.jcommander.JCommander;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.common.exception.GridException;
Expand All @@ -41,15 +41,15 @@

public class BaseRemoteProxyTest {

private static RemoteProxy p1 = null;
private static RemoteProxy p2 = null;
private RemoteProxy p1 = null;
private RemoteProxy p2 = null;

private static Map<String, Object> app1Capability = new HashMap<>();
private static Map<String, Object> app2Capability = new HashMap<>();
private static Registry registry = Registry.newInstance();
private Map<String, Object> app1Capability = new HashMap<>();
private Map<String, Object> app2Capability = new HashMap<>();
private Registry registry = Registry.newInstance();

@BeforeClass
public static void setup() throws Exception {
@Before
public void setup() throws Exception {

app1Capability.put(CapabilityType.APPLICATION_NAME, "app1");
app2Capability.put(CapabilityType.APPLICATION_NAME, "app2");
Expand All @@ -64,7 +64,6 @@ public static void setup() throws Exception {

}


@Test
public void testEqual() {
assertTrue(p1.equals(p1));
Expand Down Expand Up @@ -160,8 +159,8 @@ public void timeouts() {
}


@AfterClass
public static void teardown() {
@After
public void teardown() {
registry.stop();
}

Expand Down
19 changes: 9 additions & 10 deletions java/server/test/org/openqa/grid/internal/ConcurrencyLockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import static org.junit.Assert.assertEquals;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.mock.MockedRequestHandler;
Expand All @@ -42,16 +42,16 @@

public class ConcurrencyLockTest {

private static Registry registry;
private Registry registry;

private static Map<String, Object> ie = new HashMap<>();
private static Map<String, Object> ff = new HashMap<>();
private Map<String, Object> ie = new HashMap<>();
private Map<String, Object> ff = new HashMap<>();

/**
* create a hub with 1 IE and 1 FF
*/
@BeforeClass
public static void setup() throws Exception {
@Before
public void setup() throws Exception {
registry = Registry.newInstance();
ie.put(CapabilityType.APPLICATION_NAME, "IE");
ff.put(CapabilityType.APPLICATION_NAME, "FF");
Expand All @@ -63,7 +63,6 @@ public static void setup() throws Exception {

}


private List<String> results = Collections.synchronizedList(new ArrayList<String>());

@Test(timeout = 10000)
Expand Down Expand Up @@ -124,8 +123,8 @@ private void runTests2(Map<String, Object> cap) throws InterruptedException {
}


@AfterClass
public static void teardown() {
@After
public void teardown() {
registry.stop();
}

Expand Down
43 changes: 23 additions & 20 deletions java/server/test/org/openqa/grid/internal/GridInternalTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.openqa.grid.internal.listener.CommandListenerTest;
import org.openqa.grid.internal.listener.RegistrationListenerTest;
import org.openqa.grid.internal.listener.SessionListenerTest;
import org.openqa.grid.internal.utils.DefaultCapabilityMatcherTest;
Expand All @@ -31,32 +32,34 @@

@RunWith(Suite.class)
@Suite.SuiteClasses({
RemoteProxyInheritanceTest.class,
SmokeTest.class,
SessionTimesOutTest.class,
AddingProxyAgainFreesResources.class,
BaseRemoteProxyTest.class,
RemoteProxySlowSetup.class,
RegistryTest.class,
RegistryStateTest.class,
PriorityTestLoad.class,
PriorityTest.class,
// ParallelTests fail when run via command line with buck
// ParallelTest.class,
LoadBalancedTests.class,
CommandListenerTest.class,
ConcurrencyLockTest.class,
AddingProxyAgainFreesResources.class,
DefaultCapabilityMatcherTest.class,
SessionListenerTest.class,
RegistrationListenerTest.class,
StatusServletTests.class,
UserDefinedCapabilityMatcherTests.class,
GridShutdownTest.class,
SelfRegisteringRemoteTest.class,
StandaloneConfigurationTest.class,
GridConfigurationTest.class,
GridNodeConfigurationTest.class,
GridHubConfigurationTest.class,

GridShutdownTest.class,
LoadBalancedTests.class,
NewRequestCrashesDuringNewSessionTest.class,
NewSessionRequestTimeout.class,
// ParallelTests fail when run via command line with buck
ParallelTest.class,
PriorityTest.class,
PriorityTestLoad.class,
RegistrationListenerTest.class,
RegistryStateTest.class,
RegistryTest.class,
RemoteProxyInheritanceTest.class,
RemoteProxySlowSetup.class,
SelfRegisteringRemoteTest.class,
SessionTimesOutTest.class,
SessionListenerTest.class,
SmokeTest.class,
StandaloneConfigurationTest.class,
StatusServletTests.class,
UserDefinedCapabilityMatcherTests.class,
})
public class GridInternalTests {
}
30 changes: 15 additions & 15 deletions java/server/test/org/openqa/grid/internal/LoadBalancedTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import static org.junit.Assert.assertNotNull;
import static org.openqa.grid.common.RegistrationRequest.MAX_INSTANCES;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.internal.mock.GridHelper;
Expand All @@ -41,15 +41,15 @@
*/
public class LoadBalancedTests {

private static Registry registry;
private static Registry registry2;
private Registry registry;
private Registry registry2;

private static BaseRemoteProxy proxy1;
private static BaseRemoteProxy proxy2;
private static BaseRemoteProxy proxy3;
private BaseRemoteProxy proxy1;
private BaseRemoteProxy proxy2;
private BaseRemoteProxy proxy3;

@BeforeClass
public static void setup() {
@Before
public void setup() {
registry = Registry.newInstance();
registry2 = Registry.newInstance();

Expand All @@ -59,7 +59,7 @@ public static void setup() {

// registry :
// add 5 proxies. Total = 5 proxies * 5 slots each = 25 firefox.
private static void register5ProxiesOf5Slots() {
private void register5ProxiesOf5Slots() {
// add 5 proxies. Total = 5 proxies * 5 slots each = 25 firefox.
for (int i = 0; i < 5; i++) {
registry.add(new DetachedRemoteProxy(getRequestOfNSlots(5, "name" + i), registry));
Expand All @@ -70,7 +70,7 @@ private static void register5ProxiesOf5Slots() {
// proxy 1 -> 2 slots
// proxy 2 -> 4 slots
// proxy 3 -> 6 slots
private static void register3ProxiesVariableSlotSize() {
private void register3ProxiesVariableSlotSize() {
proxy1 = new DetachedRemoteProxy(getRequestOfNSlots(2, "proxy1"), registry2);
proxy2 = new DetachedRemoteProxy(getRequestOfNSlots(4, "proxy2"), registry2);
proxy3 = new DetachedRemoteProxy(getRequestOfNSlots(6, "proxy3"), registry2);
Expand Down Expand Up @@ -163,13 +163,13 @@ public void newSessionSpreadOnAllProxiesAccordingToTheResource() {



private static Map<String, Object> firefox() {
private Map<String, Object> firefox() {
Map<String, Object> ff = new HashMap<>();
ff.put(CapabilityType.APPLICATION_NAME, "firefox");
return ff;
}

private static RegistrationRequest getRequestOfNSlots(int n, String name) {
private RegistrationRequest getRequestOfNSlots(int n, String name) {

Map<String, Object> ff = firefox();
ff.put(MAX_INSTANCES, n);
Expand All @@ -185,8 +185,8 @@ private static RegistrationRequest getRequestOfNSlots(int n, String name) {
return request;
}

@AfterClass
public static void teardown() {
@After
public void teardown() {
registry.stop();
registry2.stop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.grid.common.SeleniumProtocol;
import org.openqa.grid.internal.mock.GridHelper;
Expand All @@ -36,15 +36,15 @@

public class NewRequestCrashesDuringNewSessionTest {

private static Registry registry;
private static Map<String, Object> ff = new HashMap<>();
private static RemoteProxy p1;
private Registry registry;
private Map<String, Object> ff = new HashMap<>();
private RemoteProxy p1;

/**
* create a hub with 1 IE and 1 FF
*/
@BeforeClass
public static void setup() throws Exception {
@Before
public void setup() throws Exception {
registry = Registry.newInstance();
ff.put(CapabilityType.APPLICATION_NAME, "FF");

Expand Down Expand Up @@ -86,8 +86,8 @@ public void requestIsremovedFromTheQeueAfterItcrashes() throws InterruptedExcept
assertEquals(0, registry.getNewSessionRequestCount());
}

@AfterClass
public static void teardown() {
@After
public void teardown() {
registry.stop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package org.openqa.grid.internal;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.mock.MockedRequestHandler;
Expand All @@ -29,15 +29,15 @@

public class NewSessionRequestTimeout {

private static Registry registry;
private static Map<String, Object> ff = new HashMap<>();
private static RemoteProxy p1;
private Registry registry;
private Map<String, Object> ff = new HashMap<>();
private RemoteProxy p1;

/**
* create a hub with 1 IE and 1 FF
*/
@BeforeClass
public static void setup() throws Exception {
@Before
public void setup() throws Exception {
registry = Registry.newInstance();
ff.put(CapabilityType.APPLICATION_NAME, "FF");

Expand All @@ -63,8 +63,8 @@ public void method() {

}

@AfterClass
public static void teardown() {
@After
public void teardown() {
registry.stop();
}
}
Loading

0 comments on commit 575507a

Please sign in to comment.