Search in sources :

Example 41 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class ContainerImplTest method testRemoveMissingProfile.

// We should be able to remove a profile that doesn't exist from a container.
// A missing profile may be added to a container during startup (not possible to validate) or after an upgrade / rollback operation.
@Test
@Ignore("[FABRIC-1110] Mocked test makes invalid assumption on the implementation")
public void testRemoveMissingProfile() throws Exception {
    String v = "1.0";
    String profile1Id = "feature-camel";
    String profile2Id = "feature-cxf";
    String missing = "missing";
    // new VersionImpl(v, fabricService);
    Version version = null;
    List<String> profiles = Arrays.asList(profile1Id, profile2Id, missing);
    List<String> profilesToSet = Arrays.asList(profile1Id, profile2Id);
    expect(profileService.getRequiredVersion(eq(v))).andReturn(version).anyTimes();
    expect(dataStore.getContainerVersion(eq(CONTAINER_ID))).andReturn(v).anyTimes();
    expect(dataStore.getContainerProfiles(eq(CONTAINER_ID))).andReturn(profiles).anyTimes();
    expect(profileRegistry.hasProfile(v, profile1Id)).andReturn(true).anyTimes();
    expect(profileRegistry.hasProfile(v, profile2Id)).andReturn(true).anyTimes();
    expect(profileRegistry.hasProfile(v, missing)).andReturn(false).anyTimes();
    // expect(profileRegistry.getProfileAttributes(eq(v), EasyMock.<String>anyObject())).andReturn(Maps.<String, String>newHashMap()).anyTimes();
    dataStore.setContainerProfiles(eq(CONTAINER_ID), eq(profilesToSet));
    expectLastCall().once();
    replay(fabricService);
    replay(dataStore);
    container.removeProfiles(missing);
    verify(fabricService);
    verify(dataStore);
}
Also used : Version(io.fabric8.api.Version) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 42 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class ContainerImplTest method testGetMultipleProfiles.

@Test
@Ignore("[FABRIC-1110] Mocked test makes invalid assumption on the implementation")
public void testGetMultipleProfiles() throws Exception {
    String v = "1.0";
    String profile1Id = "feature-camel";
    String profile2Id = "feature-cxf";
    // new VersionImpl(v, fabricService);
    Version version = null;
    List<String> profiles = Arrays.asList(profile1Id, profile2Id);
    expect(profileService.getRequiredVersion(eq(v))).andReturn(version).anyTimes();
    expect(dataStore.getContainerVersion(eq(CONTAINER_ID))).andReturn(v).anyTimes();
    expect(dataStore.getContainerProfiles(eq(CONTAINER_ID))).andReturn(profiles).anyTimes();
    expect(profileRegistry.hasProfile(v, profile1Id)).andReturn(true).anyTimes();
    expect(profileRegistry.hasProfile(v, profile2Id)).andReturn(true).anyTimes();
    replay(fabricService);
    replay(dataStore);
    Profile[] p = container.getProfiles();
    assertNotNull(p);
    assertEquals(2, p.length);
    assertEquals(profile1Id, p[0].getId());
    assertEquals(profile2Id, p[1].getId());
    verify(fabricService);
    verify(dataStore);
}
Also used : Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 43 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class PatchServiceImplTest method testCheckRequirementsSatisfied.

@Test
public void testCheckRequirementsSatisfied() throws IOException {
    PatchServiceImpl.PatchDescriptor descriptor = getPatchDescriptor("test3.patch");
    Version version = buildVersion("1.1").withProfiles("karaf", "default", "patch-prereq3", "patch-somethingelse").done();
    // this should not throw a RuntimeException
    PatchServiceImpl.checkRequirements(version, descriptor);
}
Also used : Version(io.fabric8.api.Version) Test(org.junit.Test)

Example 44 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class PatchServiceImplTest method testCheckRequirementsMultiplePatches.

@Test
public void testCheckRequirementsMultiplePatches() throws IOException {
    Collection<PatchServiceImpl.PatchDescriptor> patches = new LinkedList<PatchServiceImpl.PatchDescriptor>();
    patches.add(getPatchDescriptor("test3.patch"));
    patches.add(getPatchDescriptor("test4.patch"));
    Version version = buildVersion("1.1").withProfiles("karaf", "default", "patch-prereq4a", "patch-prereq3").done();
    try {
        PatchServiceImpl.checkRequirements(version, patches);
        fail("Patch should not have passed requirements check - required patch is missing");
    } catch (PatchException e) {
        assertTrue(e.getMessage().toLowerCase().contains("required patch 'prereq4b' is missing"));
    }
}
Also used : Version(io.fabric8.api.Version) PatchException(io.fabric8.api.PatchException) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 45 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class PatchServiceImplTest method testGetPatchProfile.

@Test
public void testGetPatchProfile() throws IOException {
    PatchServiceImpl.PatchDescriptor test1 = getPatchDescriptor("test1.patch");
    PatchServiceImpl.PatchDescriptor test3 = getPatchDescriptor("test3.patch");
    Version version = buildVersion("1.1").withProfiles("karaf", "default", "patch-test3").done();
    Profile profile = PatchServiceImpl.getPatchProfile(version, test3);
    assertNotNull("test3 patch profile should be found", profile);
    assertEquals("patch-test3", profile.getId());
    assertNull("test1 patch profile should not be found", PatchServiceImpl.getPatchProfile(version, test1));
}
Also used : Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile) Test(org.junit.Test)

Aggregations

Version (io.fabric8.api.Version)74 Profile (io.fabric8.api.Profile)70 File (java.io.File)52 Test (org.junit.Test)46 IOException (java.io.IOException)41 ArrayList (java.util.ArrayList)36 Container (io.fabric8.api.Container)35 HashMap (java.util.HashMap)34 ProfileService (io.fabric8.api.ProfileService)27 Map (java.util.Map)25 Git (org.eclipse.jgit.api.Git)22 FabricService (io.fabric8.api.FabricService)21 Version (org.osgi.framework.Version)21 ProfileBuilder (io.fabric8.api.ProfileBuilder)18 GitVersion (io.fabric8.api.commands.GitVersion)18 PatchException (io.fabric8.patch.management.PatchException)15 HashSet (java.util.HashSet)15 TreeMap (java.util.TreeMap)14 LinkedList (java.util.LinkedList)13 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)12