target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test( expected = IllegalStateException.class ) public void testNoEnumConstantsFail() throws Exception { mapperFactory.mapType( ValuesEmpty.class, null ); fail( "Must fail" ); } | @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } } | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... |
@Test public void testHugeTagNumber() throws Exception { TypeFactory factory = new CoreTypeFactory(); Module module = factory.dummyModule(); Scope scope = module.createScope(); Type tagged = factory.tagged( TagEncoding.application( 2048 ), UniversalType.INTEGER.ref() ); Type defined = factory.define( "MyTagged", tagged... | @SuppressWarnings( "NumericCastThatLosesPrecision" ) @Override public byte read() throws IOException { int read = is.read(); if( read != -1 ) position++; return (byte)read; } | DefaultBerReader extends AbstractBerReader { @SuppressWarnings( "NumericCastThatLosesPrecision" ) @Override public byte read() throws IOException { int read = is.read(); if( read != -1 ) position++; return (byte)read; } } | DefaultBerReader extends AbstractBerReader { @SuppressWarnings( "NumericCastThatLosesPrecision" ) @Override public byte read() throws IOException { int read = is.read(); if( read != -1 ) position++; return (byte)read; } DefaultBerReader( InputStream is, ValueFactory valueFactory ); } | DefaultBerReader extends AbstractBerReader { @SuppressWarnings( "NumericCastThatLosesPrecision" ) @Override public byte read() throws IOException { int read = is.read(); if( read != -1 ) position++; return (byte)read; } DefaultBerReader( InputStream is, ValueFactory valueFactory ); @Override int position(); @Override v... | DefaultBerReader extends AbstractBerReader { @SuppressWarnings( "NumericCastThatLosesPrecision" ) @Override public byte read() throws IOException { int read = is.read(); if( read != -1 ) position++; return (byte)read; } DefaultBerReader( InputStream is, ValueFactory valueFactory ); @Override int position(); @Override v... |
@Test( expected = IllegalStateException.class ) public void testIllegalIndexes() throws Exception { mapperFactory.mapType( IllegalEnum.class, null ); fail( "Must fail" ); } | @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } } | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... |
@Test( expected = IllegalStateException.class ) public void testIllegalIndexes2() throws Exception { mapperFactory.mapType( IllegalEnum2.class, null ); fail( "Must fail" ); } | @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } } | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... |
@Test public void testIntrospection() throws Exception { Introspector introspector = new Introspector(); JavaType type = introspector.introspect( Element.class ); int k = 0; } | @NotNull public JavaType introspect( Type type ) { if( typeMap.containsKey( type.getTypeName() ) ) return typeMap.get( type.getTypeName() ); if( type instanceof Class<?> ) return forClass( (Class<?>)type ); if( type instanceof ParameterizedType ) return forParameterized( (ParameterizedType)type ); if( type instanceof T... | Introspector { @NotNull public JavaType introspect( Type type ) { if( typeMap.containsKey( type.getTypeName() ) ) return typeMap.get( type.getTypeName() ); if( type instanceof Class<?> ) return forClass( (Class<?>)type ); if( type instanceof ParameterizedType ) return forParameterized( (ParameterizedType)type ); if( ty... | Introspector { @NotNull public JavaType introspect( Type type ) { if( typeMap.containsKey( type.getTypeName() ) ) return typeMap.get( type.getTypeName() ); if( type instanceof Class<?> ) return forClass( (Class<?>)type ); if( type instanceof ParameterizedType ) return forParameterized( (ParameterizedType)type ); if( ty... | Introspector { @NotNull public JavaType introspect( Type type ) { if( typeMap.containsKey( type.getTypeName() ) ) return typeMap.get( type.getTypeName() ); if( type instanceof Class<?> ) return forClass( (Class<?>)type ); if( type instanceof ParameterizedType ) return forParameterized( (ParameterizedType)type ); if( ty... | Introspector { @NotNull public JavaType introspect( Type type ) { if( typeMap.containsKey( type.getTypeName() ) ) return typeMap.get( type.getTypeName() ); if( type instanceof Class<?> ) return forClass( (Class<?>)type ); if( type instanceof ParameterizedType ) return forParameterized( (ParameterizedType)type ); if( ty... |
@Test( expected = IllegalArgumentException.class ) public void toAsn1Fails() throws Exception { TypeMapper mapper = new RealTypeMapper( double.class, REAL ); mapper.toAsn1( FACTORY, true ); fail( "Must fail" ); } | @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( isFloat() && isAssignableToFloat( value ) ) return factory.real( (Float)value ); if( isDouble() && isAssignableToDouble( value ) ) return factory.real( (Double)value ); if( isBigDecimal() && Objects.equals( value.getCla... | RealTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( isFloat() && isAssignableToFloat( value ) ) return factory.real( (Float)value ); if( isDouble() && isAssignableToDouble( value ) ) return factory.real( (Double)value ); if( isBigDe... | RealTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( isFloat() && isAssignableToFloat( value ) ) return factory.real( (Float)value ); if( isDouble() && isAssignableToDouble( value ) ) return factory.real( (Double)value ); if( isBigDe... | RealTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( isFloat() && isAssignableToFloat( value ) ) return factory.real( (Float)value ); if( isDouble() && isAssignableToDouble( value ) ) return factory.real( (Double)value ); if( isBigDe... | RealTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( isFloat() && isAssignableToFloat( value ) ) return factory.real( (Float)value ); if( isDouble() && isAssignableToDouble( value ) ) return factory.real( (Double)value ); if( isBigDe... |
@Test( expected = IllegalArgumentException.class ) public void toJavaFails() throws Exception { TypeMapper mapper = new RealTypeMapper( double.class, REAL ); mapper.toJava( BooleanValue.TRUE ); fail( "Must fail" ); } | @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.REAL ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); RealValue rv = value.toRealValue(); if( isFloat() ) return rv.asFloat(); if( isDouble() ) return rv.asDouble(); if( isBigDecima... | RealTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.REAL ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); RealValue rv = value.toRealValue(); if( isFloat() ) return rv.asFloat(); if( isDouble() ... | RealTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.REAL ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); RealValue rv = value.toRealValue(); if( isFloat() ) return rv.asFloat(); if( isDouble() ... | RealTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.REAL ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); RealValue rv = value.toRealValue(); if( isFloat() ) return rv.asFloat(); if( isDouble() ... | RealTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.REAL ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); RealValue rv = value.toRealValue(); if( isFloat() ) return rv.asFloat(); if( isDouble() ... |
@Test( expected = IllegalArgumentException.class ) public void toAsn1Fails() throws Exception { TypeMapper mapper = new StringTypeMapper( String.class, UTF8_STRING ); mapper.toAsn1( FACTORY, 1L ); fail( "Must fail" ); } | @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !javaType.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); return factory.cString( (String)value ); } | StringTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !javaType.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); return factory.cString( (String)value ); } } | StringTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !javaType.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); return factory.cString( (String)value ); } StringTypeM... | StringTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !javaType.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); return factory.cString( (String)value ); } StringTypeM... | StringTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !javaType.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); return factory.cString( (String)value ); } StringTypeM... |
@Test( expected = IllegalArgumentException.class ) public void toJavaFails() throws Exception { TypeMapper mapper = new StringTypeMapper( String.class, UTF8_STRING ); mapper.toJava( BooleanValue.TRUE ); fail( "Must fail" ); } | @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.C_STRING ) throw new IllegalArgumentException( "Unable to convert value of kind: " + value.getKind() ); return value.toStringValue().asString(); } | StringTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.C_STRING ) throw new IllegalArgumentException( "Unable to convert value of kind: " + value.getKind() ); return value.toStringValue().asString(); } } | StringTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.C_STRING ) throw new IllegalArgumentException( "Unable to convert value of kind: " + value.getKind() ); return value.toStringValue().asString(); } StringTypeMapper( Class<?> javaType, N... | StringTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.C_STRING ) throw new IllegalArgumentException( "Unable to convert value of kind: " + value.getKind() ); return value.toStringValue().asString(); } StringTypeMapper( Class<?> javaType, N... | StringTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.C_STRING ) throw new IllegalArgumentException( "Unable to convert value of kind: " + value.getKind() ); return value.toStringValue().asString(); } StringTypeMapper( Class<?> javaType, N... |
@Test( expected = IllegalArgumentException.class ) public void toAsn1Fails() throws Exception { TypeMapper mapper = new IntegerTypeMapper( Long.class, INTEGER ); mapper.toAsn1( FACTORY, true ); fail( "Must fail" ); } | @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( isByte() && isAssignableToByte( value ) ) return factory.integer( (Byte)value ); if( isShort() && isAssignableToShort( value ) ) return factory.integer( (Short)value ); if( isInteger() && isAssignableToInt( value ) ) re... | IntegerTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( isByte() && isAssignableToByte( value ) ) return factory.integer( (Byte)value ); if( isShort() && isAssignableToShort( value ) ) return factory.integer( (Short)value ); if( isIn... | IntegerTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( isByte() && isAssignableToByte( value ) ) return factory.integer( (Byte)value ); if( isShort() && isAssignableToShort( value ) ) return factory.integer( (Short)value ); if( isIn... | IntegerTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( isByte() && isAssignableToByte( value ) ) return factory.integer( (Byte)value ); if( isShort() && isAssignableToShort( value ) ) return factory.integer( (Short)value ); if( isIn... | IntegerTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( isByte() && isAssignableToByte( value ) ) return factory.integer( (Byte)value ); if( isShort() && isAssignableToShort( value ) ) return factory.integer( (Short)value ); if( isIn... |
@Test( expected = IllegalArgumentException.class ) public void toJavaFails() throws Exception { TypeMapper mapper = new IntegerTypeMapper( Long.class, INTEGER ); mapper.toJava( BooleanValue.TRUE ); fail( "Must fail" ); } | @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.INTEGER ) throw new IllegalArgumentException( "Unable to convert to integer value of kind: " + value.getKind() ); IntegerValue iv = value.toIntegerValue(); if( isByte() ) return (byte)iv.asInt(); if( isShort() ) return (short)... | IntegerTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.INTEGER ) throw new IllegalArgumentException( "Unable to convert to integer value of kind: " + value.getKind() ); IntegerValue iv = value.toIntegerValue(); if( isByte() ) return (byte)... | IntegerTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.INTEGER ) throw new IllegalArgumentException( "Unable to convert to integer value of kind: " + value.getKind() ); IntegerValue iv = value.toIntegerValue(); if( isByte() ) return (byte)... | IntegerTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.INTEGER ) throw new IllegalArgumentException( "Unable to convert to integer value of kind: " + value.getKind() ); IntegerValue iv = value.toIntegerValue(); if( isByte() ) return (byte)... | IntegerTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.INTEGER ) throw new IllegalArgumentException( "Unable to convert to integer value of kind: " + value.getKind() ); IntegerValue iv = value.toIntegerValue(); if( isByte() ) return (byte)... |
@Test( expected = IllegalArgumentException.class ) public void toAsn1Fails() throws Exception { TypeMapper mapper = new ByteArrayTypeMapper( byte[].class, OCTET_STRING ); mapper.toAsn1( FACTORY, 1L ); fail( "Must fail" ); } | @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !byte[].class.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); byte[] array = (byte[])value; return factory.byteArrayValue( array.length * 8, array ); } | ByteArrayTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !byte[].class.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); byte[] array = (byte[])value; return factory.by... | ByteArrayTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !byte[].class.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); byte[] array = (byte[])value; return factory.by... | ByteArrayTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !byte[].class.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); byte[] array = (byte[])value; return factory.by... | ByteArrayTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !byte[].class.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); byte[] array = (byte[])value; return factory.by... |
@Test( expected = AssertionError.class ) public void testDecode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( Enc... | @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.BIT_STRING; assert !context.getTag().isConstructed(); if( context.getLength() == 0 ) return context.getValueFactory().emptyByteArray(); byte unusedBits = context.read(); if(... | BitStringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.BIT_STRING; assert !context.getTag().isConstructed(); if( context.getLength() == 0 ) return context.getValueFactory().emptyByteAr... | BitStringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.BIT_STRING; assert !context.getTag().isConstructed(); if( context.getLength() == 0 ) return context.getValueFactory().emptyByteAr... | BitStringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.BIT_STRING; assert !context.getTag().isConstructed(); if( context.getLength() == 0 ) return context.getValueFactory().emptyByteAr... | BitStringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.BIT_STRING; assert !context.getTag().isConstructed(); if( context.getLength() == 0 ) return context.getValueFactory().emptyByteAr... |
@Test( expected = IllegalArgumentException.class ) public void toJavaFails() throws Exception { TypeMapper mapper = new ByteArrayTypeMapper( byte[].class, OCTET_STRING ); mapper.toJava( BooleanValue.TRUE ); fail( "Must fail" ); } | @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BYTE_ARRAY ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); return value.toByteArrayValue().asByteArray(); } | ByteArrayTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BYTE_ARRAY ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); return value.toByteArrayValue().asByteArray(); } } | ByteArrayTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BYTE_ARRAY ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); return value.toByteArrayValue().asByteArray(); } ByteArrayTypeMapper( Class<?... | ByteArrayTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BYTE_ARRAY ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); return value.toByteArrayValue().asByteArray(); } ByteArrayTypeMapper( Class<?... | ByteArrayTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BYTE_ARRAY ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); return value.toByteArrayValue().asByteArray(); } ByteArrayTypeMapper( Class<?... |
@Test( expected = IllegalArgumentException.class ) public void toAsn1Fails() throws Exception { TypeMapper mapper = new DateTypeMapper( Instant.class, G_TIME ); mapper.toAsn1( FACTORY, 1L ); fail( "Must fail" ); } | @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !javaType.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( isDate() ) return factory.timeValue( ( (Date)value ).toInstant() ); if( isInstant() ) retur... | DateTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !javaType.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( isDate() ) return factory.timeValue( ( (Date)value )... | DateTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !javaType.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( isDate() ) return factory.timeValue( ( (Date)value )... | DateTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !javaType.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( isDate() ) return factory.timeValue( ( (Date)value )... | DateTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !javaType.isAssignableFrom( value.getClass() ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( isDate() ) return factory.timeValue( ( (Date)value )... |
@Test( expected = IllegalArgumentException.class ) public void toJavaFails() throws Exception { TypeMapper mapper = new DateTypeMapper( Instant.class, G_TIME ); mapper.toJava( BooleanValue.TRUE ); fail( "Must fail" ); } | @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.TIME ) throw new IllegalArgumentException( "Unable to convert values of kind: " + value.getKind() ); Instant instant = value.toDateValue().asInstant(); if( isInstant() ) return instant; if( isDate() ) return Date.from( instant... | DateTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.TIME ) throw new IllegalArgumentException( "Unable to convert values of kind: " + value.getKind() ); Instant instant = value.toDateValue().asInstant(); if( isInstant() ) return instant; i... | DateTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.TIME ) throw new IllegalArgumentException( "Unable to convert values of kind: " + value.getKind() ); Instant instant = value.toDateValue().asInstant(); if( isInstant() ) return instant; i... | DateTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.TIME ) throw new IllegalArgumentException( "Unable to convert values of kind: " + value.getKind() ); Instant instant = value.toDateValue().asInstant(); if( isInstant() ) return instant; i... | DateTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.TIME ) throw new IllegalArgumentException( "Unable to convert values of kind: " + value.getKind() ); Instant instant = value.toDateValue().asInstant(); if( isInstant() ) return instant; i... |
@Test public void toAsn1() throws Exception { BooleanTypeMapper mapper = new BooleanTypeMapper( boolean.class, BOOLEAN ); assertEquals( "Not equals", BooleanValue.TRUE, mapper.toAsn1( FACTORY, true ) ); assertEquals( "Not equals", BooleanValue.FALSE, mapper.toAsn1( FACTORY, false ) ); } | @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !isBooleanClass( value ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( Boolean.TRUE.equals( value ) ) return BooleanValue.TRUE; if( Boolean.FALSE.equals( value ) ) return BooleanValue.... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !isBooleanClass( value ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( Boolean.TRUE.equals( value ) ) return BooleanValue.TRUE; if( Boolean.FA... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !isBooleanClass( value ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( Boolean.TRUE.equals( value ) ) return BooleanValue.TRUE; if( Boolean.FA... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !isBooleanClass( value ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( Boolean.TRUE.equals( value ) ) return BooleanValue.TRUE; if( Boolean.FA... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !isBooleanClass( value ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( Boolean.TRUE.equals( value ) ) return BooleanValue.TRUE; if( Boolean.FA... |
@Test( expected = IllegalArgumentException.class ) public void toAsn1Fails() throws Exception { BooleanTypeMapper mapper = new BooleanTypeMapper( boolean.class, BOOLEAN ); mapper.toAsn1( FACTORY, 1L ); fail( "Must fail" ); } | @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !isBooleanClass( value ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( Boolean.TRUE.equals( value ) ) return BooleanValue.TRUE; if( Boolean.FALSE.equals( value ) ) return BooleanValue.... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !isBooleanClass( value ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( Boolean.TRUE.equals( value ) ) return BooleanValue.TRUE; if( Boolean.FA... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !isBooleanClass( value ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( Boolean.TRUE.equals( value ) ) return BooleanValue.TRUE; if( Boolean.FA... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !isBooleanClass( value ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( Boolean.TRUE.equals( value ) ) return BooleanValue.TRUE; if( Boolean.FA... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Value toAsn1( @NotNull ValueFactory factory, @NotNull Object value ) { if( !isBooleanClass( value ) ) throw new IllegalArgumentException( "Unable to convert value: " + value ); if( Boolean.TRUE.equals( value ) ) return BooleanValue.TRUE; if( Boolean.FA... |
@Test public void toJava() throws Exception { BooleanTypeMapper mapper = new BooleanTypeMapper( boolean.class, BOOLEAN ); assertEquals( "Not equals", Boolean.TRUE, mapper.toJava( BooleanValue.TRUE ) ); assertEquals( "Not equals", Boolean.FALSE, mapper.toJava( BooleanValue.FALSE ) ); } | @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BOOLEAN ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); if( Objects.equals( value, BooleanValue.TRUE ) ) return Boolean.TRUE; if( Objects.equals( value, BooleanValue.FALSE ) ) retu... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BOOLEAN ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); if( Objects.equals( value, BooleanValue.TRUE ) ) return Boolean.TRUE; if( Objects.... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BOOLEAN ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); if( Objects.equals( value, BooleanValue.TRUE ) ) return Boolean.TRUE; if( Objects.... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BOOLEAN ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); if( Objects.equals( value, BooleanValue.TRUE ) ) return Boolean.TRUE; if( Objects.... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BOOLEAN ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); if( Objects.equals( value, BooleanValue.TRUE ) ) return Boolean.TRUE; if( Objects.... |
@Test( expected = IllegalArgumentException.class ) public void toJavaFails() throws Exception { BooleanTypeMapper mapper = new BooleanTypeMapper( boolean.class, BOOLEAN ); mapper.toJava( FACTORY.integer( 1 ) ); fail( "Must fail" ); } | @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BOOLEAN ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); if( Objects.equals( value, BooleanValue.TRUE ) ) return Boolean.TRUE; if( Objects.equals( value, BooleanValue.FALSE ) ) retu... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BOOLEAN ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); if( Objects.equals( value, BooleanValue.TRUE ) ) return Boolean.TRUE; if( Objects.... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BOOLEAN ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); if( Objects.equals( value, BooleanValue.TRUE ) ) return Boolean.TRUE; if( Objects.... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BOOLEAN ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); if( Objects.equals( value, BooleanValue.TRUE ) ) return Boolean.TRUE; if( Objects.... | BooleanTypeMapper implements TypeMapper { @NotNull @Override public Object toJava( @NotNull Value value ) { if( value.getKind() != Kind.BOOLEAN ) throw new IllegalArgumentException( "Unable to handle value of kind: " + value.getKind() ); if( Objects.equals( value, BooleanValue.TRUE ) ) return Boolean.TRUE; if( Objects.... |
@Test public void testWrite_Der() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.GENERALIZED_TIME.ref().resolve( scope ); Value value = new DateValueImpl( TimeUtils.parseGeneralizedTime( TIME_VALUE ) ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) )... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asInstant(); boolean optimize = context.getRules() != B... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... |
@Test public void testWrite_Ber() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.GENERALIZED_TIME.ref().resolve( scope ); Value value = new DateValueImpl( TimeUtils.parseGeneralizedTime( TIME_VALUE ) ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) )... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asInstant(); boolean optimize = context.getRules() != B... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... |
@Test( expected = AssertionError.class ) public void testEncode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new DateValueImpl( TimeUtils.parseGeneralizedTime( TIME_VALUE ) ); try( AbstractBerWriter writer = ... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asInstant(); boolean optimize = context.getRules() != B... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... |
@Test( expected = AssertionError.class ) public void testEncode_fail_value() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.GENERALIZED_TIME.ref().resolve( scope ); Value value = BooleanValue.TRUE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { ne... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asInstant(); boolean optimize = context.getRules() != B... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... | GeneralizedTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.GENERALIZED_TIME; assert context.getValue().getKind() == Kind.TIME; Instant instant = context.getValue().toDateValue().asIns... |
@Test public void testEncode_0() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.UTF8_STRING.ref().resolve( scope ); Value value = new StringValueImpl( "A" ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new StringBerEncoder().encode( new WriterC... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof StringType ) ) { assert type != null; type =... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... |
@Test( expected = AssertionError.class ) public void testEncode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new StringValueImpl( "Value" ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) {... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof StringType ) ) { assert type != null; type =... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... |
@Test( expected = AssertionError.class ) public void testDecode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( Enc... | @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getLength() > 0; List<Ref<Value>> list = new ArrayList<>(); int length = context.getLength(); while( length > 0 ) length = readObjectIDItem( context.getR... | ObjectIDBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getLength() > 0; List<Ref<Value>> list = new ArrayList<>(); int length = context.getLength(); while( length > ... | ObjectIDBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getLength() > 0; List<Ref<Value>> list = new ArrayList<>(); int length = context.getLength(); while( length > ... | ObjectIDBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getLength() > 0; List<Ref<Value>> list = new ArrayList<>(); int length = context.getLength(); while( length > ... | ObjectIDBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getLength() > 0; List<Ref<Value>> list = new ArrayList<>(); int length = context.getLength(); while( length > ... |
@Test( expected = AssertionError.class ) public void testEncode_fail_value() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.UTF8_STRING.ref().resolve( scope ); Value value = BooleanValue.TRUE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new Str... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof StringType ) ) { assert type != null; type =... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... | StringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; assert context.getValue().getKind() == Kind.C_STRING; Type type = context.getType(); while( !( type instanceof Str... |
@Test public void testWriteSequenceOf_Buffered() throws Exception { Scope scope = CoreModule.getInstance().createScope(); SequenceOfType type = new SequenceOfType(); type.setComponent( "a", UniversalType.INTEGER.ref() ); type.validate( scope ); ComponentType component = type.getComponentType(); Assert.assertNotNull( "N... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) writeCollection( ... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... |
@Test public void testWriteSequenceOf_NonBuffered() throws Exception { Scope scope = CoreModule.getInstance().createScope(); SequenceOfType type = new SequenceOfType(); type.setComponent( "a", UniversalType.INTEGER.ref() ); type.validate( scope ); ComponentType component = type.getComponentType(); Assert.assertNotNull(... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) writeCollection( ... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... |
@Test( expected = Asn1Exception.class ) public void testWriteSequenceOf_NonBuffered_Der() throws Exception { Scope scope = CoreModule.getInstance().createScope(); SequenceOfType type = new SequenceOfType(); type.setComponent( "a", UniversalType.INTEGER.ref() ); type.validate( scope ); ComponentType component = type.get... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) writeCollection( ... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... |
@Test public void testWriteSequenceOf_NoHeader() throws Exception { Scope scope = CoreModule.getInstance().createScope(); SequenceOfType type = new SequenceOfType(); type.setComponent( "a", UniversalType.INTEGER.ref() ); type.validate( scope ); ComponentType component = type.getComponentType(); Assert.assertNotNull( "N... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) writeCollection( ... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... |
@Test( expected = AssertionError.class ) public void testEncode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new ValueCollectionImpl( true ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) ... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) writeCollection( ... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... |
@Test( expected = AssertionError.class ) public void testEncode_fail_value() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = new SequenceOfType(); Value value = BooleanValue.TRUE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new SequenceOfBerEncoder().encode( ... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) writeCollection( ... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... | SequenceOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SEQUENCE_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if(... |
@Test public void testWrite_0101_Der() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.BIT_STRING.ref().resolve( scope ); Value value = CoreUtils.byteArrayFromBitString( VALUE_0101B ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { when( writer.get... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean hasNamedValues = !context.getType().getNamedVa... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... |
@Test public void testWrite_0101_Ber() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.BIT_STRING.ref().resolve( scope ); Value value = CoreUtils.byteArrayFromBitString( VALUE_0101B ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { when( writer.get... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean hasNamedValues = !context.getType().getNamedVa... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... |
@Test public void testWrite_01010000000000_Der_noNamed() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.BIT_STRING.ref().resolve( scope ); Value value = CoreUtils.byteArrayFromBitString( VALUE_01010000000000B ); try( AbstractBerWriter writer = mock( AbstractBerWriter.... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean hasNamedValues = !context.getType().getNamedVa... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... |
@Test( expected = AssertionError.class ) public void testDecode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( Enc... | @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getLength() == 1; byte content = context.read(); return content == BerUtils.BOOLEAN_FALSE ? BooleanValue.FALSE : BooleanValue.TRUE; } | BooleanBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getLength() == 1; byte content = context.read(); return content == BerUtils.BOOLEAN_FALSE ? BooleanValue.FALSE : BooleanVa... | BooleanBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getLength() == 1; byte content = context.read(); return content == BerUtils.BOOLEAN_FALSE ? BooleanValue.FALSE : BooleanVa... | BooleanBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getLength() == 1; byte content = context.read(); return content == BerUtils.BOOLEAN_FALSE ? BooleanValue.FALSE : BooleanVa... | BooleanBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getLength() == 1; byte content = context.read(); return content == BerUtils.BOOLEAN_FALSE ? BooleanValue.FALSE : BooleanVa... |
@Test public void testWrite_01010000000000_Der_hasNamed() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = new BitStringType( Arrays.asList( new NamedValueImpl( "a", new IntegerValueInt( 1 ) ), new NamedValueImpl( "b", new IntegerValueInt( 2 ) ), new NamedValueImpl( "c", new IntegerV... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean hasNamedValues = !context.getType().getNamedVa... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... |
@Test public void testWrite_0000_Der_hasNamed() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = new BitStringType( Arrays.asList( new NamedValueImpl( "a", new IntegerValueInt( 1 ) ), new NamedValueImpl( "b", new IntegerValueInt( 2 ) ), new NamedValueImpl( "c", new IntegerValueInt( 3... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean hasNamedValues = !context.getType().getNamedVa... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... |
@Test public void testWrite_0000_Ber() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.BIT_STRING.ref().resolve( scope ); Value value = CoreUtils.byteArrayFromBitString( VALUE_0000B ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { when( writer.get... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean hasNamedValues = !context.getType().getNamedVa... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... |
@Test public void testWrite_Empty_Ber() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.BIT_STRING.ref().resolve( scope ); Value value = CoreUtils.byteArrayFromBitString( "''B" ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { when( writer.getRules... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean hasNamedValues = !context.getType().getNamedVa... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... |
@Test public void testWrite_01010000000000_Ber() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.BIT_STRING.ref().resolve( scope ); Value value = CoreUtils.byteArrayFromBitString( VALUE_01010000000000B ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean hasNamedValues = !context.getType().getNamedVa... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... |
@Test( expected = AssertionError.class ) public void testEncode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = CoreUtils.byteArrayFromBitString( VALUE_0101B ); try( AbstractBerWriter writer = mock( AbstractBerW... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean hasNamedValues = !context.getType().getNamedVa... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... |
@Test( expected = AssertionError.class ) public void testEncode_fail_value() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.BIT_STRING.ref().resolve( scope ); Value value = BooleanValue.TRUE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new BitS... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean hasNamedValues = !context.getType().getNamedVa... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... | BitStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BIT_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; ByteArrayValue arrayValue = context.getValue().toByteArrayValue(); boolean ha... |
@Test public void testEncode_true() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.BOOLEAN.ref().resolve( scope ); Value value = BooleanValue.TRUE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new BooleanBerEncoder().encode( new WriterContext( w... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().asBoolean(); context.write( value ? BerUtils... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... |
@Test public void testEncode_false() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.BOOLEAN.ref().resolve( scope ); Value value = BooleanValue.FALSE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new BooleanBerEncoder().encode( new WriterContext(... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().asBoolean(); context.write( value ? BerUtils... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... |
@Test( expected = AssertionError.class ) public void testEncode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = BooleanValue.TRUE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new BooleanB... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().asBoolean(); context.write( value ? BerUtils... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... |
@Test( expected = AssertionError.class ) public void testDecode_fail_length() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.BOOLEAN.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( E... | @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getLength() == 1; byte content = context.read(); return content == BerUtils.BOOLEAN_FALSE ? BooleanValue.FALSE : BooleanValue.TRUE; } | BooleanBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getLength() == 1; byte content = context.read(); return content == BerUtils.BOOLEAN_FALSE ? BooleanValue.FALSE : BooleanVa... | BooleanBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getLength() == 1; byte content = context.read(); return content == BerUtils.BOOLEAN_FALSE ? BooleanValue.FALSE : BooleanVa... | BooleanBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getLength() == 1; byte content = context.read(); return content == BerUtils.BOOLEAN_FALSE ? BooleanValue.FALSE : BooleanVa... | BooleanBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getLength() == 1; byte content = context.read(); return content == BerUtils.BOOLEAN_FALSE ? BooleanValue.FALSE : BooleanVa... |
@Test( expected = AssertionError.class ) public void testEncode_fail_value() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.BOOLEAN.ref().resolve( scope ); Value value = NullValue.INSTANCE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new Boolea... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().asBoolean(); context.write( value ? BerUtils... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... | BooleanBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.BOOLEAN; assert context.getValue().getKind() == Kind.BOOLEAN; context.writeHeader( TAG, 1 ); boolean value = context.getValue().toBooleanValue().as... |
@Test public void testWriteSetOf_Buffered() throws Exception { Scope scope = CoreModule.getInstance().createScope(); SetOfType type = new SetOfType(); type.setComponent( "a", UniversalType.INTEGER.ref() ); type.validate( scope ); ComponentType component = type.getComponentType(); Assert.assertNotNull( "No component a",... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) SequenceOfBerEncoder.w... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... |
@Test public void testWriteSetOf_NonBuffered() throws Exception { Scope scope = CoreModule.getInstance().createScope(); SetOfType type = new SetOfType(); type.setComponent( "a", UniversalType.INTEGER.ref() ); type.validate( scope ); ComponentType component = type.getComponentType(); Assert.assertNotNull( "No component ... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) SequenceOfBerEncoder.w... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... |
@Test( expected = Asn1Exception.class ) public void testWriteSetOf_NonBuffered_Der() throws Exception { Scope scope = CoreModule.getInstance().createScope(); SetOfType type = new SetOfType(); type.setComponent( "a", UniversalType.INTEGER.ref() ); type.validate( scope ); ComponentType component = type.getComponentType()... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) SequenceOfBerEncoder.w... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... |
@Test public void testWriteSetOf_NoHeader() throws Exception { Scope scope = CoreModule.getInstance().createScope(); SetOfType type = new SetOfType(); type.setComponent( "a", UniversalType.INTEGER.ref() ); type.validate( scope ); ComponentType component = type.getComponentType(); Assert.assertNotNull( "No component a",... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) SequenceOfBerEncoder.w... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... |
@Test( expected = AssertionError.class ) public void testEncode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new ValueCollectionImpl( true ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) ... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) SequenceOfBerEncoder.w... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... |
@Test( expected = AssertionError.class ) public void testEncode_fail_value() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = new SetOfType(); Value value = BooleanValue.TRUE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new SetOfBerEncoder().encode( new Writer... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.isWriteHeader() ) SequenceOfBerEncoder.w... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... | SetOfBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.SET_OF; assert context.getValue().getKind() == Kind.COLLECTION || context.getValue().getKind() == Kind.NAMED_COLLECTION; if( !context.... |
@Test public void testEncode_Empty() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.OCTET_STRING.ref().resolve( scope ); Value value = CoreUtils.byteArrayFromHexString( "''H" ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new OctetStringBerEnco... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int length = bytes == null ? 0 : bytes.length; cont... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... |
@Test public void testEncode_AF() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.OCTET_STRING.ref().resolve( scope ); Value value = CoreUtils.byteArrayFromHexString( "'AF'H" ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new OctetStringBerEncod... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int length = bytes == null ? 0 : bytes.length; cont... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... |
@Test( expected = AssertionError.class ) public void testEncode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = CoreUtils.byteArrayFromHexString( "'AF'H" ); try( AbstractBerWriter writer = mock( AbstractBerWrite... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int length = bytes == null ? 0 : bytes.length; cont... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... |
@Test( expected = AssertionError.class ) public void testDecode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( Enc... | @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OCTET_STRING; assert !context.getTag().isConstructed(); if( context.getLength() == -1 ) return readByteArrayValueIndefinite( context.getReader(), 0 ); if( context.getLength(... | OctetStringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OCTET_STRING; assert !context.getTag().isConstructed(); if( context.getLength() == -1 ) return readByteArrayValueIndefinite( co... | OctetStringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OCTET_STRING; assert !context.getTag().isConstructed(); if( context.getLength() == -1 ) return readByteArrayValueIndefinite( co... | OctetStringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OCTET_STRING; assert !context.getTag().isConstructed(); if( context.getLength() == -1 ) return readByteArrayValueIndefinite( co... | OctetStringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OCTET_STRING; assert !context.getTag().isConstructed(); if( context.getLength() == -1 ) return readByteArrayValueIndefinite( co... |
@Test( expected = AssertionError.class ) public void testEncode_fail_value() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.OCTET_STRING.ref().resolve( scope ); Value value = BooleanValue.TRUE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new Oc... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int length = bytes == null ? 0 : bytes.length; cont... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... | OctetStringBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.OCTET_STRING; assert context.getValue().getKind() == Kind.BYTE_ARRAY; byte[] bytes = context.getValue().toByteArrayValue().asByteArray(); int l... |
@Test( expected = AssertionError.class ) public void testWrite_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new IntegerValueInt( 0 ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new Re... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ) writeRealValue( context ); else write... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... |
@Test( expected = AssertionError.class ) public void testWrite_fail_value() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new StringValueImpl( "Value" ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) {... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ) writeRealValue( context ); else write... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... |
@Test public void testWriteInteger_0() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); Value value = new IntegerValueInt( 0 ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new RealBerEncoder().encode( new WriterContex... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ) writeRealValue( context ); else write... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... |
@Test public void testWriteReal_neg_0() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); Value value = new RealValueFloat( -0.0f ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new RealBerEncoder().encode( new WriterCo... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ) writeRealValue( context ); else write... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... |
@Test public void testWriteReal_neg_inf() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); Value value = new RealValueFloat( Float.NEGATIVE_INFINITY ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new RealBerEncoder().... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ) writeRealValue( context ); else write... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... |
@Test public void testWriteReal_pos_inf() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); Value value = new RealValueFloat( Float.POSITIVE_INFINITY ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new RealBerEncoder().... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ) writeRealValue( context ); else write... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... |
@Test public void testWriteReal_nan() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); Value value = new RealValueFloat( Float.NaN ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new RealBerEncoder().encode( new Writer... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ) writeRealValue( context ); else write... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... |
@Test public void testWriteReal_big() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); BigDecimal decimal = new BigDecimal( BigInteger.valueOf( 1023234L ).pow( 5223 ) ); byte[] bytes = NRxUtils.toCanonicalNR3( decimal.toString() ).getBytes( ... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ) writeRealValue( context ); else write... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... |
@Test public void testWriteInteger_big() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); BigInteger bigInteger = BigInteger.valueOf( 1023234L ).pow( 5223 ); byte[] bytes = NRxUtils.toCanonicalNR3( new BigDecimal( bigInteger ).toString() ).g... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ) writeRealValue( context ); else write... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... |
@Test( expected = AssertionError.class ) public void testDecode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( Enc... | @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert !context.getTag().isConstructed(); if( context.getLength() == 0 ) return context.getValueFactory().rZero(); byte first = context.read(); if( first == 0 ) return context.getVal... | RealBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert !context.getTag().isConstructed(); if( context.getLength() == 0 ) return context.getValueFactory().rZero(); byte first = context.read();... | RealBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert !context.getTag().isConstructed(); if( context.getLength() == 0 ) return context.getValueFactory().rZero(); byte first = context.read();... | RealBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert !context.getTag().isConstructed(); if( context.getLength() == 0 ) return context.getValueFactory().rZero(); byte first = context.read();... | RealBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert !context.getTag().isConstructed(); if( context.getLength() == 0 ) return context.getValueFactory().rZero(); byte first = context.read();... |
@Test public void testWriteReal_1_0() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); Value value = new RealValueFloat( 1.0f ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new RealBerEncoder().encode( new WriterConte... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ) writeRealValue( context ); else write... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... |
@Test public void testWriteReal_0_15625d() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); Value value = new RealValueDouble( 0.15625d ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new RealBerEncoder().encode( new W... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ) writeRealValue( context ); else write... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... | RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ... |
@Test public void testWriteLong_0() throws Exception { try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { IntegerBerEncoder.writeLong( writer, 0L, null, false ); verify( writer ).write( 0 ); verifyNoMoreInteractions( writer ); } } | static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( writeHeader ) os.writeHeader( tag, size ); ... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... |
@Test public void testWriteLong_minus_1() throws Exception { try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { IntegerBerEncoder.writeLong( writer, -1L, null, false ); verify( writer ).write( -1 ); verifyNoMoreInteractions( writer ); } } | static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( writeHeader ) os.writeHeader( tag, size ); ... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... |
@Test public void testWriteLong_256() throws Exception { try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { IntegerBerEncoder.writeLong( writer, 256L, null, false ); verify( writer ).write( 1 ); verify( writer ).write( 0 ); verifyNoMoreInteractions( writer ); } } | static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( writeHeader ) os.writeHeader( tag, size ); ... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... |
@Test public void testWriteLong_300000() throws Exception { try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { IntegerBerEncoder.writeLong( writer, 300000L, null, false ); verify( writer ).write( (byte)0x04 ); verify( writer ).write( (byte)0x93 ); verify( writer ).write( (byte)0xE0 ); verifyNoMoreInter... | static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( writeHeader ) os.writeHeader( tag, size ); ... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... |
@Test( expected = IOException.class ) public void testWriteLong_fail() throws Exception { try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { IntegerBerEncoder.writeLong( writer, 0L, null, true ); fail( "This method must fail." ); } } | static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( writeHeader ) os.writeHeader( tag, size ); ... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... | IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w... |
@Test public void testToByteArray_0() throws Exception { byte[] array = IntegerBerEncoder.toByteArray( 0L ); Assert.assertEquals( "Illegal array size", 1, array.length ); Assert.assertArrayEquals( "Arrays are different", new byte[]{0}, array ); } | static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } @Override void encode( @NotNull Writ... | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } @Override void encode( @NotNull Writ... |
@Test public void testToByteArray_minus_1() throws Exception { byte[] array = IntegerBerEncoder.toByteArray( -1L ); Assert.assertEquals( "Illegal array size", 1, array.length ); Assert.assertArrayEquals( "Arrays are different", new byte[]{-1}, array ); } | static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } @Override void encode( @NotNull Writ... | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } @Override void encode( @NotNull Writ... |
@Test public void testToByteArray_256() throws Exception { byte[] array = IntegerBerEncoder.toByteArray( 256L ); Assert.assertEquals( "Illegal array size", 2, array.length ); Assert.assertArrayEquals( "Arrays are different", new byte[]{1, 0}, array ); } | static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } @Override void encode( @NotNull Writ... | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } @Override void encode( @NotNull Writ... |
@Test( expected = AssertionError.class ) public void testDecode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( Encodi... | @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getLength() >= 0; return readInteger( context.getReader(), context.getLength() ); } | IntegerBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getLength() >= 0; return readInteger( context.getReader(), context.getLength() ); } } | IntegerBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getLength() >= 0; return readInteger( context.getReader(), context.getLength() ); } } | IntegerBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getLength() >= 0; return readInteger( context.getReader(), context.getLength() ); } @Override Value decode( @NotNull Read... | IntegerBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getLength() >= 0; return readInteger( context.getReader(), context.getLength() ); } @Override Value decode( @NotNull Read... |
@Test public void testToByteArray_300000() throws Exception { byte[] array = IntegerBerEncoder.toByteArray( 300000L ); Assert.assertEquals( "Illegal array size", 3, array.length ); Assert.assertArrayEquals( "Arrays are different", new byte[]{0x04, (byte)0x93, (byte)0xE0}, array ); } | static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } } | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } @Override void encode( @NotNull Writ... | IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } @Override void encode( @NotNull Writ... |
@Test public void testEncode_0() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new IntegerValueInt( 0 ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new IntegerBerEncoder().encode( new WriterContex... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, context.isWriteHeader() ); } | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... |
@Test public void testEncode_minus_1() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new IntegerValueInt( -1 ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new IntegerBerEncoder().encode( new Write... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, context.isWriteHeader() ); } | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... |
@Test public void testEncode_256() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new IntegerValueInt( 256 ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new IntegerBerEncoder().encode( new WriterCo... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, context.isWriteHeader() ); } | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... |
@Test( expected = AssertionError.class ) public void testEncode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); Value value = new IntegerValueInt( 256 ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new In... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, context.isWriteHeader() ); } | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... |
@Test( expected = AssertionError.class ) public void testEncode_fail_value() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new RealValueFloat( 0.0f ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { ne... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, context.isWriteHeader() ); } | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... | IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co... |
@Test public void testEncode_NoHeader() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.OBJECT_IDENTIFIER.ref().resolve( scope ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new ObjectIDBerEncoder().encode( new WriterContext( writer, scope, type... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), context.getValue().toObjectIdentifierValue() ); e... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... |
@Test public void testEncode_Buffered() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.OBJECT_IDENTIFIER.ref().resolve( scope ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { when( writer.isBufferingAvailable() ).thenReturn( true ); new ObjectIDB... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), context.getValue().toObjectIdentifierValue() ); e... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... |
@Test( expected = AssertionError.class ) public void testEncode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new ObjectIDBerEncoder().encode( new WriterCo... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), context.getValue().toObjectIdentifierValue() ); e... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... |
@Test( expected = AssertionError.class ) public void testEncode_fail_value() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.OBJECT_IDENTIFIER.ref().resolve( scope ); Value value = BooleanValue.TRUE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { n... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), context.getValue().toObjectIdentifierValue() ); e... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... | ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex... |
@Test public void testDecode() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.UTF8_STRING.ref().resolve( scope ); Value value = new StringValueImpl( "Example" ); byte[] result = InputUtils.writeValue( scope, type, value ); int totalWritten = result.length - 2; byte[] ... | @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; Type type = context.getType(); while( !( type instanceof StringType ) ) { assert type != null; type = type.getSibling(); } byte[] content = BerDecoderUtil... | StringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; Type type = context.getType(); while( !( type instanceof StringType ) ) { assert type != null; type = type.getSib... | StringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; Type type = context.getType(); while( !( type instanceof StringType ) ) { assert type != null; type = type.getSib... | StringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; Type type = context.getType(); while( !( type instanceof StringType ) ) { assert type != null; type = type.getSib... | StringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; Type type = context.getType(); while( !( type instanceof StringType ) ) { assert type != null; type = type.getSib... |
@Test public void testEncode_value_no_header() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.NULL.ref().resolve( scope ); Value value = NullValue.INSTANCE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new NullBerEncoder().encode( new WriterCont... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } @Override void encode( @NotNull WriterContext context ); } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } @Override void encode( @NotNull WriterContext context ); } |
@Test public void testEncode_value_with_header() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.NULL.ref().resolve( scope ); Value value = NullValue.INSTANCE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new NullBerEncoder().encode( new WriterCo... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } @Override void encode( @NotNull WriterContext context ); } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } @Override void encode( @NotNull WriterContext context ); } |
@Test( expected = AssertionError.class ) public void testEncode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = NullValue.INSTANCE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new NullBer... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } @Override void encode( @NotNull WriterContext context ); } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } @Override void encode( @NotNull WriterContext context ); } |
@Test( expected = AssertionError.class ) public void testEncode_fail_value() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.NULL.ref().resolve( scope ); Value value = BooleanValue.TRUE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new NullBerEnc... | @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } @Override void encode( @NotNull WriterContext context ); } | NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } @Override void encode( @NotNull WriterContext context ); } |
@Test public void testWrite_Der() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.UTC_TIME.ref().resolve( scope ); Value value = new DateValueImpl( TimeUtils.parseUTCTime( TIME_VALUE ) ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { when( writer.... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue().asInstant(), TimeUtils.UTC_TIME_FORMAT,... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... |
@Test public void testWrite_Ber() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.UTC_TIME.ref().resolve( scope ); Value value = new DateValueImpl( TimeUtils.parseUTCTime( TIME_VALUE ) ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { when( writer.... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue().asInstant(), TimeUtils.UTC_TIME_FORMAT,... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... |
@Test( expected = AssertionError.class ) public void testEncode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new DateValueImpl( TimeUtils.parseUTCTime( TIME_VALUE ) ); try( AbstractBerWriter writer = mock( Ab... | @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue().asInstant(), TimeUtils.UTC_TIME_FORMAT,... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... | UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.