ActiveGrammarSet implements ScopedSetObserver<GrammarDocument> { public void add(final GrammarDocument grammar) { grammars.add(grammar); if (LOGGER.isDebugEnabled()) { LOGGER.debug("added 1 grammar - now containing " + grammars.size()); } } ActiveGrammarSet(final ScopeObserver scopeObserver); void addActiveGrammarSetObserver(
            final ActiveGrammarSetObserver obs); void removeActiveGrammarSetObserver(
            final ActiveGrammarSetObserver obs); int size(); void add(final GrammarDocument grammar); void addAll(final Collection<GrammarDocument> grams); void removeAll(final Collection<GrammarDocument> grams); boolean contains(final GrammarDocument document); Collection<GrammarDocument> getGrammars(); Collection<GrammarType> getGrammarTypes(); Collection<ModeType> getModeTypes(); @Override void scopedSetChange(final ScopedSet<GrammarDocument> set,
            final Collection<GrammarDocument> removed);  }
@Test public void testAdd() throws Exception { final ActiveGrammarSet set = new ActiveGrammarSet(observer); set.add(document1); set.add(document2); set.add(document1); final SrgsXmlDocument doc3 = new SrgsXmlDocument(); final Grammar grammar3 = doc3.getGrammar(); grammar3.setVersion("1.0"); final Rule rule3 = grammar3.appendChild(Rule.class); rule3.setId("test"); rule3.addText("test input"); grammar3.setRoot(rule3); final InternalGrammarDocument document3 = new InternalGrammarDocument(grammar3); set.add(document3); final byte[] buffer = grammar3.toString().getBytes(); final String encoding = System.getProperty("jvoicexml.xml.encoding", "UTF-8"); final ExternalGrammarDocument document4 = new ExternalGrammarDocument(null, buffer, encoding, true); set.add(document4); final Collection<GrammarDocument> docs = set.getGrammars(); Assert.assertEquals(2, docs.size()); }