Skip to content

Commit

Permalink
v. 2.0.3 Removed slf4j and debugging println statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
GlenKPeterson committed Mar 18, 2022
1 parent 152ac74 commit ca8b5d7
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 39 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Note that this project is just for testing, so add it only to the `test` scope o
<dependency>
<groupId>org.organicdesign</groupId>
<artifactId>TestUtils</artifactId>
<version>2.0.1</version>
<version>2.0.3</version>
<scope>test</scope>
</dependency>
```
Expand Down Expand Up @@ -121,6 +121,9 @@ gradle clean assemble publishToMavenLocal

## Change Log

### 2.0.3 2022-03-18 "Removed slf4j"
- Also removed debugging println statements.

### 2.0.2 2022-03-18 "Bumped dependencies"
- Upgraded Jetty-http to 11.0.8

Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ dependencies {
implementation("org.eclipse.jetty:jetty-http:11.0.8")

testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
testImplementation("org.slf4j:slf4j-simple:2.0.0-alpha5")
// testImplementation("org.slf4j:slf4j-simple:2.0.0-alpha5")
}

group = "org.organicdesign"
version = "2.0.2"
version = "2.0.3"
description = "Utilities for testing common Java contracts: equals(), hashCode(), and compareTo()"

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ internal constructor(
val tmpDir = Files.createTempDirectory("testUtilTestTemp").toFile()
val config = MultipartConfigElement(tmpDir.absolutePath, 100000, 100000, 0)
_multiParts = newMultiParts(config)
println("_multiParts = $_multiParts")
// println("_multiParts = $_multiParts")
val parts = _multiParts!!.parts
println("parts=$parts")
// println("parts=$parts")
var formCharset: String? = null
val charsetPart = _multiParts!!.getPart("_charset_")
println("charsetPart=$charsetPart")
// println("charsetPart=$charsetPart")
charsetPart?.inputStream?.use { `is` ->
val os = ByteArrayOutputStream()
IO.copy(`is`, os)
Expand All @@ -307,7 +307,7 @@ internal constructor(

var os: ByteArrayOutputStream? = null
for (p in parts) {
println("Part=$p")
// println("Part=$p")
if (p.submittedFileName == null) {
// Servlet Spec 3.0 pg 23, parts without filename must be put into params.
var charset: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ protected void throwIfError() throws IOException
{
if (_err != null)
{
System.out.println("MultiPart parsing failure " + _err);
// System.out.println("MultiPart parsing failure " + _err);

_err.addSuppressed(new Throwable());
if (_err instanceof IOException)
Expand All @@ -418,21 +418,21 @@ protected void throwIfError() throws IOException
*/
protected void parse()
{
System.out.println("parse()");
// System.out.println("parse()");
switch (state)
{
case UNPARSED:
state = MultiPartFormInputStream.State.PARSING;
System.out.println(" UNPARSED->PARSING");
// System.out.println(" UNPARSED->PARSING");
break;

case PARSED:
System.out.println(" PARSED");
// System.out.println(" PARSED");
return;

default:
_err = new IOException(state.name());
System.out.println(" Uh oh...");
// System.out.println(" Uh oh...");
return;
}

Expand All @@ -452,20 +452,20 @@ protected void parse()
_tmpDir = (location.isAbsolute() ? location : _contextTmpDir.toPath().resolve(location));
}

System.out.println(" _tmpDir=" + _tmpDir.toAbsolutePath());
// System.out.println(" _tmpDir=" + _tmpDir.toAbsolutePath());

if (!Files.exists(_tmpDir)) {
System.out.println(" about to make TmpDir");
// System.out.println(" about to make TmpDir");
Files.createDirectories(_tmpDir);
}

if (Files.isDirectory(_tmpDir)) {
System.out.println(" TmpDir is an existing directory");
}
// if (Files.isDirectory(_tmpDir)) {
// System.out.println(" TmpDir is an existing directory");
// }

String contentTypeBoundary = "";
int bstart = _contentType.indexOf("boundary=");
System.out.println(" bstart=" + bstart);
// System.out.println(" bstart=" + bstart);
if (bstart >= 0)
{
int bend = _contentType.indexOf(";", bstart);
Expand Down Expand Up @@ -528,7 +528,7 @@ else if (len == -1)
_err = new IOException("Incomplete Multipart");
}

System.out.println("Parsing Complete " + parser + " err=" + _err);
// System.out.println("Parsing Complete " + parser + " err=" + _err);
}
catch (Throwable e)
{
Expand Down Expand Up @@ -591,7 +591,7 @@ else if (key.equalsIgnoreCase("content-type"))
@Override
public boolean headerComplete()
{
System.out.println("headerComplete " + this);
// System.out.println("headerComplete " + this);

try
{
Expand Down Expand Up @@ -698,7 +698,7 @@ public void startPart()
@Override
public void earlyEOF()
{
System.out.println("Early EOF: " + MultiPartFormInputStream.this);
// System.out.println("Early EOF: " + MultiPartFormInputStream.this);

try
{
Expand All @@ -707,7 +707,7 @@ public void earlyEOF()
}
catch (IOException e)
{
System.out.println("part could not be closed: " + e);
// System.out.println("part could not be closed: " + e);
}
}

Expand Down
34 changes: 17 additions & 17 deletions src/main/java/org/organicdesign/testUtils/http/MultiPartParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@ public boolean parse(ByteBuffer buffer, boolean last)
{
_state = MultiPartParser.State.END;

System.out.println("messageComplete:" + this);
// System.out.println("messageComplete:" + this);

return _handler.messageComplete();
}
else
{
System.out.println("earlyEOF:" + this);
// System.out.println("earlyEOF:" + this);

_handler.earlyEOF();
return true;
Expand All @@ -225,7 +225,7 @@ public boolean parse(ByteBuffer buffer, boolean last)

private void parsePreamble(ByteBuffer buffer)
{
System.out.println("parsePreamble(" + buffer + ")");
// System.out.println("parsePreamble(" + buffer + ")");

if (_partialBoundary > 0)
{
Expand Down Expand Up @@ -262,7 +262,7 @@ private void parsePreamble(ByteBuffer buffer)

private void parseDelimiter(ByteBuffer buffer)
{
System.out.println("parseDelimiter(" + buffer + ")");
// System.out.println("parseDelimiter(" + buffer + ")");

while (__delimiterStates.contains(_state) && hasNextByte(buffer))
{
Expand All @@ -274,7 +274,7 @@ private void parseDelimiter(ByteBuffer buffer)
{
setState(MultiPartParser.State.BODY_PART);

System.out.println("startPart:" + this);
// System.out.println("startPart:" + this);

_handler.startPart();
return;
Expand Down Expand Up @@ -309,7 +309,7 @@ private void parseDelimiter(ByteBuffer buffer)
*/
protected boolean parseMimePartHeaders(ByteBuffer buffer)
{
System.out.println("parseMimePartHeaders(" + buffer + ")");
// System.out.println("parseMimePartHeaders(" + buffer + ")");

// Process headers
while (_state == MultiPartParser.State.BODY_PART && hasNextByte(buffer))
Expand Down Expand Up @@ -359,7 +359,7 @@ protected boolean parseMimePartHeaders(ByteBuffer buffer)
setState(MultiPartParser.State.FIRST_OCTETS);
_partialBoundary = 2; // CRLF is option for empty parts

System.out.println("headerComplete:" + this);
// System.out.println("headerComplete:" + this);

if (_handler.headerComplete())
return true;
Expand Down Expand Up @@ -400,7 +400,7 @@ protected boolean parseMimePartHeaders(ByteBuffer buffer)

case LF:
{
System.out.println("Line Feed in Name:" + this);
// System.out.println("Line Feed in Name:" + this);

handleField();
setState(MultiPartParser.FieldState.FIELD);
Expand Down Expand Up @@ -516,7 +516,7 @@ protected boolean parseMimePartHeaders(ByteBuffer buffer)

private void handleField()
{
System.out.println("parsedField:" + this + " _fieldName=" + _fieldName + " _fieldValue=" + _fieldValue);
// System.out.println("parsedField:" + this + " _fieldName=" + _fieldName + " _fieldValue=" + _fieldValue);

if (_fieldName != null && _fieldValue != null)
_handler.parsedField(_fieldName, _fieldValue);
Expand All @@ -525,7 +525,7 @@ private void handleField()

protected boolean parseOctetContent(ByteBuffer buffer)
{
System.out.println("parseOctetContent(" + buffer + ")");
// System.out.println("parseOctetContent(" + buffer + ")");

// Starts With
if (_partialBoundary > 0)
Expand All @@ -539,7 +539,7 @@ protected boolean parseOctetContent(ByteBuffer buffer)
setState(MultiPartParser.State.DELIMITER);
_partialBoundary = 0;

System.out.println("Content=EMPTY_BUFFER, Last=" + this);
// System.out.println("Content=EMPTY_BUFFER, Last=" + this);

return _handler.content(EMPTY_BUFFER, true);
}
Expand All @@ -560,7 +560,7 @@ protected boolean parseOctetContent(ByteBuffer buffer)
content.limit(_partialBoundary);
_partialBoundary = 0;

System.out.println("Content=" + content + ", Last=" + this);
// System.out.println("Content=" + content + ", Last=" + this);

if (_handler.content(content, false))
return true;
Expand All @@ -577,7 +577,7 @@ protected boolean parseOctetContent(ByteBuffer buffer)
buffer.position(delimiter - buffer.arrayOffset() + _delimiterSearch.getLength());
setState(MultiPartParser.State.DELIMITER);

System.out.println("Content=" + content + ", Last=" + this);
// System.out.println("Content=" + content + ", Last=" + this);

return _handler.content(content, true);
}
Expand All @@ -589,7 +589,7 @@ protected boolean parseOctetContent(ByteBuffer buffer)
ByteBuffer content = buffer.slice();
content.limit(content.limit() - _partialBoundary);

System.out.println("Content=" + content + ", Last=" + this);
// System.out.println("Content=" + content + ", Last=" + this);

clearBuffer(buffer);
return _handler.content(content, false);
Expand All @@ -598,21 +598,21 @@ protected boolean parseOctetContent(ByteBuffer buffer)
// There is normal content with no delimiter
ByteBuffer content = buffer.slice();

System.out.println("Content=" + content + ", Last=" + this);
// System.out.println("Content=" + content + ", Last=" + this);

clearBuffer(buffer);
return _handler.content(content, false);
}

private void setState(MultiPartParser.State state)
{
System.out.println("" + _state + " --> " + state);
// System.out.println("" + _state + " --> " + state);
_state = state;
}

private void setState(MultiPartParser.FieldState state)
{
System.out.println("" + _state + ":" + _fieldState + " --> " + state);
// System.out.println("" + _state + ":" + _fieldState + " --> " + state);
_fieldState = state;
}

Expand Down

0 comments on commit ca8b5d7

Please sign in to comment.