Search in sources :

Example 11 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project jvm-serializers by eishay.

the class JacksonCBORDatabind method register.

public static void register(TestGroups groups, boolean sharedNames, boolean sharedValues) {
    CBORFactory factory = new CBORFactory();
    // no point in using enum names with binary format, so:
    ObjectMapper mapper = new ObjectMapper(factory);
    groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind<MediaContent>("cbor/jackson/databind", MediaContent.class, mapper), new SerFeatures(SerFormat.BIN_CROSSLANG, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, ""));
    groups.media.add(JavaBuiltIn.mediaTransformer, new JacksonJsonManual("cbor/jackson/manual", factory), new SerFeatures(SerFormat.BIN_CROSSLANG, SerGraph.FLAT_TREE, SerClass.MANUAL_OPT, ""));
}
Also used : MediaContent(data.media.MediaContent) SerFeatures(serializers.SerFeatures) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 12 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project jvm-serializers by eishay.

the class JacksonSmileDatabind method register.

public static void register(TestGroups groups, boolean sharedNames, boolean sharedValues) {
    SmileFactory factory = new SmileFactory();
    factory.configure(SmileGenerator.Feature.CHECK_SHARED_NAMES, sharedNames);
    factory.configure(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES, sharedValues);
    // no point in using enum names with binary format, so:
    ObjectMapper mapper = new ObjectMapper(factory);
    mapper.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX);
    groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind<MediaContent>("smile/jackson/databind", MediaContent.class, mapper), new SerFeatures(SerFormat.BINARY, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, ""));
}
Also used : MediaContent(data.media.MediaContent) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 13 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project jvm-serializers by eishay.

the class JacksonWithAfterburner method registerCBOR.

public static void registerCBOR(TestGroups groups) {
    ObjectMapper mapper = new ObjectMapper(new CBORFactory());
    mapper.registerModule(new AfterburnerModule());
    groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind<MediaContent>("cbor/jackson+afterburner/databind", MediaContent.class, mapper), new SerFeatures(SerFormat.BINARY, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, STD_DESC));
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) CBORFactory(com.fasterxml.jackson.dataformat.cbor.CBORFactory) MediaContent(data.media.MediaContent) SerFeatures(serializers.SerFeatures) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 14 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.

the class AndroidBinaryIntegrationTest method testReDexIsCalledAppropriatelyFromAndroidBinary.

@Test
public void testReDexIsCalledAppropriatelyFromAndroidBinary() throws IOException {
    Path apk = workspace.buildAndReturnOutput(APP_REDEX_TARGET);
    Path unzippedApk = unzip(apk.getParent(), apk, "app_redex");
    // We use a fake ReDex binary that writes out the arguments it received as JSON so that we can
    // verify that it was called in the right way.
    ObjectMapper mapper = ObjectMappers.newDefaultInstance();
    @SuppressWarnings("unchecked") Map<String, Object> userData = mapper.readValue(unzippedApk.toFile(), Map.class);
    String androidSdk = (String) userData.get("ANDROID_SDK");
    assertTrue("ANDROID_SDK environment variable must be set so ReDex runs with zipalign", androidSdk != null && !androidSdk.isEmpty());
    assertEquals(workspace.getDestPath().toString(), userData.get("PWD"));
    assertTrue(userData.get("config").toString().endsWith("apps/sample/redex-config.json"));
    assertEquals("buck-out/gen/apps/sample/app_redex/proguard/seeds.txt", userData.get("keep"));
    assertEquals("my_alias", userData.get("keyalias"));
    assertEquals("android", userData.get("keypass"));
    assertEquals(workspace.resolve("keystores/debug.keystore").toString(), userData.get("keystore"));
    assertEquals("buck-out/gen/apps/sample/app_redex.apk.redex", userData.get("out"));
    assertEquals("buck-out/gen/apps/sample/app_redex/proguard/command-line.txt", userData.get("P"));
    assertEquals("buck-out/gen/apps/sample/app_redex/proguard/mapping.txt", userData.get("proguard-map"));
    assertTrue((Boolean) userData.get("sign"));
    assertEquals("my_param_name={\"foo\": true}", userData.get("J"));
    assertTrue("redex_extra_args: -j $(location ...) is not properly expanded!", userData.get("j").toString().endsWith(".jar"));
    assertTrue("redex_extra_args: -S $(location ...) is not properly expanded!", userData.get("S").toString().endsWith(".jar"));
}
Also used : Path(java.nio.file.Path) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 15 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.

the class DexProducedFromJavaLibraryThatContainsClassFilesTest method getOutputDoesNotAccessWrappedJavaLibrary.

@Test
public void getOutputDoesNotAccessWrappedJavaLibrary() throws Exception {
    BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    JavaLibrary javaLibrary = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:lib")).build(ruleResolver);
    BuildRuleParams params = new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//:target")).build();
    DexProducedFromJavaLibrary dexProducedFromJavaLibrary = new DexProducedFromJavaLibrary(params, javaLibrary);
    ObjectMapper mapper = ObjectMappers.newDefaultInstance();
    FakeOnDiskBuildInfo onDiskBuildInfo = new FakeOnDiskBuildInfo().putMetadata(DexProducedFromJavaLibrary.WEIGHT_ESTIMATE, "0").putMetadata(DexProducedFromJavaLibrary.CLASSNAMES_TO_HASHES, mapper.writeValueAsString(ImmutableMap.<String, String>of()));
    initialize(dexProducedFromJavaLibrary, onDiskBuildInfo);
    assertFalse(dexProducedFromJavaLibrary.hasOutput());
}
Also used : JavaLibrary(com.facebook.buck.jvm.java.JavaLibrary) DefaultJavaLibrary(com.facebook.buck.jvm.java.DefaultJavaLibrary) FakeJavaLibrary(com.facebook.buck.jvm.java.FakeJavaLibrary) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) FakeOnDiskBuildInfo(com.facebook.buck.rules.FakeOnDiskBuildInfo) FakeBuildRuleParamsBuilder(com.facebook.buck.rules.FakeBuildRuleParamsBuilder) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5262 Test (org.junit.Test)1989 IOException (java.io.IOException)837 JsonNode (com.fasterxml.jackson.databind.JsonNode)724 HashMap (java.util.HashMap)375 Map (java.util.Map)367 ArrayList (java.util.ArrayList)346 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)318 File (java.io.File)282 List (java.util.List)222 Test (org.junit.jupiter.api.Test)205 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)202 Before (org.junit.Before)202 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)197 InputStream (java.io.InputStream)143 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)137 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)127 Matchers.containsString (org.hamcrest.Matchers.containsString)127 TypeReference (com.fasterxml.jackson.core.type.TypeReference)108 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)99