Tibor17 commented on a change in pull request #310:
URL: https://github.com/apache/maven-surefire/pull/310#discussion_r487395060



##########
File path: 
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java
##########
@@ -0,0 +1,492 @@
+package org.apache.maven.plugin.surefire.extensions;
+
+import org.apache.maven.plugin.surefire.extensions.EventConsumerThread.Memento;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
+import org.apache.maven.surefire.api.booter.ForkedProcessEventType;
+import org.apache.maven.surefire.extensions.EventHandler;
+import org.apache.maven.surefire.extensions.ForkNodeArguments;
+import org.apache.maven.surefire.extensions.util.CountdownCloseable;
+import org.fest.assertions.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+import org.mockito.Mockito;
+
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.Channel;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.TimeUnit;
+
+import static java.nio.charset.CodingErrorAction.REPLACE;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static 
org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.EOF;
+import static 
org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.OVERFLOW;
+import static 
org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.UNDERFLOW;
+import static org.apache.maven.surefire.api.booter.Constants.STREAM_ENCODING;
+import static org.fest.assertions.Assertions.assertThat;
+//import static org.mockito.Mockito.mock;
+
+//@RunWith( Parameterized.class )
+public class EventConsumerThreadTest
+{
+    @Parameters
+    public static Iterable<Object> channels()
+    {
+        return Arrays.asList( (Object) complexEncodings() );
+    }
+
+    @Parameter
+    public Channel channel;
+
+    private static Channel complexEncodings()
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 
'b', (byte) 0xc2, (byte) 0xa9, 'c'};
+        bytes = 
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
 UTF_8 );
+        return new Channel( bytes, 1 );
+    }
+
+    private static Channel complexEncodings( int chunkSize )
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 
'b', (byte) 0xc2, (byte) 0xa9, 'c'};
+        bytes = 
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
 UTF_8 );
