-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RESTEASY-1066: Changed DefaultTextPlain, StringTextStar, and
JAXB providers to default to UTF-8
- Loading branch information
Showing
14 changed files
with
866 additions
and
12 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
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 |
---|---|---|
|
@@ -258,4 +258,4 @@ protected boolean suppressExpandEntityExpansion() | |
{ | ||
return !isExpandEntityReferences(); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...iders/jaxb/src/test/java/org/jboss/resteasy/test/charset/FavoriteMovieXmlRootElement.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,14 @@ | ||
package org.jboss.resteasy.test.charset; | ||
|
||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
@XmlRootElement | ||
public class FavoriteMovieXmlRootElement { | ||
private String _title; | ||
public String getTitle() { | ||
return _title; | ||
} | ||
public void setTitle(String title) { | ||
_title = title; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
jaxrs/providers/jaxb/src/test/java/org/jboss/resteasy/test/charset/MediaTypes.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,25 @@ | ||
package org.jboss.resteasy.test.charset; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.ws.rs.core.MediaType; | ||
|
||
public class MediaTypes | ||
{ | ||
public static final MediaType APPLICATION_XML_UTF16_TYPE; | ||
public static final MediaType TEXT_PLAIN_UTF16_TYPE; | ||
public static final MediaType WILDCARD_UTF16_TYPE; | ||
public static final String APPLICATION_XML_UTF16 = "application/xml;charset=UTF-16"; | ||
public static final String TEXT_PLAIN_UTF16 = "text/plain;charset=UTF-16"; | ||
public static final String WILDCARD_UTF16 = "*/*;charset=UTF-16"; | ||
|
||
static | ||
{ | ||
Map<String, String> params = new HashMap<String, String>(); | ||
params.put("charset", "UTF-16"); | ||
APPLICATION_XML_UTF16_TYPE = new MediaType("application", "xml", params); | ||
TEXT_PLAIN_UTF16_TYPE = new MediaType("text", "plain", params); | ||
WILDCARD_UTF16_TYPE = new MediaType("*", "*", params); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
jaxrs/providers/jaxb/src/test/java/org/jboss/resteasy/test/charset/TestCharsetExpand.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,89 @@ | ||
package org.jboss.resteasy.test.charset; | ||
|
||
import static org.jboss.resteasy.test.TestPortProvider.generateURL; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
import org.jboss.resteasy.client.ClientRequest; | ||
import org.jboss.resteasy.client.ClientResponse; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
|
||
/** | ||
* Unit tests for RESTEASY-1066. | ||
* | ||
* @author <a href="mailto:ron.sigal@jboss.com">Ron Sigal</a> | ||
* @date Aug 13, 2014 | ||
*/ | ||
public class TestCharsetExpand extends TestCharsetParent | ||
{ | ||
protected static Process process; | ||
|
||
@BeforeClass | ||
public static void deployServer() throws InterruptedException | ||
{ | ||
System.out.println("server default charset: " + Charset.defaultCharset()); | ||
Map<String, Charset> charsets = Charset.availableCharsets(); | ||
Charset charset = null; | ||
for (Iterator<String> it = charsets.keySet().iterator(); it.hasNext(); ) | ||
{ | ||
String cs = it.next(); | ||
if (!cs.equals(Charset.defaultCharset().name())) | ||
{ | ||
charset = charsets.get(cs); | ||
break; | ||
} | ||
} | ||
System.out.println("server using charset: " + charset); | ||
|
||
System.out.println(TestServerExpand.class.getCanonicalName()); | ||
String separator = System.getProperty("file.separator"); | ||
String classpath = System.getProperty("java.class.path"); | ||
String path = System.getProperty("java.home") + separator + "bin" + separator + "java"; | ||
System.out.println("classpath: " + classpath); | ||
System.out.println("path: " + path); | ||
ProcessBuilder processBuilder = new ProcessBuilder(path, "-cp", classpath, TestServerExpand.class.getCanonicalName()); | ||
|
||
try | ||
{ | ||
System.out.println("Starting server JVM"); | ||
process = processBuilder.start(); | ||
System.out.println("Started server JVM"); | ||
} catch (IOException e1) | ||
{ | ||
e1.printStackTrace(); | ||
} | ||
|
||
ClientRequest request = new ClientRequest(generateURL("/junk")); | ||
ClientResponse<?> response = null; | ||
while (true) | ||
{ | ||
try | ||
{ | ||
response = request.get(); | ||
if (response.getStatus() == 200) | ||
{ | ||
System.out.println("Server started: " + response.getEntity(String.class)); | ||
break; | ||
} | ||
System.out.println("Waiting on server ..."); | ||
} | ||
catch (Exception e) | ||
{ | ||
// keep trying | ||
} | ||
System.out.println("Waiting for server"); | ||
Thread.sleep(1000); | ||
} | ||
} | ||
|
||
@AfterClass | ||
public static void after() throws Exception | ||
{ | ||
process.destroy(); | ||
System.out.println("Process destroyed."); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
jaxrs/providers/jaxb/src/test/java/org/jboss/resteasy/test/charset/TestCharsetNoExpand.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,91 @@ | ||
package org.jboss.resteasy.test.charset; | ||
|
||
import static org.jboss.resteasy.test.TestPortProvider.generateURL; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.charset.Charset; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
import org.jboss.resteasy.client.ClientRequest; | ||
import org.jboss.resteasy.client.ClientResponse; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
|
||
/** | ||
* Unit tests for RESTEASY-1066. | ||
* | ||
* @author <a href="mailto:ron.sigal@jboss.com">Ron Sigal</a> | ||
* @date Aug 13, 2014 | ||
*/ | ||
public class TestCharsetNoExpand extends TestCharsetParent | ||
{ | ||
protected static Process process; | ||
|
||
@BeforeClass | ||
public static void deployServer() throws InterruptedException | ||
{ | ||
System.out.println("server default charset: " + Charset.defaultCharset()); | ||
Map<String, Charset> charsets = Charset.availableCharsets(); | ||
Charset charset = null; | ||
for (Iterator<String> it = charsets.keySet().iterator(); it.hasNext(); ) | ||
{ | ||
String cs = it.next(); | ||
if (!cs.equals(Charset.defaultCharset().name())) | ||
{ | ||
charset = charsets.get(cs); | ||
break; | ||
} | ||
} | ||
System.out.println("server using charset: " + charset); | ||
|
||
System.out.println(TestServerExpand.class.getCanonicalName()); | ||
String separator = System.getProperty("file.separator"); | ||
String classpath = System.getProperty("java.class.path"); | ||
String path = System.getProperty("java.home") + separator + "bin" + separator + "java"; | ||
System.out.println("classpath: " + classpath); | ||
System.out.println("path: " + path); | ||
ProcessBuilder processBuilder = new ProcessBuilder(path, "-cp", classpath, TestServerNoExpand.class.getCanonicalName()); | ||
|
||
try | ||
{ | ||
System.out.println("Starting server JVM"); | ||
process = processBuilder.start(); | ||
System.out.println("Started server JVM"); | ||
} catch (IOException e1) | ||
{ | ||
e1.printStackTrace(); | ||
} | ||
|
||
ClientRequest request = new ClientRequest(generateURL("/junk")); | ||
ClientResponse<?> response = null; | ||
while (true) | ||
{ | ||
try | ||
{ | ||
response = request.get(); | ||
if (response.getStatus() == 200) | ||
{ | ||
System.out.println("Server started: " + response.getEntity(String.class)); | ||
break; | ||
} | ||
System.out.println("Waiting on server ..."); | ||
} | ||
catch (Exception e) | ||
{ | ||
// keep trying | ||
} | ||
System.out.println("Waiting for server"); | ||
Thread.sleep(1000); | ||
} | ||
|
||
} | ||
|
||
@AfterClass | ||
public static void after() throws Exception | ||
{ | ||
process.destroy(); | ||
System.out.println("Process destroyed."); | ||
} | ||
} |
Oops, something went wrong.