-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #707 from goldmansachs/xml-security
Improve test coverage
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
dmn-core/src/test/java/com/gs/dmn/serialization/jackson/NSElementDeserializerTest.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,46 @@ | ||
/* | ||
* Copyright 2016 Goldman Sachs. | ||
* | ||
* Licensed 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 com.gs.dmn.serialization.jackson; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.cfg.DeserializerFactoryConfig; | ||
import com.fasterxml.jackson.databind.deser.BeanDeserializerFactory; | ||
import com.fasterxml.jackson.databind.deser.DefaultDeserializationContext; | ||
import com.fasterxml.jackson.databind.deser.DeserializerFactory; | ||
import com.fasterxml.jackson.databind.node.TextNode; | ||
import com.fasterxml.jackson.databind.node.TreeTraversingParser; | ||
import com.gs.dmn.serialization.xstream.dom.NSElement; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
class NSElementDeserializerTest { | ||
private final NSElementDeserializer deserializer = new NSElementDeserializer(); | ||
|
||
@Test | ||
void testDeserialize() throws IOException { | ||
JsonNode node = new TextNode("text"); | ||
JsonParser parser = new TreeTraversingParser(node); | ||
parser.setCodec(new ObjectMapper()); | ||
DeserializerFactoryConfig config = new DeserializerFactoryConfig(); | ||
DeserializerFactory df = new BeanDeserializerFactory(config); | ||
DeserializationContext context = new DefaultDeserializationContext.Impl(df); | ||
NSElement deserialize = deserializer.deserialize(parser, context); | ||
assertNotNull(deserialize); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
dmn-core/src/test/java/com/gs/dmn/serialization/jackson/NSElementSerializerTest.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,40 @@ | ||
/* | ||
* Copyright 2016 Goldman Sachs. | ||
* | ||
* Licensed 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 com.gs.dmn.serialization.jackson; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.core.ObjectCodec; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider; | ||
import com.fasterxml.jackson.databind.util.TokenBuffer; | ||
import com.gs.dmn.serialization.xstream.dom.NSElement; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
public class NSElementSerializerTest { | ||
private final NSElementSerializer serializer = new NSElementSerializer(); | ||
|
||
@Test | ||
public void testSerialize() throws IOException { | ||
NSElement element = new NSElement(null, "prefix", "namespace"); | ||
ObjectCodec codec = new ObjectMapper(); | ||
JsonGenerator generator = new TokenBuffer(codec, false); | ||
SerializerProvider serializers = new DefaultSerializerProvider.Impl(); | ||
serializer.serialize(element, generator, serializers); | ||
assertTrue(true); | ||
} | ||
} |