Blame | Last modification | View Log | RSS feed
package com.erggroup.buildtool.utf;import static org.junit.Assert.*;import java.util.Iterator;import org.junit.Test;import com.erggroup.buildtool.ripple.PackageCollection;import com.erggroup.buildtool.ripple.Package;public class PackageCollectionTest {/** Create a basic package**/private Package createPackage(int idx, String pName) {Package p = new Package(idx, idx, pName, "1.0.0000", ".cr", pName + ".cr" , "CC::/vob/"+pName+".WIP", 'b', 'P');return p;}@Testpublic void testAdd() {PackageCollection mCollection = new PackageCollection();Package p1 = createPackage(100, "p1");mCollection.add(p1);Package p2 = createPackage(200, "p2");mCollection.add(p2);}@Testpublic void testContainsString() {PackageCollection mCollection = new PackageCollection();Package p1 = createPackage(100, "p1");mCollection.add(p1);Package p2 = createPackage(200, "p2");mCollection.add(p2);Package px = mCollection.contains("p1.cr");assertNotNull("Contains Alias", px);assertEquals(p1, px);}@Testpublic void testContainsInteger() {PackageCollection mCollection = new PackageCollection();Package p1 = createPackage(100, "p1");mCollection.add(p1);Package p2 = createPackage(200, "p2");mCollection.add(p2);Package px = mCollection.contains(100);assertNotNull("Contains pvid", px);assertEquals(p1, px);}@Testpublic void testIterator() {PackageCollection mCollection = new PackageCollection();Package p1 = createPackage(100, "p1");mCollection.add(p1);Package p2 = createPackage(200, "p2");mCollection.add(p2);int count = 0;for (Iterator<Package> it = mCollection.iterator(); it.hasNext(); ){it.next();count++;}assertTrue("Iteration Count", count == 2);}}