1717package com .google .appengine .tools .development ;
1818
1919import static com .google .common .truth .Truth .assertThat ;
20+ import static java .nio .charset .StandardCharsets .UTF_8 ;
2021
2122import com .google .common .io .Resources ;
23+ import java .io .ByteArrayInputStream ;
2224import java .io .IOException ;
2325import java .io .InputStream ;
2426import javax .xml .XMLConstants ;
2729import javax .xml .validation .SchemaFactory ;
2830import javax .xml .validation .Validator ;
2931import junit .framework .TestCase ;
30- import org .apache .tools .ant .filters .StringInputStream ;
3132import org .xml .sax .SAXException ;
3233import org .xml .sax .SAXParseException ;
3334
@@ -325,7 +326,7 @@ public void setUp() {
325326
326327 public void testGoodXml () {
327328 try {
328- InputStream inputStream = new StringInputStream (SIMPLE_XML );
329+ InputStream inputStream = new ByteArrayInputStream (SIMPLE_XML . getBytes ( UTF_8 ) );
329330 validator .validate (new StreamSource (inputStream ));
330331 } catch (SAXException | IOException e ) {
331332 fail (e .getMessage ());
@@ -334,7 +335,8 @@ public void testGoodXml() {
334335
335336 public void testGoodXmlWithStorageLimit () {
336337 try {
337- InputStream inputStream = new StringInputStream (SIMPLE_XML_WITH_STORAGE_LIMIT );
338+ InputStream inputStream =
339+ new ByteArrayInputStream (SIMPLE_XML_WITH_STORAGE_LIMIT .getBytes (UTF_8 ));
338340 validator .validate (new StreamSource (inputStream ));
339341 } catch (SAXException | IOException e ) {
340342 fail (e .getMessage ());
@@ -343,7 +345,7 @@ public void testGoodXmlWithStorageLimit() {
343345
344346 public void testComplexXml () {
345347 try {
346- InputStream inputStream = new StringInputStream (COMPLEX_XML );
348+ InputStream inputStream = new ByteArrayInputStream (COMPLEX_XML . getBytes ( UTF_8 ) );
347349 validator .validate (new StreamSource (inputStream ));
348350 } catch (SAXException | IOException e ) {
349351 fail (e .getMessage ());
@@ -352,7 +354,7 @@ public void testComplexXml() {
352354
353355 public void testBadXmlEntry () {
354356 try {
355- InputStream inputStream = new StringInputStream (BAD_XML_ENTRY );
357+ InputStream inputStream = new ByteArrayInputStream (BAD_XML_ENTRY . getBytes ( UTF_8 ) );
356358 validator .validate (new StreamSource (inputStream ));
357359 fail ("Validator should complain." );
358360 } catch (SAXParseException e ) {
@@ -368,7 +370,7 @@ public void testBadXmlEntry() {
368370
369371 public void testBadMode () {
370372 try {
371- InputStream inputStream = new StringInputStream (BAD_XML_MODE );
373+ InputStream inputStream = new ByteArrayInputStream (BAD_XML_MODE . getBytes ( UTF_8 ) );
372374 validator .validate (new StreamSource (inputStream ));
373375 fail ("Validator should complain." );
374376 } catch (SAXParseException e ) {
@@ -384,7 +386,7 @@ public void testBadMode() {
384386
385387 public void testBadName () {
386388 try {
387- InputStream inputStream = new StringInputStream (BAD_XML_NAME );
389+ InputStream inputStream = new ByteArrayInputStream (BAD_XML_NAME . getBytes ( UTF_8 ) );
388390 validator .validate (new StreamSource (inputStream ));
389391 fail ("Validator should complain." );
390392 } catch (SAXParseException e ) {
@@ -400,7 +402,7 @@ public void testBadName() {
400402
401403 public void testBadRate () {
402404 try {
403- InputStream inputStream = new StringInputStream (BAD_XML_RATE );
405+ InputStream inputStream = new ByteArrayInputStream (BAD_XML_RATE . getBytes ( UTF_8 ) );
404406 validator .validate (new StreamSource (inputStream ));
405407 fail ("Validator should complain." );
406408 } catch (SAXParseException e ) {
@@ -416,7 +418,8 @@ public void testBadRate() {
416418
417419 public void testBadMaxConcurrentRequests () {
418420 try {
419- InputStream inputStream = new StringInputStream (BAD_XML_MAX_CONCURRENT_REQUESTS );
421+ InputStream inputStream =
422+ new ByteArrayInputStream (BAD_XML_MAX_CONCURRENT_REQUESTS .getBytes (UTF_8 ));
420423 validator .validate (new StreamSource (inputStream ));
421424 fail ("Validator should complain." );
422425 } catch (SAXParseException e ) {
@@ -430,7 +433,7 @@ public void testBadMaxConcurrentRequests() {
430433
431434 public void testBadStorageLimit () {
432435 try {
433- InputStream inputStream = new StringInputStream (BAD_XML_STORAGE_LIMIT );
436+ InputStream inputStream = new ByteArrayInputStream (BAD_XML_STORAGE_LIMIT . getBytes ( UTF_8 ) );
434437 validator .validate (new StreamSource (inputStream ));
435438 fail ("Validator should complain." );
436439 } catch (SAXParseException e ) {
@@ -446,7 +449,8 @@ public void testBadStorageLimit() {
446449
447450 public void testMultipleStorageLimit () {
448451 try {
449- InputStream inputStream = new StringInputStream (BAD_XML_MULTIPLE_STORAGE_LIMIT );
452+ InputStream inputStream =
453+ new ByteArrayInputStream (BAD_XML_MULTIPLE_STORAGE_LIMIT .getBytes (UTF_8 ));
450454 validator .validate (new StreamSource (inputStream ));
451455 fail ("Validator should complain." );
452456 } catch (SAXParseException e ) {
@@ -462,7 +466,7 @@ public void testMultipleStorageLimit() {
462466
463467 public void testBadRetryParameters () {
464468 try {
465- InputStream inputStream = new StringInputStream (BAD_RETRY_PARAMETERS_XML );
469+ InputStream inputStream = new ByteArrayInputStream (BAD_RETRY_PARAMETERS_XML . getBytes ( UTF_8 ) );
466470 validator .validate (new StreamSource (inputStream ));
467471 fail ("Validator should complain." );
468472 } catch (SAXParseException e ) {
@@ -476,7 +480,8 @@ public void testBadRetryParameters() {
476480
477481 public void testBadRetryParametersInAclXml () {
478482 try {
479- InputStream inputStream = new StringInputStream (BAD_RETRY_PARAMETERS_IN_ACL_XML );
483+ InputStream inputStream =
484+ new ByteArrayInputStream (BAD_RETRY_PARAMETERS_IN_ACL_XML .getBytes (UTF_8 ));
480485 validator .validate (new StreamSource (inputStream ));
481486 fail ("Validator should complain." );
482487 } catch (SAXParseException e ) {
@@ -492,7 +497,8 @@ public void testBadRetryParametersInAclXml() {
492497
493498 public void testBadUserEmailInRetryParameters () {
494499 try {
495- InputStream inputStream = new StringInputStream (BAD_USER_EMAIL_IN_RETRY_PARAMETERS_XML );
500+ InputStream inputStream =
501+ new ByteArrayInputStream (BAD_USER_EMAIL_IN_RETRY_PARAMETERS_XML .getBytes (UTF_8 ));
496502 validator .validate (new StreamSource (inputStream ));
497503 fail ("Validator should complain." );
498504 } catch (SAXParseException e ) {
@@ -508,13 +514,14 @@ public void testBadUserEmailInRetryParameters() {
508514 }
509515
510516 public void testOkEmptyAcl () throws Exception {
511- InputStream inputStream = new StringInputStream (OK_EMPTY_ACL_XML );
517+ InputStream inputStream = new ByteArrayInputStream (OK_EMPTY_ACL_XML . getBytes ( UTF_8 ) );
512518 validator .validate (new StreamSource (inputStream ));
513519 }
514520
515521 public void testMultipleRetryParameters () {
516522 try {
517- InputStream inputStream = new StringInputStream (MULTIPLE_RETRY_PARAMETERS_XML );
523+ InputStream inputStream =
524+ new ByteArrayInputStream (MULTIPLE_RETRY_PARAMETERS_XML .getBytes (UTF_8 ));
518525 validator .validate (new StreamSource (inputStream ));
519526 fail ("Validator should complain." );
520527 } catch (SAXParseException e ) {
0 commit comments