|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.elasticsearch.packaging.test; |
| 21 | + |
| 22 | +import org.junit.Before; |
| 23 | +import org.junit.BeforeClass; |
| 24 | +import org.junit.FixMethodOrder; |
| 25 | +import org.junit.Test; |
| 26 | +import org.junit.runners.MethodSorters; |
| 27 | + |
| 28 | +import org.elasticsearch.packaging.util.Distribution; |
| 29 | +import org.elasticsearch.packaging.util.Installation; |
| 30 | + |
| 31 | +import static org.elasticsearch.packaging.util.Cleanup.cleanEverything; |
| 32 | +import static org.elasticsearch.packaging.util.Archives.installArchive; |
| 33 | +import static org.elasticsearch.packaging.util.Archives.verifyArchiveInstallation; |
| 34 | +import static org.hamcrest.CoreMatchers.is; |
| 35 | +import static org.junit.Assume.assumeThat; |
| 36 | + |
| 37 | +/** |
| 38 | + * Tests that apply to the archive distributions (tar, zip). To add a case for a distribution, subclass and |
| 39 | + * override {@link ArchiveTestCase#distribution()}. These tests should be the same across all archive distributions |
| 40 | + */ |
| 41 | +@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
| 42 | +public abstract class ArchiveTestCase { |
| 43 | + |
| 44 | + private static Installation installation; |
| 45 | + |
| 46 | + /** The {@link Distribution} that should be tested in this case */ |
| 47 | + protected abstract Distribution distribution(); |
| 48 | + |
| 49 | + @BeforeClass |
| 50 | + public static void cleanup() { |
| 51 | + installation = null; |
| 52 | + cleanEverything(); |
| 53 | + } |
| 54 | + |
| 55 | + @Before |
| 56 | + public void onlyCompatibleDistributions() { |
| 57 | + assumeThat(distribution().packaging.compatible, is(true)); |
| 58 | + } |
| 59 | + |
| 60 | + @Test |
| 61 | + public void test10Install() { |
| 62 | + installation = installArchive(distribution()); |
| 63 | + verifyArchiveInstallation(installation, distribution()); |
| 64 | + } |
| 65 | +} |
0 commit comments