@@ -0,0 +1,2935 @@
+/*%0A* Copyright 2013 the original author or authors.%0A*%0A* Licensed under the Apache License, Version 2.0 (the %22License%22);%0A* you may not use this file except in compliance with the License.%0A* You may obtain a copy of the License at%0A*%0A* http://www.apache.org/licenses/LICENSE-2.0%0A*%0A* Unless required by applicable law or agreed to in writing, software%0A* distributed under the License is distributed on an %22AS IS%22 BASIS,%0A* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A* See the License for the specific language governing permissions and%0A* limitations under the License.%0A*/%0Apackage net.kuujo.vertigo.testtools;%0A%0Aimport java.util.Random;%0Aimport java.util.UUID;%0A%0Aimport org.vertx.java.core.AsyncResult;%0Aimport org.vertx.java.core.Handler;%0Aimport org.vertx.java.core.json.JsonArray;%0Aimport org.vertx.java.core.json.JsonObject;%0A%0Aimport net.kuujo.vertigo.component.feeder.PollingFeeder;%0Aimport net.kuujo.vertigo.definition.ComponentDefinition;%0Aimport net.kuujo.vertigo.java.VertigoVerticle;%0A%0A/**%0A * A feeder that feeder %22random%22 test words to a network.%0A *%0A * @author Jordan Halterman%0A */%0Apublic class TestWordFeeder extends VertigoVerticle %7B%0A%0A  /**%0A   * Creates a test word feeder definition.%0A   *%0A   * @param field%0A   *   The field in which to place words.%0A   * @return%0A   *   A component definition.%0A   */%0A  public static ComponentDefinition createDefinition(String field) %7B%0A    String%5B%5D words = new String%5B%5D%7B%22apples%22, %22bananas%22, %22oranges%22, %22peaches%22, %22pears%22, %22strawberries%22%7D;%0A    return createDefinition(field, words);%0A  %7D%0A%0A  /**%0A   * Creates a test word feeder definition.%0A   *%0A   * @param field%0A   *   The field in which to place words.%0A   * @param words%0A   *   An array of words to feed.%0A   * @return%0A   *   A component definition.%0A   */%0A  public static ComponentDefinition createDefinition(String field, String%5B%5D words) %7B%0A    return new ComponentDefinition(UUID.randomUUID().toString())%0A      .setConfig(new JsonObject().putString(%22field%22, field)%0A      .putArray(%22words%22, new JsonArray(words)));%0A  %7D%0A%0A  private String field;%0A%0A  private String%5B%5D words;%0A%0A  private Random random = new Random();%0A%0A  @Override%0A  public void start() %7B%0A    field = context.config().getString(%22field%22);%0A    words = (String%5B%5D) context.config().getArray(%22words%22).toArray();%0A%0A    vertigo.createPollingFeeder().start(new Handler%3CAsyncResult%3CPollingFeeder%3E%3E() %7B%0A      @Override%0A      public void handle(AsyncResult%3CPollingFeeder%3E result) %7B%0A        if (result.failed()) %7B%0A          container.logger().error(%22Failed to start feeder.%22);%0A        %7D%0A        else %7B%0A          result.result().feedHandler(new Handler%3CPollingFeeder%3E() %7B%0A            @Override%0A            public void handle(PollingFeeder feeder) %7B%0A              String word = words%5Brandom.nextInt(words.length)%5D;%0A              JsonObject data = new JsonObject().putString(field, word);%0A              feeder.feed(data);%0A            %7D%0A          %7D);%0A        %7D%0A      %7D%0A    %7D);%0A  %7D%0A%0A%7D%0A

Add test word feeder.