Ejemplo n.º 1
0
  /** Test the number of symbols in the symbol table is one since there is one capability. */
  public void testSymbolCountWithOneCapability() {
    final ISymbolMap symbolTable = context.mock(ISymbolMap.class);
    final CapabilitySymbol capSym =
        new CapabilitySymbol(
            OneCapabilityOneTestXML.capabilityId,
            OneCapabilityOneTestXML.capabilityDesc,
            OneCapabilityOneTestXML.capabilityClass);

    context.checking(
        new Expectations() {
          {
            one(symbolTable).put(OneCapabilityOneTestXML.capabilityId, capSym);
          }
        });

    final byte[] xmlBytes = OneCapabilityOneTestXML.profileXML.getBytes();
    final ByteArrayInputStream stream = new ByteArrayInputStream(xmlBytes);
    try {
      parser.setSymbolTable(symbolTable).parse(stream);
    } catch (ParserException ex) {
      fail(ex.getMessage());
    }

    context.assertIsSatisfied();
  }
Ejemplo n.º 2
0
  /**
   * Test symbol table is correct for one capability with one test and some arguments and an
   * environment.
   */
  public void testSymbolsWithOneCapabilityOneTest() {
    final ISymbolMap symbolTable = new ProfileParserTestSymbolMap();
    final byte[] xmlBytes = OneCapabilityOneTestXML.profileXML.getBytes();
    final ByteArrayInputStream stream = new ByteArrayInputStream(xmlBytes);
    try {
      parser.setSymbolTable(symbolTable).parse(stream);
    } catch (ParserException ex) {
      fail(ex.getMessage());
    }

    final CapabilitySymbol capSym =
        (CapabilitySymbol) symbolTable.get(OneCapabilityOneTestXML.capabilityId);
    assertEquals(
        new CapabilitySymbol(
            OneCapabilityOneTestXML.capabilityId,
            OneCapabilityOneTestXML.capabilityDesc,
            OneCapabilityOneTestXML.capabilityClass),
        capSym);

    final List<ArgumentSymbol> targetCapArgs = new ArrayList<ArgumentSymbol>();
    for (int idx = 0; idx < OneCapabilityOneTestXML.capArgId.length; idx++) {
      final ArgumentSymbol argSym =
          new ArgumentSymbol(
              OneCapabilityOneTestXML.capArgId[idx], OneCapabilityOneTestXML.capArgClasses[idx]);
      targetCapArgs.add(argSym);
    }
    final List<ISymbol> capArgs = capSym.getSymbolsInContext(IArgumentSymbol.CONTEXT);
    assertEquals(targetCapArgs, capArgs);

    final TestSymbol testSym =
        (TestSymbol) capSym.getSymbol(OneCapabilityOneTestXML.testId, ITestSymbol.CONTEXT);
    assertEquals(new TestSymbol(OneCapabilityOneTestXML.testId), testSym);

    final List<IEnvironmentSymbol> targetEnv =
        getProfileEnvironment(OneCapabilityOneTestXML.varNames, OneCapabilityOneTestXML.varValues);
    final List<ISymbol> envs = capSym.getSymbolsInContext(IEnvironmentSymbol.CONTEXT);
    assertEquals(targetEnv, envs);

    final List<ArgumentSymbol> targetArgs = new ArrayList<ArgumentSymbol>();
    for (int idx = 0; idx < OneCapabilityOneTestXML.argIds.length; idx++) {
      final ArgumentSymbol argSym =
          new ArgumentSymbol(
              OneCapabilityOneTestXML.argIds[idx], OneCapabilityOneTestXML.argClasses[idx]);
      targetArgs.add(argSym);
    }
    final List<ISymbol> args = testSym.getSymbolsInContext(IArgumentSymbol.CONTEXT);
    assertEquals(targetArgs, args);
  }