コード例 #1
0
  /** Test of findAll method, of class BitstreamFormat. */
  @Test
  public void testFindAll() throws SQLException {

    BitstreamFormat[] found = BitstreamFormat.findAll(context);
    assertThat("testFindAll 0", found, notNullValue());

    // check pos 0 is Unknown
    assertThat("testFindAll 1", found[0].getShortDescription(), equalTo("Unknown"));
    assertFalse("testFindAll 2", found[0].isInternal());
    assertThat("testFindAll 3", found[0].getSupportLevel(), equalTo(0));

    boolean added = false;
    for (BitstreamFormat bsf : found) {
      if (bsf.equals(bf)) {
        added = true;
      }
    }
    assertTrue("testFindAll 4", added);
  }
コード例 #2
0
  /** Test of getSupportLevel method, of class BitstreamFormat. */
  @Test
  public void testGetSupportLevel() throws SQLException {

    assertTrue("testGetSupportLevel 0", bf.getSupportLevel() >= 0);
    assertTrue("testGetSupportLevel 1", bf.getSupportLevel() <= 2);

    assertTrue("testGetSupportLevel 2", bunknown.getSupportLevel() >= 0);
    assertTrue("testGetSupportLevel 3", bunknown.getSupportLevel() <= 2);

    BitstreamFormat[] found = BitstreamFormat.findAll(context);
    int i = 0;
    for (BitstreamFormat b : found) {
      i++;
      assertTrue(
          "testGetSupportLevel " + i + " (" + b.getMIMEType() + ")", b.getSupportLevel() >= 0);
      i++;
      assertTrue(
          "testGetSupportLevel " + i + " (" + b.getMIMEType() + ")", b.getSupportLevel() <= 2);
    }
  }
コード例 #3
0
  protected BitstreamFormat getFormat(Context context, String fileName) throws SQLException {
    String fext = null;
    int lastDot = fileName.lastIndexOf(".");
    if (lastDot > -1) {
      fext = fileName.substring(lastDot + 1);
    }

    if (fext == null) {
      return null;
    }

    for (BitstreamFormat format : BitstreamFormat.findAll(context)) {
      String[] extensions = format.getExtensions();
      for (String ext : extensions) {
        if (ext.equals(fext)) {
          return format;
        }
      }
    }
    return null;
  }