Skip to content

Commit

Permalink
Merge branch 'url-storage-path' into 'master'
Browse files Browse the repository at this point in the history
Use correct storagePath by default

See merge request ghsc/hazdev/pdl!140
  • Loading branch information
emartinez-usgs committed Feb 11, 2021
2 parents 36b6a50 + cfffc85 commit ee71339
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
2 changes: 1 addition & 1 deletion code.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Product Distribution Layer",
"organization": "U.S. Geological Survey",
"description": "Distribution system used for derived earthquake information",
"version": "v2.7.8",
"version": "v2.7.9",
"status": "Production",
"permissions": {
"usageType": "openSource",
Expand Down
1 change: 0 additions & 1 deletion src/main/java/gov/usgs/earthquake/aws/AwsBatchIndexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import gov.usgs.earthquake.indexer.Indexer;
import gov.usgs.earthquake.product.Product;
import gov.usgs.earthquake.product.ProductId;
import gov.usgs.earthquake.product.io.JsonProduct;
import gov.usgs.earthquake.util.JDBCConnection;
import gov.usgs.util.Config;
import gov.usgs.util.StreamUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class ProductClient extends DefaultConfigurable implements
ProductClientMBean, Bootstrappable {

/** The "release" version number. */
public static final String RELEASE_VERSION = "Version 2.7.8 2021-02-10";
public static final String RELEASE_VERSION = "Version 2.7.9 2021-02-10";

/** Property name used on products for current RELEASE_VERSION. */
public static final String PDL_CLIENT_VERSION_PROPERTY = "pdl-client-version";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void configure(final Config config) throws Exception {
}
LOGGER.config("[" + getName() + "] using format " + storageFormat);

storagePath = config.getProperty(STORAGE_PATH_PROPERTY, DEFAULT_DIRECTORY);
storagePath = config.getProperty(STORAGE_PATH_PROPERTY, DEFAULT_STORAGE_PATH);
LOGGER.config("[" + getName() + "] using path " + storagePath);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package gov.usgs.earthquake.distribution;

import gov.usgs.earthquake.product.ProductId;
import gov.usgs.util.Config;

import java.net.URL;
import java.util.Date;

import org.junit.Assert;
import org.junit.Test;


public class URLProductStorageTest {

/**
* Test that storage path is configured properly by default
* and includes all product id components (so url is unique per product).
*/
@Test
public void testDefaultStoragePath() throws Exception {
URLProductStorage storage = new URLProductStorage();
Config config = new Config();
config.setProperty(URLProductStorage.URL_PROPERTY_NAME, "http://testserver/product/");
storage.configure(config);

ProductId id = new ProductId("example_source", "example_type", "example_code", new Date());
String path = storage.getProductPath(id);
Assert.assertTrue("contains source", path.contains("example_source"));
Assert.assertTrue("contains type", path.contains("example_type"));
Assert.assertTrue("contains code", path.contains("example_code"));
Assert.assertTrue(
"contains updateTime",
path.contains("" + id.getUpdateTime().getTime()));
}

/**
* Test that url is constructed by combining base url and product path.
*/
@Test
public void testGetProductUrl() throws Exception {
URLProductStorage storage = new URLProductStorage();
Config config = new Config();
config.setProperty(URLProductStorage.URL_PROPERTY_NAME, "http://testserver/product/");
storage.configure(config);

ProductId id = new ProductId("source", "type", "code", new Date());
URL url = storage.getProductURL(id);
Assert.assertEquals("Computes URL",
url.toExternalForm(),
"http://testserver/product/" + storage.getProductPath(id));
}

}

0 comments on commit ee71339

Please sign in to comment.