LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  October 2015

HPS-SVN October 2015

Subject:

r3870 - in /data/trunk/test-data: ./ src/ src/assembly/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/hps/ src/main/java/org/hps/data/ src/main/java/org/hps/data/test/ src/main/resources/ src/main/resources/org/ src/main/resources/org/hps/ src/main/resources/org/hps/data/ src/main/resources/org/hps/data/test/

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Thu, 22 Oct 2015 00:03:44 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (272 lines)

Author: [log in to unmask]
Date: Wed Oct 21 17:03:42 2015
New Revision: 3870

Log:
[HPSJAVA-624] Import currently used test data into SVN and provide a simple utility for accessing it as a classpath resource.

Added:
    data/trunk/test-data/
    data/trunk/test-data/pom.xml
    data/trunk/test-data/src/
    data/trunk/test-data/src/assembly/
    data/trunk/test-data/src/assembly/archive.xml
    data/trunk/test-data/src/main/
    data/trunk/test-data/src/main/java/
    data/trunk/test-data/src/main/java/org/
    data/trunk/test-data/src/main/java/org/hps/
    data/trunk/test-data/src/main/java/org/hps/data/
    data/trunk/test-data/src/main/java/org/hps/data/test/
    data/trunk/test-data/src/main/java/org/hps/data/test/TestDataUtility.java
    data/trunk/test-data/src/main/resources/
    data/trunk/test-data/src/main/resources/org/
    data/trunk/test-data/src/main/resources/org/hps/
    data/trunk/test-data/src/main/resources/org/hps/data/
    data/trunk/test-data/src/main/resources/org/hps/data/test/
    data/trunk/test-data/src/main/resources/org/hps/data/test/ConditionsTest.slcio   (with props)
    data/trunk/test-data/src/main/resources/org/hps/data/test/DataQualityMonitorTest.slcio   (with props)
    data/trunk/test-data/src/main/resources/org/hps/data/test/MockDataReconTest.slcio   (with props)
    data/trunk/test-data/src/main/resources/org/hps/data/test/ReadoutNoPileupTest.slcio   (with props)
    data/trunk/test-data/src/main/resources/org/hps/data/test/ReadoutToLcioTest.slcio   (with props)
    data/trunk/test-data/src/main/resources/org/hps/data/test/e-_1.056GeV_SLIC-v05-00-00_Geant4-v10-01-02_QGSP_BERT_HPS-EngRun2015-Nominal-v3.slcio   (with props)
    data/trunk/test-data/src/main/resources/org/hps/data/test/hps1351_test.evio   (with props)
    data/trunk/test-data/src/main/resources/org/hps/data/test/run5772_integrationTest.evio   (with props)
    data/trunk/test-data/src/main/resources/org/hps/data/test/run5772_pass1_stripOneFee_5000Events.evio   (with props)
    data/trunk/test-data/src/main/resources/org/hps/data/test/svt_evio_reader_test.evio   (with props)
    data/trunk/test-data/src/main/resources/org/hps/data/test/tritrigv1-egsv3-triv2-g4v1_s2d6_HPS-EngRun2015-Nominal-v3_3.4.0_pairs1_1.slcio   (with props)

Added: data/trunk/test-data/pom.xml
 =============================================================================
--- data/trunk/test-data/pom.xml	(added)
+++ data/trunk/test-data/pom.xml	Wed Oct 21 17:03:42 2015
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>hps-test-data</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>test-data</name>
+    <description>test data</description>
+    <parent>
+        <groupId>org.hps</groupId>
+        <artifactId>hps-parent</artifactId>
+        <version>3.4.1</version>
+    </parent>
+    <scm>
+        <url>http://java.freehep.org/svn/repos/hps/list/data/test-data/</url>
+        <connection>scm:svn:svn://svn.freehep.org/hps/data/test-data/</connection>
+        <developerConnection>scm:svn:svn://svn.freehep.org/hps/data/test-data/</developerConnection>
+    </scm>
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <excludes>
+                    <exclude>**/*.slcio</exclude>
+                    <exclude>**/*.evio</exclude>
+                </excludes>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>2.5.3</version>
+                <configuration>
+                    <descriptor>src/assembly/archive.xml</descriptor>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>create-archive</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: data/trunk/test-data/src/assembly/archive.xml
 =============================================================================
--- data/trunk/test-data/src/assembly/archive.xml	(added)
+++ data/trunk/test-data/src/assembly/archive.xml	Wed Oct 21 17:03:42 2015
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+    <id>archive</id>
+    <formats>
+        <format>jar</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <fileSets>
+        <fileSet>
+            <directory>${project.basedir}/src/main/resources/org/hps/data/test</directory>
+            <outputDirectory>org/hps/data/test</outputDirectory>
+            <includes>
+                <include>*.slcio</include>
+                <include>*.evio</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+</assembly>

Added: data/trunk/test-data/src/main/java/org/hps/data/test/TestDataUtility.java
 =============================================================================
