[BUG 283172] fix build on windows

* Undoing misplaced .toSystemLN() hack in favor of using Subversion svn:eol-style property correctly.


git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@552 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Joakim Erdfelt 2009-07-11 00:56:03 +00:00
parent 15f4e6eb47
commit 0e10f592d8
6 changed files with 53 additions and 73 deletions

View File

@ -95,34 +95,4 @@ public abstract class AbstractJettyTestCase extends TestCase
throw new AssertionFailedError("No valid connector port found.");
}
/**
* Utility method to convert "\n" found to "\r\n" if running on windows.
*
* @param str
* input string.
* @return
*/
public String toSystemLN(String str)
{
if (!IS_ON_WINDOWS)
{
return str;
}
StringBuffer ret = new StringBuffer();
for (char c : str.toCharArray())
{
switch (c)
{
case '\n':
ret.append("\r\n");
break;
default:
ret.append(c);
}
}
return ret.toString();
}
}

View File

@ -78,8 +78,9 @@ public class DefaultHandlerTest extends AbstractJettyTestCase
InputStream in = conn.getInputStream();
String response = IO.toString(in);
String expected = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
assertEquals("Response",toSystemLN("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n"),response);
assertEquals("Response",expected,response);
}
@Test

View File

@ -47,6 +47,7 @@ import org.junit.Test;
*/
public abstract class RFC2616BaseTest extends AbstractJettyTestCase
{
private static final String ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
/** STRICT RFC TESTS */
private static final boolean STRICT = false;
private List<HttpResponseTester> responses;
@ -1135,7 +1136,7 @@ public abstract class RFC2616BaseTest extends AbstractJettyTestCase
response = http.request(req1);
response.assertStatusOK();
response.assertBody("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
response.assertBody(ALPHA);
}
private void assertBadContentRange(String rangedef) throws IOException
@ -1251,7 +1252,7 @@ public abstract class RFC2616BaseTest extends AbstractJettyTestCase
@Test
public void test14_16_PartialRange() throws Exception
{
String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
String alpha = ALPHA;
// server should not return a 416 if at least one syntactically valid ranges
// are is satisfiable
@ -1271,7 +1272,7 @@ public abstract class RFC2616BaseTest extends AbstractJettyTestCase
@Test
public void test14_16_PartialRange_MixedRanges() throws Exception
{
String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
String alpha = ALPHA;
// server should not return a 416 if at least one syntactically valid ranges
// are is satisfiable
@ -1313,7 +1314,7 @@ public abstract class RFC2616BaseTest extends AbstractJettyTestCase
@Test
public void test14_16_PartialRange_MixedBytes() throws Exception
{
String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
String alpha = ALPHA;
// server should not return a 416 if at least one syntactically valid ranges
// are is satisfiable
@ -1352,7 +1353,7 @@ public abstract class RFC2616BaseTest extends AbstractJettyTestCase
@Test
public void test14_16_PartialRange_MixedMultiple() throws Exception
{
String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
String alpha = ALPHA;
// server should not return a 416 if at least one syntactically valid ranges
// are is satisfiable
@ -1506,7 +1507,7 @@ public abstract class RFC2616BaseTest extends AbstractJettyTestCase
// tested yet
//
String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
String alpha = ALPHA;
// First 3 bytes
assertByteRange("bytes=0-2","0-2/27",alpha.substring(0,2 + 1));
@ -1661,7 +1662,7 @@ public abstract class RFC2616BaseTest extends AbstractJettyTestCase
// tested yet
//
String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
String alpha = ALPHA;
// server should not return a 416 if at least one syntactically valid ranges
// are is satisfiable

View File

@ -18,6 +18,8 @@ package org.eclipse.jetty.test.support;
public class StringUtil
{
public static final String LN = System.getProperty("line.separator");
public static boolean isBlank(String str)
{
if (str == null)
@ -101,4 +103,38 @@ public class StringUtil
return ret;
}
/**
* Utility method to convert "\n" found to "\r\n" if running on windows.
*
* @param str
* input string.
* @return
*/
public static String toSystemLN(String str)
{
boolean linesep = false;
StringBuffer ret = new StringBuffer();
for (char c : str.toCharArray())
{
switch (c)
{
case '\r':
linesep = true;
break;
case '\n':
linesep = true;
break;
default:
if (linesep)
{
ret.append(LN);
linesep = false;
}
ret.append(c);
}
}
return ret.toString();
}
}

View File

@ -41,8 +41,6 @@ import org.eclipse.jetty.util.ByteArrayOutputStream2;
*/
public class HttpResponseTester
{
private static final boolean IS_ON_WINDOWS = System.getProperty("os.name").startsWith("Windows");
private class PH extends HttpParser.EventHandler
{
@Override
@ -344,45 +342,17 @@ public class HttpResponseTester
public void assertBody(String expected)
{
Assert.assertNotNull("Response.content should not be null",this.content);
Assert.assertEquals("Response.content",toSystemLN(expected),this.content.toString());
String actual = this.content.toString();
Assert.assertEquals("Response.content",expected,actual);
}
public void assertBody(String msg, String expected)
{
Assert.assertNotNull(msg + ": Response.content should not be null",this.content);
Assert.assertEquals(msg + ": Response.content",toSystemLN(expected),this.content.toString());
String actual = this.content.toString();
Assert.assertEquals(msg + ": Response.content",expected,actual);
}
/**
* Utility method to convert "\n" found to "\r\n" if running on windows.
*
* @param str
* input string.
* @return
*/
public String toSystemLN(String str)
{
if (!IS_ON_WINDOWS)
{
return str;
}
StringBuffer ret = new StringBuffer();
for (char c : str.toCharArray())
{
switch (c)
{
case '\n':
ret.append("\r\n");
break;
default:
ret.append(c);
}
}
return ret.toString();
}
public void assertNoBody(String msg)
{
Assert.assertNull(msg + ": Response.content should be null",this.content);

View File

@ -52,7 +52,9 @@ public class HttpResponseTesterTest extends AbstractJettyTestCase
assertEquals("Response[Content-Length]",28,response.getLongHeader("Content-Length"));
assertEquals("Response[Connection]","close",response.getHeader("Connection"));
assertEquals("Response.content",toSystemLN("ABCDEFGHIJKLMNOPQRSTTUVWXYZ\n"),response.getContent().toString());
String expected = "ABCDEFGHIJKLMNOPQRSTTUVWXYZ\n";
assertEquals("Response.content",expected,response.getContent().toString());
}
@Test