Search in sources :

Example 1 with MarketplaceInfo

use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo in project epp.mpc by eclipse.

the class MarketplaceInfoSerializationTest method loadMarketplaceInfo.

private MarketplaceInfo loadMarketplaceInfo() {
    MarketplaceInfo cleanInfo = new TestMarketplaceInfo();
    assertTrue(cleanInfo.getIuToNodeKey().isEmpty());
    assertTrue(cleanInfo.getNodeKeyToIU().isEmpty());
    MarketplaceInfo loaded = cleanInfo.load();
    return loaded;
}
Also used : MarketplaceInfo(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo)

Example 2 with MarketplaceInfo

use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo in project epp.mpc by eclipse.

the class MarketplaceInfoSerializationTest method loadGarbage.

@Test
public void loadGarbage() throws Exception {
    createEmptyRegistryFile(getUserHomeRegistryFile());
    FileOutputStream os = new FileOutputStream(getUserHomeRegistryFile());
    os.write(new byte[] { (byte) 0x31, (byte) 0xcc, (byte) 0x2a, (byte) 0x99, (byte) 0x84, (byte) 0xc2, (byte) 0x5a, (byte) 0xe2, (byte) 0xd6, (byte) 0xc8, (byte) 0xbb, (byte) 0x46, (byte) 0x67, (byte) 0xbb, (byte) 0x5d, (byte) 0x63, (byte) 0x2f, (byte) 0x16, (byte) 0x68, (byte) 0xf1, (byte) 0x09, (byte) 0xf4, (byte) 0x35, (byte) 0x92 });
    os.close();
    MarketplaceInfo loaded = loadMarketplaceInfo();
    assertNull(loaded);
    assertFalse(MessageFormat.format("Corrupted registry file ''{0}'' was not deleted", getUserHomeRegistryFile().getAbsolutePath()), getUserHomeRegistryFile().exists());
}
Also used : FileOutputStream(java.io.FileOutputStream) MarketplaceInfo(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo) Test(org.junit.Test)

Example 3 with MarketplaceInfo

use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo in project epp.mpc by eclipse.

the class MarketplaceInfoSerializationTest method loadNonExisting.

@Test
public void loadNonExisting() {
    MarketplaceInfo loaded = loadMarketplaceInfo();
    assertNull(loaded);
}
Also used : MarketplaceInfo(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo) Test(org.junit.Test)

Example 4 with MarketplaceInfo

use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo in project epp.mpc by eclipse.

the class MarketplaceInfoSerializationTest method saveAndLoad.

@Test
public void saveAndLoad() throws Exception {
    MarketplaceNodeCatalogItem item = MarketplaceInfoTest.createTestItem();
    catalogRegistry.map(item.getMarketplaceUrl(), item.getData());
    new MarketplaceInfo(catalogRegistry).save(getUserHomeRegistryFile());
    File registryFile = getUserHomeRegistryFile();
    assertTrue(MessageFormat.format("Registry file ''{0}'' does not exist", registryFile.getAbsolutePath()), registryFile.exists());
    assertTrue(MessageFormat.format("Registry file ''{0}'' is empty", registryFile.getAbsolutePath()), registryFile.length() > 0);
    MarketplaceInfo loaded = loadMarketplaceInfo();
    assertNotNull(loaded);
    assertFalse(loaded.getIuToNodeKey().isEmpty());
    assertFalse(loaded.getNodeKeyToIU().isEmpty());
    assertEquals(catalogRegistry.getIuToNodeKey(), loaded.getIuToNodeKey());
    assertEquals(catalogRegistry.getNodeKeyToIU(), loaded.getNodeKeyToIU());
}
Also used : MarketplaceInfo(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) File(java.io.File) Test(org.junit.Test)

Example 5 with MarketplaceInfo

use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo in project epp.mpc by eclipse.

the class MarketplaceInfoSerializationTest method loadIncomplete.

@Test
public void loadIncomplete() throws Exception {
    File registryFile = getUserHomeRegistryFile();
    copyRegistryFile(registryFile, 20);
    MarketplaceInfo loaded = loadMarketplaceInfo();
    assertNull(loaded);
}
Also used : MarketplaceInfo(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo) File(java.io.File) Test(org.junit.Test)

Aggregations

MarketplaceInfo (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo)8 Test (org.junit.Test)6 File (java.io.File)3 MarketplaceNodeCatalogItem (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)2 FileOutputStream (java.io.FileOutputStream)1 Before (org.junit.Before)1