示例#1
0
    it("should remove all listeners", function()
    {
      var serialPort = new EventEmitter();
      var spy = sinon.spy();

      serialPort.close = function() {};

      var conn = new SerialConnection(serialPort);

      conn.on('test', spy);

      conn.destroy();

      conn.emit('test', 'test');

      sinon.assert.notCalled(spy);
    });
示例#2
0
文件: movies.js 项目: sctskw/movieman
//DESTROY - remove an existing movie from the DB
function deleteMovie(req, res, next) {
  try {
    var id = req.params.id;
    var result = movies.destroy(id);

    if(!result) {
      throw new Error("MOVIE NOT DELETED");
    }

    //pass through to json response handler
    res.body = "deleted movie id " + id;
    next();

  } catch ( err ) {
    next(err);
  }
}
示例#3
0
    it("should emit empty topic for each distinct subscribed topic", function()
    {
      var mb = new MessageBroker();
      var expectedTopics = ['a', 'b', 'c'];
      var actualTopics = [];

      mb.on('empty topic', function(topic) { actualTopics.push(topic); });

      mb.subscribe('a');
      mb.subscribe('b');
      mb.subscribe('c');

      mb.destroy();

      expectedTopics.should.eql(actualTopics);
      mb.count().should.eql({});
    });
示例#4
0
function openCamera() {
Ti.API.debug("openCamera with mode = "+Ti.Platform.model);

	$.activityIndicator.text = "opening camera view...";
	$.activityIndicator.visible = true;
	
	if (Ti.Platform.model == 'Simulator') {
		acc.destroy();
		args.staticLocation = true;
		$.overlayContainer.hide();
		clearInterval(updateDisplayInterval);
		showSimulatorPois();
	}
	else {
		$.simulatorView.hide();

		var cameraTransform = Ti.UI.create2DMatrix();
		cameraTransform = cameraTransform.scale(1);
	
		Ti.Geolocation.addEventListener('heading', headingCallback);
		Ti.Geolocation.addEventListener('location', locationCallback);
		Ti.Media.showCamera({
			success : function(event) {
	//			$.win.fireEvent("cameraOpen");
			},
			cancel : function(event) {
				Ti.API.error('android user cancelled open ar view');
				cameraClosed();
			},
			error : function(error) {
				Ti.API.error('unable to open camera view');
				cameraClosed();
			},
			mediaTypes : [Ti.Media.MEDIA_TYPE_VIDEO],
			showControls : false,
			autohide : false,
			autofocus : "off",
			animated : false,
			overlay : $.overlayContainer,
			transform: cameraTransform
		});
	}
		
	$.win.fireEvent("cameraOpen");
}
示例#5
0
    it("should cancel all subscriptions", function()
    {
      var mb = new MessageBroker();
      var expectedSubs = [];
      var actualSubs = [];

      mb.on('cancel', function(sub) { actualSubs.push(sub); });

      expectedSubs.push(
        mb.subscribe('a'),
        mb.subscribe('b'),
        mb.subscribe('c')
      );

      mb.destroy();

      actualSubs.should.eql(expectedSubs);
      mb.count().should.eql({});
    });
示例#6
0
function cleanup() {

	clearInterval(updateDisplayInterval);
	acc.destroy();
    Ti.Geolocation.removeEventListener('heading', headingCallback);
	Ti.Geolocation.removeEventListener('location', locationCallback);
	
	$.activityIndicator.text = "closing camera view...";
	$.activityIndicator.visible = true;

    for (i=0, l=pois.length; i<l; i++) {
        var poi = pois[i];
        if (poi.view) {
            poi.view.removeEventListener('click', localPoiClick);
        }
    }

	$.destroy();
}
示例#7
0
    const queue = Object.keys(PACKAGES).map((path) => {
      const metadata = PACKAGES[path];
      const rpath = _path.resolve(ENV.ROOTDIR, metadata._src);
      const check = _path.join(rpath, 'api.js');
      if ( _fs.existsSync(check) ) {
        try {
          const mod = require(check);

          _logger.lognt('VERBOSE', 'Destroying:', _logger.colored('Package', 'bold'), check.replace(ENV.ROOTDIR, ''));
          if ( typeof mod.destroy === 'function' ) {
            const res = mod.destroy();
            return res instanceof Promise ? res : Promise.resolve();
          }
        } catch ( e ) {
          _logger.lognt('WARN', _logger.colored('Warning:', 'yellow'), e);
          console.warn(e.stack);
        }
      }

      return Promise.resolve();
    });
 async.eachSeries(results, (model, cb) => {
   // For a full description of behaviour see https://github.com/adaptlearning/adapt_authoring/pull/2277
   const sharedWithList = model._shareWithUsers;
   const isPartiallyShared = sharedWithList && sharedWithList.length;
   // Delete private courses if this option was set
   if (courseOption === 'delete' && !model._isShared && !isPartiallyShared) {
     courseContent.destroy({ _id: model._id }, false, cb);
     return;
   }
   // Transfer ownership of all courses to current user
   let update = { createdBy: currentUserId };
   // Remove the current user from the 'shared with' list if applicable
   if (isPartiallyShared) {
     update._shareWithUsers = sharedWithList.pull(currentUserId);
   }
   // Share private courses with everyone if this option was set
   if (courseOption === 'share') {
     update._isShared = true;
   }
   courseContent.update({ _id: model._id }, update, cb);
 }, done);
示例#9
0
		it('should get bean right', function(done) {
			var simplepath = require.resolve('../../examples/simple_destroy_method/context.json');
			var paths = [simplepath];

			var applicationContext = new ApplicationContext(paths);
			applicationContext.refresh();

			var car = applicationContext.getBean('car');
			var r = car.run();
			r.should.exist;
			r.should.eql('car');

			applicationContext.on('destroyed', function() {
				done();
			});

			applicationContext.destroy();

			var isActive = applicationContext.isActive();
			isActive.should.be.false;
		});
