Commit 9ce9654e authored by BenoitLB's avatar BenoitLB
Browse files

Ajout de quelques tests

parent e6106e54
package fr.alma.gtd.interfacedistante;
import java.rmi.RemoteException;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class MyCallBack<Object> implements CallBack<Object> {
private final Lock lock = new ReentrantLock();
private boolean ver;
@Override
public void onSucces(Object result) throws RemoteException {
ver = true;
lock.unlock();
}
@Override
public void onFailure(Exception e) throws RemoteException {
ver = false;
lock.unlock();
throw new RemoteException() ;
}
public boolean hasResult() {
lock.lock();
return true;
}
}
package fr.alma.gtd.reactor;
import fr.alma.gtd.donneespartagees.*;
import fr.alma.gtd.donneesserveur.*;
import fr.alma.gtd.interfacedistante.ModeDeMiseAJour;
import fr.alma.gtd.interfacedistante.MyCallBack;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.rmi.RemoteException;
import java.util.Date;
import java.util.List;
/**
* Classe de test de ReactorRMI
* @Author Glenn Plouhinec & Benoît Le Badezet
* @version 1.0.0.0
*/
public final class TestReactorRMI {
/**
* p'tite variable de test
*/
public ReactorRMI react;
/**
* Setup des tests
*/
@SuppressWarnings("unchecked")
@Before
public void setup(){
react = new ReactorRMI();
}
@Test
public void testConstructor(){
try {
new ReactorRMI();
} catch(Exception e) {
Assert.fail(e.getMessage());
}
}
/**
* Test des methodes de création
* C'est le même code pour toutes les création juste l'objet créer qui diffère
*/
@Test
public void testCreerCompte(){
try {
react.creerCompte("usr", "mpd", "Util", new MyCallBack<String>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testCreerContexte(){
try {
react.creerContexte(new Contexte(), "identification", new MyCallBack<IContexte>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testCreerIdee(){
try {
react.creerIdee(new Idee(), "identification", new MyCallBack<IIdee>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testCreerProjet(){
try {
react.creerProjet(new Projet(), "identification", new MyCallBack<IProjet>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testCreerTache(){
try {
react.creerTache(new Tache(), "identification", new MyCallBack<ITache>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testCreerTag(){
try {
react.creerTag(new Tag(), "identification", new MyCallBack<ITag>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testDiconnect(){
try {
react.disconnect("identification", new MyCallBack<String>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testLogin(){
try {
react.login("usr", "mdp", new MyCallBack<String>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
/**
* Tests des méthodes d'envoi
*/
@Test
public void testEnvoyerContexte(){
try {
react.envoyerContexte(new Contexte(), ModeDeMiseAJour.FORCE, "identification", new MyCallBack<IContexte>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.envoyerContexte(new Contexte(), ModeDeMiseAJour.WARNING, "identification", new MyCallBack<IContexte>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testEnvoyerIdee(){
try {
react.envoyerIdee(new Idee(), ModeDeMiseAJour.FORCE, "identification", new MyCallBack<IIdee>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.envoyerIdee(new Idee(), ModeDeMiseAJour.WARNING, "identification", new MyCallBack<IIdee>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testEnvoyerProjet(){
try {
react.envoyerProjet(new Projet(), ModeDeMiseAJour.FORCE, "identification", new MyCallBack<IProjet>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.envoyerProjet(new Projet(), ModeDeMiseAJour.WARNING, "identification", new MyCallBack<IProjet>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testEnvoyerTache(){
try {
react.envoyerTache(new Tache(), ModeDeMiseAJour.FORCE, "identification", new MyCallBack<ITache>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.envoyerTache(new Tache(), ModeDeMiseAJour.WARNING, "identification", new MyCallBack<ITache>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testEnvoyerTag(){
try {
react.envoyerTag(new Tag(), ModeDeMiseAJour.FORCE, "identification", new MyCallBack<ITag>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.envoyerTag(new Tag(), ModeDeMiseAJour.WARNING, "identification", new MyCallBack<ITag>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
/**
* Tests de modifications
*/
@Test
public void testModifierMDP(){
try {
react.modifierMotDePasse("old", "new","identification", new MyCallBack<String>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testModifierPseudo(){
try {
react.modifierPseudo( "new","identification", new MyCallBack<String>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
/**
* Tests de suppressions
*/
@Test
public void testSupprimerCompte(){
try {
react.supprimerCompte( "usr","mdp", "identification", new MyCallBack<String>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testSupprimerContexte(){
try {
react.supprimerContexte( new Contexte(), "identification", new MyCallBack<String>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testSupprimerIdee(){
try {
react.supprimerIdee( new Idee(), "identification", new MyCallBack<String>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testSupprimerProjet(){
try {
react.supprimerProjet( new Projet(), "identification", new MyCallBack<String>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testSupprimerTache(){
try {
react.supprimerTache( new Tache(), "identification", new MyCallBack<String>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testSupprimerTag(){
try {
react.supprimerTag( new Tag(), "identification", new MyCallBack<String>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
/**
* Tests telechargements
*/
@Test
public void testTelechargeArchive(){
try {
react.telechargeArchive("identification", new MyCallBack<List<IObjetServeur>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.telechargeArchive(new Date(), "identification", new MyCallBack<List<IObjetServeur>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargeCalendrier(){
try {
react.telechargeCalendrier("identification", new MyCallBack<List<ITache>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.telechargeCalendrier(new Date(), "identification", new MyCallBack<List<ITache>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargeContextes(){
try {
react.telechargeContextes("identification", new MyCallBack<List<IContexte>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargeIdees(){
try {
react.telechargeIdees("identification", new MyCallBack<List<IIdee>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargeInbox(){
try {
react.telechargeInbox("identification", new MyCallBack<List<IIdee>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.telechargeInbox(new Date(), "identification", new MyCallBack<List<IIdee>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargeParticipants(){
try {
react.telechargeParticipants("identification", new MyCallBack<List<IParticipant>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargePoubelle(){
try {
react.telechargePoubelle("identification", new MyCallBack<List<IObjetServeur>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.telechargePoubelle(new Date(), "identification", new MyCallBack<List<IObjetServeur>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargeProchainesTaches(){
try {
react.telechargeProchainesTaches("identification", new MyCallBack<List<ITache>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.telechargeProchainesTaches(new Date(), "identification", new MyCallBack<List<ITache>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargeProchainesTachesContexte(){
try {
react.telechargeProchainesTachesParContexte(new Contexte(), "identification", new MyCallBack<List<ITache>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.telechargeProchainesTachesParContexte(new Date(), new Contexte(), "identification", new MyCallBack<List<ITache>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargeProjets(){
try {
react.telechargeProjets("identification", new MyCallBack<List<IProjet>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargeTacheParTag(){
try {
react.telechargeTacheParTag(new Tag(),"identification", new MyCallBack<List<ITache>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.telechargeTacheParTag(new Date(), new Tag(), "identification", new MyCallBack<List<ITache>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargeTaches(){
try {
react.telechargeTaches("identification", new MyCallBack<List<ITache>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargeTags(){
try {
react.telechargeTags("identification", new MyCallBack<List<ITag>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargerContextes(){
try {
react.telechargerContextes("usr","identification", new MyCallBack<List<IContexte>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargerIdees(){
try {
react.telechargerIdees("usr","identification", new MyCallBack<List<IIdee>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargerLog(){
try {
react.telechargerLog("identification", new MyCallBack<List<String>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.telechargerLog(new Date(), "identification", new MyCallBack<List<String>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
try {
react.telechargerLog("usr", "identification", new MyCallBack<List<String>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargerLogAdmin(){
try {
react.telechargerLogAdmin("identification", new MyCallBack<List<String>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargerProjets(){
try {
react.telechargerProjets("usr","identification", new MyCallBack<List<IProjet>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargerTaches(){
try {
react.telechargerTaches("usr","identification", new MyCallBack<List<ITache>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testTelechargerTags(){
try {
react.telechargerTags("usr","identification", new MyCallBack<List<ITag>>() );
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment