1 /* 2 * Copyright (C) 2016 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.compatibility.common.tradefed.presubmit; 17 18 import com.android.tradefed.config.ConfigurationException; 19 import com.android.tradefed.config.ConfigurationFactory; 20 import com.android.tradefed.config.IConfigurationFactory; 21 import com.android.tradefed.log.LogUtil.CLog; 22 23 import junit.framework.TestCase; 24 25 /** 26 * Tests that validate the CTS presubmit setup to ensure no CL will break the presubmit setup 27 * itself. 28 */ 29 public class PresubmitSetupValidation extends TestCase { 30 private static final String PRESUBMIT_CTS_UNIT_TESTS = "cts-unit-tests"; 31 32 /** 33 * Test that the base cts unit tests configuration is still working, and has a reporter 34 * template placeholder. 35 */ testCtsPresubmit_unit_tests()36 public void testCtsPresubmit_unit_tests() { 37 IConfigurationFactory factory = ConfigurationFactory.getInstance(); 38 String[] presubmitCommand = {PRESUBMIT_CTS_UNIT_TESTS, "--template:map", "reporters=empty"}; 39 try { 40 factory.createConfigurationFromArgs(presubmitCommand); 41 } catch (ConfigurationException e) { 42 CLog.e(e); 43 fail(String.format("ConfigException '%s': One of your change is breaking the presubmit " 44 + "CTS unit tests configuration.", e.getMessage())); 45 } 46 } 47 48 /** 49 * Test to ensure that Zip dependency on the Apache Commons Compress coming from TradeFed is 50 * properly setup. This dependency is required for some utilities of TradeFed to work. 51 */ testDependencyCommonsCompress()52 public void testDependencyCommonsCompress() throws Exception { 53 ClassLoader loader = ClassLoader.getSystemClassLoader(); 54 // This will throw an exception if dependency isn't met. 55 loader.loadClass("org.apache.commons.compress.archivers.zip.ZipFile"); 56 } 57 } 58