Package org.kitesdk.morphline.api

Examples of org.kitesdk.morphline.api.Record


  }

  @Test
  public void testMimeTypeAlreadySpecifiedOnInputRemainsUnchanged() throws Exception {
    morphline = createMorphline("test-morphlines/detectMimeTypesWithDefaultMimeTypes");   
    Record record = new Record();   
    record.put(Fields.ATTACHMENT_BODY, Files.toByteArray(JPG_FILE));
    record.put(Fields.ATTACHMENT_MIME_TYPE, "foo/bar");
    startSession();
    morphline.process(record);
    assertEquals("foo/bar", collector.getFirstRecord().getFirstValue(Fields.ATTACHMENT_MIME_TYPE));
  }
View Full Code Here


    assertEquals("foo/bar", collector.getFirstRecord().getFirstValue(Fields.ATTACHMENT_MIME_TYPE));
  }

  @Test
  public void testPlainText() throws Exception {
    Record event = createEvent("foo".getBytes("UTF-8"));
    assertEquals("text/plain", detect(event, false));
  }
View Full Code Here

  private void testBasic(String morphlineFile) throws Exception {
    morphline = createMorphline(morphlineFile);   
     
    for (int i = 0; i < 3; i++) {
      Record record = new Record();
      String userAgentStr = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3";
      record.put("user_agents", userAgentStr);
      Record expected = new Record();
      expected.put("user_agents", userAgentStr);
      expected.put("ua_family", "Mobile Safari");
      expected.put("device_family", "iPhone");
      expected.put("string_constant1", "foo");
      expected.put("string_constant2", "");
      expected.put("ua_family_and_version", "Mobile Safari/5.1");
      expected.put("os_family_and_version", "iOS5.1.1-foo@bar");
             
      processAndVerifySuccess(record, expected, true);
     
      record = new Record();
      record.put("user_agents", userAgentStr);
      processAndVerifySuccess(record, expected, true);
    }
  }
View Full Code Here

    assertEquals("text/plain", detect(event, false));
  }

  @Test
  public void testUnknownType() throws Exception {   
    Record event = createEvent(new byte[] {3, 4, 5, 6});
    assertEquals("application/octet-stream", detect(event, false));
  }
View Full Code Here

    assertEquals("application/octet-stream", detect(event, false));
  }

  @Test
  public void testUnknownEmptyType() throws Exception {   
    Record event = createEvent(new byte[0]);
    assertEquals("application/octet-stream", detect(event, false));
  }
View Full Code Here

  }

  @Ignore
  @Test
  public void testNullType() throws Exception {   
    Record event = createEvent(null);
    assertEquals("application/octet-stream", detect(event, false));
  }
View Full Code Here

    assertEquals("application/octet-stream", detect(event, false));
  }

  @Test
  public void testXML() throws Exception {   
    Record event = createEvent("<?xml version=\"1.0\"?><foo/>".getBytes("UTF-8"));
    assertEquals("application/xml", detect(event, false));
  }
View Full Code Here

    Record event = createEvent("<?xml version=\"1.0\"?><foo/>".getBytes("UTF-8"));
    assertEquals("application/xml", detect(event, false));
  }

  public void testXML11() throws Exception {   
    Record event = createEvent("<?xml version=\"1.1\"?><foo/>".getBytes("UTF-8"));
    assertEquals("application/xml", detect(event, false));
  }
View Full Code Here

    Record event = createEvent("<?xml version=\"1.1\"?><foo/>".getBytes("UTF-8"));
    assertEquals("application/xml", detect(event, false));
  }

  public void testXMLAnyVersion() throws Exception {   
    Record event = createEvent("<?xml version=\"\"?><foo/>".getBytes("UTF-8"));
    assertEquals("application/xml", detect(event, false));
  }
View Full Code Here

    assertEquals("application/xml", detect(event, false));
  }

  @Test
  public void testXMLasTextPlain() throws Exception {   
    Record event = createEvent("<foo/>".getBytes("UTF-8"));
    assertEquals("text/plain", detect(event, false));
  }
View Full Code Here

TOP

Related Classes of org.kitesdk.morphline.api.Record

Copyright © 2018 www.massapicom. 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.