spec/misc_spec.rb in game_machine-0.0.11 vs spec/misc_spec.rb in game_machine-1.0.2

- old
+ new

@@ -1,6 +1,9 @@ require 'spec_helper' +require 'benchmark' +require "net/http" +require "uri" require 'jruby/core_ext' module GameMachine describe "misc" do let(:entity) do @@ -9,9 +12,117 @@ player = MessageLib::Player.new player.authtoken = 'authorized' player.id = '2' entity.player = player entity + end + + it "ebean test" do + config = AppConfig.instance.config + pool = GameMachine::JavaLib::DbConnectionPool.getInstance + pool.connect( + 'test', + config.jdbc.hostname, + config.jdbc.port, + config.jdbc.database, + config.jdbc.ds, + config.jdbc.username, + config.jdbc.password || '' + ) + BeanLib::TestModel.set_ds + BeanLib::TestModel.test + end + + xit "authorizes with cloudclient" do + url = "http://localhost:9000/client/login/test" + uri = URI.parse(url) + + response = Net::HTTP.post_form(uri, {'username' => 'chris', 'password' => 'pass'}) + puts response.inspect + puts response.body + + end + + xit "serialized to json" do + entity = MessageLib::Entity.new.set_id('player') + puts entity.to_json + end + + xit "couch http client" do + entity = MessageLib::Entity.new.set_id('3') + client = JavaLib::Couchclient.get_instance + 10.times do |i| + id = "TESTING#{i}" + response = client.put(id,entity.to_byte_array) + puts response.status + #puts response.body + + response = client.get(id) + puts response.status + if response.status == 200 + puts MessageLib::Entity.parse_from(response.body) + end + + + response = client.delete(id) + puts response.status + #puts response.body + end + end + + xit "msyql ogbject store stress" do + GameMachine::Application.orm_connect + ds = Commands::DatastoreCommands.new + count = 0 + puts Benchmark.realtime { + 10000.times do + entity.id = count.to_s + entity.db_put + count += 1 + sleep 0.002 + end + } + end + + xit "finds model" do + GameMachine::Application.orm_connect + MessageLib::TestObject.delete_async('player1') + if message = MessageLib::TestObject.find_by_player_id("player1") + message.set_fvalue(1.9) + message.save_async('player1') + else + message = MessageLib::TestObject.new + message.set_required_string('testing') + message.set_fvalue(1.9) + message.set_bvalue(true) + message.set_dvalue(3.4) + message.set_numbers64(555) + message.save_async('player1') + end + + sleep 2 + end + + xit "trackdata test" do + neighbors = MessageLib::Neighbors.new + trackdata = MessageLib::TrackData.new + trackdata.x = 100.0 + trackdata.y = 100.0 + trackdata.z = 100.0 + 200.times do + neighbors.add_track_data(trackdata) + end + + tracktest = MessageLib::TrackTest.new + 200.times do + tracktest.add_x(100.0) + tracktest.add_y(100.0) + tracktest.add_z(100.0) + end + 100000000.times do + tracktest.to_byte_array + #neighbors.to_byte_array + end end xit "singleton manager" do ref = Akka.instance.actor_system.actor_selection('/user/region_manager_proxy') ref.tell('HELLO',nil)