You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by GitBox <gi...@apache.org> on 2020/05/04 12:44:43 UTC

[GitHub] [uima-uimaj] reckart opened a new pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

reckart opened a new pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39


   - Escape XML element values in XMLUtil (which is used to serialize PEAR installation descriptors
   - Added unit test trying to install PEAR into a path with an XML special character
   - Cleaned up and modernized TestPearInstallationVerification
   - Formatted XMLUtil (basically adding missing curlies)


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [uima-uimaj] reckart commented on a change in pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

Posted by GitBox <gi...@apache.org>.
reckart commented on a change in pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39#discussion_r419742881



##########
File path: uimaj-core/src/main/java/org/apache/uima/pear/util/XMLUtil.java
##########
@@ -828,4 +862,18 @@ public static void printXMLTag(String tag, Properties attributes, PrintWriter oW
     oWriter.print('>');
     oWriter.flush();
   }
+  
+  private static String xmlEscape(String value)
+  {
+      if (value == null) {
+          return value;
+      }
+      
+      return value
+              .replace("&", "&amp;")

Review comment:
       Btw. I was considering to use XML escaping methods form commons-lang3 or commons-text, but didn't want to introduce the dependency. I was also considering to port this whole stuff over to Xmlizable (i.e what other UIMA descriptors use) or even JAXB - but again, it seemed to much for the time being.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [uima-uimaj] reckart commented on pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

Posted by GitBox <gi...@apache.org>.
reckart commented on pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39#issuecomment-623442189


   When reviewing, please switch the diff view to ignore whitespace to reduce visual clutter introduced by the formatting/curlies:
   
   ![Screenshot 2020-05-04 at 14 45 05](https://user-images.githubusercontent.com/1410238/80966983-e6736100-8e15-11ea-94d5-4ef3700d270b.png)
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [uima-uimaj] reckart commented on a change in pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

Posted by GitBox <gi...@apache.org>.
reckart commented on a change in pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39#discussion_r421053452



##########
File path: uimaj-core/src/main/java/org/apache/uima/pear/util/XMLUtil.java
##########
@@ -828,4 +862,18 @@ public static void printXMLTag(String tag, Properties attributes, PrintWriter oW
     oWriter.print('>');
     oWriter.flush();
   }
+  
+  private static String xmlEscape(String value)
+  {
+      if (value == null) {
+          return value;
+      }
+      
+      return value
+              .replace("&", "&amp;")

Review comment:
       Incidentally, when I first heard of the issue, I even suggested to simply escape the path before passing it to the PEAR installer, but got told it had already been tried and also hadn't worked.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [uima-uimaj] mischor commented on a change in pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

Posted by GitBox <gi...@apache.org>.
mischor commented on a change in pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39#discussion_r421746306



##########
File path: uimaj-core/src/test/java/org/apache/uima/pear/util/TestPearInstallationVerification.java
##########
@@ -19,107 +19,76 @@
 
 package org.apache.uima.pear.util;
 
-import java.io.File;
+import static org.apache.uima.pear.tools.InstallationController.TestStatus.TEST_SUCCESSFUL;
+import static org.apache.uima.test.junit_extension.JUnitExtension.getFile;
+import static org.assertj.core.api.Assertions.assertThat;
 
-import org.junit.Assert;
-import junit.framework.TestCase;
+import java.io.File;
+import java.io.IOException;
 
+import org.apache.uima.UIMAException;
+import org.apache.uima.UIMARuntimeException;
 import org.apache.uima.pear.tools.InstallationController.TestStatus;
 import org.apache.uima.pear.tools.InstallationTester;
 import org.apache.uima.pear.tools.PackageBrowser;
 import org.apache.uima.pear.tools.PackageInstaller;
-import org.apache.uima.test.junit_extension.JUnitExtension;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.util.InvalidXMLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 /**
  * Test the pear installation verification
- * 
  */
-public class TestPearInstallationVerification extends TestCase {
+public class TestPearInstallationVerification {
 
   // Temporary working directory, used to install the pear package
-  private File tempInstallDir = null;
+  public @Rule TemporaryFolder temp = new TemporaryFolder();
+  
+  @Test
+  public void testAePearVerification() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/analysisEngine.pear"), 
+            temp.newFolder("pear_verification_test_tmp"));
+  }
 
-  /**
-   * @see junit.framework.TestCase#setUp()
-   */
-  protected void setUp() throws Exception {
-    
-    // create temporary working directory
-    File tempFile = File.createTempFile("pear_verification_test_", "tmp");
-    if (tempFile.delete()) {
-      File tempDir = tempFile;
-      if (tempDir.mkdirs())
-        this.tempInstallDir = tempDir;
-    }
+  @Test
+  public void testCcPearVerification() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/casConsumer.pear"), 
+            temp.newFolder("pear_verification_test_tmp"));
   }
 
-  /**
-   * @see junit.framework.TestCase#tearDown()
-   */
-  protected void tearDown() throws Exception {
-    if (this.tempInstallDir != null) {
-      FileUtil.deleteDirectory(this.tempInstallDir);
-    }
+  @Test
+  public void testTsPearVerification() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/typeSystem.pear"), 
+            temp.newFolder("pear_verification_test_tmp"));
   }
 
-  
-  public void testAePearVerification() throws Exception {
-    
-     //get pear file to install
-    File pearFile = JUnitExtension.getFile("pearTests/analysisEngine.pear");
-    Assert.assertNotNull("analysisEngine.pear file not found", pearFile);
-    
-    // Install PEAR package without verification
-    PackageBrowser instPear = PackageInstaller.installPackage(
-            this.tempInstallDir, pearFile, false);
-    
-    //check package browser
-    Assert.assertNotNull("PackageBrowser is null", instPear);
-       
-    InstallationTester installTester = new InstallationTester(instPear);
-    TestStatus status = installTester.doTest();
-    
-    Assert.assertEquals(status.getRetCode(), TestStatus.TEST_SUCCESSFUL);
+  // TODO: create testcases for ci, cr, cpe pear packages
+
+  @Test
+  public void thatSpecialXmlCharactersInTargetPathDoNotBreakInstallation() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/analysisEngine.pear"),
+            temp.newFolder("<>'\"&"));
   }
 
-  public void testCcPearVerification() throws Exception {
-    
-    //get pear file to install
-   File pearFile = JUnitExtension.getFile("pearTests/casConsumer.pear");
-   Assert.assertNotNull("casConsumer.pear file not found", pearFile);
-   
-   // Install PEAR package without verification
-   PackageBrowser instPear = PackageInstaller.installPackage(
-           this.tempInstallDir, pearFile, false);
-   
-   //check package browser
-   Assert.assertNotNull("PackageBrowser is null", instPear);
-      
-   InstallationTester installTester = new InstallationTester(instPear);
-   TestStatus status = installTester.doTest();
-   
-   Assert.assertEquals(status.getRetCode(), TestStatus.TEST_SUCCESSFUL);
- }
+  private void assertThatPearInstalls(File pearFile, File targetDir) throws InvalidXMLException,
+          ResourceInitializationException, UIMARuntimeException, UIMAException, IOException {
+    assertThat(pearFile).as("PEAR file %s not found", pearFile).isNotNull();
 
-  public void testTsPearVerification() throws Exception {
-    
-    //get pear file to install
-   File pearFile = JUnitExtension.getFile("pearTests/typeSystem.pear");
-   Assert.assertNotNull("typeSystem.pear file not found", pearFile);
-   
-   // Install PEAR package without verification
-   PackageBrowser instPear = PackageInstaller.installPackage(
-           this.tempInstallDir, pearFile, false);
-   
-   //check package browser
-   Assert.assertNotNull("PackageBrowser is null", instPear);
-      
-   InstallationTester installTester = new InstallationTester(instPear);
-   TestStatus status = installTester.doTest();
-   
-   Assert.assertEquals(status.getRetCode(), TestStatus.TEST_SUCCESSFUL);
- }
+    // Install PEAR package without verification
+    PackageBrowser instPear = PackageInstaller.installPackage(targetDir, pearFile, false);
 
-  //TODO: create testcases for ci, cr, cpe pear packages
+    // Check package browser
+    assertThat(instPear).as("PackageBrowser is null").isNotNull();

Review comment:
       Well, not quite.  I made no assumptions.  Instead I did what many (?) might do - I entered the terms into google, and looked at the first several hits.  I guess AssertJ is farther down the list than I looked :-)
   
   Perhaps it would be good to notate in some obvious spot for a future maintainer, not familiar with this code (like me), the use of assertj.  




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [uima-uimaj] reckart commented on a change in pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

Posted by GitBox <gi...@apache.org>.
reckart commented on a change in pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39#discussion_r420875440



##########
File path: uimaj-core/src/main/java/org/apache/uima/pear/util/XMLUtil.java
##########
@@ -828,4 +862,18 @@ public static void printXMLTag(String tag, Properties attributes, PrintWriter oW
     oWriter.print('>');
     oWriter.flush();
   }
+  
+  private static String xmlEscape(String value)
+  {
+      if (value == null) {
+          return value;
+      }
+      
+      return value
+              .replace("&", "&amp;")

Review comment:
       Yep. Also, the thing that in particular the path is not only substituted in the XML file but also used to actually control the location where the pear is installed. So if it contained an `&amp;`, then the folder name would include the `&amp;` but when parsing the XML descriptor the `&amp;` would become a `&` and would no longer match the installation path.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [uima-uimaj] reckart commented on a change in pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

Posted by GitBox <gi...@apache.org>.
reckart commented on a change in pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39#discussion_r419741389



##########
File path: uimaj-core/src/main/java/org/apache/uima/pear/util/XMLUtil.java
##########
@@ -828,4 +862,18 @@ public static void printXMLTag(String tag, Properties attributes, PrintWriter oW
     oWriter.print('>');
     oWriter.flush();
   }
+  
+  private static String xmlEscape(String value)
+  {
+      if (value == null) {
+          return value;
+      }
+      
+      return value
+              .replace("&", "&amp;")

Review comment:
       I expect if the user had already written `&amp;`, then it is because the path includes `&amp;` and not because the user wants the the stuff being unescaped. 
   
   I mean if you want to install a PEAR in `/tmp/&amp;foldername`, then you don't want to loo for it in `/tmp/&foldername`, right?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [uima-uimaj] mischor commented on a change in pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

Posted by GitBox <gi...@apache.org>.
mischor commented on a change in pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39#discussion_r419740023



##########
File path: uimaj-core/src/main/java/org/apache/uima/pear/util/XMLUtil.java
##########
@@ -828,4 +862,18 @@ public static void printXMLTag(String tag, Properties attributes, PrintWriter oW
     oWriter.print('>');
     oWriter.flush();
   }
+  
+  private static String xmlEscape(String value)
+  {
+      if (value == null) {
+          return value;
+      }
+      
+      return value
+              .replace("&", "&amp;")

Review comment:
       I wonder if the user has already written &lt; for example, would this result in &amplt; ? In other words, does the replacement need  to first confirm that the character being replaced, isn't already in the right escape format?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [uima-uimaj] mischor commented on a change in pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

Posted by GitBox <gi...@apache.org>.
mischor commented on a change in pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39#discussion_r419744001



##########
File path: uimaj-core/src/main/java/org/apache/uima/pear/util/XMLUtil.java
##########
@@ -828,4 +862,18 @@ public static void printXMLTag(String tag, Properties attributes, PrintWriter oW
     oWriter.print('>');
     oWriter.flush();
   }
+  
+  private static String xmlEscape(String value)
+  {
+      if (value == null) {
+          return value;
+      }
+      
+      return value
+              .replace("&", "&amp;")

Review comment:
       This apache commons project has xml escape code for both xml version 1.0 and 1.1.  It seems it might do more than this.  I think it would be worth a look...

##########
File path: uimaj-core/src/main/java/org/apache/uima/pear/util/XMLUtil.java
##########
@@ -828,4 +862,18 @@ public static void printXMLTag(String tag, Properties attributes, PrintWriter oW
     oWriter.print('>');
     oWriter.flush();
   }
+  
+  private static String xmlEscape(String value)
+  {
+      if (value == null) {
+          return value;
+      }
+      
+      return value
+              .replace("&", "&amp;")

Review comment:
       https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/StringEscapeUtils.html




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [uima-uimaj] reckart commented on a change in pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

Posted by GitBox <gi...@apache.org>.
reckart commented on a change in pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39#discussion_r421696199



##########
File path: uimaj-core/src/test/java/org/apache/uima/pear/util/TestPearInstallationVerification.java
##########
@@ -19,107 +19,76 @@
 
 package org.apache.uima.pear.util;
 
-import java.io.File;
+import static org.apache.uima.pear.tools.InstallationController.TestStatus.TEST_SUCCESSFUL;
+import static org.apache.uima.test.junit_extension.JUnitExtension.getFile;
+import static org.assertj.core.api.Assertions.assertThat;
 
-import org.junit.Assert;
-import junit.framework.TestCase;
+import java.io.File;
+import java.io.IOException;
 
+import org.apache.uima.UIMAException;
+import org.apache.uima.UIMARuntimeException;
 import org.apache.uima.pear.tools.InstallationController.TestStatus;
 import org.apache.uima.pear.tools.InstallationTester;
 import org.apache.uima.pear.tools.PackageBrowser;
 import org.apache.uima.pear.tools.PackageInstaller;
-import org.apache.uima.test.junit_extension.JUnitExtension;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.util.InvalidXMLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 /**
  * Test the pear installation verification
- * 
  */
-public class TestPearInstallationVerification extends TestCase {
+public class TestPearInstallationVerification {
 
   // Temporary working directory, used to install the pear package
-  private File tempInstallDir = null;
+  public @Rule TemporaryFolder temp = new TemporaryFolder();
+  
+  @Test
+  public void testAePearVerification() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/analysisEngine.pear"), 
+            temp.newFolder("pear_verification_test_tmp"));
+  }
 
-  /**
-   * @see junit.framework.TestCase#setUp()
-   */
-  protected void setUp() throws Exception {
-    
-    // create temporary working directory
-    File tempFile = File.createTempFile("pear_verification_test_", "tmp");
-    if (tempFile.delete()) {
-      File tempDir = tempFile;
-      if (tempDir.mkdirs())
-        this.tempInstallDir = tempDir;
-    }
+  @Test
+  public void testCcPearVerification() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/casConsumer.pear"), 
+            temp.newFolder("pear_verification_test_tmp"));
   }
 
-  /**
-   * @see junit.framework.TestCase#tearDown()
-   */
-  protected void tearDown() throws Exception {
-    if (this.tempInstallDir != null) {
-      FileUtil.deleteDirectory(this.tempInstallDir);
-    }
+  @Test
+  public void testTsPearVerification() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/typeSystem.pear"), 
+            temp.newFolder("pear_verification_test_tmp"));
   }
 
-  
-  public void testAePearVerification() throws Exception {
-    
-     //get pear file to install
-    File pearFile = JUnitExtension.getFile("pearTests/analysisEngine.pear");
-    Assert.assertNotNull("analysisEngine.pear file not found", pearFile);
-    
-    // Install PEAR package without verification
-    PackageBrowser instPear = PackageInstaller.installPackage(
-            this.tempInstallDir, pearFile, false);
-    
-    //check package browser
-    Assert.assertNotNull("PackageBrowser is null", instPear);
-       
-    InstallationTester installTester = new InstallationTester(instPear);
-    TestStatus status = installTester.doTest();
-    
-    Assert.assertEquals(status.getRetCode(), TestStatus.TEST_SUCCESSFUL);
+  // TODO: create testcases for ci, cr, cpe pear packages
+
+  @Test
+  public void thatSpecialXmlCharactersInTargetPathDoNotBreakInstallation() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/analysisEngine.pear"),
+            temp.newFolder("<>'\"&"));
   }
 
-  public void testCcPearVerification() throws Exception {
-    
-    //get pear file to install
-   File pearFile = JUnitExtension.getFile("pearTests/casConsumer.pear");
-   Assert.assertNotNull("casConsumer.pear file not found", pearFile);
-   
-   // Install PEAR package without verification
-   PackageBrowser instPear = PackageInstaller.installPackage(
-           this.tempInstallDir, pearFile, false);
-   
-   //check package browser
-   Assert.assertNotNull("PackageBrowser is null", instPear);
-      
-   InstallationTester installTester = new InstallationTester(instPear);
-   TestStatus status = installTester.doTest();
-   
-   Assert.assertEquals(status.getRetCode(), TestStatus.TEST_SUCCESSFUL);
- }
+  private void assertThatPearInstalls(File pearFile, File targetDir) throws InvalidXMLException,
+          ResourceInitializationException, UIMARuntimeException, UIMAException, IOException {
+    assertThat(pearFile).as("PEAR file %s not found", pearFile).isNotNull();
 
-  public void testTsPearVerification() throws Exception {
-    
-    //get pear file to install
-   File pearFile = JUnitExtension.getFile("pearTests/typeSystem.pear");
-   Assert.assertNotNull("typeSystem.pear file not found", pearFile);
-   
-   // Install PEAR package without verification
-   PackageBrowser instPear = PackageInstaller.installPackage(
-           this.tempInstallDir, pearFile, false);
-   
-   //check package browser
-   Assert.assertNotNull("PackageBrowser is null", instPear);
-      
-   InstallationTester installTester = new InstallationTester(instPear);
-   TestStatus status = installTester.doTest();
-   
-   Assert.assertEquals(status.getRetCode(), TestStatus.TEST_SUCCESSFUL);
- }
+    // Install PEAR package without verification
+    PackageBrowser instPear = PackageInstaller.installPackage(targetDir, pearFile, false);
 
-  //TODO: create testcases for ci, cr, cpe pear packages
+    // Check package browser
+    assertThat(instPear).as("PackageBrowser is null").isNotNull();

Review comment:
       You assume that I am using junit assert but I use AssertJ.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [uima-uimaj] mischor commented on a change in pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

Posted by GitBox <gi...@apache.org>.
mischor commented on a change in pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39#discussion_r420870353



##########
File path: uimaj-core/src/main/java/org/apache/uima/pear/util/XMLUtil.java
##########
@@ -828,4 +862,18 @@ public static void printXMLTag(String tag, Properties attributes, PrintWriter oW
     oWriter.print('>');
     oWriter.flush();
   }
+  
+  private static String xmlEscape(String value)
+  {
+      if (value == null) {
+          return value;
+      }
+      
+      return value
+              .replace("&", "&amp;")

Review comment:
       So, your point is that this xml cleanup code is only used within the Pear context, where it would not be reasonable for anyone to have inputted the & char in an attempt to escape something?
   
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [uima-uimaj] mischor commented on a change in pull request #39: [UIMA-6225] Unable to install a pear package into a directory containing special character like <,> or &

Posted by GitBox <gi...@apache.org>.
mischor commented on a change in pull request #39:
URL: https://github.com/apache/uima-uimaj/pull/39#discussion_r421608096



##########
File path: uimaj-core/src/test/java/org/apache/uima/pear/util/TestPearInstallationVerification.java
##########
@@ -19,107 +19,76 @@
 
 package org.apache.uima.pear.util;
 
-import java.io.File;
+import static org.apache.uima.pear.tools.InstallationController.TestStatus.TEST_SUCCESSFUL;
+import static org.apache.uima.test.junit_extension.JUnitExtension.getFile;
+import static org.assertj.core.api.Assertions.assertThat;
 
-import org.junit.Assert;
-import junit.framework.TestCase;
+import java.io.File;
+import java.io.IOException;
 
+import org.apache.uima.UIMAException;
+import org.apache.uima.UIMARuntimeException;
 import org.apache.uima.pear.tools.InstallationController.TestStatus;
 import org.apache.uima.pear.tools.InstallationTester;
 import org.apache.uima.pear.tools.PackageBrowser;
 import org.apache.uima.pear.tools.PackageInstaller;
-import org.apache.uima.test.junit_extension.JUnitExtension;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.util.InvalidXMLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 /**
  * Test the pear installation verification
- * 
  */
-public class TestPearInstallationVerification extends TestCase {
+public class TestPearInstallationVerification {
 
   // Temporary working directory, used to install the pear package
-  private File tempInstallDir = null;
+  public @Rule TemporaryFolder temp = new TemporaryFolder();
+  
+  @Test
+  public void testAePearVerification() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/analysisEngine.pear"), 
+            temp.newFolder("pear_verification_test_tmp"));
+  }
 
-  /**
-   * @see junit.framework.TestCase#setUp()
-   */
-  protected void setUp() throws Exception {
-    
-    // create temporary working directory
-    File tempFile = File.createTempFile("pear_verification_test_", "tmp");
-    if (tempFile.delete()) {
-      File tempDir = tempFile;
-      if (tempDir.mkdirs())
-        this.tempInstallDir = tempDir;
-    }
+  @Test
+  public void testCcPearVerification() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/casConsumer.pear"), 
+            temp.newFolder("pear_verification_test_tmp"));
   }
 
-  /**
-   * @see junit.framework.TestCase#tearDown()
-   */
-  protected void tearDown() throws Exception {
-    if (this.tempInstallDir != null) {
-      FileUtil.deleteDirectory(this.tempInstallDir);
-    }
+  @Test
+  public void testTsPearVerification() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/typeSystem.pear"), 
+            temp.newFolder("pear_verification_test_tmp"));
   }
 
-  
-  public void testAePearVerification() throws Exception {
-    
-     //get pear file to install
-    File pearFile = JUnitExtension.getFile("pearTests/analysisEngine.pear");
-    Assert.assertNotNull("analysisEngine.pear file not found", pearFile);
-    
-    // Install PEAR package without verification
-    PackageBrowser instPear = PackageInstaller.installPackage(
-            this.tempInstallDir, pearFile, false);
-    
-    //check package browser
-    Assert.assertNotNull("PackageBrowser is null", instPear);
-       
-    InstallationTester installTester = new InstallationTester(instPear);
-    TestStatus status = installTester.doTest();
-    
-    Assert.assertEquals(status.getRetCode(), TestStatus.TEST_SUCCESSFUL);
+  // TODO: create testcases for ci, cr, cpe pear packages
+
+  @Test
+  public void thatSpecialXmlCharactersInTargetPathDoNotBreakInstallation() throws Exception {
+    assertThatPearInstalls(
+            getFile("pearTests/analysisEngine.pear"),
+            temp.newFolder("<>'\"&"));
   }
 
-  public void testCcPearVerification() throws Exception {
-    
-    //get pear file to install
-   File pearFile = JUnitExtension.getFile("pearTests/casConsumer.pear");
-   Assert.assertNotNull("casConsumer.pear file not found", pearFile);
-   
-   // Install PEAR package without verification
-   PackageBrowser instPear = PackageInstaller.installPackage(
-           this.tempInstallDir, pearFile, false);
-   
-   //check package browser
-   Assert.assertNotNull("PackageBrowser is null", instPear);
-      
-   InstallationTester installTester = new InstallationTester(instPear);
-   TestStatus status = installTester.doTest();
-   
-   Assert.assertEquals(status.getRetCode(), TestStatus.TEST_SUCCESSFUL);
- }
+  private void assertThatPearInstalls(File pearFile, File targetDir) throws InvalidXMLException,
+          ResourceInitializationException, UIMARuntimeException, UIMAException, IOException {
+    assertThat(pearFile).as("PEAR file %s not found", pearFile).isNotNull();
 
-  public void testTsPearVerification() throws Exception {
-    
-    //get pear file to install
-   File pearFile = JUnitExtension.getFile("pearTests/typeSystem.pear");
-   Assert.assertNotNull("typeSystem.pear file not found", pearFile);
-   
-   // Install PEAR package without verification
-   PackageBrowser instPear = PackageInstaller.installPackage(
-           this.tempInstallDir, pearFile, false);
-   
-   //check package browser
-   Assert.assertNotNull("PackageBrowser is null", instPear);
-      
-   InstallationTester installTester = new InstallationTester(instPear);
-   TestStatus status = installTester.doTest();
-   
-   Assert.assertEquals(status.getRetCode(), TestStatus.TEST_SUCCESSFUL);
- }
+    // Install PEAR package without verification
+    PackageBrowser instPear = PackageInstaller.installPackage(targetDir, pearFile, false);
 
-  //TODO: create testcases for ci, cr, cpe pear packages
+    // Check package browser
+    assertThat(instPear).as("PackageBrowser is null").isNotNull();

Review comment:
       Where is assertThat().as() documented?  I tried googling assertThat, but the hits I found say that assertThat returns "void", so an .as(...) etc. won't work?
   
   I found it hard to find a google hit for assertThat that gave the concise "spec" of this method.  There is a javadoc for it but it says it's deprecated, and to use use org.hamcrest.MatcherAssert.assertThat() which also says that assertThat returns void.
   
   Where did I go astray? 




----------------------------------------------------------------
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:
users@infra.apache.org