| author | Yuhong Yin | 2012-09-04 10:06:10 (EDT) |
|---|---|---|
| committer | Michael Fiedler | 2012-09-09 13:59:25 (EDT) |
| commit | 37b23c6e085b9df6e5b26889e1f57ab047489bc8 (patch) (side-by-side diff) | |
| tree | e13b7d07a6f3f1e15641ecbf182491950823865e | |
| parent | cc66eeb8fe93f0ea6b2ea31032e526736d199a8c (diff) | |
| download | org.eclipse.lyo.testsuite-37b23c6e085b9df6e5b26889e1f57ab047489bc8.zip org.eclipse.lyo.testsuite-37b23c6e085b9df6e5b26889e1f57ab047489bc8.tar.gz org.eclipse.lyo.testsuite-37b23c6e085b9df6e5b26889e1f57ab047489bc8.tar.bz2 | |
Bug 386787 - lyo test suite should not expect etag or last-modified ifrefs/changes/88/7588/2
the response body for POST is empty
Change-Id: Idb1ef32cecff05a615f0748d60309a1ea2dc3cbc
5 files changed, 64 insertions, 52 deletions
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryAtomTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryAtomTests.java index 3d7eeca..fac218d 100644 --- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryAtomTests.java +++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryAtomTests.java @@ -22,15 +22,12 @@ import java.io.InputStream; import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; -import java.util.List; import javax.xml.parsers.ParserConfigurationException; -import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathException; import javax.xml.xpath.XPathExpressionException; import org.apache.abdera.Abdera; -import org.apache.abdera.model.Entry; import org.apache.abdera.model.Feed; import org.apache.commons.httpclient.HttpStatus; import org.apache.http.HttpResponse; @@ -44,8 +41,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import org.w3c.dom.Document; -import org.w3c.dom.Node; import org.xml.sax.SAXException; /**
@@ -101,7 +96,6 @@ public class SimplifiedQueryAtomTests extends SimplifiedQueryBaseTests { } String responseBody = EntityUtils.toString(response.getEntity()); - // // Validate ATOM feed response // @@ -110,29 +104,15 @@ public class SimplifiedQueryAtomTests extends SimplifiedQueryBaseTests { // Create mapping of ATOM variables Abdera abdera = new Abdera(); org.apache.abdera.model.Document<Feed> model = abdera.getParser().parse(bais); + + assertNotNull(model); Feed feed = model.getRoot(); - List<Entry> entries = feed.getEntries(); - - // We expect at least one change request in query ATOM response -// assertTrue( entries.size()>=1 ); + // Validate the ATOS feeds + assertNotNull("Atom feeds must have a title", feed.getTitle()); + assertNotNull("Atom feeds must have an ID", feed.getId()); + assertNotNull("Atom feeds must have an updated element", feed.getUpdated()); - for(Entry entry : entries){ - String content = entry.getContent(); - - if ( content != null ) { - //Get XML Doc from Atom Description - Document description = OSLCUtils.createXMLDocFromResponseBody(content); - Node result = (Node) OSLCUtils.getXPath().evaluate("//rdf:Description/@rdf:about", - description, XPathConstants.NODE); - - if (result != null) { - String node = result.getNodeValue(); - assertNotNull(node); - break; - } - } - }
}
@Test
@@ -178,7 +158,9 @@ public class SimplifiedQueryAtomTests extends SimplifiedQueryBaseTests { @Test
public void fullTextSearchContainsExpectedResults() throws IOException,
ParserConfigurationException, SAXException,
- XPathExpressionException {
+ XPathExpressionException { + if ( !getFullTextSearch() ) return; +
String query = getQueryUrlForFullTextSearchContainsExpectedResults();
validateNonEmptyResponse(query);
}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryBaseTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryBaseTests.java index 3fece3e..61071f1 100644 --- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryBaseTests.java +++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryBaseTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 IBM Corporation. + * Copyright (c) 2011, 2012 IBM Corporation. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -12,6 +12,7 @@ * Contributors: * * Steve Speicher - initial API and implementation + * Yuhong Yin - revised *******************************************************************************/ package org.eclipse.lyo.testsuite.oslcv2;
@@ -40,7 +41,8 @@ public class SimplifiedQueryBaseTests extends TestsBase { protected String queryComparisonProperty;
protected String queryComparisonValue;
protected String fullTextSearchTerm;
- protected String additionalParameters;
+ protected String additionalParameters; + protected boolean fullTextSearch = true;
public SimplifiedQueryBaseTests(String thisUri) {
super(thisUri);
@@ -59,7 +61,11 @@ public class SimplifiedQueryBaseTests extends TestsBase { additionalParameters = setupProps
.getProperty("queryAdditionalParameters");
if (additionalParameters == null)
- additionalParameters = "";
+ additionalParameters = ""; + + if (setupProps.getProperty("fullTextSearch") != null ) { + fullTextSearch = setupProps.getProperty("fullTextSearch").equalsIgnoreCase("true"); + }
}
protected String getQueryBase() {
@@ -116,5 +122,9 @@ public class SimplifiedQueryBaseTests extends TestsBase { throws UnsupportedEncodingException {
return getQueryBase() + "oslc.searchTerms="
+ URLEncoder.encode("\"" + fullTextSearchTerm + "\"", "UTF-8");
+ } + + protected boolean getFullTextSearch() { + return fullTextSearch; }
}
\ No newline at end of file diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryJsonTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryJsonTests.java index 02389eb..dd0e46a 100644 --- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryJsonTests.java +++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryJsonTests.java @@ -146,7 +146,9 @@ public class SimplifiedQueryJsonTests extends SimplifiedQueryBaseTests { @Test
public void fullTextSearchContainsExpectedResults() throws IOException,
ParserConfigurationException, SAXException,
- XPathExpressionException, JSONException {
+ XPathExpressionException, JSONException { + if ( !getFullTextSearch() ) return; +
String query = getQueryUrlForFullTextSearchContainsExpectedResults();
validateNonEmptyResponse(query);
}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryRdfXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryRdfXmlTests.java index 770d6e2..5ebb276 100644 --- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryRdfXmlTests.java +++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryRdfXmlTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 IBM Corporation. + * Copyright (c) 2011, 2012 IBM Corporation. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -12,10 +12,10 @@ * Contributors: * * Steve Speicher - initial API and implementation + * Yuhong Yin - revised *******************************************************************************/ package org.eclipse.lyo.testsuite.oslcv2; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -92,7 +92,11 @@ public class SimplifiedQueryRdfXmlTests extends SimplifiedQueryBaseTests { String queryUrl = OSLCUtils.addQueryStringToURL(currentUrl, query); HttpResponse response = OSLCUtils.getResponseFromUrl(setupBaseUrl, queryUrl, basicCreds, OSLCConstants.CT_RDF, headers); - assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + + int statusCode = response.getStatusLine().getStatusCode(); + if (HttpStatus.SC_OK != statusCode) { + throw new IOException("Response code: " + statusCode + " for " + queryUrl); + } Model queryModel = ModelFactory.createDefaultModel(); queryModel.read(response.getEntity().getContent(), @@ -110,9 +114,6 @@ public class SimplifiedQueryRdfXmlTests extends SimplifiedQueryBaseTests { ResIterator resIter = queryModel.listSubjectsWithProperty(RDF.type, respInfoType); while (resIter.hasNext()) { Resource responseInfoRes = resIter.nextResource(); - assertEquals( - "Response info URI should match the request URI (with query parameters)", - queryUrl, responseInfoRes.getURI()); Property countMember = queryModel .getProperty(OSLCConstants.TOTAL_COUNT_PROP); @@ -173,6 +174,9 @@ public class SimplifiedQueryRdfXmlTests extends SimplifiedQueryBaseTests { @Test public void fullTextSearchContainsExpectedResults() throws IOException { + + if ( !getFullTextSearch() ) return; + String query = getQueryUrlForFullTextSearchContainsExpectedResults(); validateNonEmptyResponse(query); } diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryXmlTests.java index d916e4d..98688ee 100644 --- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryXmlTests.java +++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/SimplifiedQueryXmlTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 IBM Corporation. + * Copyright (c) 2011, 2012 IBM Corporation. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -12,10 +12,10 @@ * Contributors: * * Steve Speicher - initial API and implementation + * Yuhong Yin - revised *******************************************************************************/ package org.eclipse.lyo.testsuite.oslcv2;
-
-import static org.junit.Assert.assertEquals; + import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -69,15 +69,27 @@ public class SimplifiedQueryXmlTests extends SimplifiedQueryBaseTests { public static Collection<Object[]> getAllDescriptionUrls()
throws IOException, ParserConfigurationException, SAXException,
XPathException {
- // Checks the ServiceProviderCatalog at the specified baseUrl of the
- // REST service in order to grab all urls
- // to other ServiceProvidersCatalogs contained within it, recursively,
- // in order to find the URLs of all
- // query factories of the REST service.
- String v = "//oslc_v2:QueryCapability/oslc_v2:queryBase/@rdf:resource";
- ArrayList<String> serviceUrls = getServiceProviderURLsUsingXML(null);
- ArrayList<String> capabilityURLsUsingXML = TestsBase
- .getCapabilityURLsUsingXML(v, serviceUrls, true);
+ + ArrayList<String> capabilityURLsUsingXML = new ArrayList<String>(); + + String useThisQuery = setupProps.getProperty("useThisQuery"); + + if ( useThisQuery != null ) { + capabilityURLsUsingXML.add(useThisQuery); + } + else { + // Checks the ServiceProviderCatalog at the specified baseUrl of the + // REST service in order to grab all urls + // to other ServiceProvidersCatalogs contained within it, recursively, + // in order to find the URLs of all + // query factories of the REST service. + String v = "//oslc_v2:QueryCapability/oslc_v2:queryBase/@rdf:resource"; + ArrayList<String> serviceUrls = getServiceProviderURLsUsingXML(null); + + capabilityURLsUsingXML = TestsBase. + getCapabilityURLsUsingXML(v, serviceUrls, true); + }
+ return toCollection(capabilityURLsUsingXML);
}
@@ -102,8 +114,8 @@ public class SimplifiedQueryXmlTests extends SimplifiedQueryBaseTests { // Only test oslc:ResponseInfo if found
if (results != null) {
- assertEquals("Expended ResponseInfo/@rdf:about to equal request URL",
- queryUrl, results.getNodeValue());
+ //assertEquals("Expended ResponseInfo/@rdf:about to equal request URL",
+ // queryUrl, results.getNodeValue());
results = (Node) OSLCUtils.getXPath().evaluate("//oslc:totalCount",
doc, XPathConstants.NODE);
if (results != null) { @@ -161,7 +173,9 @@ public class SimplifiedQueryXmlTests extends SimplifiedQueryBaseTests { @Test
public void fullTextSearchContainsExpectedResults() throws IOException,
ParserConfigurationException, SAXException,
- XPathExpressionException {
+ XPathExpressionException { + if ( !getFullTextSearch() ) return; +
String query = getQueryUrlForFullTextSearchContainsExpectedResults();
validateNonEmptyResponse(query);
}
|

