Package org.rhq.core.domain.content

Examples of org.rhq.core.domain.content.ContentSource


            PackageType pt = new PackageType("testPVCSInsertPT", resource.getResourceType());
            Package pkg = new Package("testPVCSInsertPackage", pt);
            PackageBits bits = createPackageBits(em);
            PackageVersion pv = new PackageVersion(pkg, "version", arch);
            ContentSourceType cst = new ContentSourceType("testPVCSContentSourceType");
            ContentSource cs = new ContentSource("testPVCSContentSource", cst);
            PackageVersionContentSource pvcs = new PackageVersionContentSource(pv, cs, "fooLocation");

            Configuration csConfig = new Configuration();
            csConfig.put(new PropertySimple("csConfig1", "csConfig1Value"));
            cs.setConfiguration(csConfig);

            Configuration pvConfig = new Configuration();
            pvConfig.put(new PropertySimple("pvConfig1", "pvConfig1Value"));
            pv.setExtraProperties(pvConfig);

            bits.getBlob().setBits("testDeleteOrphanedPV".getBytes());
            pv.setPackageBits(bits);

            em.persist(rt);
            em.persist(resource);
            em.persist(arch);
            em.persist(pt);
            em.persist(pkg);
            em.persist(pv);
            em.persist(cst);
            em.persist(cs);
            em.persist(pvcs);
            em.flush();
            em.clear();

            PackageVersionContentSourcePK pk = new PackageVersionContentSourcePK(pv, cs);
            PackageVersionContentSource pvcsDup = em.find(PackageVersionContentSource.class, pk);
            em.clear();

            assert pvcsDup != null;
            assert pvcsDup.equals(pvcs);
            assert pvcsDup.getLocation().equals("fooLocation");

            Query q = em.createNamedQuery(PackageVersionContentSource.DELETE_BY_CONTENT_SOURCE_ID);
            q.setParameter("contentSourceId", cs.getId());
            assert 1 == q.executeUpdate();
            em.clear();

            PackageBits findBits = em.find(PackageBits.class, bits.getId());
            assert findBits != null : "The bits did not cascade-persist for some reason";
View Full Code Here


            Architecture arch = new Architecture("testCSSRInsertArch");
            PackageType pt = new PackageType("testCSSRInsertPT", resource.getResourceType());
            Package pkg = new Package("testCSSRInsertPackage", pt);
            PackageVersion pv = new PackageVersion(pkg, "version", arch);
            ContentSourceType cst = new ContentSourceType("testCSSRContentSourceType");
            ContentSource cs = new ContentSource("testCSSRContentSource", cst);
            ContentSourceSyncResults results = new ContentSourceSyncResults(cs);
            Repo repo = new Repo("testCSSRRepo");
            repo.addContentSource(cs);

            em.persist(rt);
            em.persist(resource);
            em.persist(arch);
            em.persist(pt);
            em.persist(pkg);
            em.persist(pv);
            em.persist(cst);
            em.persist(cs);
            em.persist(repo);
            em.persist(results);
            cs.addSyncResult(results);
            em.flush();

            cs = em.find(ContentSource.class, cs.getId());
            assert cs != null;
            List<ContentSourceSyncResults> syncResults = cs.getSyncResults();
            assert syncResults != null;
            assert syncResults.size() == 1;
            results = syncResults.get(0);
            assert results.getContentSource().equals(cs);
            assert results.getStatus() == ContentSyncStatus.INPROGRESS;
            assert results.getResults() == null;
            assert results.getEndTime() == null;
            assert results.getStartTime() <= System.currentTimeMillis();

            results.setEndTime(System.currentTimeMillis());
            results.setStatus(ContentSyncStatus.FAILURE);
            results.setResults("dummy failure");
            results = em.merge(results);

            // add another (make sure the start time is long enough to pass the time check below
            Thread.sleep(100);
            results = new ContentSourceSyncResults(cs);
            em.persist(results);
            cs.addSyncResult(results);
            em.flush();

            cs = em.find(ContentSource.class, cs.getId());
            assert cs != null;
            syncResults = cs.getSyncResults();
            assert syncResults != null;
            assert syncResults.size() == 2;
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.content.ContentSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.