@@ -0,0 +1,2580 @@
+/*%0A * Copyright 2013 - 2013 Cole Wen%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 org.maodian.flycat.xmpp;%0A%0Aimport static org.junit.Assert.*;%0Aimport static org.mockito.Mockito.*;%0A%0Aimport java.io.Reader;%0Aimport java.io.StringReader;%0A%0Aimport javax.xml.namespace.QName;%0Aimport javax.xml.stream.XMLStreamException;%0Aimport javax.xml.stream.XMLStreamReader;%0A%0Aimport org.junit.Test;%0Aimport org.maodian.flycat.holder.XMLInputFactoryHolder;%0A%0A/**%0A * @author Cole Wen%0A *%0A */%0Apublic class ResourceBindStateTest extends StateTest %7B%0A%0A  /* (non-Javadoc)%0A   * @see org.maodian.flycat.xmpp.StateTest#doSetup()%0A   */%0A  @Override%0A  public void doSetup() %7B%0A    %0A  %7D%0A%0A  @Test%0A  public void testSuccess() throws XMLStreamException %7B%0A    String inXML = %22%3Ciq id='tn281v37' type='set'%3E%3Cbind xmlns='urn:ietf:params:xml:ns:xmpp-bind'%3E%22 +%0A    %09%09%22%3Cresource%3Ebalcony%3C/resource%3E%3C/bind%3E%3C/iq%3E%22;%0A    String wrappedInXML = %22%3Cstream:stream from='juliet@im.example.com' id='gPybzaOzBmaADgxKXu9UClbprp0=' to='im.example.com' %22%0A    %09%09+ %22version='1.0' xml:lang='en' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'%3E%22%0A        + inXML + %22%3C/stream:stream%3E%22;%0A    state = new ResourceBindState();%0A    %0A    when(context.wrapStreamTag(inXML)).thenReturn(wrappedInXML);%0A    when(context.getBareJID()).thenReturn(%22juliet@im.example.com%22);%0A    %0A    String outXML = state.handle(context, inXML);%0A    Reader reader = new StringReader(outXML);%0A    XMLStreamReader xmlsr = XMLInputFactoryHolder.getXMLInputFactory().createXMLStreamReader(reader);%0A    %0A    xmlsr.next();%0A    QName iq = new QName(%22iq%22);%0A    assertEquals(iq, xmlsr.getName());%0A    assertEquals(%22tn281v37%22, xmlsr.getAttributeValue(%22%22, %22id%22));%0A    assertEquals(%22result%22, xmlsr.getAttributeValue(%22%22, %22type%22));%0A    %0A    xmlsr.next();%0A    QName bind = new QName(XmppNamespace.BIND, %22bind%22);%0A    assertEquals(bind, xmlsr.getName());%0A    %0A    xmlsr.next();%0A    QName jid = new QName(XmppNamespace.BIND, %22jid%22);%0A    assertEquals(jid, xmlsr.getName());%0A    assertEquals(%22juliet@im.example.com/balcony%22, xmlsr.getElementText());%0A  %7D%0A%7D%0A

add test for ResourceBindState