Author: ngn
Date: Thu Jul 15 13:41:12 2010
New Revision: 964424

URL: http://svn.apache.org/viewvc?rev=964424&view=rev
Log:
Adding JUnit tests (VYSPER-215, by Bogdan Pistol)
Fixing bug with the hold attribute (VYSPER-216, by Bogdan Pistol)

Added:
    mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/
    mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/
    mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/
    
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/
    
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/
    
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/
    
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/
    
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/
    
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContextTest.java
    
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshDecoderTest.java
    
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshHandlerTest.java
    
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/ServletInputStreamMock.java
Modified:
    mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/pom.xml
    
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContext.java
    
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/resources/keystore-README.txt

Modified: mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/pom.xml
URL: 
http://svn.apache.org/viewvc/mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/pom.xml?rev=964424&r1=964423&r2=964424&view=diff
==============================================================================
--- mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/pom.xml (original)
+++ mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/pom.xml Thu Jul 15 
13:41:12 2010
@@ -64,6 +64,14 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
+      <version>4.8.1</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.easymock</groupId>
+      <artifactId>easymock</artifactId>
+      <version>3.0</version>
       <scope>test</scope>
     </dependency>
   </dependencies>

Modified: 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContext.java
URL: 
http://svn.apache.org/viewvc/mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContext.java?rev=964424&r1=964423&r2=964424&view=diff
==============================================================================
--- 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContext.java
 (original)
+++ 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContext.java
 Thu Jul 15 13:41:12 2010
@@ -52,7 +52,7 @@ public class BoshBackedSessionContext ex
 
     private final int polling = 15;
 
-    private final int requests = 2;
+    private int requests = 2;
 
     private String boshVersion = "1.9";
 
@@ -138,7 +138,10 @@ public class BoshBackedSessionContext ex
     }
 
     public void setHold(int hold) {
-        this.hold = Math.min(hold, this.hold);
+        this.hold = hold;
+        if (hold >= 2) {
+            requests = hold + 1;
+        }
     }
 
     public int getHold() {
@@ -177,7 +180,7 @@ public class BoshBackedSessionContext ex
         return requests;
     }
 
