Examples of ConversationContext


Examples of games.stendhal.common.parser.ConversationContext

   */
  @Test
  public final void testParsing() {
    final ExpressionMatcher matcher = new ExpressionMatcher();

    Sentence sentence = matcher.parseSentence("", new ConversationContext());
    assertFalse(sentence.hasError());
    assertEquals("", sentence.toString());

    String str = matcher.readMatchingFlags("Lazy dog");
    assertEquals("Lazy dog", str);
    assertTrue(matcher.isEmpty());
    assertEquals("", matcher.toString());

    sentence = matcher.parseSentence(str, new ConversationContext());
    assertFalse(sentence.hasError());
    assertEquals("lazy dog/SUB-ANI", sentence.toString());

    str = matcher.readMatchingFlags("|TYPE|abcdef/OBJ");
    assertEquals("abcdef/OBJ", str);
    assertTrue(matcher.isAnyFlagSet());
    assertFalse(matcher.getExactMatching());
    assertTrue(matcher.getTypeMatching());
    assertEquals("|TYPE", matcher.toString());

    sentence = matcher.parseSentence(str, new ConversationContext());
    assertFalse(sentence.hasError());
    assertEquals("|TYPE|abcdef/OBJ", sentence.toString());

    str = matcher.readMatchingFlags("|EXACT|Hello world!");
    assertEquals("Hello world!", str);
    assertTrue(matcher.isAnyFlagSet());
    assertTrue(matcher.getExactMatching());
    assertFalse(matcher.getTypeMatching());
    assertEquals("|EXACT", matcher.toString());

    sentence = matcher.parseSentence(str, new ConversationContext());
    assertFalse(sentence.hasError());
    assertEquals("|EXACT|Hello world!", sentence.toString());
  }
View Full Code Here

Examples of games.stendhal.common.parser.ConversationContext

  /**
   * Tests for sentenceMatching.
   */
  @Test
  public final void testEquality() {
    final ConversationContext ctx1 = new ConversationContext();
    final ConversationContext ctx2 = new ConversationContext();
   
    assertEquals(ctx1, ctx2);
    assertTrue(ctx1.equals(ctx2));

    ctx1.forMatching = true;
View Full Code Here

Examples of games.stendhal.common.parser.ConversationContext

  /**
   * Grammar tests.
   */
  @Test
  public final void testGrammar() {
    final ConversationContext ctx = new ConversationContext();

    SentenceImplementation sentence = new SentenceImplementation(ctx, "The quick brown fox jumps over the lazy dog.");
    ConversationParser parser = new ConversationParser(sentence);
    sentence.parse(parser);
    sentence.classifyWords(parser);
View Full Code Here

Examples of games.stendhal.common.parser.ConversationContext

   * Tests for Sentence.parse().
   */
  @Test
  public final void testParse() {
    Sentence s1 = ConversationParser.parse("Give me a red ball please.");
    Sentence m1 = s1.parse(new ConversationContext());
    assertFalse(s1.hasError());
    assertFalse(m1.hasError());
    assertEquals("buy/VER red ball/OBJ-COL!", s1.toString());
    assertEquals("buy/VER red ball/OBJ-COL!", m1.toString());
    assertTrue(s1.matchesFull(m1));
View Full Code Here

Examples of org.apache.myfaces.orchestra.conversation.ConversationContext

     * TODO: what does Spring use this for????
     */
    public String getConversationId()
    {
        ConversationManager manager = ConversationManager.getInstance();
        ConversationContext ctx = manager.getCurrentConversationContext();
        if (ctx != null)
        {
            return Long.toString(ctx.getId(), 10);
        }

        return null;
    }
View Full Code Here

Examples of org.apache.webbeans.context.ConversationContext

                Iterator<Conversation> iterator = conversationContextMap.keySet().iterator();

                while (iterator.hasNext())
                {
                    Conversation conversation = iterator.next();
                    ConversationContext context = conversationContextMap.get(conversation);
                    conversationManager.addConversationContext(conversation, context);
                }
            }

            if (LOGGER.isLoggable(Level.FINE))
View Full Code Here

Examples of org.apache.webbeans.context.ConversationContext



        // ----- execute
        // create conversation
        ConversationContext conversationContext = new ConversationContext();
        conversationContext.setActive(true);

        Conversation conversation = new ConversationImpl(session.getId(), getWebBeansContext());
        conversation.begin();

        ConversationManager conversationManager = getWebBeansContext().getConversationManager();
        conversationManager.addConversationContext(conversation, conversationContext);

        getWebBeansContext().registerService(ConversationService.class, new MockConversationService(session, conversation));

        // set sample text
        getInstance(ConversationScopedBean.class, conversationContext).setText(CONVERSATION_SCOPED_SAMPLE_TEXT);

        // store beans in session
        failoverService.sessionIsIdle(session);

        // serialize / deserialize and store deserialized bag back to session
        FailOverBag failOverBag;
        failOverBag = (FailOverBag) session.getAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME);
        failOverBag = (FailOverBag) serialize(failOverBag);

        session.setAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME, failOverBag);

        // remove sample text
        getInstance(ConversationScopedBean.class, conversationContext).setText(null);

        getWebBeansContext().getContextsService().endContext(ConversationScoped.class, conversationContext);

        // restore beans from session
        failoverService.sessionDidActivate(session);



        // ----- assert
        // get and activate conversation
        Map<Conversation, ConversationContext> conversationMap =
                conversationManager.getConversationMapWithSessionId(session.getId());

        Conversation propogatedConversation =
                conversationManager.getPropogatedConversation(conversation.getId(), session.getId());

        ConversationContext propogatedConversationContext =  conversationMap.get(propogatedConversation);
        propogatedConversationContext.setActive(true);

        ConversationScopedBean beanInstance = getInstance(ConversationScopedBean.class, propogatedConversationContext);

        Assert.assertEquals(CONVERSATION_SCOPED_SAMPLE_TEXT, beanInstance.getText());
        Assert.assertTrue(beanInstance.isBeanManagerNotNull());
View Full Code Here

Examples of org.apache.webbeans.context.ConversationContext

        RequestScopedBeanInterceptorHandler.removeThreadLocals();
    }

    private void cleanupConversations()
    {
        ConversationContext conversationContext = getConversationContext();

        if (conversationContext == null)
        {
            return;
        }
View Full Code Here

Examples of org.apache.webbeans.context.ConversationContext

    {
        if (context == null)
        {
            if(conversationContexts.get() == null)
            {
                ConversationContext newContext = new ConversationContext();
                newContext.setActive(true);
               
                conversationContexts.set(newContext);
            }
            else
            {
View Full Code Here

Examples of org.apache.webbeans.context.ConversationContext

    /**
     * Destroy conversation context.
     */
    private void destroyConversationContext()
    {
        ConversationContext context = getConversationContext();

        if (context != null)
        {
            context.destroy();
        }

        conversationContexts.set(null);
        conversationContexts.remove();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.