1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.cts.tradefed.testtype; 17 18 import java.io.ByteArrayInputStream; 19 import java.io.File; 20 import java.io.InputStream; 21 22 import junit.framework.TestCase; 23 24 /** 25 * Unit tests for {@link TestPackageDef}. 26 */ 27 public class TestPackageDefTest extends TestCase { 28 29 /** 30 * Regression test for {@link TestPackageDef#generateDigest(File, String)} that ensures expected 31 * digest is generated for fixed data. 32 */ testGenerateDigest()33 public void testGenerateDigest() { 34 TestPackageDef def = new TestPackageDef() { 35 @Override 36 InputStream getFileStream(File dir, String fileName) { 37 return new ByteArrayInputStream("test data for digest".getBytes()); 38 } 39 }; 40 String digest = def.generateDigest(new File("unused"), "alsounused"); 41 assertNotNull(digest); 42 assertEquals("58c222b5f5f81b4b58891ec59924b9b2f530452e", digest); 43 44 } 45 46 } 47