1 /******************************************************************************* 2 * Copyright (c) 2013 Ericsson AB and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * Ericsson AB - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.equinox.p2.tests.touchpoint.eclipse; 15 16 import java.io.File; 17 import org.eclipse.equinox.internal.p2.touchpoint.eclipse.AgentFromInstall; 18 import org.eclipse.equinox.p2.core.IProvisioningAgent; 19 import org.eclipse.equinox.p2.engine.IProfile; 20 import org.eclipse.equinox.p2.engine.IProfileRegistry; 21 import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; 22 23 public class AgentFromInstallTests extends AbstractProvisioningTest { 24 testNormalEclipseFromInstallFolder()25 public void testNormalEclipseFromInstallFolder() { 26 File installFolder = getTestData("normalEclipse", "testData/configAreaToAgent/normalEclipse"); 27 IProvisioningAgent agent = AgentFromInstall.createAgentFrom(getAgentProvider(), installFolder, null, null); 28 assertNotNull(agent); 29 IProfile profile = agent.getService(IProfileRegistry.class).getProfile(IProfileRegistry.SELF); 30 assertNotNull(profile); 31 assertEquals("SDKProfile", profile.getProfileId()); 32 } 33 testNormalEclipseFromConfiguration()34 public void testNormalEclipseFromConfiguration() { 35 File configurationFolder = getTestData("normalEclipse", "testData/configAreaToAgent/normalEclipse/configuration"); 36 IProvisioningAgent agent = AgentFromInstall.createAgentFrom(getAgentProvider(), null, configurationFolder, null); 37 assertNotNull(agent); 38 IProfile profile = agent.getService(IProfileRegistry.class).getProfile(IProfileRegistry.SELF); 39 assertNotNull(profile); 40 assertEquals("SDKProfile", profile.getProfileId()); 41 } 42 testSharedInstallWithoutBase()43 public void testSharedInstallWithoutBase() { 44 File configurationFolder = getTestData("sharedWithoutBaseAvailable", "testData/configAreaToAgent/sharedWithoutBaseAvailable"); 45 IProvisioningAgent agent = AgentFromInstall.createAgentFrom(getAgentProvider(), null, configurationFolder, null); 46 assertNotNull(agent); 47 IProfile profile = agent.getService(IProfileRegistry.class).getProfile(IProfileRegistry.SELF); 48 assertNotNull(profile); 49 assertEquals("SDKProfile", profile.getProfileId()); 50 } 51 testMissingInstallFolder()52 public void testMissingInstallFolder() { 53 IProvisioningAgent agent = AgentFromInstall.createAgentFrom(getAgentProvider(), new File("someRandomFile_that_does_not_exists"), null, null); 54 assertNull(agent); 55 } 56 testTooManyProfiles()57 public void testTooManyProfiles() { 58 File configurationFolder = getTestData("sharedWithoutBaseAvailable", "testData/configAreaToAgent/tooManyProfiles"); 59 IProvisioningAgent agent = AgentFromInstall.createAgentFrom(getAgentProvider(), null, configurationFolder, null); 60 assertNull(agent); 61 } 62 testTooManyProfilesWithProfileId()63 public void testTooManyProfilesWithProfileId() { 64 File configurationFolder = getTestData("sharedWithoutBaseAvailable", "testData/configAreaToAgent/tooManyProfiles"); 65 IProvisioningAgent agent = AgentFromInstall.createAgentFrom(getAgentProvider(), null, configurationFolder, "OtherProfile"); 66 assertNotNull(agent); 67 } 68 } 69