void TestMovingObject::basicTest()
      {
        std::cerr << "TestMovingObject::basicTest" << std::endl ;
        std::cerr.flush() ;
        /*!
          - build a engine
          - build a listener
          - move the engine position
          - update the module for streaming during 10secondes
          -destroy all and clean sound module
        */

        // we construct a complete system
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestMovingObject::basicTest")) ;
        model->init() ;
        
        Kernel::Object* system = model->createObject() ;
        system->addTrait(new Model::Positionned()) ;
        system->addTrait(new Model::Oriented()) ;

        Kernel::Object* listener = system->createObject() ;
        listener->addTrait(new Model::Listener()) ;
        Model::Positionned* listenerPos = new Model::Positionned();
        listener->addTrait(listenerPos) ;
        listener->addTrait(new Model::Oriented()) ;
        listener->addTrait(new Model::Mobile());

        Kernel::Object* engine = system->createObject() ;
        engine->addTrait(new Model::Engine(Model::Force::Newton(10,10,10))) ;
        Model::Positionned* enginePos = new Model::Positionned(Model::Position::Meter(0,0,-50));
        engine->addTrait(enginePos);
        engine->addTrait(new Model::Oriented()) ;
        engine->addTrait(new Model::Mobile());
        
        Kernel::ViewPoint* viewpoint = model->getViewPoint<Implementation::OpenAL::RealWorldViewPoint>() ;
        
        ALuint engine_source = 
          engine->getTrait<Implementation::Engine>()
                ->getView<Implementation::OpenAL::Engine>(viewpoint)->m_source ;
        
        Kernel::Timer global_timer ;
        Kernel::Timer timer ;

        float expected_position_x = 0 ;
        float expected_position_y = 0 ;
        float expected_position_z = -50 ;

        checkSourcePosition(engine_source,
                            expected_position_x,
                            expected_position_y,
                            expected_position_z) ;
        
        /// moving on Z axis
        while (global_timer.getSecond() <= 1)
        {
          enginePos->setPosition(enginePos->getPosition()+ Model::Position::Meter(0,0,0.005));
          expected_position_z += 0.005 ;
          checkSourcePosition(engine_source,
                              expected_position_x,
                              expected_position_y,
                              expected_position_z) ;
          float seconds = timer.getSecond() ;
          timer.reset() ;
          model->update(seconds) ;
        }
        
        /// moving on X axis
        global_timer.reset();
        enginePos->setPosition(Model::Position::Meter(-50,0,0));
        
        expected_position_x = -50 ;
        expected_position_y = 0 ;
        expected_position_z = 0 ;
        
        checkSourcePosition(engine_source,
                            expected_position_x,
                            expected_position_y,
                            expected_position_z) ;
        
        while (global_timer.getSecond() <= 1)
        {
          enginePos->setPosition(enginePos->getPosition()+Model::Position::Meter(0.005,0,0));
          expected_position_x += 0.005 ;
          checkSourcePosition(engine_source,
                              expected_position_x,
                              expected_position_y,
                              expected_position_z) ;
          float seconds = timer.getSecond() ;
          timer.reset() ;
          model->update(seconds) ;
        }
        
        /// moving on Y axis
        global_timer.reset();
        enginePos->setPosition(Model::Position::Meter(0,-50,0));
        
        expected_position_x = 0 ;
        expected_position_y = -50 ;
        expected_position_z = 0 ;
        
        checkSourcePosition(engine_source,
                            expected_position_x,
                            expected_position_y,
                            expected_position_z) ;
        
        while (global_timer.getSecond() <= 1)
        {
          enginePos->setPosition(enginePos->getPosition()+Model::Position::Meter(0,0.005,0));
          expected_position_y += 0.005 ;
          checkSourcePosition(engine_source,
                              expected_position_x,
                              expected_position_y,
                              expected_position_z) ;
          float seconds = timer.getSecond() ;
          timer.reset() ;
          model->update(seconds) ;
        }
        
        /// moving on X axis listener and source
        global_timer.reset();
        enginePos->setPosition(Model::Position::Meter(0,0,-100));
        
        expected_position_x = 0 ;
        expected_position_y = 0 ;
        expected_position_z = -100 ;
        
        checkSourcePosition(engine_source,
                            expected_position_x,
                            expected_position_y,
                            expected_position_z) ;
        
        float listener_position_x ;
        float listener_position_y ;
        float listener_position_z ;

        float expected_listener_position_x = 0 ;
        float expected_listener_position_y = 0 ;
        float expected_listener_position_z = 0 ;
        
        while (global_timer.getSecond() <= 1)
        {
          listenerPos->setPosition(listenerPos->getPosition()+ Model::Position::Meter(0,0,-0.005));
          expected_listener_position_z -= 0.005 ;
          
          alGetListener3f(AL_POSITION,&listener_position_x,&listener_position_y,&listener_position_z) ;
          CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_listener_position_x,listener_position_x,delta) ;
          CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_listener_position_y,listener_position_y,delta) ;
          CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_listener_position_z,listener_position_z,delta) ;
          
          enginePos->setPosition(enginePos->getPosition()+ Model::Position::Meter(0,0,0.005));
          expected_position_z += 0.005 ;
          checkSourcePosition(engine_source,
                              expected_position_x,
                              expected_position_y,
                              expected_position_z) ;
          float seconds = timer.getSecond() ;
          timer.reset() ;
          model->update(seconds) ;
        }
        
        InternalMessage("Sound","after sound close") ;
      }
      void TestDemonstration::recreateListener()
      {
        InternalMessage("Sound","entering TestDemonstration::recreateListener") ;
        std::cerr << "TestDemonstration::oneShip" << std::endl ;
        std::cerr.flush() ;

        std::auto_ptr<Kernel::Model> model(new Kernel::Model()) ;
        model->init() ;
        Kernel::Object* root = model->createObject() ;

        Kernel::Object* universe = root->createObject() ;
        universe->addTrait(new Model::Universe()) ;
        universe->addTrait(new Model::Positionned()) ;
        universe->setName("universe") ;
        {
          Kernel::Object* system = universe->createObject() ;
          system->addTrait(new Model::StellarSystem()) ;
          system->addTrait(new Model::Positionned()) ;
          system->setName("system") ;

          Kernel::Object* pilot = system->createObject() ;
          pilot->addTrait(new Model::Listener()) ;
          pilot->addTrait(new Model::Positionned()) ;
          pilot->addTrait(new Model::Oriented()) ;
          pilot->addTrait(new Model::Player()) ;
          pilot->addTrait(new Model::Observer()) ;
          pilot->addTrait(new Model::Active()) ;

          Kernel::Object* ship2 = Model::loadShip("test_ship",system) ;

          Model::Positionned* ship2_positionned = ship2->getTrait<Model::Positionned>() ;
          ship2_positionned->setPosition(Model::Position::Meter(0,0,50)) ;
          ship2->getTrait<Model::Mobile>()->setSpeed(Model::Speed::MeterPerSecond(0,0,-50)) ;
          Kernel::Timer global_timer ;
          Kernel::Timer timer ;

          std::set<Model::Throttle*> throttles = ship2->getChildren<Model::Throttle>() ;

          (*throttles.begin())->set(100) ;

          while (global_timer.getSecond() <= 1)
          {
            float seconds = timer.getSecond() ;
            if (seconds > 0)
            {
              timer.reset() ;
              ship2_positionned->setPosition(ship2_positionned->getPosition()+Model::Position::Meter(0,0,-50*seconds)) ;
              model->update(seconds) ;
            }
          }

          system->destroyObject() ;
        }
        {
          Kernel::Object* system = universe->createObject() ;
          system->addTrait(new Model::StellarSystem()) ;
          system->addTrait(new Model::Positionned()) ;
          system->setName("system") ;

          Kernel::Object* pilot = system->createObject() ;
          pilot->addTrait(new Model::Listener()) ;
          pilot->addTrait(new Model::Positionned()) ;
          pilot->addTrait(new Model::Oriented()) ;
          pilot->addTrait(new Model::Player()) ;
          pilot->addTrait(new Model::Observer()) ;
          pilot->addTrait(new Model::Active()) ;

          Kernel::Object* ship2 = Model::loadShip("test_ship",system) ;

          Model::Positionned* ship2_positionned = ship2->getTrait<Model::Positionned>() ;
          ship2_positionned->setPosition(Model::Position::Meter(0,0,50)) ;
          ship2->getTrait<Model::Mobile>()->setSpeed(Model::Speed::MeterPerSecond(0,0,-50)) ;
          Kernel::Timer global_timer ;
          Kernel::Timer timer ;

          std::set<Model::Throttle*> throttles = ship2->getChildren<Model::Throttle>() ;

          (*throttles.begin())->set(100) ;

          while (global_timer.getSecond() <= 1)
          {
            float seconds = timer.getSecond() ;
            if (seconds > 0)
            {
              timer.reset() ;
              ship2_positionned->setPosition(ship2_positionned->getPosition()+Model::Position::Meter(0,0,-50*seconds)) ;
              model->update(seconds) ;
            }
          }
        }

        InternalMessage("Sound","leaving TestDemonstration::oneShip") ;
      }
      void TestModelControler::attackAllEnemies()
      {
        InternalMessage("Demonstration","Demonstration::TestModelControler::attackAllEnemies entering") ;
        // 1. build a model
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestModelControler::attackAllEnemies")) ;
        model->init() ;
        InternalMessage("Demonstration","Demonstration::TestModelControler::attackAllEnemies inited") ;

        Kernel::Object* team1 = model->createObject() ;
        team1->addTrait(new Model::Team("team1")) ;
        Kernel::Object* team2 = model->createObject() ;
        team2->addTrait(new Model::Team("team2")) ;

        Kernel::Object* universe = model->createObject() ;
        universe->addTrait(new Model::Universe()) ;
        universe->addTrait(new Model::Positioned()) ;

        Kernel::Object* system = universe->createObject() ;
        system->addTrait(new Model::StellarSystem()) ;
        system->addTrait(new Model::Positioned()) ;

        Kernel::Object* observer = system->createObject() ;
        observer->addTrait(new Model::Observer()) ;
        observer->addTrait(new Model::Player()) ;
        observer->addTrait(new Model::Active()) ;
        observer->addTrait(new Model::Positioned(Model::Position::Meter(400,1500,-1000))) ;
        observer->addTrait(new Model::Oriented(Model::Orientation(::Ogre::Quaternion(::Ogre::Degree(-90),::Ogre::Vector3::UNIT_X)))) ;

        Kernel::ObjectReference ship1 ;
        {
          Kernel::Object* ship = Model::createShip(system) ;
          ship->getTrait<Model::Positioned>()->setPosition(Model::Position::Meter(0,0,0)) ;
          ship->addTrait(new Model::Transponder(team1)) ;
          Kernel::Object* agent = Model::createAI(ship) ;
          agent->getTrait<Model::WithObjectives>()->addObjective(Model::Objective::attackAllEnemies()) ;
          ship1 = ship ;
        }

        // the attacked enemy ship
        Kernel::Object* enemy_ship = system->createObject() ;
        enemy_ship->addTrait(new Model::Positioned(Model::Position::Meter(500,0,-1000))) ;
        enemy_ship->addTrait(new Model::Massive(Model::Mass::Kilogram(1000))) ;
        enemy_ship->addTrait(new Model::Oriented()) ;
        enemy_ship->addTrait(new Model::Mobile()) ;
        enemy_ship->addTrait(new Model::Solid(Model::Mesh("default_ship.mesh"))) ;
        enemy_ship->addTrait(new Model::Transponder(team2)) ;
        enemy_ship->addTrait(new Model::Destroyable(Model::Energy::Joule(1))) ;
        enemy_ship->addTrait(new Model::Dragger(Kernel::Parameters::getValue<float>("Model","DraggerCoeeficient",0.01))) ;
        {
          Kernel::Object* st1 = enemy_ship->createObject() ;
          st1->addTrait(new Model::Stabilizer(0,Kernel::Parameters::getValue<float>("Model","StabilizerForce",10),0)) ;
          st1->addTrait(new Model::Component()) ;

          Kernel::Object* st2 = enemy_ship->createObject() ;
          st2->addTrait(new Model::Stabilizer(Kernel::Parameters::getValue<float>("Model","StabilizerForce",10),0,0)) ;
          st2->addTrait(new Model::Component()) ;

          Kernel::Object* st3 = enemy_ship->createObject() ;
          st3->addTrait(new Model::Stabilizer(0,0,Kernel::Parameters::getValue<float>("Model","StabilizerForce",10))) ;
          st3->addTrait(new Model::Component()) ;
        }

        Kernel::ObjectReference enemy(enemy_ship) ;
        InternalMessage("Demonstration","Demonstration::TestModelControler::attackAllEnemies created") ;

        Kernel::Timer timer ;
        Kernel::Timer global_timer ;

        while (global_timer.getSecond() < 10)
        {
          float seconds = timer.getSecond() ;
          if (seconds > 0)
          {
            timer.reset() ;
            model->update(seconds) ;
          }
        }

        // enemy is destroyed
        CPPUNIT_ASSERT(!enemy) ;
        InternalMessage("Demonstration","Demonstration::TestModelControler::attackAllEnemies leaving") ;
      }
      void TestSoundEnvironnement::basicTest()
      {
        std::cerr << "TestSoundEnvironnement::basicTest"  ;
        std::cerr.flush() ;
        
        /*!
         - build a SoundEnvironnement
         - build an Engine in this environnement
         - build a listener in the same environnement   
         - change a parent and listen the sound continue with just a little artefact between the close and init
         */

        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestSoundEnvironnement::basicTest"));
        model->init() ;

        Kernel::Object* system = model->createObject() ;
        system->addTrait(new Model::Positioned()) ;
        system->addTrait(new Model::Oriented()) ;

        Kernel::Object* listener = createObserver(system) ;
        listener->getTrait<Model::Oriented>()->setOrientation(Model::Orientation(Ogre::Quaternion(1.0, 0.0, 10.0, 0.0))) ;

        Kernel::Object* ship = Model::createShip(system) ;

        ship->getChild<Model::Throttle>()->set(100) ;

        Kernel::Timer timer;
        Kernel::Timer global_timer;

        std::cerr << " normal... " ;
        std::cerr.flush() ;

        while (global_timer.getSecond() <= 3)
        {
          float seconds = timer.getSecond() ;
          timer.reset() ;
          model->update(seconds) ;
        }

        Kernel::Object* env = system->createObject() ;
        Model::SoundEnvironnement* soundEnv = new Model::SoundEnvironnement();
        //        soundEnv->setDensity(0.5) ;
        //        soundEnv->setDiffusion(1.0) ;
        //        soundEnv->setGain(0.5) ;
        //        soundEnv->setGainHF(1.0) ;
        //        soundEnv->setDecayTime(2.0) ;
        //        soundEnv->setDecayHFRatio(1.1) ;
        //        soundEnv->setReflexionsGain(1.0) ;
        //        soundEnv->setReflexionsDelay(2.0) ;
        //        soundEnv->setLateReverbGain(1.0) ;
        //        soundEnv->setLateReverbDelay(2.5) ;
        env->addTrait(soundEnv) ;
        ship->changeParent(env) ;

        std::cerr << " switching environement... " << std::endl ;
        std::cerr.flush() ;

        while (global_timer.getSecond() <= 6)
        {
          float seconds = timer.getSecond() ;
          timer.reset() ;
          model->update(seconds) ;
        }
      }
      void TestModelControler::basicDestroy()
      {
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestModelControler::basicDestroy")) ;
        model->init() ;

        Kernel::Object* team1 = model->createObject() ;
        team1->addTrait(new Model::Team("team1")) ;
        Kernel::Object* team2 = model->createObject() ;
        team2->addTrait(new Model::Team("team2")) ;

        Kernel::Object* universe = model->createObject() ;
        universe->addTrait(new Model::Universe()) ;
        universe->addTrait(new Model::Positioned()) ;

        Kernel::Object* system = universe->createObject() ;
        system->addTrait(new Model::StellarSystem()) ;
        system->addTrait(new Model::Positioned()) ;

        Kernel::Object* observer = system->createObject() ;
        observer->addTrait(new Model::Observer()) ;
        observer->addTrait(new Model::Player()) ;
        observer->addTrait(new Model::Active()) ;
        observer->addTrait(new Model::Positioned(Model::Position::Meter(0,1000,0))) ;
        observer->addTrait(new Model::Oriented(Model::Orientation(::Ogre::Quaternion(::Ogre::Degree(-90),::Ogre::Vector3::UNIT_X)))) ;

        /*
        Situation seen from top :

        ------------------------
        |                      |
        | <--            -->   |
        | ship1          ship2 |
        |                      |
        ------------------------

        Objective of the the system : they must stay in the box
        (initial_distance+ship_size*4,ship_size*4,ship_size*4)
        */

        Kernel::ObjectReference ship1 ;
        {
          Kernel::Object* ship = Model::createShip(system) ;
          ship->getTrait<Model::Positioned>()->setPosition(Model::Position::Meter(-500,0,0)) ;
          ship->getTrait<Model::Oriented>()->setOrientation(Model::Orientation(Ogre::Quaternion(Ogre::Degree(90),Ogre::Vector3::UNIT_Y))) ;
          ship->addTrait(new Model::Transponder(team1)) ;
          ship->destroyTrait(ship->getTrait<Model::Destroyable>()) ;
          Kernel::Object* agent = Model::createAI(ship) ;
          agent->getTrait<Model::WithObjectives>()->addObjective(Model::Objective::attackAllEnemies()) ;
          ship1 = ship ;
        }

        Kernel::ObjectReference ship2 ;
        {
          Kernel::Object* ship = Model::createShip(system) ;
          ship->getTrait<Model::Positioned>()->setPosition(Model::Position::Meter(1000,0,0)) ;
          ship->getTrait<Model::Oriented>()->setOrientation(Model::Orientation(Ogre::Quaternion(Ogre::Degree(-90),Ogre::Vector3::UNIT_Y))) ;
          Kernel::Object* agent = Model::createAI(ship) ;
          agent->getTrait<Model::WithObjectives>()->addObjective(Model::Objective::attackAllEnemies()) ;
          ship->addTrait(new Model::Transponder(team2)) ;
          ship2 = ship ;
        }

        Kernel::Timer timer ;
        Kernel::Timer global_timer ;

        while (global_timer.getSecond() < 20)
        {
          float seconds = timer.getSecond() ;
          if (seconds > 0)
          {
            timer.reset() ;
            model->update(seconds) ;
          }
        }

        CPPUNIT_ASSERT(!ship2) ;
      }