Skip to content

Commit db9229c

Browse files
authored
Merge branch 'master' into feat-peak-ewma
2 parents 4f2266c + 07aa062 commit db9229c

26 files changed

Lines changed: 639 additions & 31 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ jobs:
4040
os: ubuntu-latest
4141
- java: 17
4242
os: ubuntu-latest
43+
- java: 18
44+
os: ubuntu-latest
45+
- java: 19
46+
os: ubuntu-latest
47+
- java: 20
48+
os: ubuntu-latest
49+
- java: 21
50+
os: ubuntu-latest
4351
runs-on: ${{ matrix.os }}
4452
if: (github.repository == 'apache/shenyu')
4553
steps:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
<javatuples.version>1.2</javatuples.version>
160160
<k8s-client.version>17.0.2</k8s-client.version>
161161
<polaris.version>1.13.0</polaris.version>
162-
<bytebuddy.version>1.12.6</bytebuddy.version>
162+
<bytebuddy.version>1.14.11</bytebuddy.version>
163163
<spring-ldap.version>2.3.4.RELEASE</spring-ldap.version>
164164
<jaxb.api.version>2.3.1</jaxb.api.version>
165165
<mail.version>1.6.2</mail.version>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.shenyu.client.core.disruptor.subcriber;
19+
20+
import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository;
21+
import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO;
22+
import org.apache.shenyu.register.common.type.DataType;
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Test;
25+
26+
import java.util.ArrayList;
27+
import java.util.Collection;
28+
29+
import static org.junit.jupiter.api.Assertions.assertEquals;
30+
import static org.mockito.Mockito.mock;
31+
import static org.mockito.Mockito.verify;
32+
import static org.mockito.Mockito.never;
33+
import static org.mockito.Mockito.any;
34+
import static org.mockito.Mockito.times;
35+
36+
/**
37+
* Test for {@link ShenyuClientMetadataExecutorSubscriber}.
38+
*/
39+
public class ShenyuClientMetadataExecutorSubscriberTest {
40+
41+
private ShenyuClientRegisterRepository shenyuClientRegisterRepository;
42+
43+
private ShenyuClientMetadataExecutorSubscriber executorSubscriber;
44+
45+
@BeforeEach
46+
public void setUp() {
47+
shenyuClientRegisterRepository = mock(ShenyuClientRegisterRepository.class);
48+
executorSubscriber = new ShenyuClientMetadataExecutorSubscriber(shenyuClientRegisterRepository);
49+
}
50+
51+
@Test
52+
public void testGetType() {
53+
DataType expected = DataType.META_DATA;
54+
DataType actual = executorSubscriber.getType();
55+
assertEquals(expected, actual);
56+
}
57+
58+
@Test
59+
public void testExecutorWithEmptyData() {
60+
Collection<MetaDataRegisterDTO> metaDataRegisterDTOList = new ArrayList<>();
61+
executorSubscriber.executor(metaDataRegisterDTOList);
62+
63+
verify(shenyuClientRegisterRepository, never()).persistInterface(any());
64+
}
65+
66+
@Test
67+
public void testExecutorValidData() {
68+
Collection<MetaDataRegisterDTO> metaList = new ArrayList<>();
69+
70+
MetaDataRegisterDTO metaDataRegisterDTO =
71+
MetaDataRegisterDTO.builder().contextPath("/test").path("/meta").pathDesc("application/json")
72+
.rpcType("http")
73+
.serviceName("UserService")
74+
.methodName("getUserInfo")
75+
.ruleName("AuthorizationRule")
76+
.parameterTypes("String, int")
77+
.rpcExt("test")
78+
.enabled(true)
79+
.host("localhost")
80+
.port(8080)
81+
.pluginNames(new ArrayList<>())
82+
.build();
83+
metaList.add(metaDataRegisterDTO);
84+
85+
executorSubscriber.executor(metaList);
86+
87+
verify(shenyuClientRegisterRepository, times(1)).persistInterface(metaDataRegisterDTO);
88+
}
89+
90+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.shenyu.client.grpc;
19+
20+
/**
21+
* name request message.
22+
*/
23+
public class TestRequest {
24+
private final String name;
25+
26+
public TestRequest(final String name) {
27+
this.name = name;
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.shenyu.client.grpc;
19+
20+
/**
21+
* name response message.
22+
*/
23+
public class TestResponse {
24+
private final String name;
25+
26+
public TestResponse(final String name) {
27+
this.name = name;
28+
}
29+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.shenyu.client.grpc.json;
19+
20+
import org.apache.shenyu.client.grpc.TestRequest;
21+
import org.apache.shenyu.client.grpc.TestResponse;
22+
import org.junit.jupiter.api.Test;
23+
24+
import static org.mockito.Mockito.mock;
25+
26+
public class JsonForwardingServerCallTest {
27+
private final JsonForwardingServerCall<TestRequest, TestResponse> testJsonForwardingServerCall = mock(JsonForwardingServerCall.class);
28+
29+
@Test
30+
public void sentMsgTest() {
31+
testJsonForwardingServerCall.sendMessage(new TestResponse("test-response"));
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.shenyu.client.grpc.json;
19+
20+
import org.apache.shenyu.client.grpc.TestRequest;
21+
import org.apache.shenyu.client.grpc.TestResponse;
22+
import org.junit.jupiter.api.Test;
23+
24+
import static org.mockito.Mockito.mock;
25+
26+
public class JsonServerCallListenerTest {
27+
private final JsonServerCallListener<TestRequest, TestResponse> testJsonServerCallListener = mock(JsonServerCallListener.class);
28+
29+
@Test
30+
public void testOnMessage() {
31+
testJsonServerCallListener.onMessage(new TestRequest("test-on-message"));
32+
}
33+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.shenyu.client.grpc.json;
19+
20+
public class JsonServerServiceInterceptorTest {
21+
22+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.shenyu.client.grpc.server;
19+
20+
import io.grpc.ServerBuilder;
21+
import org.apache.shenyu.client.grpc.GrpcClientEventListener;
22+
import org.junit.jupiter.api.Test;
23+
import org.springframework.context.event.ContextRefreshedEvent;
24+
25+
import static org.mockito.Mockito.mock;
26+
27+
public class GrpcServerRunnerTest {
28+
private final ContextRefreshedEvent testEvent = mock(ContextRefreshedEvent.class);
29+
30+
private final GrpcClientEventListener testGrpcClientEventListener = mock(GrpcClientEventListener.class);
31+
32+
@Test
33+
public void testOnApplicationEvent() {
34+
GrpcServerBuilder testGrpcServerBuilder = () -> ServerBuilder.forPort(8088);
35+
36+
GrpcServerRunner testGrpcServerRunner = new GrpcServerRunner(testGrpcServerBuilder, testGrpcClientEventListener);
37+
38+
testGrpcServerRunner.onApplicationEvent(testEvent);
39+
}
40+
}

shenyu-plugin/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
<modules>
3030
<module>shenyu-plugin-api</module>
31+
<module>shenyu-plugin-wasm-api</module>
3132
<module>shenyu-plugin-base</module>
3233
<module>shenyu-plugin-wasm-base</module>
3334
<module>shenyu-plugin-httpclient</module>

0 commit comments

Comments
 (0)