+        return new Channel( bytes, chunkSize );
+    }
+
+    @Test
+    public void test5() throws IOException, InterruptedException
+    {
+        /*final CharsetDecoder decoder = STREAM_ENCODING.newDecoder()

Review comment:
       ah no, these tests yet contain performance tests. Now they don't have a 
value for us and they can be deleted.
   Yet only `EventConsumerThread` can be reviewed.
   
   Initially i used the tests to measure several approaches for decoding byte[] 
to String, e.g. `new String()` vs CharacterBuffer, strings concatenation, 
decoding with/out number-of-bytes in the stream `:2:AB:`, i had to measure time 
of objects creation, measured the exec time of HashMap and hashcode/equals 
methods - see the class `Segment`  and measured the performance of binary data 
tree against hashcode/equals. So initially these tests were used for selecting 
the right approach means performance/code-approach.

##########
File path: 
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java
##########
@@ -0,0 +1,492 @@
+package org.apache.maven.plugin.surefire.extensions;
+
+import org.apache.maven.plugin.surefire.extensions.EventConsumerThread.Memento;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
+import org.apache.maven.surefire.api.booter.ForkedProcessEventType;
+import org.apache.maven.surefire.extensions.EventHandler;
+import org.apache.maven.surefire.extensions.ForkNodeArguments;
+import org.apache.maven.surefire.extensions.util.CountdownCloseable;
+import org.fest.assertions.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+import org.mockito.Mockito;
+
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.Channel;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.TimeUnit;
+
+import static java.nio.charset.CodingErrorAction.REPLACE;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static 
org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.EOF;
+import static 
org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.OVERFLOW;
+import static 
org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.UNDERFLOW;
+import static org.apache.maven.surefire.api.booter.Constants.STREAM_ENCODING;
+import static org.fest.assertions.Assertions.assertThat;
+//import static org.mockito.Mockito.mock;
+
+//@RunWith( Parameterized.class )
+public class EventConsumerThreadTest
+{
+    @Parameters
+    public static Iterable<Object> channels()
+    {
+        return Arrays.asList( (Object) complexEncodings() );
+    }
+
+    @Parameter
+    public Channel channel;
+
+    private static Channel complexEncodings()
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 
'b', (byte) 0xc2, (byte) 0xa9, 'c'};
+        bytes = 
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
 UTF_8 );
+        return new Channel( bytes, 1 );
+    }
+
+    private static Channel complexEncodings( int chunkSize )
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 
'b', (byte) 0xc2, (byte) 0xa9, 'c'};
+        bytes = 
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
 UTF_8 );
+        return new Channel( bytes, chunkSize );
+    }
+
+    @Test
+    public void test5() throws IOException, InterruptedException
+    {
+        /*final CharsetDecoder decoder = STREAM_ENCODING.newDecoder()

Review comment:
       ah no, these tests yet contain performance tests. Now they don't have a 
value for us and they can be deleted.
   Yet only `EventConsumerThread` can be reviewed.
   
   Initially i used the tests to measure several approaches for decoding byte[] 
to String, e.g. `new String()` vs CharacterBuffer, strings concatenation, 
decoding with/out number-of-bytes in the stream `:2:AB:`, i had to measure time 
of objects creation, measured the exec time of HashMap and hashcode/equals 
methods - see the class `Segment`  and measured the performance of binary data 
tree against hashcode/equals. So initially these tests were used for selecting 
the right approach means performance/code-approach.

##########
File path: 
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java
##########
@@ -0,0 +1,492 @@
+package org.apache.maven.plugin.surefire.extensions;
+
+import org.apache.maven.plugin.surefire.extensions.EventConsumerThread.Memento;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
+import org.apache.maven.surefire.api.booter.ForkedProcessEventType;
+import org.apache.maven.surefire.extensions.EventHandler;
+import org.apache.maven.surefire.extensions.ForkNodeArguments;
+import org.apache.maven.surefire.extensions.util.CountdownCloseable;
+import org.fest.assertions.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+import org.mockito.Mockito;
+
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.Channel;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.TimeUnit;
+
+import static java.nio.charset.CodingErrorAction.REPLACE;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static 
org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.EOF;
+import static 
org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.OVERFLOW;
+import static 
org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.UNDERFLOW;
+import static org.apache.maven.surefire.api.booter.Constants.STREAM_ENCODING;
+import static org.fest.assertions.Assertions.assertThat;
+//import static org.mockito.Mockito.mock;
+
+//@RunWith( Parameterized.class )
+public class EventConsumerThreadTest
+{
+    @Parameters
+    public static Iterable<Object> channels()
+    {
+        return Arrays.asList( (Object) complexEncodings() );
+    }
+
+    @Parameter
+    public Channel channel;
+
+    private static Channel complexEncodings()
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 
'b', (byte) 0xc2, (byte) 0xa9, 'c'};
+        bytes = 
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
 UTF_8 );
+        return new Channel( bytes, 1 );
+    }
+
+    private static Channel complexEncodings( int chunkSize )
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 
'b', (byte) 0xc2, (byte) 0xa9, 'c'};
+        bytes = 
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
 UTF_8 );
+        return new Channel( bytes, chunkSize );
+    }
+
+    @Test
+    public void test5() throws IOException, InterruptedException
+    {
+        /*final CharsetDecoder decoder = STREAM_ENCODING.newDecoder()

Review comment:
       ah no, these tests yet contain performance tests. Now they don't have a 
value for us and they can be deleted.
   Yet only `EventConsumerThread` can be reviewed.
   
   Initially i used the tests to measure several approaches for decoding byte[] 
to String, e.g. `new String()` vs CharacterBuffer, strings concatenation, 
decoding with/out number-of-bytes in the stream `:2:AB:`, i had to measure time 
of objects creation, measured the exec time of HashMap and hashcode/equals 
methods - see the class `Segment`  and measured the performance of binary data 
tree against hashcode/equals. So initially these tests were used for selecting 
the right approach means performance/code-approach.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to