Skip to content

Commit 7da28db

Browse files
committed
DM-7829: more cleanup, use local file in unit test instead.
1 parent 0da1138 commit 7da28db

File tree

6 files changed

+7
-87
lines changed

6 files changed

+7
-87
lines changed

config/app.config

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ visualize.fits.Security= true
5656
// IRSA Periodogram API
5757
irsa.gator.service.periodogram.url = "http://bacchus.ipac.caltech.edu:9027/cgi-bin/periodogram/nph-periodogram_api"
5858

59-
// Periodogram API request parameter list definition, separated by space
60-
irsa.gator.service.periodogram.keys = "x y alg step_method pmin pmax step_size peaks"
61-
6259
environments{
6360
local {
6461
visualize.fits.search.path = "/Library/WebServer/Documents:/irsadata:/hydra"

src/firefly/config/app.prop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ python.exe= @python.exe@
2828
# IRSA Periodogram API
2929
irsa.gator.service.periodogram.url=@irsa.gator.service.periodogram.url@
3030

31-
# Periodogram API request parameter list definition, separated by space
32-
irsa.gator.service.periodogram.keys=@irsa.gator.service.periodogram.keys@
31+
// Periodogram API request parameter list definition, separated by space
32+
irsa.gator.service.periodogram.keys=x y alg step_method pmin pmax step_size peaks

src/firefly/java/edu/caltech/ipac/firefly/server/query/lc/LightCurveProcessor.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ protected File loadDataFile(TableServerRequest request) throws IOException, Data
8282
*/
8383
public File computePeriodogram(PeriodogramAPIRequest req, String tblName) throws FailedRequestException {
8484

85-
// LightCurveHandler h = new IrsaLightCurveHandler();
8685
if (tblName.equalsIgnoreCase(PERIODOGRAM_TABLE_NAME)) {
8786
return h.getPeriodogramTable(req);
8887
} else if (tblName.equalsIgnoreCase(PEAKS_TABLE_NAME)) {
@@ -91,31 +90,4 @@ public File computePeriodogram(PeriodogramAPIRequest req, String tblName) throws
9190
throw new FailedRequestException("Unable to deal with the request table name " + tblName);
9291
}
9392
}
94-
95-
private static File makeFileName(PeriodogramAPIRequest req) throws IOException {
96-
return File.createTempFile("lc-result", ".xml", ServerContext.getPermWorkDir());
97-
}
98-
99-
private URL createURL(PeriodogramAPIRequest req) throws EndUserException, IOException {
100-
PeriodogramAPIRequest request = (PeriodogramAPIRequest) req.cloneRequest();
101-
String url = req.getUrl();
102-
if (url == null || url.length() < 5) {
103-
url = PERIODOGRAM_API_URL;
104-
}
105-
String paramStr = buildParamFrom(request);
106-
if (paramStr.startsWith("&")) {
107-
paramStr = paramStr.substring(1);
108-
}
109-
url += "?" + paramStr;
110-
111-
return new URL(url);
112-
}
113-
114-
private String buildParamFrom(PeriodogramAPIRequest request) {
115-
String outputMode = request.getParam(PeriodogramAPIRequest.OUTPUT_MODE);
116-
if (StringUtils.isEmpty(outputMode)) {
117-
outputMode = "VOTable";
118-
}
119-
return "pmin=0&peaks=50";
120-
}
12193
}

src/firefly/java/edu/caltech/ipac/firefly/server/query/lc/PeriodogramAPIRequest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ public PeriodogramAPIRequest() {
4646
super(PeriodogramAPIRequest.class.getSimpleName());
4747
}
4848

49-
public String getUrl() {
50-
return getParam(URL);
51-
}
52-
5349
/**
5450
* Period value
5551
*

src/firefly/js/templates/lightcurve/LcPhaseFoldingPanel.jsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -457,16 +457,4 @@ function getPeriodFromTable(tbl_id) {
457457
} else if (tbl_id === PEAK_TABLE) {
458458
return getCellValue(tableModel, tableModel.highlightedRow, 'Period');
459459
}
460-
}
461-
462-
/**
463-
* return true if the table is LC raw or phase folded table
464-
* @param {string} tbl_id
465-
* @returns
466-
*/
467-
function isLcTable(tbl_id) {
468-
const tableModel = getTblById(tbl_id);
469-
if (!tableModel || isNil(tableModel.highlightedRow)) return;
470-
return !![RAW_TABLE, PHASE_FOLDED].includes(tbl_id);
471-
472460
}

src/firefly/test/edu/caltech/ipac/firefly/server/query/LightCurveProcessorTest.java

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@
99
import edu.caltech.ipac.firefly.server.query.lc.IrsaLightCurveHandler;
1010
import edu.caltech.ipac.firefly.server.query.lc.LightCurveHandler;
1111
import edu.caltech.ipac.firefly.server.query.lc.PeriodogramAPIRequest;
12-
import edu.caltech.ipac.util.AppProperties;
12+
import edu.caltech.ipac.firefly.util.FileLoader;
1313
import edu.caltech.ipac.util.DataGroup;
1414
import edu.caltech.ipac.util.DataObject;
1515
import edu.caltech.ipac.util.DataType;
16-
import edu.caltech.ipac.util.download.FailedRequestException;
17-
import edu.caltech.ipac.util.download.URLDownload;
1816
import org.junit.Assert;
1917
import org.junit.BeforeClass;
2018
import org.junit.Test;
2119

2220
import java.io.File;
2321
import java.io.IOException;
24-
import java.net.MalformedURLException;
25-
import java.net.URL;
26-
import java.net.URLConnection;
2722
import java.util.List;
2823

2924
/**
@@ -33,17 +28,11 @@ public class LightCurveProcessorTest extends ConfigTest {
3328

3429

3530
private static PeriodogramAPIRequestTest req;
36-
private static File rawTable;
3731

3832

3933
@BeforeClass
4034
public static void setUp() {
4135
req = new PeriodogramAPIRequestTest();
42-
try {
43-
rawTable = File.createTempFile("phasefolded-temp-", ".tbl", new File("."));
44-
} catch (IOException e) {
45-
e.printStackTrace();
46-
}
4736
}
4837

4938
@Test
@@ -128,21 +117,8 @@ protected File makeApiResultTempFile() throws IOException {
128117
@Test
129118
public void testPhaseFoldedCurve() {
130119

131-
try {
132-
URL demo = new URL("http://web.ipac.caltech.edu/staff/ejoliet/demo/AllWISE-MEP-m82-2targets-10arsecs.tbl");
133-
URLConnection uc = URLDownload.makeConnection(demo);
134-
URLDownload.getDataToFile(uc, rawTable);
135-
} catch (MalformedURLException e) {
136-
e.printStackTrace();
137-
} catch (FailedRequestException e) {
138-
e.printStackTrace();
139-
} catch (IOException e) {
140-
e.printStackTrace();
141-
}
120+
File rlc = FileLoader.resolveFile(LightCurveProcessorTest.class, "/AllWISE-MEP-m82-2targets-10arsecs-oneTarget.tbl");
142121
boolean deleteOnExit = true;
143-
if (deleteOnExit) {
144-
rawTable.deleteOnExit();
145-
}
146122
IrsaLightCurveHandler t = new IrsaLightCurveHandler() {
147123
@Override
148124
protected File createPhaseFoldedTempFile() throws IOException {
@@ -156,14 +132,14 @@ protected File createPhaseFoldedTempFile() throws IOException {
156132

157133
DataGroup inDataGroup = null;
158134
try {
159-
inDataGroup = IpacTableReader.readIpacTable(rawTable, "lc_raw");
135+
inDataGroup = IpacTableReader.readIpacTable(rlc, "lc_raw");
160136
} catch (IpacTableException e) {
161137
e.printStackTrace();
162138
}
163139
List<DataObject> dgjListOrigin = inDataGroup.values();
164140
DataType[] inColumns = inDataGroup.getDataDefinitions();
165141

166-
File p = t.toPhaseFoldedTable(rawTable, req.getPeriod(), req.getTimeColName());
142+
File p = t.toPhaseFoldedTable(rlc, req.getPeriod(), req.getTimeColName());
167143

168144
try {
169145
inDataGroup = IpacTableReader.readIpacTable(p, "phasefolded");
@@ -196,7 +172,7 @@ static class PeriodogramAPIRequestTest extends PeriodogramAPIRequest {
196172
private int n_peaks = 52;
197173
// Fake values passed from client,
198174
// see test properties irsa.gator.service.periodogram.keys
199-
private final String[] reqValues = new String[]{"x=mjd", "y=w1mpro_ep", "peaks="+n_peaks, "alg=ls"};
175+
private final String[] reqValues = new String[]{"x=mjd", "y=w1mpro_ep", "peaks=" + n_peaks, "alg=ls"};
200176

201177
@Override
202178
public String getParam(String param) {
@@ -235,15 +211,6 @@ public String getTimeColName() {
235211
return "mjd";
236212
}
237213

238-
/**
239-
* @return the built url api
240-
*/
241-
@Override
242-
public String getUrl() {
243-
//As for the test, we return the result table
244-
return getResultTable();
245-
}
246-
247214
@Override
248215
public String getResultTable() {
249216
return "http://web.ipac.caltech.edu/staff/ejoliet/demo/vo-nexsci-result-sample-old.xml";

0 commit comments

Comments
 (0)