-    synchronized public void requestExpired(Continuation continuation) {
+    synchronized private void requestExpired(Continuation continuation) {
         HttpServletRequest req = (HttpServletRequest) 
continuation.getAttribute("request");
         if (req == null) {
             LOGGER.warn("Continuation expired without having an associated 
request!");

Modified: 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/resources/keystore-README.txt
URL: 
http://svn.apache.org/viewvc/mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/resources/keystore-README.txt?rev=964424&r1=964423&r2=964424&view=diff
==============================================================================
--- 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/resources/keystore-README.txt
 (original)
+++ 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/resources/keystore-README.txt
 Thu Jul 15 13:41:12 2010
@@ -28,7 +28,7 @@ The password for the keystore and for th
 The CN must be the domain name used by the clients to connect to the Vysper 
server (otherwise
 the browser will warn the user that the certificate is issued for another 
domain name)
 
-Using the self-signed certificate (from the keystore) will make the web 
browser warn you that the certificate if self-signed,
+Using the self-signed certificate (from the keystore) will make the web 
browser warn you that the certificate is self-signed,
 but for testing purposes you can add an exception for the browser to accept it.
 
 More information about keytool: 
http://java.sun.com/javase/6/docs/technotes/tools/windows/keytool.html
\ No newline at end of file

Added: 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContextTest.java
URL: 
http://svn.apache.org/viewvc/mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContextTest.java?rev=964424&view=auto
==============================================================================
--- 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContextTest.java
 (added)
+++ 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContextTest.java
 Thu Jul 15 13:41:12 2010
@@ -0,0 +1,215 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.vysper.xmpp.extension.xep0124;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.vysper.xml.fragment.Renderer;
+import org.apache.vysper.xmpp.addressing.EntityImpl;
+import org.apache.vysper.xmpp.protocol.NamespaceURIs;
+import org.apache.vysper.xmpp.server.ServerRuntimeContext;
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.stanza.StanzaBuilder;
+import org.easymock.Capture;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
+import org.eclipse.jetty.continuation.Continuation;
+import org.eclipse.jetty.continuation.ContinuationListener;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class BoshBackedSessionContextTest {
+
+    private IMocksControl mocksControl;
+
+    private BoshHandler boshHandler;
+
+    private ServerRuntimeContext serverRuntimeContext;
+
+    private BoshBackedSessionContext boshBackedSessionContext;
+
+    @Before
+    public void setUp() throws Exception {
+        mocksControl = createControl();
+        boshHandler = mocksControl.createMock(BoshHandler.class);
+        serverRuntimeContext = 
mocksControl.createMock(ServerRuntimeContext.class);
+        expect(serverRuntimeContext.getNextSessionId()).andReturn("123");
+        expect(serverRuntimeContext.getServerEnitity()).andReturn(new 
EntityImpl(null, "vysper.org", null));
+        expect(serverRuntimeContext.getDefaultXMLLang()).andReturn("en");
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    public void testWrite0() {
+        Continuation continuation = 
mocksControl.createMock(Continuation.class);
+        HttpServletRequest httpServletRequest = 
mocksControl.createMock(HttpServletRequest.class);
+        
expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
+        expectLastCall().atLeastOnce();
+        continuation.setTimeout(anyLong());
+        continuation.setAttribute("request", httpServletRequest);
+        continuation.suspend();
+        continuation.resume();
+        continuation.addContinuationListener(EasyMock.<ContinuationListener> 
anyObject());
+        Capture<BoshResponse> captured = new Capture<BoshResponse>();
+        continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> 
capture(captured));
+        mocksControl.replay();
+
+        boshBackedSessionContext = new BoshBackedSessionContext(boshHandler, 
serverRuntimeContext);
+        boshBackedSessionContext.addRequest(httpServletRequest);
+        Stanza stanza = new StanzaBuilder("body", 
NamespaceURIs.XEP0124_BOSH).build();
+        boshBackedSessionContext.write0(stanza);
+        mocksControl.verify();
+
+        BoshResponse boshResponse = captured.getValue();
+        assertEquals(BoshServlet.XML_CONTENT_TYPE, 
boshResponse.getContentType());
+        assertEquals(new Renderer(stanza).getComplete(), new 
String(boshResponse.getContent()));
+    }
+
+    @Test
+    public void testSetBoshVersion1() {
+        mocksControl.replay();
+        boshBackedSessionContext = new BoshBackedSessionContext(boshHandler, 
serverRuntimeContext);
+        boshBackedSessionContext.setBoshVersion("1.8");
+        assertEquals("1.8", boshBackedSessionContext.getBoshVersion());
+    }
+
+    @Test
+    public void testSetBoshVersion2() {
+        mocksControl.replay();
+        boshBackedSessionContext = new BoshBackedSessionContext(boshHandler, 
serverRuntimeContext);
+        boshBackedSessionContext.setBoshVersion("2.0");
+        assertEquals("1.9", boshBackedSessionContext.getBoshVersion());
+    }
+
+    @Test
+    public void testRequestExpired() {
+        Stanza stanza = new StanzaBuilder("body", 
NamespaceURIs.XEP0124_BOSH).build();
+
+        // addRequest
+        HttpServletRequest httpServletRequest = 
mocksControl.createMock(HttpServletRequest.class);
+        Continuation continuation = 
mocksControl.createMock(Continuation.class);
+        
expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
+        expectLastCall().atLeastOnce();
+        continuation.setTimeout(anyLong());
+        continuation.suspend();
+        continuation.setAttribute("request", httpServletRequest);
+
+        Capture<ContinuationListener> listenerCaptured = new 
Capture<ContinuationListener>();
+        continuation.addContinuationListener(EasyMock.<ContinuationListener> 
capture(listenerCaptured));
+
+        // requestExpired
+        
expect(continuation.getAttribute("request")).andReturn(httpServletRequest);
+        Capture<BoshResponse> responseCaptured = new Capture<BoshResponse>();
+        continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> 
capture(responseCaptured));
+
+        expect(boshHandler.getEmptyStanza()).andReturn(stanza);
+        expectLastCall().atLeastOnce();
+
+        // write0
+        continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> 
anyObject());
+        continuation.resume();
+
+        mocksControl.replay();
+        boshBackedSessionContext = new BoshBackedSessionContext(boshHandler, 
serverRuntimeContext);
+        boshBackedSessionContext.addRequest(httpServletRequest);
+        listenerCaptured.getValue().onTimeout(continuation);
+        mocksControl.verify();
+
+        assertEquals(new Renderer(stanza).getComplete(), new 
String(responseCaptured.getValue().getContent()));
+        assertEquals(BoshServlet.XML_CONTENT_TYPE, 
responseCaptured.getValue().getContentType());
+    }
+
+    @Test
+    public void testAddRequest() {
+        // addRequest
+        HttpServletRequest httpServletRequest1 = 
mocksControl.createMock(HttpServletRequest.class);
+        HttpServletRequest httpServletRequest2 = 
mocksControl.createMock(HttpServletRequest.class);
+        Continuation continuation1 = 
mocksControl.createMock(Continuation.class);
+        Continuation continuation2 = 
mocksControl.createMock(Continuation.class);
+        
expect(httpServletRequest1.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation1);
+        expectLastCall().atLeastOnce();
+        
expect(httpServletRequest2.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation2);
+        expectLastCall().atLeastOnce();
+        continuation1.setTimeout(anyLong());
+        continuation1.suspend();
+        continuation1.setAttribute("request", httpServletRequest1);
+        continuation2.setTimeout(anyLong());
+        continuation2.suspend();
+        continuation2.setAttribute("request", httpServletRequest2);
+        continuation1.addContinuationListener(EasyMock.<ContinuationListener> 
anyObject());
+        continuation2.addContinuationListener(EasyMock.<ContinuationListener> 
anyObject());
+
+        // write0
+        Capture<BoshResponse> captured = new Capture<BoshResponse>();
+        continuation1.setAttribute(eq("response"), EasyMock.<BoshResponse> 
capture(captured));
+        continuation1.resume();
+
+        mocksControl.replay();
+        boshBackedSessionContext = new BoshBackedSessionContext(boshHandler, 
serverRuntimeContext);
+
+        boshBackedSessionContext.setHold(2);
+        boshBackedSessionContext.addRequest(httpServletRequest1);
+        boshBackedSessionContext.addRequest(httpServletRequest2);
+        Stanza stanza = new StanzaBuilder("body", 
NamespaceURIs.XEP0124_BOSH).build();
+        boshBackedSessionContext.write0(stanza);
+        mocksControl.verify();
+
+        assertEquals(new Renderer(stanza).getComplete(), new 
String(captured.getValue().getContent()));
+        assertEquals(BoshServlet.XML_CONTENT_TYPE, 
captured.getValue().getContentType());
+    }
+
+    @Test
+    public void testAddRequestWithDelayedResponses() {
+        HttpServletRequest httpServletRequest = 
mocksControl.createMock(HttpServletRequest.class);
+        Continuation continuation = 
mocksControl.createMock(Continuation.class);
+        
expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
+        expectLastCall().atLeastOnce();
+        continuation.setTimeout(anyLong());
+        continuation.suspend();
+        continuation.setAttribute("request", httpServletRequest);
+
+        continuation.addContinuationListener(EasyMock.<ContinuationListener> 
anyObject());
+
+        Stanza stanza1 = mocksControl.createMock(Stanza.class);
+        Stanza stanza2 = mocksControl.createMock(Stanza.class);
+        expect(boshHandler.mergeStanzas(EasyMock.<Stanza> anyObject(), 
EasyMock.<Stanza> anyObject())).andReturn(
+                new StanzaBuilder("body", NamespaceURIs.XEP0124_BOSH).build());
+        expectLastCall().times(2);
+
+        continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> 
anyObject());
+        continuation.resume();
+
+        mocksControl.replay();
+
+        boshBackedSessionContext = new BoshBackedSessionContext(boshHandler, 
serverRuntimeContext);
+        boshBackedSessionContext.write0(stanza1);
+        boshBackedSessionContext.write0(stanza2);
+        boshBackedSessionContext.addRequest(httpServletRequest);
+        mocksControl.verify();
+    }
+
+}
\ No newline at end of file

Added: 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshDecoderTest.java
URL: 
http://svn.apache.org/viewvc/mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshDecoderTest.java?rev=964424&view=auto
==============================================================================
--- 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshDecoderTest.java
 (added)
+++ 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshDecoderTest.java
 Thu Jul 15 13:41:12 2010
@@ -0,0 +1,83 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.vysper.xmpp.extension.xep0124;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static org.easymock.EasyMock.createStrictControl;
+import static org.easymock.EasyMock.expect;
+
+import java.io.IOException;
+
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.easymock.Capture;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+public class BoshDecoderTest {
+    
+    private IMocksControl mocksControl;
+    
+    private BoshHandler boshHandler;
+    private HttpServletRequest request;
+    private BoshDecoder boshDecoder;
+
+    @Before
+    public void setUp() throws Exception {
+        mocksControl = createStrictControl();
+        boshHandler = mocksControl.createMock(BoshHandler.class);
+        request = mocksControl.createMock(HttpServletRequest.class);
+        boshDecoder = new BoshDecoder(boshHandler, request);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    public void testDecode() throws IOException, SAXException {
+        ServletInputStream input = new ServletInputStreamMock("<body 
rid='3549788615' xmlns='http://jabber.org/protocol/httpbind' to='vysper.org' 
xml:lang='en' wait='60' hold='1' ver='1.6' xmpp:version='1.0' 
xmlns:xmpp='urn:xmpp:xbosh'/>");
+        expect(request.getInputStream()).andReturn(input);
+        Capture<Stanza> captured = new Capture<Stanza>();
+        boshHandler.process(EasyMock.<HttpServletRequest>notNull(), 
EasyMock.<Stanza>capture(captured));
+        mocksControl.replay();
+        boshDecoder.decode();
+        mocksControl.verify();
+        Stanza stanza = captured.getValue();
+        assertNotNull(stanza);
+        assertEquals("body", stanza.getName());
+        assertEquals("http://jabber.org/protocol/httpbind";, 
stanza.getNamespaceURI());
+        assertEquals("3549788615", stanza.getAttributeValue("rid"));
+        assertEquals("vysper.org", stanza.getAttributeValue("to"));
+        assertEquals("60", stanza.getAttributeValue("wait"));
+        assertEquals("1", stanza.getAttributeValue("hold"));
+        assertEquals("1.6", stanza.getAttributeValue("ver"));
+        assertEquals("1.0", stanza.getAttributeValue("urn:xmpp:xbosh", 
"version"));
+        assertEquals("en", 
stanza.getAttributeValue("http://www.w3.org/XML/1998/namespace";, "lang"));
+    }
+
+}

Added: 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshHandlerTest.java
URL: 
http://svn.apache.org/viewvc/mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshHandlerTest.java?rev=964424&view=auto
==============================================================================
--- 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshHandlerTest.java
 (added)
+++ 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshHandlerTest.java
 Thu Jul 15 13:41:12 2010
@@ -0,0 +1,84 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.vysper.xmpp.extension.xep0124;
+
+import static org.junit.Assert.*;
+
+import org.apache.vysper.xmpp.protocol.NamespaceURIs;
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.stanza.StanzaBuilder;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class BoshHandlerTest {
+
+    @Before
+    public void setUp() throws Exception {
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    @Ignore
+    public void testProcess() {
+        fail("Not yet implemented");
+    }
+
+    @Test
+    @Ignore
+    public void testGetSessionCreationStanza() {
+        fail("Not yet implemented");
+    }
+
+    @Test
+    @Ignore
+    public void testWrapStanza() {
+        fail("Not yet implemented");
+    }
+
+    @Test
+    @Ignore
+    public void testMergeStanzas() {
+        fail("Not yet implemented");
+    }
+
+    private Stanza createPingRequestStanza(String to, String id) {
+        StanzaBuilder body = new StanzaBuilder("body", 
NamespaceURIs.XEP0124_BOSH);
+        StanzaBuilder iq = body.startInnerElement("iq", 
NamespaceURIs.JABBER_CLIENT).addAttribute("to", to)
+                .addAttribute("type", "get").addAttribute("id", id);
+        iq.startInnerElement("ping", 
NamespaceURIs.URN_XMPP_PING).endInnerElement();
+        iq.endInnerElement();
+        body.endInnerElement();
+        return body.build();
+    }
+
+    private static Stanza createPingResponseStanza(String from, String to, 
String id) {
+        StanzaBuilder body = new StanzaBuilder("body", 
NamespaceURIs.XEP0124_BOSH);
+        body.startInnerElement("iq", 
NamespaceURIs.JABBER_CLIENT).addAttribute("from", from)
+                .addAttribute("type", "result").addAttribute("to", 
to).addAttribute("id", id);
+        body.endInnerElement();
+        return body.build();
+    }
+
+}
\ No newline at end of file

Added: 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/ServletInputStreamMock.java
URL: 
http://svn.apache.org/viewvc/mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/ServletInputStreamMock.java?rev=964424&view=auto
==============================================================================
--- 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/ServletInputStreamMock.java
 (added)
+++ 
mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/ServletInputStreamMock.java
 Thu Jul 15 13:41:12 2010
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.vysper.xmpp.extension.xep0124;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import javax.servlet.ServletInputStream;
+
+public class ServletInputStreamMock extends ServletInputStream {
+    
+    private ByteArrayInputStream bytes;
+    
+    public ServletInputStreamMock(String input) {
+        bytes = new ByteArrayInputStream(input.getBytes());
+    }
+
+    @Override
+    public int read() throws IOException {
+        return bytes.read();
+    }
+
+}


Reply via email to