-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmethod_test.go
60 lines (45 loc) · 974 Bytes
/
method_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package gop
import (
"fmt"
"reflect"
"testing"
)
type Aspect struct{}
func (a *Aspect) Before(point *JoinPoint) bool {
fmt.Println("before")
return true
}
func (a *Aspect) After(point *JoinPoint) {
fmt.Println("after")
}
func (a *Aspect) Finally(point *JoinPoint) {
fmt.Println("finally")
}
func (a *Aspect) GetAspectExpress() string {
return ".*\\.HelloAop"
}
type Aspect1 struct{}
func (a *Aspect1) Before(point *JoinPoint) bool {
fmt.Println("before1")
return true
}
func (a *Aspect1) After(point *JoinPoint) {
fmt.Println("after1")
}
func (a *Aspect1) Finally(point *JoinPoint) {
fmt.Println("finally1")
}
func (a *Aspect1) GetAspectExpress() string {
return ".*"
}
type HelloAop struct {
}
func (h *HelloAop) HelloAop() {
fmt.Println("helloAop")
}
func TestRegisterMethodPoint(t *testing.T) {
RegisterAspect([]AspectInterface{&Aspect1{}, &Aspect{}})
RegisterMethodPoint(reflect.TypeOf((*HelloAop)(nil)))
h := &HelloAop{}
h.HelloAop()
}