Пример #1
0
func TestGetUsePut(t *testing.T) {
	cr := New("tcp", serverAddress)
	conn, err := cr.Get(resourcepool.MakeImmediateCanceler(), 0)
	if err != nil {
		t.Error(err)
		return
	}
	conn.LocalAddr()
	conn.Put()
}
Пример #2
0
func TestGetCallPut(t *testing.T) {
	cr := New("tcp", serverAddress, true, "")
	client, err := cr.Get(resourcepool.MakeImmediateCanceler())
	if err != nil {
		t.Error(err)
		return
	}
	var request, reply int
	client.Call("Service.Method", request, &reply)
	client.Put()
}
Пример #3
0
func TestGetClosePut(t *testing.T) {
	cr := New("tcp", serverAddress, true, "")
	client, err := cr.Get(resourcepool.MakeImmediateCanceler())
	if err != nil {
		t.Error(err)
		return
	}
	if err := client.Close(); err != nil {
		t.Error(err)
	}
	client.Put()
}
Пример #4
0
func TestGetPutPut(t *testing.T) {
	cr := New("tcp", serverAddress, true, "")
	client, err := cr.Get(resourcepool.MakeImmediateCanceler())
	if err != nil {
		t.Error(err)
		return
	}
	client.Put()
	defer func() {
		if err := recover(); err == nil {
			t.Errorf("Multiple Put() did not panic")
		}
	}()
	client.Put()
}
Пример #5
0
func TestUseAfterClose(t *testing.T) {
	cr := New("tcp", serverAddress)
	conn, err := cr.Get(resourcepool.MakeImmediateCanceler(), 0)
	if err != nil {
		t.Error(err)
		return
	}
	conn.Close()
	defer func() {
		if err := recover(); err == nil {
			t.Errorf("Use after Close() did not panic")
		}
	}()
	conn.LocalAddr()
}
Пример #6
0
func TestCallAfterClose(t *testing.T) {
	cr := New("tcp", serverAddress, true, "")
	client, err := cr.Get(resourcepool.MakeImmediateCanceler())
	if err != nil {
		t.Error(err)
		return
	}
	client.Close()
	defer func() {
		if err := recover(); err == nil {
			t.Errorf("Call() after Close() did not panic")
		}
	}()
	var request, reply int
	err = client.Call("Service.Method", request, &reply)
	t.Error(err)
}