You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by si...@apache.org on 2020/02/15 05:51:47 UTC

[incubator-pinot] branch master updated: Use getResourceAsStream to load test resource file packaged inside (#5072)

This is an automated email from the ASF dual-hosted git repository.

siddteotia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 4be7490  Use getResourceAsStream to load test resource file packaged inside (#5072)
4be7490 is described below

commit 4be7490eeef635157fc62d8750a5dde6e5a5db5e
Author: Sidd <si...@gmail.com>
AuthorDate: Fri Feb 14 21:51:36 2020 -0800

    Use getResourceAsStream to load test resource file packaged inside (#5072)
    
    test jar.
    
    Text search integration test which is in pinot-integrations tests
    module uses test data resources from pinot-core. pinot-core test
    jar is available to pinot-integration-tests module via
    pom dependency.
    
    However, our internal release builds failed since the test file
    is actually present in pinot-core-VERSION-SNAPSHOT-tests.jar.
    
    getClass().getClassLoader().getResource() works only if the resource
    is a physical file object. For resources available inside jars,
    the path as an "!" to denote that resource is actually inside a
    jar. getResourceAsStream() should be used in such cases
---
 .../pinot/integration/tests/LuceneRealtimeClusterIntegrationTest.java | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/LuceneRealtimeClusterIntegrationTest.java b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/LuceneRealtimeClusterIntegrationTest.java
index 7bbeb27..73003e5 100644
--- a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/LuceneRealtimeClusterIntegrationTest.java
+++ b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/LuceneRealtimeClusterIntegrationTest.java
@@ -127,11 +127,9 @@ public class LuceneRealtimeClusterIntegrationTest extends BaseClusterIntegration
   private File createAvroFile()
       throws Exception {
     // read the skills file
-    URL resourceUrl = getClass().getClassLoader().getResource("data/text_search_data/skills.txt");
-    File skillFile = new File(resourceUrl.getFile());
     String[] skills = new String[100];
     int skillCount = 0;
-    try (InputStream inputStream = new FileInputStream(skillFile);
+    try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("data/text_search_data/skills.txt");
         BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
       String line;
       while ((line = reader.readLine()) != null) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org