[ 
https://issues.apache.org/jira/browse/STORM-1255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15152745#comment-15152745
 ] 

ASF GitHub Bot commented on STORM-1255:
---------------------------------------

Github user revans2 commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1114#discussion_r53354956
  
    --- Diff: storm-core/test/jvm/org/apache/storm/utils/UtilsTest.java ---
    @@ -0,0 +1,213 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.storm.utils;
    +
    +import java.util.Arrays;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.HashMap;
    +import org.junit.Test;
    +import org.junit.Assert;
    +
    +import org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider;
    +import org.apache.curator.ensemble.fixed.FixedEnsembleProvider;
    +import org.apache.curator.framework.AuthInfo;
    +import org.apache.curator.framework.CuratorFramework;
    +import org.apache.curator.framework.CuratorFrameworkFactory;
    +
    +import org.apache.storm.Config;
    +import org.apache.thrift.transport.TTransportException;
    +
    +public class UtilsTest {
    +    @Test
    +    public void newCuratorUsesExponentialBackoffTest() throws 
InterruptedException {
    +        final int expectedInterval = 2400;
    +        final int expectedRetries = 10;
    +        final int expectedCeiling = 3000;
    +
    +        Map<String, Object> config = Utils.readDefaultConfig();
    +        config.put(Config.STORM_ZOOKEEPER_RETRY_INTERVAL, 
expectedInterval); 
    +        config.put(Config.STORM_ZOOKEEPER_RETRY_TIMES, expectedRetries); 
    +        config.put(Config.STORM_ZOOKEEPER_RETRY_INTERVAL_CEILING, 
expectedCeiling); 
    +
    +        CuratorFramework curator = Utils.newCurator(config, 
Arrays.asList("bogus_server"), 42 /*port*/, "");
    +        StormBoundedExponentialBackoffRetry policy = 
    +            (StormBoundedExponentialBackoffRetry) 
curator.getZookeeperClient().getRetryPolicy();
    +        Assert.assertEquals(policy.getBaseSleepTimeMs(), expectedInterval);
    +        Assert.assertEquals(policy.getN(), expectedRetries);
    +        Assert.assertEquals(policy.getSleepTimeMs(10, 0), expectedCeiling);
    +    }
    +
    +    @Test(expected = RuntimeException.class)
    +    public void getConfiguredClientThrowsRuntimeExceptionOnBadArgsTest () 
throws RuntimeException, TTransportException {
    +        Map config = ConfigUtils.readStormConfig();
    +        config.put(Config.STORM_NIMBUS_RETRY_TIMES, 0);
    +        new NimbusClient(config, "", 65535);
    --- End diff --
    
    Can we change this to 
    
    ```
    try {
        new NimbusClient(config, "", 65535);
        Assert.fail("Expected Exception to be thrown");
    } catch (RuntimeException e) {
        assertTrue("Cause is not TTransportException "+e, 
Utils.exceptionCauseIsInstanceOf(TTransportException.class, e));
    }
    ```


> port backtype.storm.utils-test to java
> --------------------------------------
>
>                 Key: STORM-1255
>                 URL: https://issues.apache.org/jira/browse/STORM-1255
>             Project: Apache Storm
>          Issue Type: New Feature
>          Components: rm-core, storm-core
>            Reporter: Robert Joseph Evans
>            Assignee: Alessandro Bellina
>              Labels: java-migration, jstorm-merger
>
> junit test migration



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to