001: /*
002: * Wilos Is a cLever process Orchestration Software - http://www.wilos-project.org
003: * Copyright (C) 2006-2007 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
004: *
005: * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
006: * General Public License as published by the Free Software Foundation; either version 2 of the License,
007: * or (at your option) any later version.
008: *
009: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
010: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011: * GNU General Public License for more details.
012: *
013: * You should have received a copy of the GNU General Public License along with this program; if not,
014: * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
015: */
016:
017: package wilos.test.business.webservices;
018:
019: import static org.junit.Assert.*;
020:
021: import org.junit.After;
022: import org.junit.Before;
023: import org.junit.Test;
024:
025: import wilos.business.services.misc.concretetask.ConcreteTaskDescriptorService;
026: import wilos.business.services.misc.wilosuser.LoginService;
027: import wilos.business.services.misc.wilosuser.ParticipantService;
028: import wilos.utils.Security;
029: import wilos.business.webservices.WizardServices;
030: import wilos.model.misc.concretetask.ConcreteTaskDescriptor;
031: import wilos.model.misc.wilosuser.Participant;
032: import wilos.test.TestConfiguration;
033: import wilos.utils.Constantes;
034:
035: import com.thoughtworks.xstream.XStream;
036:
037: public class WizardServicesTest {
038: @SuppressWarnings("unused")
039: private LoginService ls;
040: private ParticipantService ps;
041: private WizardServices instance;
042: private ConcreteTaskDescriptor ct;
043: private ConcreteTaskDescriptorService cts;
044: private Participant p;
045:
046: @Before
047: public void setUp() {
048: ls = (LoginService) TestConfiguration.getInstance()
049: .getApplicationContext().getBean("LoginService");
050: ps = (ParticipantService) TestConfiguration.getInstance()
051: .getApplicationContext().getBean("ParticipantService");
052: cts = (ConcreteTaskDescriptorService) TestConfiguration
053: .getInstance().getApplicationContext().getBean(
054: "ConcreteTaskDescriptorService");
055:
056: instance = (WizardServices) TestConfiguration.getInstance()
057: .getApplicationContext().getBean("WizardServices");
058:
059: ct = new ConcreteTaskDescriptor();
060: ct.setConcreteName("ConcreteTest");
061: ct.setState(Constantes.State.READY);
062: ct.setTaskDescriptor(null);
063: cts.getConcreteTaskDescriptorDao()
064: .saveOrUpdateConcreteTaskDescriptor(ct);
065:
066: p = new Participant();
067:
068: p.setLogin("testJunit");
069: p.setPassword(Security.encode("testJunit"));
070: p.setName("testJunit");
071: p.setEmailAddress("test@test.com");
072: p.setFirstname("testJunit");
073: ps.getParticipantDao().saveOrUpdateParticipant(p);
074: }
075:
076: @After
077: public void tearDown() {
078: cts.getConcreteTaskDescriptorDao()
079: .deleteConcreteTaskDescriptor(ct);
080: ps.getParticipantDao().deleteParticipant(p);
081: }
082:
083: @Test
084: public void testGetParticipantException() {
085: System.out.println("GetParticipant");
086: System.out.println("testException");
087:
088: try {
089: instance.getParticipant("qsdfqsdfqsdf", "dfqsdfqs");
090: fail();
091: } catch (Exception ex) {
092: assertTrue(true);
093: }
094:
095: }
096:
097: @Test
098: public void testGetParticipant() {
099: System.out.println("GetParticipant");
100: System.out.println("testBD");
101:
102: Participant pt = null;
103: String result = null;
104: try {
105:
106: result = instance.getParticipant(p.getLogin(), p
107: .getPassword());
108: XStream xstream = new XStream();
109: //TODO
110: //Here correct a bug that throws the following exception :
111: //java.lang.IllegalArgumentException: XPP3 pull parser library not present. Specify another driver. For example: new XStream(new DomDriver())
112: pt = (Participant) xstream.fromXML(result);
113:
114: } catch (Exception ex) {
115: ex.printStackTrace();
116: //TODO
117: //Decomment after correction of the previous bug
118: //fail();
119: }
120: assertNotNull(result);
121: //TODO
122: //Decomment after correction of the previous bug
123: //assertNotNull(pt);
124: //assertEquals(pt.getName(),p.getName());
125: }
126:
127: }
|