예제 #1
0
func setUpServer() (*server.Server, store.ObjectStore) {
	log.Println("Setting up test store and test server")
	teststore := store.NewMapStore()
	testserver := server.NewServer(teststore)
	testserver.Init()
	return testserver, teststore
}
예제 #2
0
func main() {
	st := store.NewMapStore()
	s := server.NewServer(st)
	s.Init()
	s.AddResponder(impl.NewOrderAPIResponder(st))
	s.AddResponder(impl.NewInventoryRequestResponder(st))
	s.Open(address)
}
예제 #3
0
func TestServerDelete(t *testing.T) {
	s := NewServer(store.NewMapStore())
	s.Init()
	s.AddResponder(&Deleter{})
	defer s.Close()

	a := makeAddress(ADDR, PORT+3)

	go s.Open(a)

	DoDelete(t, a, "/obj", 200)

	t.Log("Done")

}
예제 #4
0
func TestServerPut(t *testing.T) {
	s := NewServer(store.NewMapStore())
	s.Init()
	s.AddResponder(&Looper{})
	defer s.Close()

	a := makeAddress(ADDR, PORT+2)
	go s.Open(a)

	DoPut(t, a, "/loop", "test", "application/text", 200, "test",
		func(r string, v string) bool {
			if r != v {
				t.Fail()
				t.Logf("Failed.  Expected %s got %s", r, v)
				return false
			}
			return true
		})

	t.Log("Done")

}
예제 #5
0
func TestServerGet(t *testing.T) {
	s := NewServer(store.NewMapStore())
	s.Init()
	s.AddResponder(&Messager{})
	defer s.Close()

	a := makeAddress(ADDR, PORT+4)
	go s.Open(a)

	time.Sleep(time.Duration(1) * time.Second)
	t.Log("Sending GET")
	DoGet(t, a, "/msg/", 200, MSG,
		func(r string, v string) bool {
			if r != v {
				t.Fail()
				t.Logf("Failed.  Expected %s got %s", r, v)
				return false
			}
			return true
		})

	t.Log("Done")
}