示例#10
0
文件: common.js 项目: NortySpock/dat
 function destroy() {
   dat.destroy(function(err) {
     if (err) throw err
     if (dat2) {
       dat2.destroy(function(err) {
         if (err) throw err
         cleanup()
       })
     } else cleanup()
 
     function cleanup() {
       common.destroyTmpDats(function() {
         if (opts.noTestEnd) {
           if (cb) return cb()
           return
         }
         t.end()
         if (cb) cb()
       })
     }
   })
 }
示例#11
0
It('Test multiple pools - kill a server and restart it - discovery: true', function* (done) {
    server1.cleanMockServersStatus();
    server2.cleanMockServersStatus();
    server3.cleanMockServersStatus();

    server1.mockServersStatus([server1, server2, server3])
    server2.mockServersStatus([server1, server2, server3])
    server3.mockServersStatus([server1, server2, server3])
    server1.mockServersStatus([server1, server2, server3])
    server2.mockServersStatus([server1, server2, server3])
    server3.mockServersStatus([server1, server2, server3])
    var r = require(__dirname+'/../lib')({
        servers: [
            {host: server1.host, port: server1.port},
            {host: server2.host, port: server2.port},
            {host: server3.host, port: server3.port}
        ],
        max: 10*3,
        buffer: 4*3,
        silent: true
    });
    try {
        yield util.sleep(100);
        var success = 0;
        var error = 0;
        for(var i=0; i<9; i++) {
            r.expr(100).run().then(function() {
                success++;
            }).error(function() {
                error++;
            });
        }
        server2.destroy();
        yield util.sleep(1000);
        // Attempt to fill the two remaining pools
        for(var i=0; i<30; i++) {
            r.expr(100).run().then(function() {
                success++;
            }).error(function() {
                error++;
            });
        }

        // Restart server2 since we killed it
        server2 = new Server({
            host: server2.host,
            port: server2.port 
        })

        yield util.sleep(2000);
        assert.equal(r.getPool(0).options.max, 10);
        assert.equal(r.getPool(1).options.max, 10);
        assert.equal(r.getPool(2).options.max, 10);
        assert.equal(r.getPool(0).options.buffer, 4);
        assert.equal(r.getPool(1).options.buffer, 4);
        assert.equal(r.getPool(2).options.buffer, 4);

        assert.equal(success, 6+30);
        assert.equal(error, 3);

        var p = []
        for(var i=0; i<40; i++) {
            p.push(r.expr(100).run());
        }
        var result =yield p;
        assert.equal(result.length, 40);
        yield util.sleep(1000); // yield to let the connection some time to close
        assert.equal(r.getPool(0).getLength(), 10);
        assert.equal(r.getPool(1).getLength(), 10);
        assert.equal(r.getPool(2).getLength(), 10);

        yield r.getPoolMaster().drain();
        done();
    }
    catch(e) {
        done(e);
    }
});
router.post('/destroy/confirm', (req, res, next) => {
    notes.destroy(req.body.notekey)
    .then(() => { res.redirect('/'); })
    .catch(err => { next(err); });
});
示例#13
0
 deleteOne: function(query) {
   return sessionModel.destroy({where: query});
 },
示例#14
0
文件: dal.js 项目: EssenceAPI/hallway
    destroy: function (client) {
      logger.debug("Cleaning up a DB connection");

      if (backendModule.destroy) backendModule.destroy(client);
    },
 afterEach(function(done){
     Application.destroy();
     Application.once(Application.DESTROYED, function(){ done(); });
 });
示例#16
0
文件: index.js 项目: pringles49/OS.js
 process.on('exit', () => {
   instance.destroy();
 });
 function __destroy()
 {
     try
     {
         var moduleMainFile = self.downloadedModuleMainFileCache[moduleName];
         if (moduleMainFile)
         {
             var module = require(moduleMainFile);
             if (module && _.isFunction(module.destroy))
             {
                 // NOTE(ovaussy - 9/26/13): If the destroy function doesn't call our call back then the module will never be evicted.
                 module.destroy(function (err)
                                {
                                    if (err)
                                    {
                                        logger.warn("[dynamic-module-loader] An error occurred while destroying the module, the eviction will go on", err);
                                    }
                                    else
                                    {
                                        self.emit(self.events.moduleDestroyed, moduleName);
                                    }
                                    __evict();
                                });
             }
             else
             {
                 __evict();
             }
         }
         else
         {
             __evict();
         }
     }
     catch (e)
     {
         logger.warn("[dynamic-module-loader] An error occurred while destroying the module, the eviction will go on", e);
         __evict();
     }
 }
示例#18
0
router.post('/destroy/confirm', usersRouter.ensureAuthenticated, (req, res, next) => {
  books.destroy(req.body.bookkey)
  .then(() => { res.redirect('/'); })
  .catch(err => { next(err); });
});
示例#19
0
 destroy: function() {
   app.destroy();
   var observerService = Cc["@mozilla.org/observer-service;1"]
       .getService(Components.interfaces.nsIObserverService);
   observerService.notifyObservers(null, "startupcache-invalidate", null);
 },
示例#20
0
文件: index.js 项目: pringles49/OS.js
 process.on(sig, () => {
   console.log('\n');
   instance.destroy((err) => {
     process.exit(err ? 1 : 0);
   });
 });
示例#21
0
 var todel = keyz.map(key => model.destroy(key)); 
 it('should delete a difficulty', function () {
   var level = 'casual';
   model.destroy(level).then(function () {
     expect(stub.remove.calledWith({ label: level })).to.be.true;
   });
 });