[savara-commits] savara SVN: r585 - in branches/experimental/2.0.x/bundles/org.savara.monitor/src: main/java/org/savara/monitor/impl and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sun Jan 16 11:44:13 EST 2011
Author: objectiser
Date: 2011-01-16 11:44:13 -0500 (Sun, 16 Jan 2011)
New Revision: 585
Added:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/SessionStore.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemorySessionStore.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemorySessionStoreTest.java
Removed:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationStore.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryConversationStore.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemoryConversationStoreTest.java
Modified:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Monitor.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMonitor.java
Log:
Changed from conversation to session store as multiple protocols may be monitored against the same conversation instance.
Deleted: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationStore.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationStore.java 2011-01-16 14:41:55 UTC (rev 584)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationStore.java 2011-01-16 16:44:13 UTC (rev 585)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.savara.monitor;
-
-/**
- * This interface represents a conversation store responsible for
- * persisting information about conversation instances being
- * monitored.
- *
- */
-public interface ConversationStore {
-
- /**
- * This method returns a new conversation associated with
- * the supplied conversation id.
- *
- * @param id The conversation id
- * @return The conversation
- * @throws IllegalArgumentException Conversation id is invalid
- * @throws IOException Failed to create new conversation
- */
- public java.io.Serializable create(ConversationInstanceId id) throws IllegalArgumentException,
- java.io.IOException;
-
- /**
- * This method returns an existing conversation associated with
- * the supplied conversation id.
- *
- * @param id The conversation id
- * @return The conversation
- * @throws IllegalArgumentException Conversation id is invalid
- * @throws IOException Failed to retrieve conversation
- */
- public java.io.Serializable find(ConversationInstanceId id) throws IllegalArgumentException,
- java.io.IOException;
-
- /**
- * This method removes an existing conversation associated
- * with the supplied conversation id.
- *
- * @param id The conversation id
- * @throws IllegalArgumentException Conversation id is invalid or unknown
- * @throws java.io.IOException Failed to remove existing conversation
- */
- public void remove(ConversationInstanceId id) throws IllegalArgumentException,
- java.io.IOException;
-
- /**
- * This method updates an existing conversation associated
- * with the supplied conversation id.
- *
- * @param id The id
- * @param conv The conversation
- * @throws IllegalArgumentException Conversation id is invalid or unknown
- * @throws java.io.IOException Failed to update existing conversation
- */
- public void update(ConversationInstanceId id, java.io.Serializable conv) throws IllegalArgumentException,
- java.io.IOException;
-
-}
Modified: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Monitor.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Monitor.java 2011-01-16 14:41:55 UTC (rev 584)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Monitor.java 2011-01-16 16:44:13 UTC (rev 585)
@@ -33,7 +33,7 @@
*
* @param store The conversation store
*/
- public void setConversationStore(ConversationStore store);
+ public void setConversationStore(SessionStore store);
/**
* This method is used to indicate that a message has been
Copied: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/SessionStore.java (from rev 584, branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationStore.java)
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/SessionStore.java (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/SessionStore.java 2011-01-16 16:44:13 UTC (rev 585)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.savara.monitor;
+
+/**
+ * This interface represents a session store responsible for
+ * persisting information about conversation instances being
+ * monitored against protocols.
+ *
+ */
+public interface SessionStore {
+
+ /**
+ * This method returns a new session associated with
+ * the supplied protocol and conversation instance id.
+ *
+ * @param pid The protocol id
+ * @param cid The conversation instance id
+ * @return The session
+ * @throws IllegalArgumentException Protocol or conversation instance id is invalid
+ * @throws IOException Failed to create new session
+ */
+ public java.io.Serializable create(ProtocolId pid, ConversationInstanceId cid)
+ throws IllegalArgumentException, java.io.IOException;
+
+ /**
+ * This method returns an existing session associated with
+ * the supplied protocol and conversation instance id.
+ *
+ * @param pid The protocol id
+ * @param cid The conversation instance id
+ * @return The session
+ * @throws IllegalArgumentException Protocol or conversation instance id is invalid
+ * @throws IOException Failed to retrieve session
+ */
+ public java.io.Serializable find(ProtocolId pid, ConversationInstanceId cid)
+ throws IllegalArgumentException, java.io.IOException;
+
+ /**
+ * This method removes an existing session associated
+ * with the supplied protocol and conversation instance id.
+ *
+ * @param pid The protocol id
+ * @param cid The conversation instance id
+ * @throws IllegalArgumentException Conversation instance id is invalid or unknown
+ * @throws java.io.IOException Failed to remove existing session
+ */
+ public void remove(ProtocolId pid, ConversationInstanceId cid)
+ throws IllegalArgumentException, java.io.IOException;
+
+ /**
+ * This method updates an existing session associated
+ * with the supplied protocol and conversation instance id.
+ *
+ * @param pid The protocol id
+ * @param cid The conversation instance id
+ * @param session The session
+ * @throws IllegalArgumentException Conversation instance id is invalid or unknown
+ * @throws java.io.IOException Failed to update existing session
+ */
+ public void update(ProtocolId pid, ConversationInstanceId cid,
+ java.io.Serializable session) throws IllegalArgumentException,
+ java.io.IOException;
+
+}
Modified: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMonitor.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMonitor.java 2011-01-16 14:41:55 UTC (rev 584)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMonitor.java 2011-01-16 16:44:13 UTC (rev 585)
@@ -17,7 +17,7 @@
*/
package org.savara.monitor.impl;
-import org.savara.monitor.ConversationStore;
+import org.savara.monitor.SessionStore;
import org.savara.monitor.Message;
import org.savara.monitor.Monitor;
import org.savara.monitor.MonitorListener;
@@ -32,7 +32,7 @@
public class DefaultMonitor implements Monitor {
private MonitorListener m_listener=null;
- private ConversationStore m_store=null;
+ private SessionStore m_store=null;
private ProtocolMonitor m_monitor=new DefaultProtocolMonitor();
/**
@@ -60,7 +60,7 @@
*
* @param store The conversation store
*/
- public void setConversationStore(ConversationStore store) {
+ public void setConversationStore(SessionStore store) {
m_store = store;
}
Deleted: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryConversationStore.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryConversationStore.java 2011-01-16 14:41:55 UTC (rev 584)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryConversationStore.java 2011-01-16 16:44:13 UTC (rev 585)
@@ -1,115 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.savara.monitor.impl;
-
-import org.savara.monitor.ConversationInstanceId;
-import org.savara.monitor.ConversationStore;
-import org.scribble.protocol.monitor.Conversation;
-import org.scribble.protocol.monitor.DefaultConversation;
-
-public class InMemoryConversationStore implements ConversationStore {
-
- private java.util.Map<ConversationInstanceId, java.io.Serializable> m_conversations=
- new java.util.HashMap<ConversationInstanceId, java.io.Serializable>();
-
- /**
- * This method returns a new conversation associated with
- * the supplied conversation id.
- *
- * @param id The conversation id
- * @return The conversation
- * @throws IllegalArgumentException Conversation id is invalid
- * @throws IOException Failed to create new conversation
- */
- public java.io.Serializable create(ConversationInstanceId id) throws IllegalArgumentException,
- java.io.IOException {
- if (id == null) {
- throw new IllegalArgumentException("Id not specified");
- } else if (m_conversations.containsKey(id)) {
- throw new IllegalArgumentException("Conversation id already in use");
- }
-
- java.io.Serializable ret=new DefaultConversation();
-
- m_conversations.put(id, ret);
-
- return(ret);
- }
-
- /**
- * This method returns an existing conversation associated with
- * the supplied conversation id.
- *
- * @param id The conversation id
- * @return The conversation
- * @throws IllegalArgumentException Conversation id is invalid
- * @throws IOException Failed to retrieve conversation
- */
- public java.io.Serializable find(ConversationInstanceId id) throws IllegalArgumentException,
- java.io.IOException {
-
- if (id == null) {
- throw new IllegalArgumentException("Id not specified");
- } else if (m_conversations.containsKey(id) == false) {
- throw new IllegalArgumentException("Conversation id is unknown");
- }
-
- return(m_conversations.get(id));
- }
-
- /**
- * This method removes an existing conversation associated
- * with the supplied conversation id.
- *
- * @param id The conversation id
- * @throws IllegalArgumentException Conversation id is invalid or unknown
- * @throws java.io.IOException Failed to remove existing conversation
- */
- public void remove(ConversationInstanceId id) throws IllegalArgumentException,
- java.io.IOException {
- if (id == null) {
- throw new IllegalArgumentException("Id not specified");
- } else if (m_conversations.containsKey(id) == false) {
- throw new IllegalArgumentException("Conversation id is unknown");
- }
-
- m_conversations.remove(id);
- }
-
- /**
- * This method updates an existing conversation associated
- * with the supplied conversation id.
- *
- * @param id The id
- * @param conv The conversation
- * @throws IllegalArgumentException Conversation id is invalid or unknown
- * @throws java.io.IOException Failed to update existing conversation
- */
- public void update(ConversationInstanceId id, java.io.Serializable conv) throws IllegalArgumentException,
- java.io.IOException {
-
- if (id == null) {
- throw new IllegalArgumentException("Id not specified");
- } else if (m_conversations.containsKey(id) == false) {
- throw new IllegalArgumentException("Conversation id unknown");
- }
-
- m_conversations.put(id, conv);
- }
-
-}
Copied: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemorySessionStore.java (from rev 584, branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryConversationStore.java)
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemorySessionStore.java (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemorySessionStore.java 2011-01-16 16:44:13 UTC (rev 585)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.savara.monitor.impl;
+
+import org.savara.monitor.ConversationInstanceId;
+import org.savara.monitor.ProtocolId;
+import org.savara.monitor.SessionStore;
+import org.scribble.protocol.monitor.DefaultSession;
+
+public class InMemorySessionStore implements SessionStore {
+
+ private java.util.Map<ProtocolId,java.util.Map<ConversationInstanceId,java.io.Serializable>> m_sessions=
+ new java.util.HashMap<ProtocolId,java.util.Map<ConversationInstanceId, java.io.Serializable>>();
+
+ /**
+ * This method returns a new session associated with
+ * the supplied protocol and conversation instance id.
+ *
+ * @param pid The protocol id
+ * @param cid The conversation instance id
+ * @return The session
+ * @throws IllegalArgumentException Protocol or conversation id is invalid
+ * @throws IOException Failed to create new session
+ */
+ public java.io.Serializable create(ProtocolId pid, ConversationInstanceId cid)
+ throws IllegalArgumentException, java.io.IOException {
+ if (pid == null) {
+ throw new IllegalArgumentException("Protocol id not specified");
+ } else if (cid == null) {
+ throw new IllegalArgumentException("Conversation instance id not specified");
+ }
+
+ java.util.Map<ConversationInstanceId,java.io.Serializable> sessions=
+ m_sessions.get(pid);
+
+ if (sessions == null) {
+ sessions = new java.util.HashMap<ConversationInstanceId,java.io.Serializable>();
+ m_sessions.put(pid, sessions);
+
+ } else if (sessions.containsKey(cid)) {
+ throw new IllegalArgumentException("Conversation instance id already in use");
+ }
+
+ java.io.Serializable ret=new DefaultSession();
+
+ sessions.put(cid, ret);
+
+ return(ret);
+ }
+
+ /**
+ * This method returns an existing session associated with
+ * the supplied protocol and conversation instance id.
+ *
+ * @param pid The protocol id
+ * @param cid The conversation instance id
+ * @return The session, or null if not found
+ * @throws IllegalArgumentException Protocol or conversation id is invalid
+ * @throws IOException Failed to retrieve session
+ */
+ public java.io.Serializable find(ProtocolId pid, ConversationInstanceId cid)
+ throws IllegalArgumentException, java.io.IOException {
+ java.io.Serializable ret=null;
+
+ if (pid == null) {
+ throw new IllegalArgumentException("Protocol id not specified");
+ } else if (cid == null) {
+ throw new IllegalArgumentException("Conversation instance id not specified");
+ }
+
+ java.util.Map<ConversationInstanceId,java.io.Serializable> sessions=
+ m_sessions.get(pid);
+
+ if (sessions != null) {
+ ret = sessions.get(cid);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method removes an existing session associated
+ * with the supplied protocol and conversation instance id.
+ *
+ * @param pid The protocol id
+ * @param cid The conversation instance id
+ * @throws IllegalArgumentException Conversation instance id is invalid or unknown
+ * @throws java.io.IOException Failed to remove existing session
+ */
+ public void remove(ProtocolId pid, ConversationInstanceId cid)
+ throws IllegalArgumentException, java.io.IOException {
+ if (pid == null) {
+ throw new IllegalArgumentException("Protocol id not specified");
+ } else if (cid == null) {
+ throw new IllegalArgumentException("Conversation instance id not specified");
+ }
+
+ java.util.Map<ConversationInstanceId,java.io.Serializable> sessions=
+ m_sessions.get(pid);
+
+ if (sessions == null || sessions.containsKey(cid) == false) {
+ throw new IllegalArgumentException("Conversation instance id is unknown");
+ }
+
+ sessions.remove(cid);
+
+ // Clear up sub map associated with the protocol id
+ if (sessions.size() == 0) {
+ m_sessions.remove(pid);
+ }
+ }
+
+ /**
+ * This method updates an existing session associated
+ * with the supplied protocol and conversation instance id.
+ *
+ * @param pid The protocol id
+ * @param cid The conversation instance id
+ * @param session The session
+ * @throws IllegalArgumentException Conversation instance id is invalid or unknown
+ * @throws java.io.IOException Failed to update existing session
+ */
+ public void update(ProtocolId pid, ConversationInstanceId cid,
+ java.io.Serializable session) throws IllegalArgumentException,
+ java.io.IOException {
+ if (pid == null) {
+ throw new IllegalArgumentException("Protocol id not specified");
+ } else if (cid == null) {
+ throw new IllegalArgumentException("Conversation instance id not specified");
+ }
+
+ java.util.Map<ConversationInstanceId,java.io.Serializable> sessions=
+ m_sessions.get(pid);
+
+ if (sessions == null || sessions.containsKey(cid) == false) {
+ throw new IllegalArgumentException("Conversation instance id unknown");
+ }
+
+ sessions.put(cid, session);
+ }
+
+}
Deleted: branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemoryConversationStoreTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemoryConversationStoreTest.java 2011-01-16 14:41:55 UTC (rev 584)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemoryConversationStoreTest.java 2011-01-16 16:44:13 UTC (rev 585)
@@ -1,185 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.savara.monitor.impl;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.savara.monitor.ConversationInstanceId;
-import org.scribble.protocol.monitor.Conversation;
-
-public class InMemoryConversationStoreTest {
-
- @Test
- public void testCreateConversationContextNoId() {
- InMemoryConversationStore store=new InMemoryConversationStore();
-
- try {
- store.create(null);
-
- fail("Should have thrown IllegalArgumentException");
- } catch(IllegalArgumentException iae) {
- // Expected
- } catch(Exception e) {
- fail("Not expecting: "+e);
- }
- }
-
- @Test
- public void testCreateConversationContextDuplicateInvalidId() {
- InMemoryConversationStore store=new InMemoryConversationStore();
-
- try {
- ConversationInstanceId id=new ConversationInstanceId("1");
-
- try {
- store.create(id);
- } catch(Exception inner) {
- fail("Should not have failed");
- }
-
- store.create(id);
-
- fail("Should have thrown IllegalArgumentException");
- } catch(IllegalArgumentException iae) {
- // Expected
- } catch(Exception e) {
- fail("Not expecting: "+e);
- }
- }
-
- @Test
- public void testCreateConversationContext() {
- InMemoryConversationStore store=new InMemoryConversationStore();
-
- try {
- ConversationInstanceId id=new ConversationInstanceId("1");
-
- if (store.create(id) == null) {
- fail("No context created");
- }
-
- } catch(Exception e) {
- fail("Not expecting: "+e);
- }
- }
-
- @Test
- public void testRemoveConversation() {
- InMemoryConversationStore store=new InMemoryConversationStore();
-
- try {
- ConversationInstanceId id=new ConversationInstanceId("1");
-
- if (store.create(id) == null) {
- fail("No context created");
- }
-
- java.io.Serializable c1=store.find(id);
-
- if (c1 == null) {
- fail("Should not be null");
- }
-
- store.remove(id);
-
- try {
- store.find(id);
-
- fail("Should not find the conversation");
- } catch(IllegalArgumentException inner) {
- // Ignore
- }
- } catch(Exception e) {
- fail("Not expecting: "+e);
- }
- }
-
- @Test
- public void testFindConversation() {
- InMemoryConversationStore store=new InMemoryConversationStore();
-
- try {
- ConversationInstanceId id1=new ConversationInstanceId("1");
-
- java.io.Serializable c1=null;
-
- if ((c1=store.create(id1)) == null) {
- fail("No context created for id 1");
- }
-
- ConversationInstanceId id2=new ConversationInstanceId("2");
-
- java.io.Serializable c2=null;
-
- if ((c2=store.create(id2)) == null) {
- fail("No context created for id 2");
- }
-
- java.io.Serializable result=store.find(id1);
-
- if (result == null) {
- fail("Result is null");
- }
-
- if (result != c1) {
- fail("Conversation 1 was not returned");
- }
- } catch(Exception e) {
- fail("Not expecting: "+e);
- }
- }
-
- @Test
- public void testUpdateConversation() {
- InMemoryConversationStore store=new InMemoryConversationStore();
-
- try {
- ConversationInstanceId id1=new ConversationInstanceId("1");
-
- java.io.Serializable c1=null;
-
- if ((c1=store.create(id1)) == null) {
- fail("No context created for id 1");
- }
-
- ConversationInstanceId id2=new ConversationInstanceId("2");
-
- java.io.Serializable c2=null;
-
- if ((c2=store.create(id2)) == null) {
- fail("No context created for id 2");
- }
-
- // Update context for id1 with context for id2
- store.update(id1, c2);
-
- java.io.Serializable result=store.find(id1);
-
- if (result == null) {
- fail("Result is null");
- }
-
- if (result != c2) {
- fail("Conversation context 2 was not returned");
- }
- } catch(Exception e) {
- fail("Not expecting: "+e);
- }
- }
-}
Copied: branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemorySessionStoreTest.java (from rev 584, branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemoryConversationStoreTest.java)
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemorySessionStoreTest.java (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemorySessionStoreTest.java 2011-01-16 16:44:13 UTC (rev 585)
@@ -0,0 +1,201 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.savara.monitor.impl;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.savara.monitor.ConversationInstanceId;
+import org.savara.monitor.ProtocolId;
+
+public class InMemorySessionStoreTest {
+
+ @Test
+ public void testCreateSessionNoConversationInstanceId() {
+ InMemorySessionStore store=new InMemorySessionStore();
+
+ try {
+ store.create(new ProtocolId("name","role"), null);
+
+ fail("Should have thrown IllegalArgumentException");
+ } catch(IllegalArgumentException iae) {
+ // Expected
+ } catch(Exception e) {
+ fail("Not expecting: "+e);
+ }
+ }
+
+ @Test
+ public void testCreateSessionNoProtocolId() {
+ InMemorySessionStore store=new InMemorySessionStore();
+
+ try {
+ store.create(null, new ConversationInstanceId("id"));
+
+ fail("Should have thrown IllegalArgumentException");
+ } catch(IllegalArgumentException iae) {
+ // Expected
+ } catch(Exception e) {
+ fail("Not expecting: "+e);
+ }
+ }
+
+ @Test
+ public void testCreateSessionDuplicateInvalidId() {
+ InMemorySessionStore store=new InMemorySessionStore();
+
+ try {
+ ProtocolId pid=new ProtocolId("p","r");
+ ConversationInstanceId id=new ConversationInstanceId("1");
+
+ try {
+ store.create(pid, id);
+ } catch(Exception inner) {
+ fail("Should not have failed");
+ }
+
+ store.create(pid, id);
+
+ fail("Should have thrown IllegalArgumentException");
+ } catch(IllegalArgumentException iae) {
+ // Expected
+ } catch(Exception e) {
+ fail("Not expecting: "+e);
+ }
+ }
+
+ @Test
+ public void testCreateSession() {
+ InMemorySessionStore store=new InMemorySessionStore();
+
+ try {
+ ProtocolId pid=new ProtocolId("p","r");
+ ConversationInstanceId id=new ConversationInstanceId("1");
+
+ if (store.create(pid, id) == null) {
+ fail("No context created");
+ }
+
+ } catch(Exception e) {
+ fail("Not expecting: "+e);
+ }
+ }
+
+ @Test
+ public void testRemoveSession() {
+ InMemorySessionStore store=new InMemorySessionStore();
+
+ try {
+ ProtocolId pid=new ProtocolId("p","r");
+ ConversationInstanceId id=new ConversationInstanceId("1");
+
+ if (store.create(pid, id) == null) {
+ fail("No context created");
+ }
+
+ java.io.Serializable c1=store.find(pid, id);
+
+ if (c1 == null) {
+ fail("Should not be null");
+ }
+
+ store.remove(pid, id);
+
+ if (store.find(pid, id) != null) {
+ fail("Should not find the session");
+ }
+ } catch(Exception e) {
+ fail("Not expecting: "+e);
+ }
+ }
+
+ @Test
+ public void testFindSession() {
+ InMemorySessionStore store=new InMemorySessionStore();
+
+ try {
+ ProtocolId pid=new ProtocolId("p","r");
+ ConversationInstanceId id1=new ConversationInstanceId("1");
+
+ java.io.Serializable c1=null;
+
+ if ((c1=store.create(pid, id1)) == null) {
+ fail("No context created for id 1");
+ }
+
+ ConversationInstanceId id2=new ConversationInstanceId("2");
+
+ java.io.Serializable c2=null;
+
+ if ((c2=store.create(pid, id2)) == null) {
+ fail("No context created for id 2");
+ }
+
+ java.io.Serializable result=store.find(pid, id1);
+
+ if (result == null) {
+ fail("Result is null");
+ }
+
+ if (result != c1) {
+ fail("Conversation 1 was not returned");
+ }
+ } catch(Exception e) {
+ fail("Not expecting: "+e);
+ }
+ }
+
+ @Test
+ public void testUpdateSession() {
+ InMemorySessionStore store=new InMemorySessionStore();
+
+ try {
+ ProtocolId pid=new ProtocolId("p","r");
+ ConversationInstanceId id1=new ConversationInstanceId("1");
+
+ java.io.Serializable c1=null;
+
+ if ((c1=store.create(pid, id1)) == null) {
+ fail("No session created for id 1");
+ }
+
+ ConversationInstanceId id2=new ConversationInstanceId("2");
+
+ java.io.Serializable c2=null;
+
+ if ((c2=store.create(pid, id2)) == null) {
+ fail("No session created for id 2");
+ }
+
+ // Update context for id1 with context for id2
+ store.update(pid, id1, c2);
+
+ java.io.Serializable result=store.find(pid, id1);
+
+ if (result == null) {
+ fail("Result is null");
+ }
+
+ if (result != c2) {
+ fail("Session 2 was not returned");
+ }
+ } catch(Exception e) {
+ fail("Not expecting: "+e);
+ }
+ }
+}
More information about the savara-commits
mailing list