@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 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 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 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 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 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); }
@Test public void getRangeDataForExistingTarget_firstOKlastOK2() 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-99"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_PARTIAL_CONTENT); assertResponseHeaderNotPresent("Content-Length"); assertResponseHeaderValue("Content-Range", "bytes 2-99/*"); assertResponseOutput(2, 98); }
@Test public void getRangeDataForExistingTarget_firstOKlastTooBig() 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-100"; m_servlet.doGet(m_request, m_response); assertResponseCode(HttpServletResponse.SC_PARTIAL_CONTENT); assertResponseHeaderNotPresent("Content-Length"); assertResponseHeaderValue("Content-Range", "bytes 2-100/*"); assertResponseOutput(2, 98); }