Skip to content

Commit

Permalink
Merge branch '2.18' into 2.19
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 5, 2024
2 parents 61b27fd + 5c2bd50 commit 18a6349
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.fasterxml.jackson.module.jaxb.failing;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.*;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.jaxb.BaseJaxbTest;

public class TestEnums256 extends BaseJaxbTest
{
// [modules-base#256]
@XmlRootElement(name = "document")
@XmlAccessorType(XmlAccessType.FIELD)
public static class Document256 {

@XmlElement(name = "code")
private final Code _code;

public Document256(Code code) { _code = code; }

public Code getCode() {
return _code;
}
}

@XmlEnum
@XmlType(name = "CodeType")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
public enum Code {
@XmlEnumValue("RED")
RED;
}

/*
/**********************************************************
/* Test methods
/**********************************************************
*/

private final ObjectMapper MAPPER = getJaxbMapper();

// [modules-base#256]
public void testEnumSerialize256() throws Exception
{
final Document256 document = new Document256(Code.RED);

String json = MAPPER.writeValueAsString(document);

assertEquals(a2q("{'code':'RED'}"), json);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.fasterxml.jackson.module.jaxb.misc;

import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.*;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.jaxb.BaseJaxbTest;
Expand All @@ -14,15 +14,16 @@ enum Numeric { A, B; }

/*
/**********************************************************
/* Unit tests
/* Test methods
/**********************************************************
*/

private final ObjectMapper MAPPER = getJaxbMapper();

// [JACKSON-436]
public void testWrapperWithCollection() throws Exception
{
ObjectMapper mapper = getJaxbMapper();
assertEquals("\"B\"", mapper.writeValueAsString(Plain.B));
assertEquals("1", mapper.writeValueAsString(Numeric.B));
assertEquals("\"B\"", MAPPER.writeValueAsString(Plain.B));
assertEquals("1", MAPPER.writeValueAsString(Numeric.B));
}
}

0 comments on commit 18a6349

Please sign in to comment.