Changeset 10062 in josm for trunk/test


Ignore:
Timestamp:
2016-03-28T00:22:42+02:00 (9 years ago)
Author:
Don-vip
Message:

see #12652 - about dialog: replace old bug report link with new bug report button, remove unused code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/bugreport/BugReportExceptionHandlerTest.java

    r10055 r10062  
    22package org.openstreetmap.josm.tools.bugreport;
    33
    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 
    144import org.junit.Before;
    15 import org.junit.Test;
    165import org.openstreetmap.josm.JOSMFixture;
    17 import org.openstreetmap.josm.Main;
    18 import org.openstreetmap.josm.actions.ShowStatusReportAction;
    196
    207/**
     
    3017        JOSMFixture.createUnitTestFixture().init();
    3118    }
    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 occurs
    36      */
    37     @Test
    38     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 purpose
    46         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     }
    5619}
Note: See TracChangeset for help on using the changeset viewer.