r1376 - in trunk/wikitty-api/src/test/java/org/nuiton/wikitty: . services
Author: echatellier Date: 2012-01-26 17:39:21 +0100 (Thu, 26 Jan 2012) New Revision: 1376 Url: http://nuiton.org/repositories/revision/wikitty/1376 Log: Move service tests to correct packages Added: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceCachedCopyTest.java trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceNotifierTest.java trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceNotifierXMPPTest.java Removed: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/layers/ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/memory/ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/notification/ Modified: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/WikittyClientTest.java trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceCachedTest.java Modified: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/WikittyClientTest.java =================================================================== --- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/WikittyClientTest.java 2012-01-26 15:00:35 UTC (rev 1375) +++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/WikittyClientTest.java 2012-01-26 16:39:21 UTC (rev 1376) @@ -25,6 +25,9 @@ package org.nuiton.wikitty; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; + import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -41,6 +44,7 @@ import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Test; +import org.nuiton.util.ApplicationConfig; import org.nuiton.wikitty.addons.WikittyI18nTestUtil; import org.nuiton.wikitty.addons.WikittyI18nUtil; import org.nuiton.wikitty.addons.WikittyImportExportService; @@ -64,7 +68,10 @@ import org.nuiton.wikitty.query.WikittyQueryParser; import org.nuiton.wikitty.query.WikittyQueryResult; import org.nuiton.wikitty.query.WikittyQueryResultTreeNode; +import org.nuiton.wikitty.services.WikittyCacheJCS; import org.nuiton.wikitty.services.WikittyEvent; +import org.nuiton.wikitty.services.WikittyServiceCached; +import org.nuiton.wikitty.services.WikittyServiceInMemory; import org.nuiton.wikitty.test.Category; import org.nuiton.wikitty.test.Product; Added: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceCachedCopyTest.java =================================================================== --- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceCachedCopyTest.java (rev 0) +++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceCachedCopyTest.java 2012-01-26 16:39:21 UTC (rev 1376) @@ -0,0 +1,77 @@ +/* + * #%L + * Wikitty :: api + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Benjamin Poussin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.wikitty.services; + +import org.junit.Assert; +import org.junit.Test; +import org.nuiton.wikitty.WikittyClient; +import org.nuiton.wikitty.WikittyClientTest; +import org.nuiton.wikitty.WikittyConfigOption; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.entities.Wikitty; + +/** + * Same test as {@link WikittyServiceCachedTest} but with different cache policy. + * + * @author poussin + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + */ +public class WikittyServiceCachedCopyTest extends WikittyClientTest { + + /** + * Override to method in sub tests to change wikitty client implementation. + * + * @return wikitty client implementation to use in current test case instance + */ + @Override + protected WikittyClient getWikittyClient() { + wikittyConfig.setOption( + WikittyConfigOption.WIKITTY_CACHE_RESTORE_COPIES.getKey(), + "true"); + + WikittyService wikittyService = new WikittyServiceInMemory(wikittyConfig); + wikittyService = new WikittyServiceCached(wikittyConfig, wikittyService, new WikittyCacheJCS(wikittyConfig)); + WikittyClient client = new WikittyClient(wikittyConfig, wikittyService); + return client; + } + + /** + * This test is the same but service cache policy is changed. + * + * Inverse of test {@link WikittyServiceCachedTest#testRestoreNoCopyPolicy()} test + */ + @Test + public void testRestoreAllwaysCopyPolicy() { + // restoring two times the same wikitty should produces two different copies + Wikitty anotherWikitty = wikittyClient.restore("4d221e31-ff9b-44f0-8545-f9884435f30d"); + Wikitty yetAnotherWikitty = wikittyClient.restore("4d221e31-ff9b-44f0-8545-f9884435f30d"); + + Assert.assertEquals(anotherWikitty, yetAnotherWikitty); + Assert.assertNotSame(anotherWikitty, yetAnotherWikitty); // two different objects + } +} Property changes on: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceCachedCopyTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceCachedTest.java =================================================================== --- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceCachedTest.java 2012-01-26 15:00:35 UTC (rev 1375) +++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceCachedTest.java 2012-01-26 16:39:21 UTC (rev 1376) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2009 - 2010 CodeLutin, Benjamin Poussin + * Copyright (C) 2009 - 2012 CodeLutin, Benjamin Poussin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -24,49 +24,57 @@ */ package org.nuiton.wikitty.services; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.junit.Assert; import org.junit.Test; -import org.nuiton.util.ApplicationConfig; -import org.nuiton.wikitty.WikittyConfig; -import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyClient; +import org.nuiton.wikitty.WikittyClientTest; +import org.nuiton.wikitty.WikittyConfigOption; +import org.nuiton.wikitty.WikittyService; import org.nuiton.wikitty.entities.BusinessEntity; +import org.nuiton.wikitty.entities.Wikitty; import org.nuiton.wikitty.entities.WikittyUser; import org.nuiton.wikitty.entities.WikittyUserImpl; +import org.nuiton.wikitty.test.Product; -import java.util.ArrayList; -import java.util.List; -import org.nuiton.wikitty.WikittyConfigOption; - /** - * + * Re passe les tests du wikitty client en ajoutant une couche de de cache dans + * les services. + * * @author poussin * @version $Revision$ * * Last update: $Date$ * by : $Author$ */ -public class WikittyServiceCachedTest { +public class WikittyServiceCachedTest extends WikittyClientTest { - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(WikittyServiceCachedTest.class); + /** + * Override to method in sub tests to change wikitty client implementation. + * + * @return wikitty client implementation to use in current test case instance + */ + @Override + protected WikittyClient getWikittyClient() { + wikittyConfig.setOption(WikittyConfigOption + .JCS_DEFAULT_CACHEATTRIBUTES_MAXOBJECTS.getKey(), "10"); - protected ApplicationConfig getConfig() { - ApplicationConfig result = WikittyConfig.getConfig(); - return result; + WikittyService wikittyService = new WikittyServiceInMemory(wikittyConfig); + wikittyService = new WikittyServiceCached(wikittyConfig, wikittyService, new WikittyCacheJCS(wikittyConfig)); + WikittyClient client = new WikittyClient(wikittyConfig, wikittyService); + return client; } + /** + * Test + * @throws Exception + */ @Test public void testCache() throws Exception { - ApplicationConfig config = getConfig(); - config.setOption(WikittyConfigOption - .JCS_DEFAULT_CACHEATTRIBUTES_MAXOBJECTS.getKey(), "10"); - WikittyServiceInMemory ws = new WikittyServiceInMemory(config); - WikittyCache cache = new WikittyCacheJCS(config); - WikittyServiceCached wscached = new WikittyServiceCached(config, ws, cache); - - WikittyProxy proxy = new WikittyProxy(config, wscached); + List<BusinessEntity> toStore = new ArrayList<BusinessEntity>(); List<String> toRestore = new ArrayList<String>(); @@ -82,16 +90,16 @@ toStore.add(u4); toStore.add(u5); - toStore = proxy.store(toStore); + toStore = wikittyClient.store(toStore); - u1 = proxy.restore(WikittyUser.class, u1.getWikittyId()); - u2 = proxy.restore(WikittyUser.class, u2.getWikittyId()); - u3 = proxy.restore(WikittyUser.class, u3.getWikittyId()); - u4 = proxy.restore(WikittyUser.class, u4.getWikittyId()); - u5 = proxy.restore(WikittyUser.class, u5.getWikittyId()); - u1 = proxy.restore(WikittyUser.class, u1.getWikittyId()); - u2 = proxy.restore(WikittyUser.class, u2.getWikittyId()); - u3 = proxy.restore(WikittyUser.class, u3.getWikittyId()); + u1 = wikittyClient.restore(WikittyUser.class, u1.getWikittyId()); + u2 = wikittyClient.restore(WikittyUser.class, u2.getWikittyId()); + u3 = wikittyClient.restore(WikittyUser.class, u3.getWikittyId()); + u4 = wikittyClient.restore(WikittyUser.class, u4.getWikittyId()); + u5 = wikittyClient.restore(WikittyUser.class, u5.getWikittyId()); + u1 = wikittyClient.restore(WikittyUser.class, u1.getWikittyId()); + u2 = wikittyClient.restore(WikittyUser.class, u2.getWikittyId()); + u3 = wikittyClient.restore(WikittyUser.class, u3.getWikittyId()); toRestore.add(u1.getWikittyId()); toRestore.add(u2.getWikittyId()); @@ -99,6 +107,67 @@ toRestore.add(u4.getWikittyId()); toRestore.add(u5.getWikittyId()); - proxy.restore(WikittyUser.class, toRestore); + wikittyClient.restore(WikittyUser.class, toRestore); } + + /** + * Setting a field value doesn't corrupt cache. + * + * @throws IOException + */ + @Test + public void testCacheRestore() throws IOException { + importBooks(); // to get a known id + Product book = wikittyClient.restore(Product.class, "4d221e31-ff9b-44f0-8545-f9884435f30d"); + Assert.assertNotNull(book); + + // we set the value of a field + book.setName("My new name"); + + // now let's suppose, the user cancel its modification + // we don't have call store() + book = wikittyClient.restore(Product.class, "4d221e31-ff9b-44f0-8545-f9884435f30d"); + + // the remaining wikitty should hold old value + Assert.assertEquals("Harry Potter à l'école des sorciers", book.getName()); + } + + /** + * Same as testCacheRestore() using methods that restore multiple ids. + * + * @throws IOException + */ + @Test + public void testCacheRestoreMultipleIds() throws IOException { + importBooks(); // to get a known id + // now, let's do the same test, just by using others restore() available + List<String> idsToRestore = new ArrayList<String>(); + idsToRestore.add("4d221e31-ff9b-44f0-8545-f9884435f30d"); + + List<Product> otherWikitties = wikittyClient.restore(Product.class, idsToRestore); + Product book = otherWikitties.get(0); + + // we set the value of a field + book.setName("My new name"); + + // now let's suppose, the user cancel its modification + // we don't have call store() + otherWikitties = wikittyClient.restore(Product.class, idsToRestore); + book = otherWikitties.get(0); + + // the remaining wikitty should hold old value + Assert.assertEquals("Harry Potter à l'école des sorciers", book.getName()); + } + + /** + * Test que deux restore consecutif retourne la même instance (cache). + */ + @Test + public void testRestoreNoCopyPolicy() { + // restoring two times the same wikitty should produces two different copies + Wikitty anotherWikitty = wikittyClient.restore("4d221e31-ff9b-44f0-8545-f9884435f30d"); + Wikitty yetAnotherWikitty = wikittyClient.restore("4d221e31-ff9b-44f0-8545-f9884435f30d"); + + Assert.assertSame(anotherWikitty, yetAnotherWikitty); // same reference + } } Copied: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceNotifierTest.java (from rev 1356, trunk/wikitty-api/src/test/java/org/nuiton/wikitty/notification/WikittyServiceNotificationTest.java) =================================================================== --- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceNotifierTest.java (rev 0) +++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceNotifierTest.java 2012-01-26 16:39:21 UTC (rev 1376) @@ -0,0 +1,232 @@ +/* + * #%L + * Wikitty :: api + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Benjamin Poussin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.wikitty.services; + + +import java.util.EnumSet; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assert; +import org.junit.Test; +import org.nuiton.wikitty.WikittyService.ServiceListenerType; +import org.nuiton.wikitty.services.WikittyEvent; +import org.nuiton.wikitty.services.WikittyListener; +import org.nuiton.wikitty.services.WikittyServiceNotifier; + +/** + * Test si la notification par event fonctionne bien (les bons types d'event + * sont envoyes et recus. + * + * @author poussin + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + */ +public class WikittyServiceNotifierTest { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(WikittyServiceNotifierTest.class); + + protected EnumSet<WikittyEvent.WikittyEventType> lastEvent = null; + protected int nbEvent = 0; + + /** + * Test si les events sont bien lever et bien recu + * @throws Exception + */ + @Test + public void testEvent() throws Exception { + WikittyServiceNotifier wsn = new WikittyServiceNotifier(null, null, null); + Listener l = new Listener(); + + // test d'envoi et de bonne reception + wsn.addWikittyServiceListener(l, ServiceListenerType.ALL); + sendEvent(wsn, true); + + // si on enleve le listener, plus aucun event ne doit arriver + wsn.removeWikittyServiceListener(l, ServiceListenerType.ALL); + sendEvent(wsn, false); + + // donc au total seulement 5 events on du etre envoye + Assert.assertEquals(6, nbEvent); + + } + + /** + * Envoi tous les events possible. Permet de tester la methode process et + * la method fireEvent de WikittyServiceNotifier vu que la premiere + * appelle la deuxieme + * + * @param wsn + */ + protected void sendEvent(WikittyServiceNotifier wsn, boolean hasListener) throws Exception { + { + WikittyEvent event = new WikittyEvent("test"); + event.addType(WikittyEvent.WikittyEventType.PUT_WIKITTY); + wsn.processRemoteEvent(event); + wsn.getEventThread().waitFor(event.getTime()); + if (hasListener) { + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.PUT_WIKITTY), + lastEvent); + } else { + Assert.assertEquals(null, lastEvent); + } + lastEvent = null; + } + { + WikittyEvent event = new WikittyEvent("test"); + event.addType(WikittyEvent.WikittyEventType.REMOVE_WIKITTY); + wsn.processRemoteEvent(event); + wsn.getEventThread().waitFor(event.getTime()); + if (hasListener) { + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.REMOVE_WIKITTY), + lastEvent); + } else { + Assert.assertEquals(null, lastEvent); + } + lastEvent = null; + } + { + WikittyEvent event = new WikittyEvent("test"); + event.addType(WikittyEvent.WikittyEventType.CLEAR_WIKITTY); + wsn.processRemoteEvent(event); + wsn.getEventThread().waitFor(event.getTime()); + if (hasListener) { + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.CLEAR_WIKITTY), + lastEvent); + } else { + Assert.assertEquals(null, lastEvent); + } + lastEvent = null; + } + { + WikittyEvent event = new WikittyEvent("test"); + event.addType(WikittyEvent.WikittyEventType.PUT_EXTENSION); + wsn.processRemoteEvent(event); + wsn.getEventThread().waitFor(event.getTime()); + if (hasListener) { + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.PUT_EXTENSION), + lastEvent); + } else { + Assert.assertEquals(null, lastEvent); + } + lastEvent = null; + } + { + WikittyEvent event = new WikittyEvent("test"); + event.addType(WikittyEvent.WikittyEventType.REMOVE_EXTENSION); + wsn.processRemoteEvent(event); + wsn.getEventThread().waitFor(event.getTime()); + if (hasListener) { + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.REMOVE_EXTENSION), + lastEvent); + } else { + Assert.assertEquals(null, lastEvent); + } + lastEvent = null; + } + { + WikittyEvent event = new WikittyEvent("test"); + event.addType(WikittyEvent.WikittyEventType.CLEAR_EXTENSION); + wsn.processRemoteEvent(event); + wsn.getEventThread().waitFor(event.getTime()); + if (hasListener) { + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.CLEAR_EXTENSION), + lastEvent); + } else { + Assert.assertEquals(null, lastEvent); + } + lastEvent = null; + } + } + + /** + * Class listener des events, check la bonne reception + */ + class Listener implements WikittyListener { + + @Override + public void putWikitty(WikittyEvent event) { + nbEvent++; + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.PUT_WIKITTY), + event.getType()); + lastEvent = event.getType(); + } + + @Override + public void removeWikitty(WikittyEvent event) { + nbEvent++; + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.REMOVE_WIKITTY), + event.getType()); + lastEvent = event.getType(); + } + + @Override + public void clearWikitty(WikittyEvent event) { + nbEvent++; + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.CLEAR_WIKITTY), + event.getType()); + lastEvent = event.getType(); + } + + @Override + public void putExtension(WikittyEvent event) { + nbEvent++; + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.PUT_EXTENSION), + event.getType()); + lastEvent = event.getType(); + } + + @Override + public void removeExtension(WikittyEvent event) { + nbEvent++; + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.REMOVE_EXTENSION), + event.getType()); + lastEvent = event.getType(); + } + + @Override + public void clearExtension(WikittyEvent event) { + nbEvent++; + Assert.assertEquals( + EnumSet.of(WikittyEvent.WikittyEventType.CLEAR_EXTENSION), + event.getType()); + lastEvent = event.getType(); + } + + } +} Copied: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceNotifierXMPPTest.java (from rev 1356, trunk/wikitty-api/src/test/java/org/nuiton/wikitty/notification/XMPPNotificationTest.java) =================================================================== --- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceNotifierXMPPTest.java (rev 0) +++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/services/WikittyServiceNotifierXMPPTest.java 2012-01-26 16:39:21 UTC (rev 1376) @@ -0,0 +1,109 @@ +/* + * #%L + * Wikitty :: api + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Benjamin Poussin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.wikitty.services; + +import java.util.Date; + +import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.XMPPConnection; +import org.jivesoftware.smack.packet.Packet; +import org.jivesoftware.smackx.muc.DiscussionHistory; +import org.jivesoftware.smackx.muc.MultiUserChat; +import org.junit.Ignore; +import org.junit.Test; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.wikitty.WikittyConfig; +import org.nuiton.wikitty.WikittyConfigOption; +import org.nuiton.wikitty.WikittyUtil; + +/** + * Wikitty service test based on XMPP transporter. + * + * Test disabled, need to fix http://www.nuiton.org/issues/1060 before + * to add embedded xmpp server available in test. + * + * @author poussin + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + */ +@Ignore +public class WikittyServiceNotifierXMPPTest { + + @Test + public void testXMPP() throws Exception { + String server = "im.codelutin.com"; + String room = "test@conference.im.codelutin.com"; + ApplicationConfig config = WikittyConfig.getConfig(); + config.setOption(WikittyConfigOption.WIKITTY_EVENT_TRANSPORTER_XMPP_SERVER.getKey(), server); + config.setOption(WikittyConfigOption.WIKITTY_EVENT_TRANSPORTER_XMPP_ROOM.getKey(), room); + + // Envoi d'un message avec le transporter normal + WikittyServiceNotifier.RemoteNotifierTransporter transporteur = + new XMPPNotifierTransporter(config); + WikittyServiceNotifier wsn = new WikittyServiceNotifier(config, null, transporteur); + WikittyEvent event = new WikittyEvent("test"); + event.addRemoveDate("theId", new Date()); + + transporteur.sendMessage(event); + + + // essaie de recuperation du message + + XMPPConnection connection = new XMPPConnection(server); + connection.connect(); + connection.loginAnonymously(); + + MultiUserChat muc = new MultiUserChat(connection, room); + String pseudo = WikittyUtil.getUniqueLoginName(); + System.out.println("pseudo: " + pseudo); + + DiscussionHistory history = new DiscussionHistory(); + history.setMaxStanzas(0); + muc.join(pseudo, "", history, 4000); + + muc.addMessageListener(new PacketListener() { + + @Override + public void processPacket(Packet packet) { + System.out.println("ext: " + packet.getExtensions()); + System.out.println("prop: " + packet.getPropertyNames()); + Object event = packet.getProperty(XMPPNotifierTransporter.PROPERTY_EVENT_NAME); + System.out.println("event " + event + " PACKET: " + + " xml: " + packet.toXML()); + } + }); + + // Discover information about the room roomName@conference.myserver +// RoomInfo info = MultiUserChat.getRoomInfo(connection, room); +// System.out.println("Number of occupants:" + info.getOccupantsCount()); +// System.out.println("Room Subject:" + info.getSubject()); + +// Thread t = new Thread(); +// Thread.currentThread().sleep(1000*60); + } + +}
participants (1)
-
echatellier@users.nuiton.org