Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/test/java/org/seqdoop/hadoop_bam/TestSAMInputFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,50 @@ public void testMapReduceJob() throws Exception {
}
br.close();
}

@Test
public void testCorruptedReadNameSAM() throws Exception {
// override setup with different input
Configuration conf = new Configuration();
input = ClassLoader.getSystemClassLoader().getResource("small.sam").getFile();
conf.set("mapred.input.dir", "file://" + input);

taskAttemptContext = new TaskAttemptContextImpl(conf, mock(TaskAttemptID.class));
jobContext = new JobContextImpl(conf, taskAttemptContext.getJobID());

AnySAMInputFormat inputFormat = new AnySAMInputFormat();
List<InputSplit> splits = inputFormat.getSplits(jobContext);
assertEquals(1, splits.size());
RecordReader<LongWritable, SAMRecordWritable> reader = inputFormat
.createRecordReader(splits.get(0), taskAttemptContext);
reader.initialize(splits.get(0), taskAttemptContext);

assertTrue(reader.nextKeyValue());
SAMRecord record = reader.getCurrentValue().get();
assertEquals("1", record.getReferenceName());
assertEquals(26472784, record.getStart());
assertEquals("simread:1:26472783:false", record.getReadName());
}

@Test
public void testCorruptedHeaderSAM() throws Exception {
// override setup with different input
Configuration conf = new Configuration();
input = ClassLoader.getSystemClassLoader().getResource("flag-values.sam").getFile();
conf.set("mapred.input.dir", "file://" + input);

taskAttemptContext = new TaskAttemptContextImpl(conf, mock(TaskAttemptID.class));
jobContext = new JobContextImpl(conf, taskAttemptContext.getJobID());

AnySAMInputFormat inputFormat = new AnySAMInputFormat();
List<InputSplit> splits = inputFormat.getSplits(jobContext);
assertEquals(1, splits.size());
RecordReader<LongWritable, SAMRecordWritable> reader = inputFormat
.createRecordReader(splits.get(0), taskAttemptContext);
reader.initialize(splits.get(0), taskAttemptContext);

assertTrue(reader.nextKeyValue());
SAMRecord record = reader.getCurrentValue().get();
assertEquals("read:0", record.getReadName());
}
}
Loading