Examples of TextRecord


Examples of org.nfctools.ndef.wkt.records.TextRecord

  @Test
  public void testEncode() throws Exception {
    GenericControlRecord gcr = new GenericControlRecord(new GcTargetRecord(new UriRecord(
        "file://localhost/Appli/CustomerBonus")));

    gcr.setAction(new GcActionRecord(new TextRecord("add", Charset.forName("utf8"), Locale.US)));
    gcr.setData(new GcDataRecord(new TextRecord("500", Locale.US)));

    byte[] encodedGcr = messageEncoder.encodeSingle(gcr);

    assertArrayEquals(GenericControlRecordDecoderTest.payload, encodedGcr);
  }
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.TextRecord

  private static String string = new String(new char[]{84, 101, 115, 116, 246, 228, 252, 223, 214, 196, 220, 63});
 
  @Test
  public void testCreateTextRecordUtf8German() throws Exception {
   
    TextRecord textRecord = new TextRecord(string, Charset.forName("utf8"), Locale.GERMAN);
    byte[] bytes = encoder.encodePayload(textRecord, messageEncoder);
    assertEquals("02646554657374C3B6C3A4C3BCC39FC396C384C39C3F", NfcUtils.convertBinToASCII(bytes));
  }
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.TextRecord

    assertEquals("02646554657374C3B6C3A4C3BCC39FC396C384C39C3F", NfcUtils.convertBinToASCII(bytes));
  }

  @Test
  public void testCreateTextRecordUtf16German() throws Exception {
    TextRecord textRecord = new TextRecord(string, Charset.forName("utf-16be"), Locale.GERMAN);
    byte[] bytes = encoder.encodePayload(textRecord, messageEncoder);
    assertEquals("826465005400650073007400F600E400FC00DF00D600C400DC003F", NfcUtils.convertBinToASCII(bytes));
  }
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.TextRecord

    assertEquals("826465005400650073007400F600E400FC00DF00D600C400DC003F", NfcUtils.convertBinToASCII(bytes));
  }

  @Test
  public void testCreateTextRecordUtf8English() throws Exception {
    TextRecord textRecord = new TextRecord(string, Charset.forName("utf8"), Locale.ENGLISH);
    byte[] bytes = encoder.encodePayload(textRecord, messageEncoder);
    assertEquals("02656E54657374C3B6C3A4C3BCC39FC396C384C39C3F", NfcUtils.convertBinToASCII(bytes));
  }
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.TextRecord

    assertEquals("02656E54657374C3B6C3A4C3BCC39FC396C384C39C3F", NfcUtils.convertBinToASCII(bytes));
  }

  @Test
  public void testCreateTextRecordUtf16English() throws Exception {
    TextRecord textRecord = new TextRecord(string, Charset.forName("utf-16be"), Locale.ENGLISH);
    byte[] bytes = encoder.encodePayload(textRecord, messageEncoder);
    assertEquals("82656E005400650073007400F600E400FC00DF00D600C400DC003F", NfcUtils.convertBinToASCII(bytes));
  }
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.TextRecord

    assertEquals("file://localhost/Appli/CustomerBonus", uriRecord.getUri());

    assertTrue(gcr.getAction().hasActionRecord());
    assertTrue(gcr.getAction().getActionRecord() instanceof TextRecord);

    TextRecord actionTextRecord = (TextRecord)gcr.getAction().getActionRecord();

    assertEquals("add", actionTextRecord.getText());

    assertEquals(1, gcr.getData().getRecords().size());
  }
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.TextRecord

    encoder.encode(records);
  }

  @Test
  public void testEncodeMultiple() throws Exception {
    byte[] encode = encoder.encode(new TextRecord("R1", Locale.GERMANY), new TextRecord("R2", Locale.GERMANY));
    assertEquals("910108540564652D44455231510108540564652D44455232", NfcUtils.convertBinToASCII(encode));
  }
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.TextRecord

public class TextRecordTest {

  @Test(expected = IllegalArgumentException.class)
  public void testUnsupportedEncodingUsAscii() throws Exception {

    new TextRecord("", Charset.forName("US-ASCII"), Locale.GERMAN);
  }
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.TextRecord

  }

  @Test(expected = IllegalArgumentException.class)
  public void testUnsupportedEncodingUtf16() throws Exception {

    new TextRecord("", Charset.forName("utf16"), Locale.GERMAN);
  }
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.TextRecord

      + "303F626F64793D486921253230576965253230676568742532306573253230646972253346";

  @Test
  public void testEncode() throws Exception {
    SmartPosterRecord smartPosterRecord = new SmartPosterRecord();
    smartPosterRecord.setTitle(new TextRecord("Test", Charset.forName("UTF8"), Locale.GERMAN));
    smartPosterRecord.setUri(new UriRecord("sms:+491234567890?body=Hi!%20Wie%20geht%20es%20dir%3F"));
    byte[] payload = messageEncoder.encodeSingle(smartPosterRecord);
    assertEquals(innerSmartPoster, NfcUtils.convertBinToASCII(payload));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.