@SuppressWarnings("unused") public void setStatus(int status, String desc) { setStatus(status); } });
@SuppressWarnings("unused") public void sendError(int status, String desc) { sendError(status); }
@Test() public void getUpgradeFixPackageWithExistingFromVersion() throws Exception { // try to request a version range with an existing from-version, should cause a fix package to be returned... m_requestPathInfo = "/existing/versions/2.0.0"; m_requestCurrentParameter = "2.0.0"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_OK); assertResponseOutput(0, 100); assertGeneratorTargetId("existing"); assertGeneratorToVersion("2.0.0"); assertGeneratorFromVersion("2.0.0"); }
@Test() public void getRangeDataForExistingTarget_firstOKlastOK() throws Exception { // valid range not starting at 0 m_requestPathInfo = "/existing/versions/2.0.0"; m_requestRangeHeader = "bytes=2-50"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_PARTIAL_CONTENT); assertResponseHeaderNotPresent("Content-Length"); assertResponseHeaderValue("Content-Range", "bytes 2-50/*"); assertResponseOutput(2, 49); }
@Test public void getDataForExistingTarget() throws Exception { m_requestPathInfo = "/existing/versions/2.0.0"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_OK); assertResponseHeaderNotPresent("Content-Length"); assertResponseOutput(0, 100); assertGeneratorTargetId("existing"); assertGeneratorToVersion("2.0.0"); }
@Test public void getSizeForExistingTargetWithKnownSize() throws Exception { m_artifactSize = 10; m_requestPathInfo = "/existing/versions/2.0.0"; m_servlet.doHead(m_request, m_response); assertResponseCode(HttpServletResponse.SC_OK); assertResponseHeaderValue("X-ACE-DPSize", "11"); // 10 + 10% }
@Test public void getSizeForExistingTargetWithUnknownSize() throws Exception { m_artifactSize = -1; m_requestPathInfo = "/existing/versions/2.0.0"; m_servlet.doHead(m_request, m_response); assertResponseCode(HttpServletResponse.SC_OK); assertResponseHeaderNotPresent("X-ACE-DPSize"); }
@Test public void getVersionsNonExistingTarget() throws Exception { m_requestPathInfo = "/nonexisting/versions"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_NOT_FOUND); assertResponseOutput(-1, 0); }
@Test public void getDataForNonExistingTarget() throws Exception { m_requestPathInfo = "/nonexisting/versions/2.0.0"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_NOT_FOUND); }
@Test public void getRangeDataForExistingTarget_firstTooBiglastTooBig() throws Exception { // invalid range: start=toobig end=toobig m_requestPathInfo = "/existing/versions/2.0.0"; m_requestRangeHeader = "bytes=100-110"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_PARTIAL_CONTENT); assertResponseHeaderValue("Content-Range", "bytes 100-110/*"); assertResponseHeaderNotPresent("Content-Length"); assertResponseOutput(-1, 0); }
@Test() public void getUpgradeFixPackageWithNonExistingFromVersion() throws Exception { // try to request a version range with a non-existing from-version, should cause a complete (non-fix) package to // be returned... m_requestPathInfo = "/existing/versions/2.0.0"; m_requestCurrentParameter = "1.0.0"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_OK); assertResponseOutput(0, 100); assertGeneratorTargetId("existing"); assertGeneratorToVersion("2.0.0"); assertGeneratorFromVersion(null); }
@Test public void getSizeForFixPackageExistingTargetWithKnownSize() throws Exception { m_artifactSize = 10; m_requestCurrentParameter = "2.0.0"; m_requestPathInfo = "/existing/versions/2.0.0"; m_servlet.doHead(m_request, m_response); assertResponseCode(HttpServletResponse.SC_OK); assertResponseHeaderValue("X-ACE-DPSize", "22"); // 20 + 10% }
@Test public void getSizeForNonExistingTarget() throws Exception { m_artifactSize = 10; m_requestPathInfo = "/existing/versions/1.0.0"; m_servlet.doHead(m_request, m_response); assertResponseCode(HttpServletResponse.SC_OK); assertResponseHeaderNotPresent("X-ACE-DPSize"); }
@Test() public void getDowngradeFixPackageWithNonExistingToVersion() throws Exception { // try to request a version range with a non-existing from-version, should cause a complete (non-fix) package to // be returned... m_requestPathInfo = "/existing/versions/1.0.0"; m_requestCurrentParameter = "2.0.0"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_NOT_FOUND); }
@Test public void getRangeDataForExistingTarget_badHeaderValue() throws Exception { // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16 // If the server ignores a byte-range-spec because it is syntactically invalid, the server SHOULD treat the // request as if the invalid Range header field did not exist. (Normally, this means return a 200 response // containing the full entity). m_requestPathInfo = "/existing/versions/2.0.0"; m_requestRangeHeader = "bytes=a-1"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_OK); assertResponseHeaderNotPresent("Content-Length"); assertResponseOutput(0, 100); }
@Test() public void getUpgradeWithExistingToVersion() throws Exception { // try to request a version range with a non-existing from-version, should cause a complete (non-fix) package to // be returned... m_requestPathInfo = "/existing/versions/2.0.0"; m_requestCurrentParameter = null; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_OK); assertResponseOutput(0, 100); assertGeneratorTargetId("existing"); assertGeneratorToVersion("2.0.0"); assertGeneratorFromVersion(null); }
@Test() public void getUpgradeFixPackageWithNonExistingToVersion() throws Exception { // try to request a version range with a non-existing from-version, should cause a complete (non-fix) package to // be returned... m_requestPathInfo = "/existing/versions/3.0.0"; m_requestCurrentParameter = "2.0.0"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_NOT_FOUND); }
@Test public void getRangeDataForExistingTarget_first0lastOK() throws Exception { // valid range starting at 0 m_requestPathInfo = "/existing/versions/2.0.0"; m_requestRangeHeader = "bytes=0-10"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_PARTIAL_CONTENT); assertResponseHeaderNotPresent("Content-Length"); assertResponseHeaderValue("Content-Range", "bytes 0-10/*"); }
@Test() public void getUpgradeWithNonExistingToVersion() throws Exception { // try to request a version range with a non-existing from-version, should cause a complete (non-fix) package to // be returned... m_requestPathInfo = "/existing/versions/3.0.0"; m_requestCurrentParameter = null; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_NOT_FOUND); }
@Test public void getRangeDataForExistingTarget_firstOKlastANY() throws Exception { // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1 // If the last-byte-pos value is absent, or if the value is greater than or equal to the current length of the // entity-body, last-byte-pos is taken to be equal to one less than the current length of the entity- body in // bytes. m_requestPathInfo = "/existing/versions/2.0.0"; m_requestRangeHeader = "bytes=2-"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_PARTIAL_CONTENT); assertResponseHeaderNotPresent("Content-Length"); assertResponseHeaderValue("Content-Range", "bytes 2-/*"); assertResponseOutput(2, 98); }