[GitHub] Tibor17 commented on a change in pull request #199: Surefire 1593

2018-11-15 Thread GitBox
Tibor17 commented on a change in pull request #199: Surefire 1593
URL: https://github.com/apache/maven-surefire/pull/199#discussion_r233983855
 
 

 ##
 File path: 
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java
 ##
 @@ -0,0 +1,216 @@
+package org.apache.maven.plugin.surefire.booterclient;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Path;
+
+import 
org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
+
+import static 
org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.relativize;
+import static 
org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.toAbsoluteUri;
+import static 
org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.toClasspathElementUri;
+import static org.fest.assertions.Assertions.assertThat;
+
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import static org.mockito.ArgumentMatchers.same;
+import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+/**
+ * Unit tests for {@link JarManifestForkConfiguration}.
+ */
+@RunWith( PowerMockRunner.class )
+@PrepareForTest( { JarManifestForkConfiguration.class, 
InPluginProcessDumpSingleton.class } )
+public class JarManifestForkConfigurationTest
+{
+@ClassRule
+public static final TemporaryFolder TMP = new TemporaryFolder();
+
+private static File dumpDirectory;
+
+@BeforeClass
+public static void createSystemTemporaryDir()
+throws IOException
+{
+TMP.create();
 
 Review comment:
   @jglick 
   done.  
   Avoided `@Rule` in PowerMock test. Used assertion f/w `fest-assert` utility 
class `org.fest.util.Files`.
   I checked the temp folders are properly created and deleted with content in 
it.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] Tibor17 commented on a change in pull request #199: Surefire 1593

2018-11-14 Thread GitBox
Tibor17 commented on a change in pull request #199: Surefire 1593
URL: https://github.com/apache/maven-surefire/pull/199#discussion_r233728638
 
 

 ##
 File path: 
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java
 ##
 @@ -0,0 +1,216 @@
+package org.apache.maven.plugin.surefire.booterclient;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Path;
+
+import 
org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
+
+import static 
org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.relativize;
+import static 
org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.toAbsoluteUri;
+import static 
org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.toClasspathElementUri;
+import static org.fest.assertions.Assertions.assertThat;
+
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import static org.mockito.ArgumentMatchers.same;
+import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+/**
+ * Unit tests for {@link JarManifestForkConfiguration}.
+ */
+@RunWith( PowerMockRunner.class )
+@PrepareForTest( { JarManifestForkConfiguration.class, 
InPluginProcessDumpSingleton.class } )
+public class JarManifestForkConfigurationTest
+{
+@ClassRule
+public static final TemporaryFolder TMP = new TemporaryFolder();
+
+private static File dumpDirectory;
+
+@BeforeClass
+public static void createSystemTemporaryDir()
+throws IOException
+{
+TMP.create();
 
 Review comment:
   The problem is that `create` was not called. Now I found the root cause. 
Powermock does not implement Rules ,


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] Tibor17 commented on a change in pull request #199: Surefire 1593

2018-11-13 Thread GitBox
Tibor17 commented on a change in pull request #199: Surefire 1593
URL: https://github.com/apache/maven-surefire/pull/199#discussion_r233200172
 
 

 ##
 File path: 
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
 ##
 @@ -116,10 +116,10 @@ private File createJar( @Nonnull List classPath, 
@Nonnull String startCl
 StringBuilder cp = new StringBuilder();
 for ( Iterator it = classPath.iterator(); it.hasNext(); )
 {
-File classPathElement = new File( it.next() );
+String classPathElement = it.next();
 String uri = toClasspathElementUri( parent, classPathElement, 
dumpLogDirectory );
 cp.append( uri );
-if ( classPathElement.isDirectory() && !uri.endsWith( "/" ) )
+if ( new File( classPathElement ).isDirectory() && 
!uri.endsWith( "/" ) )
 
 Review comment:
   Thst's correct. The Strings are already platform specific.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] Tibor17 commented on a change in pull request #199: Surefire 1593

2018-11-13 Thread GitBox
Tibor17 commented on a change in pull request #199: Surefire 1593
URL: https://github.com/apache/maven-surefire/pull/199#discussion_r233119261
 
 

 ##
 File path: 
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java
 ##
 @@ -0,0 +1,190 @@
+package org.apache.maven.plugin.surefire.booterclient;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.net.URI;
+
+import 
org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
+import static org.fest.assertions.Assertions.assertThat;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.when;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+/**
+ * Unit tests for {@link JarManifestForkConfiguration}.
+ */
+@RunWith( PowerMockRunner.class )
+@PrepareForTest( { JarManifestForkConfiguration.class, 
InPluginProcessDumpSingleton.class } )
+public class JarManifestForkConfigurationTest
+{
+private static final String BASE_DIR = System.getProperty( "user.dir" );
+
+@Test
+public void relativeClasspathUnixSimple()
+throws Exception
+{
+mockStatic( JarManifestForkConfiguration.class );
+String parent = "/home/me/prj/target/surefire";
+String classPathElement = 
"/home/me/.m2/repository/grp/art/1.0/art-1.0.jar";
+when( JarManifestForkConfiguration.relativize( parent, 
classPathElement ) )
+.thenReturn( "../../../.m2/repository/grp/art/1.0/art-1.0.jar" 
);
+when( JarManifestForkConfiguration.toClasspathElementUri( anyString(), 
anyString(), any( File.class ) ) )
+.thenCallRealMethod();
+File dump = new File( BASE_DIR, "target/test-dump" );
+//noinspection ResultOfMethodCallIgnored
+dump.mkdir();
+assertThat( JarManifestForkConfiguration.toClasspathElementUri( 
parent, classPathElement, dump ) )
+.isEqualTo( "../../../.m2/repository/grp/art/1.0/art-1.0.jar" 
);
+}
+
+@Test
+public void relativeClasspathUnixTricky()
+throws Exception
+{
+mockStatic( JarManifestForkConfiguration.class );
+String parent = "/home/me/prj/target/surefire";
+String classPathElement = "/the Maven repo/grp/art/1.0/art-1.0.jar";
+when( JarManifestForkConfiguration.relativize( parent, 
classPathElement ) )
+.thenReturn( "../../../../../the Maven 
repo/grp/art/1.0/art-1.0.jar" );
+when( JarManifestForkConfiguration.toClasspathElementUri( anyString(), 
anyString(), any( File.class ) ) )
+.thenCallRealMethod();
+File dump = new File( BASE_DIR, "target/test-dump" );
+assertThat( JarManifestForkConfiguration.toClasspathElementUri( 
parent, classPathElement, dump ) )
+.isEqualTo( 
"../../../../../the%20Maven%20repo/grp/art/1.0/art-1.0.jar" );
+}
+
+@Test
+public void relativeClasspathWindowsSimple()
+throws Exception
+{
+mockStatic( JarManifestForkConfiguration.class );
+String parent = "C:\\Windows\\Temp\\surefire";
+String classPathElement = 
"C:\\Users\\me\\.m2\\repository\\grp\\art\\1.0\\art-1.0.jar";
+when( JarManifestForkConfiguration.relativize( parent, 
classPathElement ) )
+.thenReturn( 
"..\\..\\..\\Users\\me\\.m2\\repository\\grp\\art\\1.0\\art-1.0.jar" );
+when( JarManifestForkConfiguration.toClasspathElementUri( anyString(), 
anyString(), any( File.class ) ) )
+.thenCallRealMethod();
+File dump = new File( BASE_DIR, "target/test-dump" );
+assertThat( JarManifestForkConfiguration.toClasspathElementUri( 
parent, classPathElement, dump ) )
+.isEqualTo( 
"../../../Users/me/.m2/repository/grp/art/1.0/art-1.0.jar" );
+}
+
+@Test
+

[GitHub] Tibor17 commented on a change in pull request #199: Surefire 1593

2018-11-13 Thread GitBox
Tibor17 commented on a change in pull request #199: Surefire 1593
URL: https://github.com/apache/maven-surefire/pull/199#discussion_r233115721
 
 

 ##
 File path: 
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java
 ##
 @@ -0,0 +1,190 @@
+package org.apache.maven.plugin.surefire.booterclient;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.net.URI;
+
+import 
org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
+import static org.fest.assertions.Assertions.assertThat;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.when;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+/**
+ * Unit tests for {@link JarManifestForkConfiguration}.
+ */
+@RunWith( PowerMockRunner.class )
+@PrepareForTest( { JarManifestForkConfiguration.class, 
InPluginProcessDumpSingleton.class } )
+public class JarManifestForkConfigurationTest
+{
+private static final String BASE_DIR = System.getProperty( "user.dir" );
 
 Review comment:
   These are files for testing purposes in target folder. Here we run the build 
`mvn install` in the root and not in a child. Even if you run this particular 
test in IntelliJIDEA, the `user.dir` is `maven-surefire-common/pom.xml`, so I 
think it is fine for this test but we can create the temporal folders in TEMP 
if you like, this does not harm the goal of the test.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] Tibor17 commented on a change in pull request #199: Surefire 1593

2018-11-10 Thread GitBox
Tibor17 commented on a change in pull request #199: Surefire 1593
URL: https://github.com/apache/maven-surefire/pull/199#discussion_r232476665
 
 

 ##
 File path: 
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
 ##
 @@ -116,10 +116,10 @@ private File createJar( @Nonnull List classPath, 
@Nonnull String startCl
 StringBuilder cp = new StringBuilder();
 for ( Iterator it = classPath.iterator(); it.hasNext(); )
 {
-File classPathElement = new File( it.next() );
+String classPathElement = it.next();
 String uri = toClasspathElementUri( parent, classPathElement, 
dumpLogDirectory );
 cp.append( uri );
-if ( classPathElement.isDirectory() && !uri.endsWith( "/" ) )
+if ( new File( classPathElement ).isDirectory() && 
!uri.endsWith( "/" ) )
 
 Review comment:
   I am totally with you. Let's wait for @jglick until he makes all changes.
   off-topic: We have one JUnit5 issue and some easy issues to fix. I guess we 
can release a new release candidate next week,


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] Tibor17 commented on a change in pull request #199: Surefire 1593

2018-11-10 Thread GitBox
Tibor17 commented on a change in pull request #199: Surefire 1593
URL: https://github.com/apache/maven-surefire/pull/199#discussion_r232466200
 
 

 ##
 File path: 
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
 ##
 @@ -116,10 +116,10 @@ private File createJar( @Nonnull List classPath, 
@Nonnull String startCl
 StringBuilder cp = new StringBuilder();
 for ( Iterator it = classPath.iterator(); it.hasNext(); )
 {
-File classPathElement = new File( it.next() );
+String classPathElement = it.next();
 String uri = toClasspathElementUri( parent, classPathElement, 
dumpLogDirectory );
 cp.append( uri );
-if ( classPathElement.isDirectory() && !uri.endsWith( "/" ) )
+if ( new File( classPathElement ).isDirectory() && 
!uri.endsWith( "/" ) )
 
 Review comment:
   It would be nice to have `Path parent` created once before the loop.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] Tibor17 commented on a change in pull request #199: Surefire 1593

2018-11-10 Thread GitBox
Tibor17 commented on a change in pull request #199: Surefire 1593
URL: https://github.com/apache/maven-surefire/pull/199#discussion_r232466133
 
 

 ##
 File path: 
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
 ##
 @@ -116,10 +116,10 @@ private File createJar( @Nonnull List classPath, 
@Nonnull String startCl
 StringBuilder cp = new StringBuilder();
 for ( Iterator it = classPath.iterator(); it.hasNext(); )
 {
-File classPathElement = new File( it.next() );
+String classPathElement = it.next();
 String uri = toClasspathElementUri( parent, classPathElement, 
dumpLogDirectory );
 cp.append( uri );
-if ( classPathElement.isDirectory() && !uri.endsWith( "/" ) )
+if ( new File( classPathElement ).isDirectory() && 
!uri.endsWith( "/" ) )
 
 Review comment:
   @eolivelli 
   yes, and moreover we should change the method signature from this:
   `toClasspathElementUri( String parent, String classPathElement, File 
dumpLogDirectory )`
   to this:
   `toClasspathElementUri( Path parent, Path classPathElement, Path 
dumpLogDirectory )`
   Which requires calling `dumpLogDir.toPath()` in `ForkStarter` (Line 580) but 
pls do not go deeper changing File to Path in all project since it is not a 
matter of this PR.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services