コード例 #1
0
  /**
   * Tests {@link GeneratorSetDocReader#getGeneratorSet getGeneratorSet()} using the following
   * inputs.
   *
   * <p>
   *
   * <TABLE border="1" cellpadding="8">
   * <TR align="left"><TH colspan=2> 2.   getGeneratorSet (Success) </TH></TR>
   * <TR align="left"><TH> Input Choice </TH> <TH> Value </TH></TR>
   * <TR><TD> TupleGenerator.Count </TD> <TD> Many </TD></TR>
   * <TR><TD> TupleGenerator.Function </TD> <TD> Default </TD></TR>
   * <TR><TD> TupleGenerator.Seed </TD> <TD> Default </TD></TR>
   * <TR><TD> TupleGenerator.Tuples </TD> <TD> Default </TD></TR>
   * <TR><TD> Combiner.Count </TD> <TD> None </TD></TR>
   * <TR><TD> Combiner.Tuples </TD> <TD> NA </TD></TR>
   * <TR><TD> Include.Count </TD> <TD> NA </TD></TR>
   * <TR><TD> Include.Var </TD> <TD> NA </TD></TR>
   * <TR><TD> Exclude.Count </TD> <TD> NA </TD></TR>
   * <TR><TD> Exclude.Var </TD> <TD> NA </TD></TR>
   * </TABLE>
   */
  @Test
  public void testGetGeneratorSet_2() {
    IGeneratorSet generatorSet = generatorSetResources_.read("generator-set-2.xml");
    ITestCaseGenerator[] generators =
        IteratorUtils.toArray(generatorSet.getGenerators(), ITestCaseGenerator.class);
    assertEquals("Generators", 4, generators.length);

    TupleGenerator tupleGenerator;
    String functionName;

    functionName = "F1";
    tupleGenerator = (TupleGenerator) generatorSet.getGenerator(functionName);
    assertEquals("getGenerator, function=" + functionName, true, tupleGenerator != null);
    assertEquals("Generator(" + functionName + "), seed", null, tupleGenerator.getRandomSeed());
    assertEquals(
        "Generator(" + functionName + "), defaultTupleSize",
        1,
        tupleGenerator.getDefaultTupleSize());
    assertEquals(
        "Generator(" + functionName + "), combiners", 0, tupleGenerator.getCombiners().size());

    functionName = "F2";
    tupleGenerator = (TupleGenerator) generatorSet.getGenerator(functionName);
    assertEquals("getGenerator, function=" + functionName, true, tupleGenerator != null);
    assertEquals("Generator(" + functionName + "), seed", null, tupleGenerator.getRandomSeed());
    assertEquals(
        "Generator(" + functionName + "), defaultTupleSize",
        1,
        tupleGenerator.getDefaultTupleSize());
    assertEquals(
        "Generator(" + functionName + "), combiners", 0, tupleGenerator.getCombiners().size());

    functionName = "F3";
    tupleGenerator = (TupleGenerator) generatorSet.getGenerator(functionName);
    assertEquals("getGenerator, function=" + functionName, true, tupleGenerator != null);
    assertEquals("Generator(" + functionName + "), seed", null, tupleGenerator.getRandomSeed());
    assertEquals(
        "Generator(" + functionName + "), defaultTupleSize",
        1,
        tupleGenerator.getDefaultTupleSize());
    assertEquals(
        "Generator(" + functionName + "), combiners", 0, tupleGenerator.getCombiners().size());

    functionName = null;
    tupleGenerator = (TupleGenerator) generatorSet.getGenerator(functionName);
    assertEquals("getGenerator, function=" + functionName, true, tupleGenerator != null);
    assertEquals("Generator(" + functionName + "), seed", null, tupleGenerator.getRandomSeed());
    assertEquals(
        "Generator(" + functionName + "), defaultTupleSize",
        1,
        tupleGenerator.getDefaultTupleSize());
    assertEquals(
        "Generator(" + functionName + "), combiners", 0, tupleGenerator.getCombiners().size());

    functionName = "F4";
    assertEquals(
        "Found default generator for function=" + functionName,
        true,
        tupleGenerator == generatorSet.getGenerator(functionName));
  }
