/**
 * 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.activeblaze;

import java.util.LinkedList;

/**
 *
 *
 */
public class BlazePointcastChannelTest extends BlazeChannelTest {
    private static int PORTSTART = 61616;
    private LinkedList<Integer> portList = new LinkedList<Integer>();

    protected void setGroupSize(int groupSize) {
        for (int i = 0; i < groupSize; i++) {
            portList.add((PORTSTART + i));
        }
    }

    protected void resetGroupSize() {
        portList.clear();
    }


    protected BlazeChannelFactory getChannelFactory() {
        BlazeChannelFactory result = new BlazeChannelFactory();
        String uri = "static://(";
        for (int i = 0; i < portList.size(); i++) {
            uri += "udp://localhost:" + (portList.get(i));
            uri += ",";
        }
        uri += ")";
        result.getConfiguration().setManagementURI("");
        result.getConfiguration().setBroadcastURI(uri);
        result.getConfiguration().setReliableBroadcast("swp");
        portList.addLast(portList.removeFirst());
        return result;
    }
}
