Changeset 10062 in josm for trunk/test
- Timestamp:
- 2016-03-28T00:22:42+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/bugreport/BugReportExceptionHandlerTest.java
r10055 r10062 2 2 package org.openstreetmap.josm.tools.bugreport; 3 3 4 import static org.junit.Assert.assertEquals;5 import static org.junit.Assert.assertTrue;6 7 import java.io.ByteArrayInputStream;8 import java.io.IOException;9 import java.nio.charset.StandardCharsets;10 import java.util.zip.GZIPInputStream;11 12 import javax.xml.bind.DatatypeConverter;13 14 4 import org.junit.Before; 15 import org.junit.Test;16 5 import org.openstreetmap.josm.JOSMFixture; 17 import org.openstreetmap.josm.Main;18 import org.openstreetmap.josm.actions.ShowStatusReportAction;19 6 20 7 /** … … 30 17 JOSMFixture.createUnitTestFixture().init(); 31 18 } 32 33 /**34 * Test method for {@link org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler#getBugReportUrl(java.lang.String)}.35 * @throws IOException if any I/O error occurs36 */37 @Test38 public void testGetBugReportUrl() throws IOException {39 String report = ShowStatusReportAction.getReportHeader();40 String url = BugReportExceptionHandler.getBugReportUrl(report).toExternalForm();41 String prefix = Main.getJOSMWebsite()+"/josmticket?gdata=";42 assertTrue(url.startsWith(prefix));43 44 String gdata = url.substring(prefix.length());45 // JAXB only provides support for "base64" decoding while we encode url in "base64url", so switch encoding, only for test purpose46 byte[] data = DatatypeConverter.parseBase64Binary(gdata.replace('-', '+').replace('_', '/'));47 byte[] buff = new byte[8192];48 try (GZIPInputStream is = new GZIPInputStream(new ByteArrayInputStream(data))) {49 StringBuilder sb = new StringBuilder();50 for (int n = is.read(buff); n > 0; n = is.read(buff)) {51 sb.append(new String(buff, 0, n, StandardCharsets.UTF_8));52 }53 assertEquals(report, sb.toString());54 }55 }56 19 }
Note:
See TracChangeset
for help on using the changeset viewer.