### Question:
ByteCodeFilter { @SuppressWarnings("unused") public boolean accept(InputStream classFileStream) throws IOException { DataInputStream in = new DataInputStream(classFileStream); int magic = in.readInt(); if (magic != CLASS_FILE_MAGIC) { if (log.isDebugEnabled()) { log.debug("Magic not found! Not a valid class file!"); } return false; } int minor = in.readUnsignedShort(); int major = in.readUnsignedShort(); if (major < 49) { if (log.isTraceEnabled()) { log.trace("Not a JDK5 class! It cannot contain annotations!"); } return false; } int constantPoolEntries = in.readUnsignedShort() - 1; for (int i = 0; i < constantPoolEntries; i++) { int tag = in.readUnsignedByte(); switch (tag) { case CONSTANT_Class: in.readUnsignedShort(); break; case CONSTANT_Fieldref: case CONSTANT_Methodref: case CONSTANT_InterfaceMethodref: in.readUnsignedShort(); in.readUnsignedShort(); break; case CONSTANT_String: in.readUnsignedShort(); break; case CONSTANT_Integer: case CONSTANT_Float: in.readInt(); break; case CONSTANT_Long: case CONSTANT_Double: in.readLong(); i++; break; case CONSTANT_NameAndType: in.readUnsignedShort(); in.readUnsignedShort(); break; case CONSTANT_Utf8: String str = in.readUTF(); if (containsFieldDescriptor(str)) { if (log.isTraceEnabled()) { log.trace("Found interesting annotation reference in constant pool: " + str); } return true; } break; case CONSTANT_MethodHandle: in.readByte(); in.readShort(); break; case CONSTANT_MethodType: in.readShort(); break; case CONSTANT_InvokeDynamic: in.readShort(); in.readShort(); break; default: if (log.isDebugEnabled()) { log.debug("Unknown constant pool tag found: " + tag); } return true; } } return false; } ByteCodeFilter(Set<Class<? extends Annotation>> types); @SuppressWarnings("unused") boolean accept(InputStream classFileStream); @Override String toString();  }### Answer:
@Test public void testInvalidClass() throws IOException { assertFalse(filter.accept(new ByteArrayInputStream(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0xd3, (byte) 0x45, (byte) 0x13, (byte) 0x35, (byte) 0xd4, (byte) 0x46, (byte) 0x14, (byte) 0x36, (byte) 0xd5, (byte) 0x47, (byte) 0x15, (byte) 0x37, (byte) 0xd6, (byte) 0x48 }))); }
@Test public void testJdk14Class() throws IOException { assertFalse(filter.accept(new ByteArrayInputStream(new byte[] { (byte) 0xca, (byte) 0xfe, (byte) 0xba, (byte) 0xbe, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 48 }))); }
@Test public void testNoAnnotationsOnClass() throws IOException { assertFalse(filter.accept(getByteCodeInputStream(ClassWithoutAnnotations.class))); }
@Test public void testUrlMappingAnnotationOnClass() throws IOException { assertTrue(filter.accept(getByteCodeInputStream(ClassWithUrlMapping.class))); }
@Test public void testClassWithLongValueInConstantPool() throws IOException { assertFalse(filter.accept(getByteCodeInputStream(ClassWithLongValueInConstantPool.class))); }
@Test public void testUrlActionOnMethod() throws IOException { assertTrue(filter.accept(getByteCodeInputStream(ClassWithUrlAction.class))); }