-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SCB-933]Revert changes to RestObjectMapper that fail on primitive ty…
…pes not present
- Loading branch information
Showing
11 changed files
with
355 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...tion-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/RequestBaseModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.servicecomb.it.schema; | ||
|
||
public class RequestBaseModel { | ||
private int type; | ||
|
||
private Integer integerType; | ||
|
||
private String message; | ||
|
||
public int getType() { | ||
return type; | ||
} | ||
|
||
public void setType(int type) { | ||
this.type = type; | ||
} | ||
|
||
public Integer getIntegerType() { | ||
return integerType; | ||
} | ||
|
||
public void setIntegerType(Integer integerType) { | ||
this.integerType = integerType; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
integration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/RequestModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.servicecomb.it.schema; | ||
|
||
public class RequestModel extends RequestBaseModel { | ||
private int catalog; | ||
|
||
private Integer integerCatalog; | ||
|
||
private String extendedMessage; | ||
|
||
public int getCatalog() { | ||
return catalog; | ||
} | ||
|
||
public void setCatalog(int catalog) { | ||
this.catalog = catalog; | ||
} | ||
|
||
public Integer getIntegerCatalog() { | ||
return integerCatalog; | ||
} | ||
|
||
public void setIntegerCatalog(Integer integerCatalog) { | ||
this.integerCatalog = integerCatalog; | ||
} | ||
|
||
public String getExtendedMessage() { | ||
return extendedMessage; | ||
} | ||
|
||
public void setExtendedMessage(String extendedMessage) { | ||
this.extendedMessage = extendedMessage; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...ion-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/ResponseBaseModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.servicecomb.it.schema; | ||
|
||
public class ResponseBaseModel { | ||
private int type; | ||
|
||
private Integer integerType; | ||
|
||
private String message; | ||
|
||
public int getType() { | ||
return type; | ||
} | ||
|
||
public void setType(int type) { | ||
this.type = type; | ||
} | ||
|
||
public Integer getIntegerType() { | ||
return integerType; | ||
} | ||
|
||
public void setIntegerType(Integer integerType) { | ||
this.integerType = integerType; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...gration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/ResponseModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.servicecomb.it.schema; | ||
|
||
public class ResponseModel extends ResponseBaseModel { | ||
private int catalog; | ||
|
||
private Integer integerCatalog; | ||
|
||
private String extendedMessage; | ||
|
||
public int getCatalog() { | ||
return catalog; | ||
} | ||
|
||
public void setCatalog(int catalog) { | ||
this.catalog = catalog; | ||
} | ||
|
||
public Integer getIntegerCatalog() { | ||
return integerCatalog; | ||
} | ||
|
||
public void setIntegerCatalog(Integer integerCatalog) { | ||
this.integerCatalog = integerCatalog; | ||
} | ||
|
||
public String getExtendedMessage() { | ||
return extendedMessage; | ||
} | ||
|
||
public void setExtendedMessage(String extendedMessage) { | ||
this.extendedMessage = extendedMessage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...umer/src/main/java/org/apache/servicecomb/it/testcase/TestRequestBodySpringMvcSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.servicecomb.it.testcase; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.apache.servicecomb.it.extend.engine.GateRestTemplate; | ||
import org.apache.servicecomb.it.junit.ITJUnitUtils; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
public class TestRequestBodySpringMvcSchema { | ||
private static RestTemplate edgeClient; | ||
|
||
private static String producerName; | ||
|
||
@Before | ||
public void prepare() { | ||
if (!ITJUnitUtils.getProducerName().equals(producerName)) { | ||
producerName = ITJUnitUtils.getProducerName(); | ||
edgeClient = new GateRestTemplate("it-edge", producerName, "requestBodySpringMvcSchema"); | ||
} | ||
} | ||
|
||
@Test | ||
public void basicRequestResponse() { | ||
basicRequestResponseImpl(); | ||
basicRequestResponseImpl(); | ||
basicRequestResponseImpl(); | ||
} | ||
|
||
@Test | ||
public void testDefaultForPremitive() { | ||
testDefaultForPremitiveImpl(); | ||
testDefaultForPremitiveImpl(); | ||
testDefaultForPremitiveImpl(); | ||
} | ||
|
||
private void testDefaultForPremitiveImpl() { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setContentType(MediaType.APPLICATION_JSON); | ||
Map<String, Object> request = new HashMap<>(); | ||
request.put("integerType", 100); | ||
request.put("message", "hi"); | ||
request.put("catalog", 100); | ||
request.put("extendedMessage", "hi"); | ||
|
||
HttpEntity<Map<String, Object>> entity = new HttpEntity<>(request, headers); | ||
Map result = | ||
edgeClient.postForObject("/base", entity, Map.class); | ||
Assert.assertEquals(result.size(), 6); | ||
Assert.assertEquals(result.get("type"), 0); | ||
Assert.assertEquals(result.get("integerType"), request.get("integerType")); | ||
Assert.assertEquals(result.get("message"), request.get("message")); | ||
Assert.assertEquals(result.get("catalog"), request.get("catalog")); | ||
Assert.assertEquals(result.get("integerCatalog"), null); | ||
Assert.assertEquals(result.get("extendedMessage"), request.get("extendedMessage")); | ||
} | ||
|
||
private void basicRequestResponseImpl() { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setContentType(MediaType.APPLICATION_JSON); | ||
Map<String, Object> request = new HashMap<>(); | ||
request.put("type", 100); | ||
request.put("integerType", 100); | ||
request.put("message", "hi"); | ||
request.put("catalog", 100); | ||
request.put("integerCatalog", 100); | ||
request.put("extendedMessage", "hi"); | ||
|
||
HttpEntity<Map<String, Object>> entity = new HttpEntity<>(request, headers); | ||
Map result = | ||
edgeClient.postForObject("/base", entity, Map.class); | ||
Assert.assertEquals(result.size(), request.size()); | ||
Assert.assertEquals(result.get("type"), request.get("type")); | ||
Assert.assertEquals(result.get("integerType"), request.get("integerType")); | ||
Assert.assertEquals(result.get("message"), request.get("message")); | ||
Assert.assertEquals(result.get("catalog"), request.get("catalog")); | ||
Assert.assertEquals(result.get("integerCatalog"), request.get("integerCatalog")); | ||
Assert.assertEquals(result.get("extendedMessage"), request.get("extendedMessage")); | ||
} | ||
} |
Oops, something went wrong.