Search in sources :

Example 36 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project rhsm-qe by RedHatQE.

the class EventTests method assertTheNewFeedContains.

protected void assertTheNewFeedContains(SyndFeed oldFeed, List<String> newEventTitles) throws IllegalArgumentException, IOException, FeedException {
    // assert the feed...
    SyndFeed newFeed = CandlepinTasks.getSyndFeed(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
    Assert.assertEquals(newFeed.getTitle(), "Event Feed");
    assertFeedContainsNoUnknownEvents(newFeed);
    log.info("Expecting the new feed to have grown by events that contain (at a minimum) the following events: ");
    for (String newEventTitle : newEventTitles) log.info("    " + newEventTitle);
    // int newFeedGrowthCount = newFeed.getEntries().size() - oldFeed_EntriesSize;
    int newFeedGrowthCount = getFeedGrowthCount(newFeed, oldFeed);
    log.info(newFeedGrowthCount + " new events have been pushed onto the atom feed stack.");
    List<String> actualNewEventTitles = new ArrayList<String>();
    for (int i = 0; i < newFeedGrowthCount; i++) {
        actualNewEventTitles.add(((SyndEntryImpl) newFeed.getEntries().get(i)).getTitle());
    }
    Assert.assertTrue(actualNewEventTitles.containsAll(newEventTitles), "The newest event feed entries contains (at a minimum) all of the expected new event titles.");
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) ArrayList(java.util.ArrayList)

Example 37 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project rhsm-qe by RedHatQE.

the class EventTests method assertTheNewFeed.

protected void assertTheNewFeed(SyndFeed oldFeed, String[] newEventTitles) throws IllegalArgumentException, IOException, FeedException {
    // assert the feed...
    SyndFeed newFeed = CandlepinTasks.getSyndFeed(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
    Assert.assertEquals(newFeed.getTitle(), "Event Feed");
    assertFeedContainsNoUnknownEvents(newFeed);
    log.info("Expecting the new feed to have grown by (" + newEventTitles.length + ") events:");
    int e = 0;
    for (String newEventTitle : newEventTitles) log.info(String.format("  Expecting entry[%d].title %s", e++, newEventTitle));
    // Assert.assertEquals(newConsumerFeed.getEntries().size(), oldFeed_EntriesSize+newEventTitles.length, "The event feed entries has increased by "+newEventTitles.length);
    // if (oldFeed_EntriesSize+newEventTitles.length <= feedLimit) {
    // Assert.assertEquals(newFeed.getEntries().size(), oldFeed_EntriesSize+newEventTitles.length, "The event feed entries has increased by "+newEventTitles.length);
    // } else {
    // Assert.assertEquals(newFeed.getEntries().size(), feedLimit, "The event feed has hit the max entry count as set by the Candlepin class AtomResource/ConsumerResource/OwnerResource hard-coded variable feedlimit.");
    // }
    Assert.assertEquals(getFeedGrowthCount(newFeed, oldFeed), newEventTitles.length, newEventTitles.length + " new event feed entries has been pushed onto the stack.");
    int i = 0;
    for (String newEventTitle : newEventTitles) {
        String actualEventTitle = ((SyndEntryImpl) newFeed.getEntries().get(i)).getTitle();
        Assert.assertEquals(actualEventTitle, newEventTitle, "The next (" + i + ") newest event feed entry is '" + newEventTitle + "'.");
        i++;
    }
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl)

Example 38 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project rhsm-qe by RedHatQE.

the class EventTests method testExportCreated.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21850", "RHEL7-51671" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "subscription-manager: events: Export Created is sent over an RSS atom feed.", groups = { "Tier3Tests", "ExportCreated_Test" }, dependsOnGroups = { "ProductDeleted_Test" }, enabled = true, alwaysRun = true)
public // @ImplementsTCMS(id="")
void testExportCreated() throws Exception {
    if (sm_serverAdminUsername.equals("") || sm_serverAdminPassword.equals(""))
        throw new SkipException("This test requires the candlepin server admin username and password credentials.");
    // start fresh by unregistering
    clienttasks.unregister(null, null, null, null);
    // NOTE: Without the subscribe, this bugzilla is thrown:
    if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", /*TODO CHANGE TO ">" after candlepin 2.1.2-1 is tagged*/
    "2.1.1-1")) {
        // candlepin commit 739b51a0d196d9d3153320961af693a24c0b826f Bug 1455361: Disallow candlepin consumers to be registered via Subscription Manager
        clienttasks.registerCandlepinConsumer(sm_clientUsername, sm_clientPassword, sm_clientOrg, sm_serverUrl, "candlepin");
    } else {
        clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, ConsumerType.candlepin, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    }
    List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    // avoid "Too many content sets..." from Issue/Bug 1455361 - strange pool availability and bind behavior for consumer of type candlepin
    pools.remove(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", "mktProductId-93x2", pools));
    // avoid "Too many content sets..." from Issue/Bug 1455361 - strange pool availability and bind behavior for consumer of type candlepin
    pools.remove(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", "mktProductId-186", pools));
    // randomly pick a pool
    testPool = pools.get(randomGenerator.nextInt(pools.size()));
    clienttasks.subscribe(null, null, testPool.poolId, null, null, null, null, null, null, null, null, null, null);
    // String consumerKey = result.getStdout().split(" ")[0];
    // get the owner and consumer feeds before we test the firing of a new event
    ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
    String ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerCert.consumerid);
    SyndFeed oldFeed = CandlepinTasks.getSyndFeed(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
    SyndFeed oldOwnerFeed = CandlepinTasks.getSyndFeedForOwner(ownerKey, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
    SyndFeed oldConsumerFeed = CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
    consumerCert.consumerid, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
    // do something that will fire a exported created event
    CandlepinTasks.exportConsumerUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerCert.consumerid, "/tmp/export.zip");
    String[] newEventTitles = new String[] { "EXPORT CREATED" };
    // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=721136 - jsefler 07/14/2011
    boolean invokeWorkaroundWhileBugIsOpen = true;
    String bugId = "721136";
    try {
        if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
            log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
            SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
        } else {
            invokeWorkaroundWhileBugIsOpen = false;
        }
    } catch (BugzillaAPIException be) {
    /* ignore exception */
    } catch (RuntimeException re) {
    /* ignore exception */
    }
    if (invokeWorkaroundWhileBugIsOpen) {
        newEventTitles = new String[] { ownerKey + " created an export for consumer " + consumerCert.name };
    }
    // END OF WORKAROUND
    // assert the consumer feed...
    assertTheNewConsumerFeed(ownerKey, consumerCert.consumerid, oldConsumerFeed, newEventTitles);
    // assert the owner feed...
    assertTheNewOwnerFeed(ownerKey, oldOwnerFeed, newEventTitles);
    // assert the feed...
    assertTheNewFeed(oldFeed, newEventTitles);
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) SubscriptionPool(rhsm.data.SubscriptionPool) ConsumerCert(rhsm.data.ConsumerCert) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 39 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project rhsm-qe by RedHatQE.

the class EventTests method testEntitlementCreated.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21842", "RHEL7-51663" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "subscription-manager: events: Enitlement Created is sent over an RSS atom feed.", groups = { "Tier3Tests", "EntitlementCreated_Test" }, dependsOnGroups = { "ConsumerCreated_Test" }, enabled = true)
@ImplementsNitrateTest(caseId = 50403)
public void testEntitlementCreated() throws Exception {
    // test prerequisites
    List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
    // 7/30/2012 updating consumer's autoheal to prevent an auto 'ENTITLEMENT CREATED' event
    CandlepinTasks.setAutohealForConsumer(sm_clientUsername, sm_clientPassword, sm_serverUrl, consumerCert.consumerid, false);
    // get the owner and consumer feeds before we test the firing of a new event
    String ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerCert.consumerid);
    SyndFeed oldFeed = CandlepinTasks.getSyndFeed(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
    SyndFeed oldOwnerFeed = CandlepinTasks.getSyndFeedForOwner(ownerKey, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
    SyndFeed oldConsumerFeed = CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
    consumerCert.consumerid, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
    // fire a subscribe event
    // SubscriptionPool pool = pools.get(0); // pick the first pool
    // randomly pick a pool
    testPool = pools.get(randomGenerator.nextInt(pools.size()));
    // debugTesting randomly picked standalone non-zero virt_limit pools
    // testPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", "awesomeos-virt-4", pools);
    // testPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", "awesomeos-virt-unlimited", pools);
    // testPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", "awesomeos-server-basic-dc", pools);
    // testPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", "8a90860f5eed6282015eed64099a0193", pools);
    // testPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("contract", "", pools);
    // testPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionType", "Standard (Temporary)", pools);
    // clienttasks.subscribeToSubscriptionPoolUsingPoolId(testPool);	// RHEL59: THIS IS GENERATING EXTRA CONSUMER MODIFIED EVENTS THAT WE DON'T REALLY WANT TO TEST
    clienttasks.subscribe(null, null, testPool.poolId, null, null, null, null, null, null, null, null, null, null);
    List<String> newEventTitles = new ArrayList<String>();
    // newEventTitles.add("COMPLIANCE CREATED");	// COMPLIANCE CREATED events were added to support gutterball
    newEventTitles.add("ENTITLEMENT CREATED");
    // newEventTitles.add("COMPLIANCE CREATED");
    // newEventTitles.add("COMPLIANCE CREATED");
    // TEMPORARY WORKAROUND FOR BUG
    // Status: 	CLOSED CURRENTRELEASE
    boolean invokeWorkaroundWhileBugIsOpen = false;
    // jsefler 07/14/2011 Bug 721136 - the content of the atom feeds has the same value for title and description
    String bugId = "721136";
    try {
        if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
            log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
            SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
        } else {
            invokeWorkaroundWhileBugIsOpen = false;
        }
    } catch (BugzillaAPIException be) {
    /* ignore exception */
    } catch (RuntimeException re) {
    /* ignore exception */
    }
    if (invokeWorkaroundWhileBugIsOpen) {
        newEventTitles.clear();
        newEventTitles.add(clienttasks.hostname + " consumed a subscription for product " + testPool.subscriptionName);
    }
    // END OF WORKAROUND
    // assert the consumer feed...
    // assertTheNewConsumerFeed(ownerKey, consumerCert.consumerid, oldConsumerFeed, newEventTitles.toArray(new String[]{}));	// worked prior to RHEL59
    // TODO Using the IgnoringEventTitles is a workaround bug 838123#c2
    assertTheNewConsumerFeedIgnoringEventTitles(ownerKey, consumerCert.consumerid, oldConsumerFeed, newEventTitles.toArray(new String[] {}), new HashSet<String>() {

        {
            add("CONSUMER MODIFIED");
            add("COMPLIANCE CREATED");
        }
    });
    // adjust the expected events when the candlepin server is standalone and the pool has a non-zero virt_limit
    String virt_limit = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, testPool.poolId, "virt_limit");
    if (servertasks.statusStandalone && virt_limit != null && !virt_limit.equals("0")) {
        newEventTitles.add(1, "POOL CREATED");
    }
    // assert the owner feed...
    // assertTheNewOwnerFeed(ownerKey, oldOwnerFeed, newEventTitles.toArray(new String[]{}));	// worked prior to RHEL59
    // TODO Using the IgnoringEventTitles is a workaround bug 838123#c2
    assertTheNewOwnerFeedIgnoringEventTitles(ownerKey, oldOwnerFeed, newEventTitles.toArray(new String[] {}), new HashSet<String>() {

        {
            add("CONSUMER MODIFIED");
            add("COMPLIANCE CREATED");
        }
    });
    // assert the feed...
    // assertTheNewFeed(oldFeed, newEventTitles.toArray(new String[]{}));	// worked prior to RHEL59
    assertTheNewFeedIgnoringEventTitles(oldFeed, newEventTitles.toArray(new String[] {}), new HashSet<String>() {

        {
            add("CONSUMER MODIFIED");
            add("COMPLIANCE CREATED");
        }
    });
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) ArrayList(java.util.ArrayList) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) SubscriptionPool(rhsm.data.SubscriptionPool) ConsumerCert(rhsm.data.ConsumerCert) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 40 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project eol-globi-data by jhpoelen.

