Index: topia2/src/test/org/codelutin/topia/service/TestServiceServer.java diff -u /dev/null topia2/src/test/org/codelutin/topia/service/TestServiceServer.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/test/org/codelutin/topia/service/TestServiceServer.java Wed Apr 18 12:21:25 2007 @@ -0,0 +1,59 @@ +/* *##% + * Copyright (C) 2006 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.codelutin.topia.service; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * TopiaServiceServer.java + * + * Class main chargee de lire le fichier de configuration et de lancer les + * serveurs, pour les protocoles définit. + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/04/18 12:21:25 $ By : $Author: chatellier $ + */ +public class TestServiceServer { + + /** Logger (common logging) */ + private static final Log logger = LogFactory + .getLog(TestServiceServer.class); + + /** + * Main. Demarre les serveurs. + * + * @param args + * arguments + */ + public static void main(String args[]) { + + // TestService ts = new TestServiceImpl("Bonjour"); + // TopiaServiceFactory.addService(TestService.class, ts , + // Protocole.XML_RPC); + //TopiaServiceFactory.addService(TestService.class, + // TestServiceImpl.class, Protocole.XML_RPC); + TopiaServiceFactory.addService(TestService.class, + TestServiceImpl.class, Protocole.SOAP); + + logger.info("Service TestService added..."); + } +} Index: topia2/src/test/org/codelutin/topia/service/TestService.java diff -u /dev/null topia2/src/test/org/codelutin/topia/service/TestService.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/test/org/codelutin/topia/service/TestService.java Wed Apr 18 12:21:25 2007 @@ -0,0 +1,42 @@ +/* *##% + * Copyright (C) 2006 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.codelutin.topia.service; + +import org.codelutin.topia.TopiaException; + +/** + * TestService.java + * + * Genere par Topia ! + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/04/18 12:21:25 $ By : $Author: chatellier $ + */ +public interface TestService extends TopiaApplicationService { + + /** + * Declaration d'un service + * + * @param name + * le nom + */ + public String sayHello(String name) throws TopiaException; +} Index: topia2/src/test/org/codelutin/topia/service/TestServiceImpl.java diff -u /dev/null topia2/src/test/org/codelutin/topia/service/TestServiceImpl.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/test/org/codelutin/topia/service/TestServiceImpl.java Wed Apr 18 12:21:25 2007 @@ -0,0 +1,64 @@ +/* *##% + * Copyright (C) 2006 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.codelutin.topia.service; + +/** + * TestServiceImpl.java + * + * Developpe par le programmeur ! + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/04/18 12:21:25 $ By : $Author: chatellier $ + */ +public class TestServiceImpl extends TopiaApplicationServiceAbstract implements + TestService { + + private String prefix; + + private static int nb = 0; + + /** + * + * @param prefix + */ + public TestServiceImpl() { + this.prefix = "Salut"; + nb = nb + 1; + } + + /** + * + * @param prefix + */ + public TestServiceImpl(String prefix) { + this(); + this.prefix = prefix; + } + + /* + * (non-Javadoc) + * + * @see service.TestService#sayHello(java.lang.String) + */ + public String sayHello(String name) { + return prefix + " " + name + " (instance " + nb + ")"; + } +} Index: topia2/src/test/org/codelutin/topia/service/TestServiceTestCase.java diff -u /dev/null topia2/src/test/org/codelutin/topia/service/TestServiceTestCase.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/test/org/codelutin/topia/service/TestServiceTestCase.java Wed Apr 18 12:21:25 2007 @@ -0,0 +1,67 @@ +/* *##% + * Copyright (C) 2006 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.codelutin.topia.service; + +import junit.framework.TestCase; + +import org.codelutin.topia.TopiaException; +import org.codelutin.topia.TopiaNotFoundException; + +/** + * TestServiceTestCase.java + * + * Test junit du service. + * + * Il faut lancer les serveurs avant ce test + * @see org.codelutin.topia.service.TestServiceServer + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/04/18 12:21:25 $ By : $Author: chatellier $ + */ +public class TestServiceTestCase extends TestCase { + + /** + * Test de la methode say hello + */ + public void testSayHello() { + + String reponse = null; + + TestService testService; + try { + testService = TopiaServiceFactory.getService(TestService.class); + + String myName = "eric"; + + reponse = testService.sayHello(myName); + + System.out.println("TestService says : " + reponse); + } catch (TopiaNotFoundException e) { + System.err + .println("TopiaNotFoundException: erreur du fichier de configuration"); + } catch (TopiaException e) { + System.err + .println("TopiaException: impossible d'instancier le service"); + } + + assertNotNull(reponse); + } +}