Package tests

Source Code of tests.Tests

/**
*
*/
package tests;

import java.sql.Date;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

import metier.GestionConnection;
import metier.reservations.AttributionPlaces;

import data.reservation.Reservation;
import database.HsqlDbConnection;
//import database.TableManager;
import exceptions.metier.NombreTotalPlacesInsuffisantException;

import factories.FabReservation;

/**
* @author Matej Hausenblas matej.hausenblas@gmail.com
*
*/
public class Tests {
  public static void main(String[] args){
   
    // tests sur des dates
    Date d1 = Date.valueOf("2007-01-13");
    Date d2 = Date.valueOf("2007-01-21");
    System.out.println( Calendar.getInstance().getTimeInMillis() );
    System.out.println( Calendar.getInstance().getTime().getTime() );
    System.out.println(d2.getTime() - d1.getTime());
    if(d2.getTime() - 8*86400000 >= d1.getTime())
      System.out.println("plus de 8 jours");
    else
      System.out.println("moins de 8 jours");
    System.out.println(new Date(d2.getTime() - 8*86400000));
   
   
    // test sur la fabrique de reservations
    try{
      FabReservation fr = FabReservation.getInstance();
      GestionConnection gc = new GestionConnection();
      fr.setConnection(gc.getConnection());
      java.util.Date today = Calendar.getInstance().getTime();
      Collection anciennesReservations = fr.getAnciennesReservations(today);
      for(Iterator itRes = anciennesReservations.iterator(); itRes.hasNext();){
        String r = (String)itRes.next();
        System.out.println(r.toString());
        fr.supprimerReservation(r);
       
      }
      anciennesReservations.clear();
      anciennesReservations = fr.getAnciennesReservations(today);
      System.out.println("Nouvelle situation des anciennes reservations: "+anciennesReservations);
     
     
      ArrayList propose = (ArrayList)new AttributionPlaces().proposeFauteuils("balcon","4TR", 45);
     
      System.out.println("Places trouvees"+propose);
     
     
     
    }catch(SQLException e){
      e.printStackTrace();
    }catch(NombreTotalPlacesInsuffisantException e){
      e.printStackTrace();
    }
  }
}
TOP

Related Classes of tests.Tests

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.