Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
27 changes: 15 additions & 12 deletions src/test/java/com/asascience/ncsos/DSNetworkTest.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package com.asascience.ncsos;

import com.asascience.ncsos.util.XMLDomUtils;
import junit.framework.Assert;
import org.jdom.Element;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.io.File;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;

import org.jdom.Element;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class DSNetworkTest extends NcSOSTest {

Expand All @@ -23,9 +22,11 @@ public class DSNetworkTest extends NcSOSTest {

private Element currentFile;
private String authority;
public DSNetworkTest(Element file, String authority){

public DSNetworkTest(Element file, String authority, String testLabel){
this.currentFile = file;
this.authority = authority;
//discard testLabel
}

public static void setUpClass() throws Exception {
Expand All @@ -45,17 +46,19 @@ public static void setUpClass() throws Exception {
kvp.put("service", "SOS");
}

// Create the parameters for the test constructor
@Parameters
// Create the parameters for the test constructor
@Parameters(name = "{index}: {2}")
public static Collection<Object[]> testCases() throws Exception {
setUpClass();
Object[][] data = new Object[fileElements.size()][2];
Object[][] data = new Object[fileElements.size()][3];
int curIndex = 0;
String authority;
for (Element e : fileElements) {
data[curIndex][0] = e;
authority = e.getAttributeValue("authority","ncsos"); // "ncsos" is the default authority in NcSOS
data[curIndex][1] = authority;
//label for parameterized test
data[curIndex][2] = getTestLabel(e);
curIndex++;
}
return Arrays.asList(data);
Expand Down
10 changes: 6 additions & 4 deletions src/test/java/com/asascience/ncsos/DSPlatformTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.asascience.ncsos;

import junit.framework.Assert;
import org.junit.Assert;
import org.jdom.Element;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -20,9 +20,10 @@ public class DSPlatformTest extends NcSOSTest {

private Element currentFile;
private String procedure;
public DSPlatformTest(Element file, String procedure) {
public DSPlatformTest(Element file, String procedure, String testLabel) {
this.currentFile = file;
this.procedure = procedure;
//discard testLabel
}

public static void setUpClass() throws Exception {
Expand All @@ -43,7 +44,7 @@ public static void setUpClass() throws Exception {
}

// Create the parameters for the test constructor
@Parameters
@Parameters(name = "{index}: {2}")
public static Collection<Object[]> testCases() throws Exception {
setUpClass();

Expand All @@ -58,12 +59,13 @@ public static Collection<Object[]> testCases() throws Exception {
}
}

Object[][] data = new Object[nonGrids][2];
Object[][] data = new Object[nonGrids][3];
int curIndex = 0;
for (Element e : fileElements) {
for (Element p : (List<Element>) e.getChildren("platform")) {
data[curIndex][0] = e;
data[curIndex][1] = p.getAttributeValue("id");
data[curIndex][2] = getTestLabel(e);
curIndex++;
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/test/java/com/asascience/ncsos/GCBaseTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.asascience.ncsos;

import junit.framework.Assert;
import org.junit.Assert;
import org.jdom.Element;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.io.File;
import java.util.Arrays;
Expand All @@ -19,8 +20,9 @@ public class GCBaseTest extends NcSOSTest {
private static String exampleDir;

private Element currentFile;
public GCBaseTest(Element file){
public GCBaseTest(Element file, String testLabel){
this.currentFile = file;
//discard testLabel
}

public static void setUpClass() throws Exception {
Expand All @@ -39,13 +41,15 @@ public static void setUpClass() throws Exception {
}

// Create the parameters for the test constructor
@Parameterized.Parameters
@Parameters(name = "{index}: {1}")
public static Collection<Object[]> testCases() throws Exception {
setUpClass();
Object[][] data = new Object[fileElements.size()][1];
Object[][] data = new Object[fileElements.size()][2];
int curIndex = 0;
for (Element e : fileElements) {
data[curIndex][0] = e;
//include test label
data[curIndex][1] = getTestLabel(e);
curIndex++;
}
return Arrays.asList(data);
Expand Down
30 changes: 22 additions & 8 deletions src/test/java/com/asascience/ncsos/GOBaseGridTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.asascience.ncsos;

import junit.framework.Assert;
import org.junit.Assert;
import org.jdom.Element;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -25,14 +25,16 @@ public class GOBaseGridTest extends NcSOSTest {
private String latitude;
private String longitude;
private String observedProperty;
public GOBaseGridTest(Element file, String offering, String procedure, String observedProperty, String latitude, String longitude, String testType) {
public GOBaseGridTest(Element file, String offering, String procedure, String observedProperty,
String latitude, String longitude, String testType, String testLabel) {
this.currentFile = file;
this.offering = offering;
this.procedure = procedure;
this.observedProperty = observedProperty;
this.latitude = latitude;
this.longitude = longitude;
this.testType = testType;
//discard testLabel
}

public static void setUpClass() throws Exception {
Expand All @@ -57,7 +59,7 @@ public static void setUpClass() throws Exception {
}

// Create the parameters for the test constructor
@Parameters
@Parameters(name = "{index}: {7}")
public static Collection<Object[]> testCases() throws Exception {
setUpClass();

Expand All @@ -73,13 +75,13 @@ public static Collection<Object[]> testCases() throws Exception {
}
}

Object[][] data = new Object[grids*3][7];
Object[][] data = new Object[grids*3][8];
int curIndex = 0;
for (Element e : fileElements) {

String authority = e.getAttributeValue("authority","ncsos");
String networkOffering = "urn:ioos:network:" + authority + ":all";

String testType;
for (Element s : (List<Element>) e.getChildren("sensor")) {

String standard = s.getAttributeValue("standard");
Expand All @@ -99,7 +101,11 @@ public static Collection<Object[]> testCases() throws Exception {
data[curIndex][3] = standard;
data[curIndex][4] = lat;
data[curIndex][5] = lon;
data[curIndex][6] = "grid0_offering_grid0_procedure" + lat + lon;
testType = "grid0_offering_grid0_procedure" + lat + lon;
data[curIndex][6] = testType;
//include test label
data[curIndex][7] = getTestLabel(e, testType);

curIndex++;
// A request with the offering as network:all
data[curIndex][0] = e;
Expand All @@ -108,16 +114,24 @@ public static Collection<Object[]> testCases() throws Exception {
data[curIndex][3] = standard;
data[curIndex][4] = lat;
data[curIndex][5] = lon;
data[curIndex][6] = "network_offering_grid0_procedure" + lat + lon;
testType = "network_offering_grid0_procedure" + lat + lon;
data[curIndex][6] = testType;
//include test label
data[curIndex][7] = getTestLabel(e, testType);
curIndex++;

// A request with only the offering
data[curIndex][0] = e;
data[curIndex][1] = "urn:ioos:station:" + authority + ":Grid0";
data[curIndex][2] = null;
data[curIndex][3] = standard;
data[curIndex][4] = lat;
data[curIndex][5] = lon;
data[curIndex][6] = "grid0_offering_no_procedure" + lat + lon;
testType = "grid0_offering_no_procedure" + lat + lon;
data[curIndex][6] = testType;
//include test label
data[curIndex][7] = getTestLabel(e, testType);

curIndex++;
}
}
Expand Down
42 changes: 29 additions & 13 deletions src/test/java/com/asascience/ncsos/GOBasePlatformTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.asascience.ncsos;

import junit.framework.Assert;
import org.junit.Assert;

import org.apache.commons.lang.StringUtils;
import org.jdom.Element;
Expand All @@ -27,13 +27,14 @@ public class GOBasePlatformTest extends NcSOSTest {
private String offering;
private String testType;
private String observedProperty;
public GOBasePlatformTest(Element file, String offering, String procedure, String observedProperty, String testType) {
public GOBasePlatformTest(Element file, String offering, String procedure, String observedProperty,
String testType, String testLabel) {
this.currentFile = file;
this.procedure = procedure;
this.offering = offering;
this.observedProperty = observedProperty;
this.testType = testType;

//discard testLabel
}

public static void setUpClass() throws Exception {
Expand All @@ -54,7 +55,7 @@ public static void setUpClass() throws Exception {
}

// Create the parameters for the test constructor
@Parameters
@Parameters(name = "{index}: {5}")
public static Collection<Object[]> testCases() throws Exception {
setUpClass();

Expand All @@ -72,9 +73,10 @@ public static Collection<Object[]> testCases() throws Exception {
}
}

Object[][] data = new Object[nonGrids][5];
Object[][] data = new Object[nonGrids][6];
int curIndex = 0;
List<String> observedPropertyList;

for (Element e : fileElements) {

String networkOffering = "urn:ioos:network:" + e.getAttributeValue("authority","ncsos") + ":all";
Expand All @@ -84,7 +86,7 @@ public static Collection<Object[]> testCases() throws Exception {
String procedure = p.getAttributeValue("id");
String offering = procedure;
observedPropertyList = new ArrayList<String>();

String testType;
for (Element s : (List<Element>) p.getChildren("sensor")) {
// Keep track of the observedProperties so we can make a request
// with all of them outside of this forloop.
Expand All @@ -99,21 +101,27 @@ public static Collection<Object[]> testCases() throws Exception {
data[curIndex][1] = offering;
data[curIndex][2] = procedure;
data[curIndex][3] = observedProperty;
data[curIndex][4] = "platform_offering_platform_procedure";
testType = "platform_offering_platform_procedure";
data[curIndex][4] = testType;
data[curIndex][5] = getTestLabel(e, testType);
curIndex++;
// A request with the offering as network:all
data[curIndex][0] = e;
data[curIndex][1] = networkOffering;
data[curIndex][2] = procedure;
data[curIndex][3] = observedProperty;
data[curIndex][4] = "network_offering_platform_procedure";
testType = "network_offering_platform_procedure";
data[curIndex][4] = testType;
data[curIndex][5] = getTestLabel(e, testType);
curIndex++;
// A request with only the offering
data[curIndex][0] = e;
data[curIndex][1] = offering;
data[curIndex][2] = null;
data[curIndex][3] = observedProperty;
data[curIndex][4] = "platform_offering_no_procedure";
testType = "platform_offering_no_procedure";
data[curIndex][4] = testType;
data[curIndex][5] = getTestLabel(e, testType);
curIndex++;


Expand All @@ -123,7 +131,9 @@ public static Collection<Object[]> testCases() throws Exception {
data[curIndex][1] = offering;
data[curIndex][2] = procedure;
data[curIndex][3] = VocabDefinitions.GetDefinitionForParameter(observedProperty);
data[curIndex][4] = "platform_offering_platform_procedure_ioos_vocab";
testType = "platform_offering_platform_procedure_ioos_vocab";
data[curIndex][4] = testType;
data[curIndex][5] = getTestLabel(e, testType);
curIndex++;


Expand All @@ -137,21 +147,27 @@ public static Collection<Object[]> testCases() throws Exception {
data[curIndex][1] = offering;
data[curIndex][2] = procedure;
data[curIndex][3] = StringUtils.join(observedPropertyList, ',');
data[curIndex][4] = "platform_offering_platform_procedure";
testType = "platform_offering_platform_procedure";
data[curIndex][4] = testType;
data[curIndex][5] = getTestLabel(e, testType);
curIndex++;
// A request with the offering as network:all
data[curIndex][0] = e;
data[curIndex][1] = networkOffering;
data[curIndex][2] = procedure;
data[curIndex][3] = StringUtils.join(observedPropertyList, ',');
data[curIndex][4] = "network_offering_platform_procedure";
testType = "network_offering_platform_procedure";
data[curIndex][4] = testType;
data[curIndex][5] = getTestLabel(e, testType);
curIndex++;
// A request with only the offering
data[curIndex][0] = e;
data[curIndex][1] = offering;
data[curIndex][2] = null;
data[curIndex][3] = StringUtils.join(observedPropertyList, ',');
data[curIndex][4] = "platform_offering_no_procedure";
testType = "platform_offering_no_procedure";
data[curIndex][4] = testType;
data[curIndex][5] = getTestLabel(e, testType);
curIndex++;

}
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/com/asascience/ncsos/NcSOSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,16 @@ protected static void fileWriter(String filePath, Writer writer, boolean append)
output.write(writer.toString());
output.close();
}

protected static String getTestLabel(Element e, String... extraLabels) {
StringBuilder sb = new StringBuilder();
sb.append(e.getAttributeValue("path", "[no path]"));
sb.append(" - ");
sb.append(e.getAttributeValue("feature", "[no feature]"));
for (String extraLabel : extraLabels) {
sb.append(" - ");
sb.append(extraLabel);
}
return sb.toString();
}
}