summaryrefslogtreecommitdiffstats
path: root/configserver/src/test/java/com/yahoo/vespa/config/server/application/PermanentApplicationPackageTest.java
blob: a710384701fc663433886617dbe53373ecb2371e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.application;

import com.yahoo.cloud.config.ConfigserverConfig;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

import java.io.File;
import java.io.IOException;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
 * @author lulf
 * @since 5.15
 */
public class PermanentApplicationPackageTest {
    @Test
    public void testNonexistingApplication() {
        PermanentApplicationPackage permanentApplicationPackage = new PermanentApplicationPackage(new ConfigserverConfig(new ConfigserverConfig.Builder().applicationDirectory("_no_such_dir")));
        assertFalse(permanentApplicationPackage.applicationPackage().isPresent());
    }

    @Rule
    public TemporaryFolder folder = new TemporaryFolder();

    @Test
    public void testExistingApplication() throws IOException {
        File tmpDir = folder.newFolder();
        PermanentApplicationPackage permanentApplicationPackage = new PermanentApplicationPackage(new ConfigserverConfig(new ConfigserverConfig.Builder().applicationDirectory(tmpDir.getAbsolutePath())));
        assertTrue(permanentApplicationPackage.applicationPackage().isPresent());
    }
}