--- data/trunk/test-data/src/main/java/org/hps/data/test/TestDataUtility.java	(added)
+++ data/trunk/test-data/src/main/java/org/hps/data/test/TestDataUtility.java	Wed Oct 21 17:03:42 2015
@@ -0,0 +1,108 @@
+package org.hps.data.test;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.logging.Logger;
+
+/**
+ * Extracts test data from a classpath resource to a specified cache directory.
+ * 
+ * @author Jeremy McCormick, SLAC
+ */
+public final class TestDataUtility {
+    
+    /**
+     * The target directory where data files will be extracted.
+     */
+    private File cacheDir = null;
+    
+    /**
+     * The resource directory where test data is available.
+     */
+    private static String TEST_DATA_RESOURCE_DIR = "/" + TestDataUtility.class.getPackage().getName().replace(".", "/");
+    
+    /**
+     * Default cache dir which is within the target directory of the current Maven project.
+     */
+    private static String DEFAULT_CACHE_DIR = "target/test-data";
+    
+    /**
+     * Package logger.
+     */
+    private static final Logger LOGGER = Logger.getLogger(TestDataUtility.class.getPackage().getName());
+        
+    /**
+     * Class constructor.
+     * @param cacheDir the directory where test data files will be extracted
+     */
+    public TestDataUtility(String cacheDir) {
+        if (cacheDir != null) {
+            this.cacheDir = new File(cacheDir);
+        } else {
+            this.cacheDir = new File(DEFAULT_CACHE_DIR);
+        }
+        if (!this.cacheDir.exists()) {
+            if (!this.cacheDir.mkdirs()) {
+                throw new RuntimeException("Failed to create cache dir.");
+            }
+        }
+        LOGGER.config("initialized with cache dir " + this.cacheDir.getPath());
+    }
+    
+    /**
+     * Class constructor using default cache dir location.
+     */
+    public TestDataUtility() {
+        this(null);
+    }
+    
+    /**
+     * Get test data from a classpath resource and extract it to the local cache directory.
+     * @param fileName name of the resource relative to {@link TEST_DATA_RESOURCE_DIR} 
+     * @return the test data file
+     */
+    public File getTestData(String fileName) {
+        LOGGER.info("getting test data file " + fileName + " ...");
+        InputStream inputStream = null;
+        OutputStream outputStream = null;
+        File testDataFile = null;
+        try {
+            testDataFile = new File(cacheDir.getCanonicalPath() + File.separator + fileName);
+            String resource = TEST_DATA_RESOURCE_DIR + "/" + fileName;
+            LOGGER.info("looking for resource at " + resource + " ...");
+            inputStream = TestDataUtility.class.getResourceAsStream(TEST_DATA_RESOURCE_DIR + "/" + fileName);
+            if (inputStream == null) {
+                throw new IllegalArgumentException("The resource " + resource + " was not found.");
+            }
+            LOGGER.info("extracting file from archive ...");
+            outputStream = new FileOutputStream(testDataFile);
+            int read = 0;
+            byte[] bytes = new byte[1024];
+            while ((read = inputStream.read(bytes)) != -1) {
+                outputStream.write(bytes, 0, read);
+            }
+        } catch (IOException e) {
+            
+        } finally {
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        LOGGER.info("extracted test data file to " + testDataFile.getPath());
+        return testDataFile;
+    }
+}

Added: data/trunk/test-data/src/main/resources/org/hps/data/test/ConditionsTest.slcio
 =============================================================================
Binary file - no diff available.

Added: data/trunk/test-data/src/main/resources/org/hps/data/test/DataQualityMonitorTest.slcio
 =============================================================================
Binary file - no diff available.

Added: data/trunk/test-data/src/main/resources/org/hps/data/test/MockDataReconTest.slcio
 =============================================================================
Binary file - no diff available.

Added: data/trunk/test-data/src/main/resources/org/hps/data/test/ReadoutNoPileupTest.slcio
 =============================================================================
Binary file - no diff available.

Added: data/trunk/test-data/src/main/resources/org/hps/data/test/ReadoutToLcioTest.slcio
 =============================================================================
Binary file - no diff available.

Added: data/trunk/test-data/src/main/resources/org/hps/data/test/e-_1.056GeV_SLIC-v05-00-00_Geant4-v10-01-02_QGSP_BERT_HPS-EngRun2015-Nominal-v3.slcio
 =============================================================================
Binary file - no diff available.

Added: data/trunk/test-data/src/main/resources/org/hps/data/test/hps1351_test.evio
 =============================================================================
Binary file - no diff available.

Added: data/trunk/test-data/src/main/resources/org/hps/data/test/run5772_integrationTest.evio
 =============================================================================
Binary file - no diff available.

Added: data/trunk/test-data/src/main/resources/org/hps/data/test/run5772_pass1_stripOneFee_5000Events.evio
 =============================================================================
Binary file - no diff available.

Added: data/trunk/test-data/src/main/resources/org/hps/data/test/svt_evio_reader_test.evio
 =============================================================================
Binary file - no diff available.

Added: data/trunk/test-data/src/main/resources/org/hps/data/test/tritrigv1-egsv3-triv2-g4v1_s2d6_HPS-EngRun2015-Nominal-v3_3.4.0_pairs1_1.slcio
 =============================================================================
Binary file - no diff available.

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use