@Test
  public void testUpsertValuesWithDate() throws Exception {
    long ts = nextTimestamp();
    Properties props = new Properties();
    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
    Connection conn = DriverManager.getConnection(getUrl(), props);
    conn.createStatement()
        .execute("create table UpsertDateTest (k VARCHAR not null primary key,date DATE)");
    conn.close();

    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
    conn = DriverManager.getConnection(getUrl(), props);
    conn.createStatement()
        .execute("upsert into UpsertDateTest values ('a',to_date('2013-06-08 00:00:00'))");
    conn.commit();
    conn.close();

    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
    conn = DriverManager.getConnection(getUrl(), props);
    ResultSet rs =
        conn.createStatement().executeQuery("select k,to_char(date) from UpsertDateTest");
    assertTrue(rs.next());
    assertEquals("a", rs.getString(1));
    assertEquals("2013-06-08 00:00:00", rs.getString(2));
  }
  @Test
  public void getTopologyLogLocalWhileAuthenticated() {
    final String requestTopologyId = "topology-test";
    final TopologyLog mockedLog = RandomGenerator.randomObject(TopologyLog.class);

    doReturn(mockedLog)
        .when(topologyServiceMock)
        .getTopologyLogLocal(
            requestTopologyId, TEST_SUBJECT_ID, mockedLog.getOffset(), mockedLog.getCount());

    mockAuthenticatedSubject();

    TopologyLog responseLog =
        resource()
            .path("/api/topologies/" + requestTopologyId + "/log")
            .queryParam("offset", Long.toString(mockedLog.getOffset()))
            .queryParam("limit", Long.toString(mockedLog.getCount()))
            .accept(MediaType.APPLICATION_JSON)
            .get(TopologyLog.class);

    assertEquals(
        "Response topology log should match the request topology log", mockedLog, responseLog);

    verify(topologyServiceMock)
        .getTopologyLogLocal(
            requestTopologyId, TEST_SUBJECT_ID, mockedLog.getOffset(), mockedLog.getCount());
  }
  @Test
  public void testUpsertDateValues() throws Exception {
    long ts = nextTimestamp();
    Date now = new Date(System.currentTimeMillis());
    ensureTableCreated(getUrl(), TestUtil.PTSDB_NAME, null, ts - 2);
    Properties props = new Properties();
    props.setProperty(
        PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 1)); // Execute at timestamp 1
    Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
    String dateString = "1999-01-01 02:00:00";
    PreparedStatement upsertStmt =
        conn.prepareStatement(
            "upsert into ptsdb(inst,host,date) values('aaa','bbb',to_date('" + dateString + "'))");
    int rowsInserted = upsertStmt.executeUpdate();
    assertEquals(1, rowsInserted);
    upsertStmt =
        conn.prepareStatement(
            "upsert into ptsdb(inst,host,date) values('ccc','ddd',current_date())");
    rowsInserted = upsertStmt.executeUpdate();
    assertEquals(1, rowsInserted);
    conn.commit();

    props.setProperty(
        PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 1
    conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
    String select = "SELECT date,current_date() FROM ptsdb";
    ResultSet rs = conn.createStatement().executeQuery(select);
    Date then = new Date(System.currentTimeMillis());
    assertTrue(rs.next());
    Date date = DateUtil.parseDate(dateString);
    assertEquals(date, rs.getDate(1));
    assertTrue(rs.next());
    assertTrue(rs.getDate(1).after(now) && rs.getDate(1).before(then));
    assertFalse(rs.next());
  }
  @Test
  public void testUpsertValuesWithExpression() throws Exception {
    long ts = nextTimestamp();
    ensureTableCreated(getUrl(), "IntKeyTest", null, ts - 2);
    Properties props = new Properties();
    props.setProperty(
        PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 1)); // Execute at timestamp 1
    Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
    String upsert = "UPSERT INTO IntKeyTest VALUES(-1)";
    PreparedStatement upsertStmt = conn.prepareStatement(upsert);
    int rowsInserted = upsertStmt.executeUpdate();
    assertEquals(1, rowsInserted);
    upsert = "UPSERT INTO IntKeyTest VALUES(1+2)";
    upsertStmt = conn.prepareStatement(upsert);
    rowsInserted = upsertStmt.executeUpdate();
    assertEquals(1, rowsInserted);
    conn.commit();
    conn.close();

    props.setProperty(
        PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 1
    conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
    String select = "SELECT i FROM IntKeyTest";
    ResultSet rs = conn.createStatement().executeQuery(select);
    assertTrue(rs.next());
    assertEquals(-1, rs.getInt(1));
    assertTrue(rs.next());
    assertEquals(3, rs.getInt(1));
    assertFalse(rs.next());
  }
 @Test
 public void testLANG984() { // Long durations
   assertEquals("0", DurationFormatUtils.formatDuration(0, "S"));
   assertEquals(
       Integer.toString(Integer.MAX_VALUE),
       DurationFormatUtils.formatDuration(Integer.MAX_VALUE, "S"));
   long maxIntPlus = Integer.MAX_VALUE;
   maxIntPlus++;
   assertEquals(Long.toString(maxIntPlus), DurationFormatUtils.formatDuration(maxIntPlus, "S"));
   assertEquals(
       Long.toString(Long.MAX_VALUE), DurationFormatUtils.formatDuration(Long.MAX_VALUE, "S"));
 }
 @Test
 public void testParseDecOrDefaultOk() throws Exception {
   long i = 12;
   String s = Long.toString(i);
   int def = 14;
   assertEquals(i, ParseLong.parseDecOrDefault(s, def));
 }
 @Test
 public void testCompareLongGTEDecimal() throws Exception {
   long ts = nextTimestamp();
   initTableValues(null, ts);
   String query = "SELECT l FROM LongInKeyTest where l >= 1.5";
   Properties props = new Properties();
   props.setProperty(
       PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
   Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
   try {
     PreparedStatement statement = conn.prepareStatement(query);
     ResultSet rs = statement.executeQuery();
     /*
      *  Failing because we're not converting the constant to the type of the RHS
      *  when forming the start/stop key.
      *  For this case, 1.5 -> 1L
      *  if where l < 1.5 then 1.5 -> 1L and then to 2L because it's not inclusive
      *
      */
     assertTrue(rs.next());
     assertEquals(2, rs.getLong(1));
     assertFalse(rs.next());
   } finally {
     conn.close();
   }
 }
Beispiel #8
0
  /**
   * Assert that getSplitEditFilesSorted returns files in expected order and that it skips
   * moved-aside files.
   *
   * @throws IOException
   */
  @Test
  public void testGetSplitEditFilesSorted() throws IOException {
    FileSystem fs = FileSystem.get(util.getConfiguration());
    Path regiondir = util.getDataTestDir("regiondir");
    fs.delete(regiondir, true);
    fs.mkdirs(regiondir);
    Path recoverededits = HLogUtil.getRegionDirRecoveredEditsDir(regiondir);
    String first = HLogSplitter.formatRecoveredEditsFileName(-1);
    createFile(fs, recoverededits, first);
    createFile(fs, recoverededits, HLogSplitter.formatRecoveredEditsFileName(0));
    createFile(fs, recoverededits, HLogSplitter.formatRecoveredEditsFileName(1));
    createFile(fs, recoverededits, HLogSplitter.formatRecoveredEditsFileName(11));
    createFile(fs, recoverededits, HLogSplitter.formatRecoveredEditsFileName(2));
    createFile(fs, recoverededits, HLogSplitter.formatRecoveredEditsFileName(50));
    String last = HLogSplitter.formatRecoveredEditsFileName(Long.MAX_VALUE);
    createFile(fs, recoverededits, last);
    createFile(
        fs, recoverededits, Long.toString(Long.MAX_VALUE) + "." + System.currentTimeMillis());

    HLogFactory.createHLog(fs, regiondir, "dummyLogName", util.getConfiguration());
    NavigableSet<Path> files = HLogUtil.getSplitEditFilesSorted(fs, regiondir);
    assertEquals(7, files.size());
    assertEquals(files.pollFirst().getName(), first);
    assertEquals(files.pollLast().getName(), last);
    assertEquals(files.pollFirst().getName(), HLogSplitter.formatRecoveredEditsFileName(0));
    assertEquals(files.pollFirst().getName(), HLogSplitter.formatRecoveredEditsFileName(1));
    assertEquals(files.pollFirst().getName(), HLogSplitter.formatRecoveredEditsFileName(2));
    assertEquals(files.pollFirst().getName(), HLogSplitter.formatRecoveredEditsFileName(11));
  }
Beispiel #9
0
  /**
   * Assert that getSplitEditFilesSorted returns files in expected order and that it skips
   * moved-aside files.
   *
   * @throws IOException
   */
  @Test
  public void testGetSplitEditFilesSorted() throws IOException {
    FileSystem fs = FileSystem.get(util.getConfiguration());
    Path regiondir = util.getDataTestDir("regiondir");
    fs.delete(regiondir, true);
    fs.mkdirs(regiondir);
    Path recoverededits = WALSplitter.getRegionDirRecoveredEditsDir(regiondir);
    String first = WALSplitter.formatRecoveredEditsFileName(-1);
    createFile(fs, recoverededits, first);
    createFile(fs, recoverededits, WALSplitter.formatRecoveredEditsFileName(0));
    createFile(fs, recoverededits, WALSplitter.formatRecoveredEditsFileName(1));
    createFile(fs, recoverededits, WALSplitter.formatRecoveredEditsFileName(11));
    createFile(fs, recoverededits, WALSplitter.formatRecoveredEditsFileName(2));
    createFile(fs, recoverededits, WALSplitter.formatRecoveredEditsFileName(50));
    String last = WALSplitter.formatRecoveredEditsFileName(Long.MAX_VALUE);
    createFile(fs, recoverededits, last);
    createFile(
        fs, recoverededits, Long.toString(Long.MAX_VALUE) + "." + System.currentTimeMillis());

    final Configuration walConf = new Configuration(util.getConfiguration());
    FSUtils.setRootDir(walConf, regiondir);
    (new WALFactory(walConf, null, "dummyLogName")).getWAL(new byte[] {}, null);

    NavigableSet<Path> files = WALSplitter.getSplitEditFilesSorted(fs, regiondir);
    assertEquals(7, files.size());
    assertEquals(files.pollFirst().getName(), first);
    assertEquals(files.pollLast().getName(), last);
    assertEquals(files.pollFirst().getName(), WALSplitter.formatRecoveredEditsFileName(0));
    assertEquals(files.pollFirst().getName(), WALSplitter.formatRecoveredEditsFileName(1));
    assertEquals(files.pollFirst().getName(), WALSplitter.formatRecoveredEditsFileName(2));
    assertEquals(files.pollFirst().getName(), WALSplitter.formatRecoveredEditsFileName(11));
  }
Beispiel #10
0
 @Test
 public void testScanUri() throws Exception {
   GroupByCaseTest gbt = new GroupByCaseTest();
   long ts = gbt.createTable();
   gbt.loadData(ts);
   Properties props = new Properties(TEST_PROPERTIES);
   props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 1));
   Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
   Statement stmt = conn.createStatement();
   ResultSet rs = stmt.executeQuery("select uri from " + GROUPBYTEST_NAME);
   assertTrue(rs.next());
   assertEquals("Report1", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("Report2", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("Report3", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("Report4", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("SOQL1", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("SOQL2", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("SOQL3", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("SOQL4", rs.getString(1));
   assertFalse(rs.next());
   conn.close();
 }
 @Test
 public void test_int64_t() throws IOException {
   for (Long exp : expected_int64) {
     SignedLong result = binFileReader.int64_t();
     assertEquals("int64_t " + exp + " getSignedValue()", exp, result.getSignedValue());
     assertEquals("int64_t " + exp + " toString()", exp.toString(), result.toString());
   }
 }
Beispiel #12
0
 private void insertRandomParts(long seed) {
   java.util.Random rnd = new java.util.Random(seed);
   XTextCursor xCursor = m_xDoc.getText().createTextCursor();
   for (int i = 0; i < 600; i++) {
     xCursor.goRight((short) rnd.nextInt(100), false);
     xCursor.setString(Long.toString(rnd.nextLong()));
   }
 }
 @Test
 public void testParseDecOptionalOk() throws Exception {
   long i = 14;
   String s = Long.toString(i);
   OptionalLong ret = ParseLong.parseDecOptional(s);
   assertTrue(ret.isPresent());
   assertEquals(i, ret.getAsLong());
 }
  private String associateString(Source source, String propertyName) throws Exception {
    DataSource ds = dsf.getDataSource(SOURCE);
    ds.open();
    long rc = ds.getRowCount();
    ds.close();

    String rcStr = Long.toString(rc);
    source.putProperty(propertyName, rcStr);
    return rcStr;
  }
 @Test
 public void test_uint64_t() throws IOException {
   for (Long exp : expected_uint64) {
     UnsignedLong result = binFileReader.uint64_t();
     assertEquals("uint64_t " + exp + " getSignedValue()", exp, result.getSignedValue());
     assertEquals(
         "uint64_t " + exp + " toString()",
         Long.toString(exp < 0 ? exp + 256 : exp),
         result.toString());
   }
 }
 @Test
 public void test_int32_t() throws IOException {
   for (Long exp : expected_int32) {
     SignedInteger result = binFileReader.int32_t();
     assertEquals("int32_t " + exp + " asInt()", exp, result.asLong());
     assertEquals(
         "int32_t " + exp + " getSignedValue()",
         (Integer) exp.intValue(),
         result.getSignedValue());
     assertEquals("int32_t " + exp + " toString()", exp.toString(), result.toString());
   }
 }
Beispiel #17
0
  @Test
  public void testUpsertVarCharWithMaxLength() throws Exception {
    long ts = nextTimestamp();
    Properties props = new Properties();
    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
    Connection conn = DriverManager.getConnection(getUrl(), props);
    conn.createStatement()
        .execute(
            "create table phoenix_uuid_mac (mac_md5 VARCHAR not null primary key,raw_mac VARCHAR)");
    conn.close();

    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
    conn = DriverManager.getConnection(getUrl(), props);
    conn.createStatement().execute("upsert into phoenix_uuid_mac values ('00000000591','a')");
    conn.createStatement().execute("upsert into phoenix_uuid_mac values ('000000005919','b')");
    conn.commit();
    conn.close();

    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
    conn = DriverManager.getConnection(getUrl(), props);
    ResultSet rs = conn.createStatement().executeQuery("select max(mac_md5) from phoenix_uuid_mac");
    assertTrue(rs.next());
    assertEquals("000000005919", rs.getString(1));
    conn.close();

    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 15));
    conn = DriverManager.getConnection(getUrl(), props);
    conn.createStatement()
        .execute(
            "upsert into phoenix_uuid_mac values ('000000005919adfasfasfsafdasdfasfdasdfdasfdsafaxxf1','b')");
    conn.commit();
    conn.close();

    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20));
    conn = DriverManager.getConnection(getUrl(), props);
    rs = conn.createStatement().executeQuery("select max(mac_md5) from phoenix_uuid_mac");
    assertTrue(rs.next());
    assertEquals("000000005919adfasfasfsafdasdfasfdasdfdasfdsafaxxf1", rs.getString(1));
    conn.close();
  }
Beispiel #18
0
 private void loadData(long ts) throws SQLException {
   Properties props = new Properties(TEST_PROPERTIES);
   props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
   Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
   insertRow(conn, "Report1", 10);
   insertRow(conn, "Report2", 10);
   insertRow(conn, "Report3", 30);
   insertRow(conn, "Report4", 30);
   insertRow(conn, "SOQL1", 10);
   insertRow(conn, "SOQL2", 10);
   insertRow(conn, "SOQL3", 30);
   insertRow(conn, "SOQL4", 30);
   conn.commit();
   conn.close();
 }
  private String associateFile(Source source, String propertyName) throws Exception {
    if (source.hasProperty(propertyName)) {
      source.deleteProperty(propertyName);
    }
    File stats = source.createFileProperty(propertyName);
    DataSource ds = dsf.getDataSource(source.getName());
    ds.open();
    long rc = ds.getRowCount();
    ds.close();

    FileOutputStream fis = new FileOutputStream(stats);
    String rcStr = Long.toString(rc);
    fis.write(rcStr.getBytes());
    fis.close();

    return rcStr;
  }
Beispiel #20
0
 @Test
 public void testGroupByCase() throws Exception {
   GroupByCaseTest gbt = new GroupByCaseTest();
   long ts = gbt.createTable();
   gbt.loadData(ts);
   Properties props = new Properties(TEST_PROPERTIES);
   props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 1));
   Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
   gbt.executeQuery(conn, GROUPBY1);
   gbt.executeQuery(conn, GROUPBY2);
   // TODO: validate query results
   try {
     gbt.executeQuery(conn, GROUPBY3);
     fail();
   } catch (SQLException e) {
     assertTrue(e.getMessage().contains("Aggregate expressions may not be used in GROUP BY"));
   }
   conn.close();
 }
 @Test
 public void testCompareLongGTDecimal() throws Exception {
   long ts = nextTimestamp();
   initTableValues(null, ts);
   String query = "SELECT l FROM LongInKeyTest where l > 1.5";
   Properties props = new Properties();
   props.setProperty(
       PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
   Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
   try {
     PreparedStatement statement = conn.prepareStatement(query);
     ResultSet rs = statement.executeQuery();
     assertTrue(rs.next());
     assertEquals(2, rs.getLong(1));
     assertFalse(rs.next());
   } finally {
     conn.close();
   }
 }
  @Test
  public void testFindEmployees() {
    Employee emp = getSampleEmployee();

    final String sampleUniqueName = Long.toString(System.currentTimeMillis());
    emp.setName(sampleUniqueName);
    createEmployee(emp);

    List<Employee> empList =
        empDaoBean.findEmployees(
            new EmployeeMatcherCreator() {
              public EmployeeMatcher createEmployeeMatcher() {
                EmployeeMatcher empMatcher = new EmployeeMatcher();
                empMatcher.setNameToFind(sampleUniqueName);
                return empMatcher;
              }
            });
    assertEquals(1, empList.size());
  }
Beispiel #23
0
  @Test
  public void dateValueIndexFieldEncoding() {

    String[] dateFormats =
        new String[] {
          "Long-format",
          "yyyy-MM-dd HH:mm:ss Z",
          "yyyy-MM-dd HH:mm:ss",
          "yyyy-MM-dd HH:mm",
          "yyyy-MM-dd HH",
          "yyyy-MM-dd"
        };

    Date now = new Date();
    String[] dateStrings =
        new String[] {
          Long.toString(now.getTime()),
          "2005-10-10 14:22:00 +0100",
          "2005-10-10 14:22:00",
          "2005-10-10 14:22",
          "2005-10-10 14",
          "2005-10-10"
        };

    for (int i = 0; i < dateStrings.length; i++) {
      try {
        pf.queryTerm("someDate", dateStrings[i], PropertyType.Type.TIMESTAMP, false);
      } catch (Exception e) {
        fail(
            "Failed to encode index field value for date format '"
                + dateFormats[i]
                + "', date string '"
                + dateStrings[i]
                + "':"
                + e.getMessage());
      }
    }
  }
  @Test
  public void testRailway() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("railway", "rail");
    assertTrue(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("highway", "path");
    way.setTag("railway", "abandoned");
    assertTrue(encoder.acceptWay(way) == 0);

    way.setTag("highway", "track");
    assertTrue(encoder.acceptWay(way) > 0);

    // this is fully okay as sometimes old rails are on the road
    way.setTag("highway", "primary");
    way.setTag("railway", "historic");
    assertTrue(encoder.acceptWay(way) > 0);

    way.setTag("motorcar", "no");
    assertTrue(encoder.acceptWay(way) == 0);

    way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("railway", "tram");
    // but allow tram to be on the same way
    assertTrue(encoder.acceptWay(way) > 0);

    way = new ReaderWay(1);
    way.setTag("route", "shuttle_train");
    way.setTag("motorcar", "yes");
    way.setTag("bicycle", "no");
    // Provide the duration value in seconds:
    way.setTag("duration:seconds", Long.toString(35 * 60));
    way.setTag("estimated_distance", 50000);
    // accept
    assertTrue(encoder.acceptWay(way) > 0);
    // calculate speed from estimated_distance and duration
    assertEquals(61, encoder.getFerrySpeed(way, 20, 30, 40), 1e-1);

    // Test for very short and slow 0.5km/h still realisitic ferry
    way = new ReaderWay(1);
    way.setTag("route", "ferry");
    way.setTag("motorcar", "yes");
    // Provide the duration of 12 minutes in seconds:
    way.setTag("duration:seconds", Long.toString(12 * 60));
    way.setTag("estimated_distance", 100);
    // accept
    assertTrue(encoder.acceptWay(way) > 0);
    // We can't store 0.5km/h, but we expect the lowest possible speed (5km/h)
    assertEquals(2.5, encoder.getFerrySpeed(way, 20, 30, 40), 1e-1);
    assertEquals(5, encoder.getSpeed(encoder.setSpeed(0, 2.5)), 1e-1);

    // Test for an unrealisitic long duration
    way = new ReaderWay(1);
    way.setTag("route", "ferry");
    way.setTag("motorcar", "yes");
    // Provide the duration of 2 months in seconds:
    way.setTag("duration:seconds", Long.toString(87900 * 60));
    way.setTag("estimated_distance", 100);
    // accept
    assertTrue(encoder.acceptWay(way) > 0);
    // We have ignored the unrealisitc long duration and take the unknown speed
    assertEquals(20, encoder.getFerrySpeed(way, 20, 30, 40), 1e-1);
  }
 //  Test dec/hex picking
 @Test
 public void testParse_Dec() throws Exception {
   long i = 123456;
   String s = Long.toString(i);
   assertEquals(i, ParseLong.parse(s));
 }
 @Test
 public void testParseDec_MaxSigned() throws Exception {
   long i = Long.MAX_VALUE;
   String s = Long.toString(i);
   assertEquals(i, ParseLong.parseDec(s));
 }
 //  Test negative sign prefix
 @Test
 public void testParseDec_Negative() throws Exception {
   long i = -123456;
   String s = Long.toString(i);
   assertEquals(i, ParseLong.parseDec(s));
 }
 private char randChar() {
   return Long.toString(Math.abs(r.nextLong()), 36).charAt(0);
 }
 //  Test dec/hex dec trimming
 @Test
 public void testParse_DecTrim() throws Exception {
   long i = 123456;
   String s = WHITESPACE + Long.toString(i) + WHITESPACE;
   assertEquals(i, ParseLong.parse(s));
 }