コード例 #2
0
  /**
   * Tests {@link GeneratorSetDocReader#getGeneratorSet getGeneratorSet()} using the following
   * inputs.
   *
   * <p>
   *
   * <TABLE border="1" cellpadding="8">
   * <TR align="left"><TH colspan=2> 1.   getGeneratorSet (Success) </TH></TR>
   * <TR align="left"><TH> Input Choice </TH> <TH> Value </TH></TR>
   * <TR><TD> TupleGenerator.Count </TD> <TD> One </TD></TR>
   * <TR><TD> TupleGenerator.Function </TD> <TD> Defined </TD></TR>
   * <TR><TD> TupleGenerator.Seed </TD> <TD> Defined </TD></TR>
   * <TR><TD> TupleGenerator.Tuples </TD> <TD> Defined </TD></TR>
   * <TR><TD> Combiner.Count </TD> <TD> One </TD></TR>
   * <TR><TD> Combiner.Tuples </TD> <TD> Default </TD></TR>
   * <TR><TD> Include.Count </TD> <TD> None </TD></TR>
   * <TR><TD> Include.Var </TD> <TD> NA </TD></TR>
   * <TR><TD> Exclude.Count </TD> <TD> Many </TD></TR>
   * <TR><TD> Exclude.Var </TD> <TD> Valid </TD></TR>
   * </TABLE>
   */
  @Test
  public void testGetGeneratorSet_1() {
    IGeneratorSet generatorSet = generatorSetResources_.read("generator-set-1.xml");
    ITestCaseGenerator[] generators =
        IteratorUtils.toArray(generatorSet.getGenerators(), ITestCaseGenerator.class);
    assertEquals("Generators", 1, generators.length);

    TupleGenerator tupleGenerator;
    String functionName;
    TupleCombiner[] combiners;
    TupleCombiner combiner;
    VarSet varSet;
    IVarDef varDef;

    tupleGenerator = (TupleGenerator) generators[0];
    assertEquals("Generator 0, seed", new Long(1234L), tupleGenerator.getRandomSeed());
    assertEquals("Generator 0, defaultTupleSize", 3, tupleGenerator.getDefaultTupleSize());

    functionName = "F1";
    assertEquals(
        "getGenerator, function=" + functionName,
        tupleGenerator,
        generatorSet.getGenerator(functionName));

    functionName = null;
    assertEquals(
        "getGenerator, function=" + functionName, null, generatorSet.getGenerator(functionName));

    combiners =
        tupleGenerator
            .getCombiners()
            .toArray(new TupleCombiner[tupleGenerator.getCombiners().size()]);
    assertEquals("Generator 0, combiners", 1, combiners.length);

    combiner = combiners[0];

    varSet = new VarSet("include1").addMember(new VarSet("B").addMember(new VarDef("C")));

    varDef = varSet.getDescendant("B.C");
    assertEquals("Combiner[0], var=" + varDef + ", eligible", true, combiner.isEligible(varDef));

    varDef = new VarDef("include2");
    assertEquals("Combiner[0], var=" + varDef + ", eligible", true, combiner.isEligible(varDef));

    varSet = new VarSet("exclude1").addMember(new VarDef("var")).addMember(new VarDef("var2"));

    varDef = varSet.getDescendant("var");
    assertEquals("Combiner[0], var=" + varDef + ", eligible", false, combiner.isEligible(varDef));

    varDef = varSet.getDescendant("var2");
    assertEquals("Combiner[0], var=" + varDef + ", eligible", true, combiner.isEligible(varDef));

    varSet =
        new VarSet("exclude2")
            .addMember(new VarSet("var").addMember(new VarSet("A").addMember(new VarDef("B"))))
            .addMember(new VarDef("var2"));

    varDef = varSet.getDescendant("var.A.B");
    assertEquals("Combiner[0], var=" + varDef + ", eligible", false, combiner.isEligible(varDef));
  }
コード例 #3
0
  /**
   * Tests {@link GeneratorSetDocReader#getGeneratorSet getGeneratorSet()} using the following
   * inputs.
   *
   * <p>
   *
   * <TABLE border="1" cellpadding="8">
   * <TR align="left"><TH colspan=2> 4.   getGeneratorSet (Success) </TH></TR>
   * <TR align="left"><TH> Input Choice </TH> <TH> Value </TH></TR>
   * <TR><TD> TupleGenerator.Count </TD> <TD> One </TD></TR>
   * <TR><TD> TupleGenerator.Function </TD> <TD> Default </TD></TR>
   * <TR><TD> TupleGenerator.Seed </TD> <TD> Defined </TD></TR>
   * <TR><TD> TupleGenerator.Tuples </TD> <TD> Defined </TD></TR>
   * <TR><TD> Combiner.Count </TD> <TD> One </TD></TR>
   * <TR><TD> Combiner.Tuples </TD> <TD> Default </TD></TR>
   * <TR><TD> Include.Count </TD> <TD> One </TD></TR>
   * <TR><TD> Include.Var </TD> <TD> Valid </TD></TR>
   * <TR><TD> Exclude.Count </TD> <TD> None </TD></TR>
   * <TR><TD> Exclude.Var </TD> <TD> NA </TD></TR>
   * </TABLE>
   */
  @Test
  public void testGetGeneratorSet_4() {
    IGeneratorSet generatorSet = generatorSetResources_.read("generator-set-4.xml");
    ITestCaseGenerator[] generators =
        IteratorUtils.toArray(generatorSet.getGenerators(), ITestCaseGenerator.class);
    assertEquals("Generators", 1, generators.length);

    TupleGenerator tupleGenerator;
    String functionName;
    TupleCombiner[] combiners;
    TupleCombiner combiner;
    VarSet varSet;
    IVarDef varDef;

    tupleGenerator = (TupleGenerator) generators[0];
    functionName = "F4";
    assertEquals(
        "Found default generator for function=" + functionName,
        true,
        tupleGenerator == generatorSet.getGenerator(functionName));
    assertEquals("Default generator, seed", new Long(12345L), tupleGenerator.getRandomSeed());
    assertEquals("Default generator, defaultTupleSize", 3, tupleGenerator.getDefaultTupleSize());

    combiners =
        tupleGenerator
            .getCombiners()
            .toArray(new TupleCombiner[tupleGenerator.getCombiners().size()]);
    assertEquals("Default generator, combiners", 1, tupleGenerator.getCombiners().size());

    combiner = combiners[0];
    assertEquals(
        "Combiner[0], tupleSize", tupleGenerator.getDefaultTupleSize(), combiner.getTupleSize());

    varSet = new VarSet("A").addMember(new VarSet("X").addMember(new VarDef("Y")));

    varDef = varSet.getDescendant("X");
    assertEquals("Combiner[0], var=" + varDef + ", eligible", false, combiner.isEligible(varDef));

    varDef = new VarDef("B");
    assertEquals("Combiner[0], var=" + varDef + ", eligible", false, combiner.isEligible(varDef));

    varDef = new VarDef("X");
    assertEquals("Combiner[0], var=" + varDef + ", eligible", true, combiner.isEligible(varDef));
  }