Skip to content

Commit

Permalink
[grid] Remove "DefaultGridRegistry.newInstance()" method which is onl…
Browse files Browse the repository at this point in the history
…y used in tests
  • Loading branch information
shs96c committed Mar 6, 2018
1 parent 12655f7 commit 87c8732
Show file tree
Hide file tree
Showing 25 changed files with 119 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.openqa.grid.internal.listeners.RegistrationListener;
import org.openqa.grid.internal.listeners.SelfHealingProxy;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.grid.web.servlet.handler.RequestHandler;
import org.openqa.selenium.remote.DesiredCapabilities;
Expand Down Expand Up @@ -86,16 +87,6 @@ public void start() {
}
}

/**
* Creates a new {@link GridRegistry} that is not associated with a Hub and starts it.
*
* @return the registry
*/
@SuppressWarnings({"NullableProblems"})
public static GridRegistry newInstance() {
return newInstance(null);
}

/**
* Creates a new {@link GridRegistry} and starts it.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.junit.Test;
import org.openqa.grid.common.exception.GridException;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.grid.web.servlet.handler.RequestHandler;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.support.ui.FluentWait;
Expand Down Expand Up @@ -52,7 +54,7 @@ public class AddingProxyAgainFreesResources {
*/
@Before
public void setup() throws Exception {
registry = DefaultGridRegistry.newInstance();
registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
ff.put(CapabilityType.APPLICATION_NAME, "FF");
p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine1:4444", registry);
registry.add(p1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class BaseRemoteProxyTest {

@Before
public void before() {
registry = DefaultGridRegistry.newInstance();
registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
}

@Test
Expand Down Expand Up @@ -102,9 +102,9 @@ public void proxyConfigIsInheritedFromRegistry() {

@Test
public void proxyConfigOverwritesRegistryConfig() {
GridRegistry registry = DefaultGridRegistry.newInstance();
registry.getConfiguration().cleanUpCycle = 42;
registry.getConfiguration().maxSession = 1;
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
registry.getHub().getConfiguration().cleanUpCycle = 42;
registry.getHub().getConfiguration().maxSession = 1;

GridNodeConfiguration nodeConfiguration = parseCliOptions(
"-role", "webdriver", "-cleanUpCycle", "100", "-maxSession", "50");
Expand All @@ -122,7 +122,7 @@ public void proxyConfigOverwritesRegistryConfig() {
@Test
public void proxyTakesRemoteAsIdIfIdNotSpecified() {
String remoteHost ="http://machine1:5555";
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));

GridNodeConfiguration nodeConfiguration = parseCliOptions(
"-role", "webdriver","-host", "machine1", "-port", "5555");
Expand All @@ -136,7 +136,7 @@ public void proxyTakesRemoteAsIdIfIdNotSpecified() {

@Test
public void proxyWithIdSpecified() {
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
GridNodeConfiguration nodeConfiguration = parseCliOptions(
"-role", "webdriver","-host", "machine1", "-port", "5555","-id", "abc");
RegistrationRequest req = RegistrationRequest.build(nodeConfiguration);
Expand All @@ -149,7 +149,7 @@ public void proxyWithIdSpecified() {

@Test
public void timeouts() {
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
GridNodeConfiguration nodeConfiguration = parseCliOptions(
"-role", "webdriver","-host", "machine1", "-port", "5555","-id", "abc","-timeout", "23", "-browserTimeout", "12");
RegistrationRequest req = RegistrationRequest.build(nodeConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.junit.Test;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.mock.MockedRequestHandler;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.remote.CapabilityType;

import java.util.ArrayList;
Expand Down Expand Up @@ -52,7 +54,7 @@ public class ConcurrencyLockTest {
*/
@Before
public void setup() throws Exception {
registry = DefaultGridRegistry.newInstance();
registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
ie.put(CapabilityType.APPLICATION_NAME, "IE");
ff.put(CapabilityType.APPLICATION_NAME, "FF");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.junit.Test;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.mock.MockedRequestHandler;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.grid.web.servlet.handler.RequestHandler;
import org.openqa.selenium.remote.CapabilityType;

Expand All @@ -43,7 +45,8 @@ public void shutdown() throws Exception {
ff.put(CapabilityType.APPLICATION_NAME, "FF");
ff.put(MAX_INSTANCES, 1);

final GridRegistry registry = DefaultGridRegistry.newInstance();
final GridRegistry registry =
DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));

RemoteProxy p1 =
RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine1:4444", registry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.mock.MockedRequestHandler;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.internal.utils.configuration.GridNodeConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

Expand All @@ -50,8 +52,8 @@ public class LoadBalancedTests {

@Before
public void setup() {
registry = DefaultGridRegistry.newInstance();
registry2 = DefaultGridRegistry.newInstance();
registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
registry2 = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));

register5ProxiesOf5Slots();
register3ProxiesVariableSlotSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.openqa.grid.common.SeleniumProtocol;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.mock.MockedRequestHandler;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.grid.web.servlet.handler.SeleniumBasedRequest;
import org.openqa.selenium.remote.CapabilityType;

Expand All @@ -45,7 +47,7 @@ public class NewRequestCrashesDuringNewSessionTest {
*/
@Before
public void setup() throws Exception {
registry = DefaultGridRegistry.newInstance();
registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
ff.put(CapabilityType.APPLICATION_NAME, "FF");

p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine1:4444", registry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.junit.Test;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.mock.MockedRequestHandler;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.remote.CapabilityType;

import java.util.HashMap;
Expand All @@ -38,7 +40,7 @@ public class NewSessionRequestTimeout {
*/
@Before
public void setup() throws Exception {
registry = DefaultGridRegistry.newInstance();
registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
ff.put(CapabilityType.APPLICATION_NAME, "FF");

p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine1:4444", registry);
Expand Down
18 changes: 12 additions & 6 deletions java/server/test/org/openqa/grid/internal/ParallelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.mock.MockedRequestHandler;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.grid.web.servlet.handler.RequestHandler;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
Expand Down Expand Up @@ -65,7 +67,7 @@ public void prepareReqRequest() {

@Test
public void canGetApp2() {
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
RemoteProxy p1 = new BaseRemoteProxy(req, registry);
try {
registry.add(p1);
Expand All @@ -84,7 +86,8 @@ public void canGetApp2() {
*/
@Test
public void cannotGet2App2() {
final GridRegistry registry = DefaultGridRegistry.newInstance();
final GridRegistry registry =
DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
RemoteProxy p1 = new BaseRemoteProxy(req, registry);
try {
registry.add(p1);
Expand All @@ -110,7 +113,8 @@ public void cannotGet2App2() {
*/
@Test(timeout = 2000)
public void canGet5App1() {
final GridRegistry registry = DefaultGridRegistry.newInstance();
final GridRegistry registry =
DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
RemoteProxy p1 = new BaseRemoteProxy(req, registry);
try {
registry.add(p1);
Expand All @@ -129,7 +133,8 @@ public void canGet5App1() {
*/
@Test(timeout = 1000)
public void cannotGet6App1() {
final GridRegistry registry = DefaultGridRegistry.newInstance();
final GridRegistry registry =
DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
RemoteProxy p1 = new BaseRemoteProxy(req, registry);
try {
registry.add(p1);
Expand Down Expand Up @@ -163,7 +168,8 @@ public void cannotGet6App1() {
*/
@Test(timeout = 1000)
public void cannotGetApp2() {
final GridRegistry registry = DefaultGridRegistry.newInstance();
final GridRegistry registry =
DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
RemoteProxy p1 = new BaseRemoteProxy(req, registry);
try {
registry.add(p1);
Expand Down Expand Up @@ -192,7 +198,7 @@ public void cannotGetApp2() {

@Test(timeout = 10000)
public void releaseAndReserve() {
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
RemoteProxy p1;
RegistrationRequest req;
Map<String, Object> app1 = new HashMap<>();
Expand Down
6 changes: 4 additions & 2 deletions java/server/test/org/openqa/grid/internal/PriorityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.junit.Test;
import org.openqa.grid.internal.listeners.Prioritizer;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.grid.web.servlet.handler.RequestHandler;
import org.openqa.selenium.remote.CapabilityType;

Expand Down Expand Up @@ -64,8 +66,8 @@ public int compareTo(Map<String, Object> a, Map<String, Object> b) {
*/
@Before
public void setup() throws Exception {
registry = DefaultGridRegistry.newInstance();
registry.getConfiguration().prioritizer = highestNumberHasPriority;
registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
registry.getHub().getConfiguration().prioritizer = highestNumberHasPriority;
ff.put(CapabilityType.APPLICATION_NAME, "FF");
p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine1:4444", registry);
registry.add(p1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.junit.Test;
import org.openqa.grid.internal.listeners.Prioritizer;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.grid.web.servlet.handler.RequestHandler;
import org.openqa.selenium.remote.CapabilityType;

Expand Down Expand Up @@ -64,8 +66,8 @@ public int compareTo(Map<String, Object> a, Map<String, Object> b) {
*/
@Before
public void setup() throws Exception {
registry = DefaultGridRegistry.newInstance();
registry.getConfiguration().prioritizer = highestNumberHasPriority;
registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
registry.getHub().getConfiguration().prioritizer = highestNumberHasPriority;
ff.put(CapabilityType.APPLICATION_NAME, "FF");
RemoteProxy
p1 =
Expand Down
6 changes: 4 additions & 2 deletions java/server/test/org/openqa/grid/internal/ProxySetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

import org.junit.Test;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.internal.utils.configuration.GridNodeConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;

Expand All @@ -34,7 +36,7 @@ public class ProxySetTest {

@Test
public void removeIfPresent() throws Exception {
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
try {
ProxySet set = registry.getAllProxies();
RemoteProxy
Expand All @@ -61,7 +63,7 @@ public void removeIfPresent() throws Exception {

@Test
public void testProxySortingByIdle() throws Exception {
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
try {
ProxySet set = registry.getAllProxies();

Expand Down
12 changes: 7 additions & 5 deletions java/server/test/org/openqa/grid/internal/RegistryStateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.internal.mock.GridHelper;
import org.openqa.grid.internal.mock.MockedRequestHandler;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.grid.web.servlet.handler.RequestHandler;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
Expand Down Expand Up @@ -65,7 +67,7 @@ public void prepareReqRequest() {

@Test
public void sessionIsRemoved() {
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));

RemoteProxy p1 = new BaseRemoteProxy(req, registry);

Expand All @@ -85,7 +87,7 @@ public void sessionIsRemoved() {

@Test(timeout = 5000)
public void basicChecks() {
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
RemoteProxy p1 = new BaseRemoteProxy(req, registry);

try {
Expand Down Expand Up @@ -114,7 +116,7 @@ public void basicChecks() {

@Test(timeout = 4000)
public void sessionIsRemoved2() {
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
RemoteProxy p1 = new BaseRemoteProxy(req, registry);

try {
Expand All @@ -133,7 +135,7 @@ public void sessionIsRemoved2() {

@Test(timeout = 4000)
public void sessionByExtKey() {
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
RemoteProxy p1 = new BaseRemoteProxy(req, registry);

try {
Expand Down Expand Up @@ -162,7 +164,7 @@ public void sessionByExtKey() {

@Test
public void sessionByExtKeyNull() {
GridRegistry registry = DefaultGridRegistry.newInstance();
GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration()));
RemoteProxy p1 = new BaseRemoteProxy(req, registry);

try {
Expand Down
Loading

0 comments on commit 87c8732

Please sign in to comment.