Skip to content

Commit

Permalink
server: InvalidParameterException is expected
Browse files Browse the repository at this point in the history
Logging the original exception in this case is confusing when reading
the test results as they look like real issues. Because
InvalidParameterException is expected, it's OK to not log.
  • Loading branch information
andreastt committed Mar 2, 2015
1 parent 5fcb57f commit c724384
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
10 changes: 3 additions & 7 deletions java/server/src/org/openqa/grid/internal/BaseRemoteProxy.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright 2011 Selenium committers
Copyright 2011 - 2012 Software Freedom Conservancy
Copyright 2011-2015 Software Freedom Conservancy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -408,8 +408,8 @@ public boolean isBusy() {
* @return a new instance built from the request.
*/
@SuppressWarnings("unchecked")
public static <T extends RemoteProxy> T getNewInstance(RegistrationRequest request,
Registry registry) {
public static <T extends RemoteProxy> T getNewInstance(
RegistrationRequest request, Registry registry) {
try {
String proxyClass = request.getRemoteProxyClass();
if (proxyClass == null) {
Expand All @@ -428,13 +428,9 @@ public static <T extends RemoteProxy> T getNewInstance(RegistrationRequest reque
} else {
throw new InvalidParameterException("Error: " + proxy.getClass() + " isn't a remote proxy");
}

} catch (InvocationTargetException e) {
log.log(Level.SEVERE, e.getTargetException().getMessage(), e.getTargetException());
throw new InvalidParameterException("Error: " + e.getTargetException().getMessage());

} catch (Exception e) {
log.log(Level.SEVERE, e.getMessage(), e);
throw new InvalidParameterException("Error: " + e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright 2011 Selenium committers
Copyright 2011 Software Freedom Conservancy
Copyright 2011-2015 Software Freedom Conservancy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,23 +33,18 @@
import java.util.HashMap;
import java.util.Map;


public class RemoteProxyInheritanceTest {

private Registry registry = Registry.newInstance();

@Test
public void defaultToRemoteProxy() {


RegistrationRequest req = RegistrationRequest.localWebdriverNoCapabilities();

Map<String, Object> app1 = new HashMap<String, Object>();
Map<String, Object> config = new HashMap<String, Object>();
app1.put(APP, "app1");
config.put(ID, "abc");


req.addDesiredCapability(app1);
req.setConfiguration(config);

Expand All @@ -58,7 +53,6 @@ public void defaultToRemoteProxy() {
assertEquals(BaseRemoteProxy.class, p.getClass());
}


@Test
public void existing() {
Map<String, Object> app1 = new HashMap<String, Object>();
Expand All @@ -82,7 +76,6 @@ public void existing() {
assertEquals("B", myRemoteProxy.getCustom2());
assertEquals("A", myRemoteProxy.getConfig().get("Custom1"));
assertEquals("B", myRemoteProxy.getConfig().get("Custom2"));

}

@Test(expected = InvalidParameterException.class)
Expand All @@ -106,7 +99,6 @@ public void notExtendingProxyExisting() {
app1.put(APP, "app1");
config.put(PROXY_CLASS, "java.lang.String");


RegistrationRequest req = new RegistrationRequest();
req.addDesiredCapability(app1);
req.setConfiguration(config);
Expand All @@ -130,10 +122,8 @@ public void badConfig() {
BaseRemoteProxy.getNewInstance(req, registry);
}


@After
public void tearDown(){
public void tearDown() {
registry.stop();
}

}

0 comments on commit c724384

Please sign in to comment.