Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtendedCharacters tests fail on command line, but pass in Eclipse (Windows) #131

Closed
khitrenovich opened this issue Oct 22, 2013 · 2 comments
Milestone

Comments

@khitrenovich
Copy link
Contributor

Two ExtendedCharacters test that fail are:

  • writeExtendedCharactersAsUtf8SourceCode
  • writeExtendedCharactersAsSingleByteSourceCode

Failure message of the first one (excerpt):

Failed tests:
  writeExtendedCharactersAsUtf8SourceCode(org.jsonschema2pojo.integration.config.OutputEncodingIT):
Expected: a string containing "????????"
     but: was "
package com.example;

import java.util.HashMap;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
    "name"
})
public class ExtendedCharacters {

    /**
     * \u042b\u0429\u0414\u0452\u0438\u040a\u0409\u042f
     *
     */
    @JsonProperty("name")
    private String name;
    private Map<String, Object> additionalProperties = new HashMap<String, Object>();

    /**
     * \u042b\u0429\u0414\u0452\u0438\u040a\u0409\u042f
     *
     */
    @JsonProperty("name")
    public String getName() {
        return name;
    }

    /**
     * \u042b\u0429\u0414\u0452\u0438\u040a\u0409\u042f
     *
     */
    @JsonProperty("name")
    public void setName(String name) {
        this.name = name;
    }
.....

It looks like a difference is some system properties, but I did not manage to figure it out yet.

@khitrenovich
Copy link
Contributor Author

OK, I see a difference in system property "file.encoding". In Eclipse it states "UTF-8", but it command line run it is "Cp1252". Maybe this is a hint.

@joelittlejohn
Copy link
Owner

Thanks Anton. I think this is caused by a bug in CodeModel 2.6 (specifically, in com.sun.codemodel.util.EncoderFactory#createEncoder) that causes the configured character encoding to be ignored. Since the default character encoding on Windows is 'Windows-1256', the unicode chars get escaped.

I'll make a tweak to org.jsonschema2pojo.integration.config.OutputEncodingIT to make sure that it fails on all platforms, even those where the default charset is UTF-8. We can then fix this bug quite easily by extending some of the CodeModel classes and overriding a couple of methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants