Skip to content

Commit

Permalink
SYMMETRICDS-87 - Test connection exception scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed May 15, 2009
1 parent eacc704 commit f02b3b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Expand Up @@ -34,10 +34,10 @@
*/
public class BandwidthService implements IBandwidthService {

protected final Log logger = LogFactory.getLog(getClass());
protected Log logger = LogFactory.getLog(getClass());

public double getDownloadKbpsFor(String syncUrl, long sampleSize, long maxTestDuration) {
double downloadSpeed = -1;
double downloadSpeed = -1d;
try {
BandwidthTestResults bw = getDownloadResultsFor(syncUrl, sampleSize, maxTestDuration);
downloadSpeed = (int) bw.getKbps();
Expand Down
Expand Up @@ -19,6 +19,7 @@
*/
package org.jumpmind.symmetric.service.impl;

import org.apache.commons.logging.impl.NoOpLog;
import org.jumpmind.symmetric.transport.BandwidthTestResults;
import org.jumpmind.symmetric.web.BandwidthSamplerServlet;
import org.junit.Assert;
Expand All @@ -35,6 +36,7 @@ public class BandwidthServiceUnitTest {
public void testDownloadKbps() throws Exception {

BandwidthService service = new BandwidthService();
service.logger = new NoOpLog();
int port = 9768;
BandwidthSamplerServlet servlet = new BandwidthSamplerServlet();
Server server = startServer(port, "", servlet);
Expand All @@ -46,6 +48,9 @@ public void testDownloadKbps() throws Exception {
BandwidthTestResults bw2 = service.getDownloadResultsFor(String.format("http://localhost:%s", port), 1000, 2000);
Assert.assertTrue(bw2.getKbps() < bw1.getKbps());
server.stop();

Assert.assertEquals(-1d, service.getDownloadKbpsFor(String.format("http://localhost:%s", port), 1000, 2000), 0);


}

Expand Down

0 comments on commit f02b3b7

Please sign in to comment.