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

[SUREFIRE-2046] Resolved TODOs. Updated callbacks ForkedProcessPropertyEventListener and ForkedProcessStandardOutErrEventListener. #501

Merged
merged 1 commit into from Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -211,7 +211,7 @@ public void handle( ReportEntry reportEntry )
private final class SystemPropertiesListener implements ForkedProcessPropertyEventListener
{
@Override
public void handle( RunMode runMode, String key, String value )
public void handle( String key, String value, RunMode runMode, Long testRunId )
{
testVmSystemProperties.put( key, value );
}
Expand All @@ -220,18 +220,18 @@ public void handle( RunMode runMode, String key, String value )
private final class StdOutListener implements ForkedProcessStandardOutErrEventListener
{
@Override
public void handle( RunMode runMode, String output, boolean newLine )
public void handle( String output, boolean newLine, RunMode runMode, Long testRunId )
{
writeTestOutput( output, newLine, true );
writeTestOutput( output, true, newLine, runMode, testRunId );
}
}

private final class StdErrListener implements ForkedProcessStandardOutErrEventListener
{
@Override
public void handle( RunMode runMode, String output, boolean newLine )
public void handle( String output, boolean newLine, RunMode runMode, Long testRunId )
{
writeTestOutput( output, newLine, false );
writeTestOutput( output, false, newLine, runMode, testRunId );
}
}

Expand Down Expand Up @@ -393,10 +393,10 @@ void dumpToLoFile( String msg )
util.dumpStreamText( msg, reportsDir, forkNumber );
}

private void writeTestOutput( String output, boolean newLine, boolean isStdout )
private void writeTestOutput( String output, boolean isStdout, boolean newLine, RunMode runMode, Long testRunId )
{
getConsoleOutputReceiver()
.writeTestOutput( new TestOutputReportEntry( output, isStdout, newLine, /*todo*/ null, null ) );
.writeTestOutput( new TestOutputReportEntry( output, isStdout, newLine, runMode, testRunId ) );
}

public Map<String, String> getTestVmSystemProperties()
Expand Down
Expand Up @@ -207,18 +207,20 @@ else if ( event.isStandardStreamCategory() )
ForkedProcessStandardOutErrEventListener listener = stdOutErrEventListeners.get( eventType );
if ( listener != null )
{
listener.handle( standardStreamEvent.getRunMode(), standardStreamEvent.getMessage(), newLine );
listener.handle( standardStreamEvent.getMessage(), newLine,
standardStreamEvent.getRunMode(), standardStreamEvent.getTestRunId() );
}
}
else if ( event.isSysPropCategory() )
{
SystemPropertyEvent systemPropertyEvent = (SystemPropertyEvent) event;
RunMode runMode = systemPropertyEvent.getRunMode();
Long testRunId = systemPropertyEvent.getTestRunId();
String key = systemPropertyEvent.getKey();
String value = systemPropertyEvent.getValue();
if ( propertyEventListener != null )
{
propertyEventListener.handle( runMode, key, value );
propertyEventListener.handle( key, value, runMode, testRunId );
}
}
else if ( event.isTestCategory() )
Expand Down
Expand Up @@ -27,5 +27,5 @@
*/
public interface ForkedProcessPropertyEventListener
{
void handle( RunMode runMode, String key, String value );
void handle( String key, String value, RunMode runMode, Long testRunId );
}
Expand Up @@ -27,5 +27,5 @@
*/
public interface ForkedProcessStandardOutErrEventListener
{
void handle( RunMode runMode, String output, boolean newLine );
void handle( String output, boolean newLine, RunMode runMode, Long testRunId );
}
Expand Up @@ -540,7 +540,7 @@ public void testStdOutStream() throws Exception

ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier();
StandardOutErrEventAssertionListener listener =
new StandardOutErrEventAssertionListener( NORMAL_RUN, "msg", false );
new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, "msg", false );
notifier.setStdOutListener( listener );

EH eventHandler = new EH();
Expand Down Expand Up @@ -579,7 +579,7 @@ public void testStdOutStreamPrint() throws Exception

ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier();
StandardOutErrEventAssertionListener listener =
new StandardOutErrEventAssertionListener( NORMAL_RUN, "", false );
new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, "", false );
notifier.setStdOutListener( listener );

EH eventHandler = new EH();
Expand Down Expand Up @@ -618,7 +618,7 @@ public void testStdOutStreamPrintWithNull() throws Exception

ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier();
StandardOutErrEventAssertionListener listener =
new StandardOutErrEventAssertionListener( NORMAL_RUN, null, false );
new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, null, false );
notifier.setStdOutListener( listener );

EH eventHandler = new EH();
Expand Down Expand Up @@ -657,7 +657,7 @@ public void testStdOutStreamPrintln() throws Exception

ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier();
StandardOutErrEventAssertionListener listener =
new StandardOutErrEventAssertionListener( NORMAL_RUN, "", true );
new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, "", true );
notifier.setStdOutListener( listener );

EH eventHandler = new EH();
Expand Down Expand Up @@ -696,7 +696,7 @@ public void testStdOutStreamPrintlnWithNull() throws Exception

ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier();
StandardOutErrEventAssertionListener listener =
new StandardOutErrEventAssertionListener( NORMAL_RUN, null, true );
new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, null, true );
notifier.setStdOutListener( listener );

EH eventHandler = new EH();
Expand Down Expand Up @@ -735,7 +735,7 @@ public void testStdErrStream() throws Exception

ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier();
StandardOutErrEventAssertionListener listener =
new StandardOutErrEventAssertionListener( NORMAL_RUN, "msg", false );
new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, "msg", false );
notifier.setStdErrListener( listener );

EH eventHandler = new EH();
Expand Down Expand Up @@ -995,11 +995,12 @@ private static class PropertyEventAssertionListener implements ForkedProcessProp
private final Map<?, ?> sysProps = System.getProperties();
private final AtomicInteger counter = new AtomicInteger();

public void handle( RunMode runMode, String key, String value )
public void handle( String key, String value, RunMode runMode, Long testRunId )
{
called.set( true );
counter.incrementAndGet();
assertThat( runMode ).isEqualTo( NORMAL_RUN );
assertThat( testRunId ).isEqualTo( 1L );
assertTrue( sysProps.containsKey( key ) );
assertThat( sysProps.get( key ) ).isEqualTo( value );
}
Expand Down Expand Up @@ -1067,23 +1068,28 @@ private static class StandardOutErrEventAssertionListener implements ForkedProce
{
final AtomicBoolean called = new AtomicBoolean();
private final RunMode runMode;
private final long testRunId;
private final String output;
private final boolean newLine;

StandardOutErrEventAssertionListener( RunMode runMode, String output, boolean newLine )
StandardOutErrEventAssertionListener( RunMode runMode, long testRunId, String output, boolean newLine )
{
this.runMode = runMode;
this.testRunId = testRunId;
this.output = output;
this.newLine = newLine;
}

public void handle( RunMode runMode, String output, boolean newLine )
public void handle( String output, boolean newLine, RunMode runMode, Long testRunId )
{
called.set( true );

assertThat( runMode )
.isEqualTo( this.runMode );

assertThat( testRunId )
.isEqualTo( this.testRunId );

assertThat( output )
.isEqualTo( this.output );

Expand Down