1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18/** 19* @author Stepan M. Mishura 20*/ 21 22package org.apache.harmony.security.tests.asn1.der; 23 24import java.io.IOException; 25import java.util.Arrays; 26 27import org.apache.harmony.security.asn1.ASN1Any; 28import org.apache.harmony.security.asn1.DerInputStream; 29import org.apache.harmony.security.asn1.DerOutputStream; 30 31import junit.framework.TestCase; 32 33 34/** 35 * ASN.1 DER test for ANY type 36 * 37 * @see http://asn1.elibel.tm.fr/en/standards/index.htm 38 */ 39 40public class AnyTest extends TestCase { 41 42 private static byte[] encoded = new byte[] { 0x01, 0x03, 0x11, 0x13, 0x15 }; 43 44 public void testDecode() throws IOException { 45 DerInputStream in = new DerInputStream(encoded); 46 assertTrue(Arrays.equals(encoded, (byte[]) ASN1Any.getInstance() 47 .decode(in))); 48 } 49 50 public void testEncode() throws IOException { 51 DerOutputStream out = new DerOutputStream(ASN1Any.getInstance(), 52 encoded); 53 assertTrue("False", Arrays.equals(encoded, out.encoded)); 54 } 55} 56