本文整理汇总了Java中org.fosstrak.tdt.TDTException类的典型用法代码示例。如果您正苦于以下问题:Java TDTException类的具体用法?Java TDTException怎么用?Java TDTException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TDTException类属于org.fosstrak.tdt包,在下文中一共展示了TDTException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAddTagAsRawDecimalErrorInTDT
import org.fosstrak.tdt.TDTException; //导入依赖的package包/类
/**
* test adding a tag as raw decimal - test the case where TDT has a problem.
*/
@Test
public void testAddTagAsRawDecimalErrorInTDT() {
final String original = "original";
TDTEngine tdt = EasyMock.createMock(TDTEngine.class);
EasyMock.expect(tdt.bin2dec(original)).andThrow(new TDTException("MOCK EXCEPTION"));
EasyMock.replay(tdt);
TagHelper.setTDTEngine(null);
ECReportGroupListMember groupMember = EasyMock.createMock(ECReportGroupListMember.class);
EasyMock.replay(groupMember);
Tag tag = EasyMock.createMock(Tag.class);
EasyMock.expect(tag.getTagAsBinary()).andReturn(original).atLeastOnce();
EasyMock.replay(tag);
Assert.assertNull(TagHelper.addTagAsRawDecimal(tdt, groupMember, tag));
EasyMock.verify(tdt);
EasyMock.verify(tag);
EasyMock.verify(groupMember);
}
示例2: testAddTagAsTagEncodingErrorInTDT
import org.fosstrak.tdt.TDTException; //导入依赖的package包/类
/**
* test adding a tag as tag encoding - test the case where TDT has a problem.
*/
@SuppressWarnings("unchecked")
@Test
public void testAddTagAsTagEncodingErrorInTDT() {
final String original = "original";
TDTEngine tdt = EasyMock.createMock(TDTEngine.class);
EasyMock.expect(tdt.convert(EasyMock.eq(original), EasyMock.isA(Map.class), EasyMock.eq(LevelTypeList.TAG_ENCODING))).andThrow(new TDTException("MOCK EXCEPTION"));
EasyMock.replay(tdt);
TagHelper.setTDTEngine(null);
ECReportGroupListMember groupMember = EasyMock.createMock(ECReportGroupListMember.class);
EasyMock.replay(groupMember);
Tag tag = EasyMock.createMock(Tag.class);
EasyMock.expect(tag.getTagAsBinary()).andReturn(original).atLeastOnce();
EasyMock.expect(tag.getTagLength()).andReturn("tagLength").atLeastOnce();
EasyMock.expect(tag.getFilter()).andReturn("tagFilter").atLeastOnce();
EasyMock.expect(tag.getCompanyPrefixLength()).andReturn("companyPrefixLength").atLeastOnce();
EasyMock.replay(tag);
Assert.assertNull(TagHelper.addTagAsTagEncoding(tdt, groupMember, tag));
EasyMock.verify(tdt);
EasyMock.verify(tag);
EasyMock.verify(groupMember);
}
示例3: testAddTagAsRawHexErrorInTDT
import org.fosstrak.tdt.TDTException; //导入依赖的package包/类
/**
* test adding a tag as raw hex - test the case where TDT has a problem.
*/
@Test
public void testAddTagAsRawHexErrorInTDT() {
final String original = "original";
TDTEngine tdt = EasyMock.createMock(TDTEngine.class);
EasyMock.expect(tdt.bin2hex(original)).andThrow(new TDTException("MOCK EXCEPTION"));
EasyMock.replay(tdt);
TagHelper.setTDTEngine(null);
ECReportGroupListMember groupMember = EasyMock.createMock(ECReportGroupListMember.class);
EasyMock.replay(groupMember);
Tag tag = EasyMock.createMock(Tag.class);
EasyMock.expect(tag.getTagAsBinary()).andReturn(original).atLeastOnce();
EasyMock.replay(tag);
Assert.assertNull(TagHelper.addTagAsRawHex(tdt, groupMember, tag));
EasyMock.verify(tdt);
EasyMock.verify(tag);
EasyMock.verify(groupMember);
}
示例4: convert
import org.fosstrak.tdt.TDTException; //导入依赖的package包/类
/**
* converts a given input with the given TDT to the desired output format.
* @param input the tag to convert. Must be in binary format or in TAG_ENCODING.
* @param extraparms conversion parameters.
* @param outputLevel the destination format.
* @return the converted tag.
* @throws TDTException whenever a tag conversion error occurs.
*/
public static String convert(String input, Map<String, String> extraparms, LevelTypeList outputLevel, TDTEngine tdt) throws TDTException {
try {
return tdt.convert(input, extraparms, outputLevel);
} catch (NullPointerException npe) {
LOG.error("caught NullPointerException during transformation - could not perform the transformation ", npe);
throw new TDTException("caught NullPointerException during transformation - could not perform the transformation " + npe.getMessage());
}
}
示例5: testAddTagAsEPCErrorInTDT
import org.fosstrak.tdt.TDTException; //导入依赖的package包/类
/**
* test adding a tag as EPC - test the case where TDT has a problem.
*/
@SuppressWarnings("unchecked")
@Test
public void testAddTagAsEPCErrorInTDT() {
final String original = "original";
final String pureURI = "pureURI";
TDTEngine tdt = EasyMock.createMock(TDTEngine.class);
EasyMock.expect(tdt.convert(EasyMock.eq(original), EasyMock.isA(Map.class), EasyMock.eq(LevelTypeList.PURE_IDENTITY))).andThrow(new TDTException("MOCK EXCEPTION"));
EasyMock.replay(tdt);
TagHelper.setTDTEngine(null);
ECReportGroupListMember groupMember = EasyMock.createMock(ECReportGroupListMember.class);
groupMember.setEpc(EasyMock.isA(EPC.class));
EasyMock.expectLastCall();
EasyMock.replay(groupMember);
Tag tag = EasyMock.createMock(Tag.class);
EasyMock.expect(tag.getTagAsBinary()).andReturn(original).atLeastOnce();
EasyMock.expect(tag.getTagLength()).andReturn("tagLength").atLeastOnce();
EasyMock.expect(tag.getFilter()).andReturn("tagFilter").atLeastOnce();
EasyMock.expect(tag.getCompanyPrefixLength()).andReturn("companyPrefixLength").atLeastOnce();
EasyMock.expect(tag.getTagIDAsPureURI()).andReturn(pureURI).atLeastOnce();
EasyMock.replay(tag);
Assert.assertEquals(pureURI, TagHelper.addTagAsEPC(tdt, groupMember, tag));
EasyMock.verify(tdt);
EasyMock.verify(tag);
EasyMock.verify(groupMember);
}
示例6: testTDTNotThrowingNullPointerException
import org.fosstrak.tdt.TDTException; //导入依赖的package包/类
/**
* TagHelper must not throw NullPointerException - only TDTException is allowed.
*/
@Test(expected = TDTException.class)
public void testTDTNotThrowingNullPointerException() {
TagHelper.setTDTEngine(null);
TagHelper.convert(null, null, null, null);
}