the class StudyImporterForArthopodEasyCapture method getStudyImportersForRSSFeed.

public static List<StudyImporter> getStudyImportersForRSSFeed(Dataset datasetOrig, ParserFactory parserFactory, NodeFactory nodeFactory) throws StudyImporterException {
    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed;
    String rss = getRss(datasetOrig);
    try {
        feed = input.build(new XmlReader(new URL(rss)));
    } catch (FeedException | IOException e) {
        throw new StudyImporterException("failed to read rss feed [" + rss + "]", e);
    }
    List<StudyImporter> importers = new ArrayList<StudyImporter>();
    final List entries = feed.getEntries();
    for (Object entry : entries) {
        if (entry instanceof SyndEntry) {
            SyndEntry syndEntry = (SyndEntry) entry;
            Dataset dataset = embeddedDatasetFor(datasetOrig, StringUtils.trim(syndEntry.getDescription().getValue()), URI.create(StringUtils.trim(syndEntry.getLink())));
            final StudyImporterForSeltmann studyImporter = new StudyImporterForSeltmann(parserFactory, nodeFactory);
            studyImporter.setDataset(dataset);
            importers.add(studyImporter);
        }
    }
    return importers;
}
Also used : SyndEntry(com.sun.syndication.feed.synd.SyndEntry) Dataset(org.eol.globi.service.Dataset) FeedException(com.sun.syndication.io.FeedException) ArrayList(java.util.ArrayList) XmlReader(com.sun.syndication.io.XmlReader) IOException(java.io.IOException) URL(java.net.URL) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndFeedInput(com.sun.syndication.io.SyndFeedInput) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

SyndFeed (com.sun.syndication.feed.synd.SyndFeed)90 ArrayList (java.util.ArrayList)28 SyndEntry (com.sun.syndication.feed.synd.SyndEntry)25 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)16 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)16 SyndEntryImpl (com.sun.syndication.feed.synd.SyndEntryImpl)16 Test (org.testng.annotations.Test)16 Test (org.junit.Test)11 SkipException (org.testng.SkipException)11 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)10 SyndFeedImpl (com.sun.syndication.feed.synd.SyndFeedImpl)10 FeedException (com.sun.syndication.io.FeedException)10 SyndFeedInput (com.sun.syndication.io.SyndFeedInput)10 IOException (java.io.IOException)10 URL (java.net.URL)10 Date (java.util.Date)9 XmlReader (com.sun.syndication.io.XmlReader)8 HashMap (java.util.HashMap)8 ConsumerCert (rhsm.data.ConsumerCert)8 SyndFeedOutput (com.sun.syndication.io.SyndFeedOutput)6