Skip to content

Commit 3a7f065

Browse files
committed
core: add unit test ResponseTest
Prior to this fix ``` java.lang.IllegalArgumentException: Class com.cloud.agent.api.CheckS2SVpnConnectionsAnswer declares multiple JSON fields named 'details'; conflict is caused by fields com.cloud.agent.api.CheckS2SVpnConnectionsAnswer#details and com.cloud.agent.api.Answer#details at com.cloud.agent.transport.ResponseTest.testCheckS2SVpnConnectionsAnswer(ResponseTest.java:42) ```
1 parent a3c44b3 commit 3a7f065

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

core/src/main/java/com/cloud/agent/api/CheckS2SVpnConnectionsAnswer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
public class CheckS2SVpnConnectionsAnswer extends Answer {
2626
Map<String, Boolean> ipToConnected;
2727
Map<String, String> ipToDetail;
28-
String details;
2928

3029
protected CheckS2SVpnConnectionsAnswer() {
3130
ipToConnected = new HashMap<String, Boolean>();
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package com.cloud.agent.transport;
21+
22+
import junit.framework.TestCase;
23+
24+
import org.apache.logging.log4j.Logger;
25+
import org.apache.logging.log4j.LogManager;
26+
import org.junit.Assert;
27+
import com.cloud.agent.api.Answer;
28+
import com.cloud.agent.api.CheckS2SVpnConnectionsAnswer;
29+
30+
import com.cloud.agent.transport.Request.Version;
31+
32+
public class ResponseTest extends TestCase {
33+
protected Logger logger = LogManager.getLogger(getClass());
34+
35+
public void testCheckS2SVpnConnectionsAnswer() {
36+
logger.info("Testing CheckS2SVpnConnectionsAnswer");
37+
String content = "[{\"com.cloud.agent.api.CheckS2SVpnConnectionsAnswer\":{\"ipToConnected\":{\"10.0.53.13\":true}," +
38+
"\"ipToDetail\":{\"10.0.53.13\":\"IPsec SA found;Site-to-site VPN have connected\"}," +
39+
"\"details\":\"10.0.53.13:0:IPsec SA found;Site-to-site VPN have connected\\u0026\\n\"," +
40+
"\"result\":true,\"contextMap\":{},\"wait\":0,\"bypassHostMaintenance\":false}}]";
41+
Response response = new Response(Version.v2, 1L, 2L, 3L, 1L, (short)1, content);
42+
Answer answer = response.getAnswer();
43+
Assert.assertTrue(answer instanceof CheckS2SVpnConnectionsAnswer);
44+
}
45+
46+
}

0 commit comments

Comments
 (0)