List of usage examples for java.util GregorianCalendar add
@Override public void add(int field, int amount)
From source file:org.oscarehr.web.Cds4ReportUIBean.java
private int getCdsHospitalisationDaysCount2YearsBeforeProgramAdmission(Collection<CdsClientForm> forms) { int numberOfDaysInHospital = 0; if (forms != null) { for (CdsClientForm form : forms) { List<CdsHospitalisationDays> hospitalisationDays = getHopitalisationDays2YearsBeforeAdmission(form); Admission admission = admissionMap.get(form.getAdmissionId()); GregorianCalendar startBound = (GregorianCalendar) admission.getAdmissionCalendar().clone(); startBound.add(GregorianCalendar.YEAR, -2); // 2 years prior to admission // materialise results startBound.getTimeInMillis(); numberOfDaysInHospital = numberOfDaysInHospital + getTotalDayCount(hospitalisationDays, startBound, admission.getAdmissionCalendar()); }//from w w w . j a va 2 s . com } return (numberOfDaysInHospital); }
From source file:org.outermedia.solrfusion.SolrFusionServletTest.java
@Test public void testConfigReload() throws ServletException, IOException, InterruptedException { TestSolrFusionServlet servlet = new TestSolrFusionServlet(); GregorianCalendar currentCal = new GregorianCalendar(2014, 6, 3, 12, 0, 0); long startTime = currentCal.getTimeInMillis(); servlet.currentTime = startTime;//ww w . j ava 2 s . c o m File tmpSchema = File.createTempFile("test-schema-", ".xml", new File("target/test-classes")); FileUtils.copyFile(new File("target/test-classes/test-fusion-schema.xml"), tmpSchema); FileUtils.touch(tmpSchema); servlet.loadSolrFusionConfig(tmpSchema.getName(), false); Configuration oldCfg = servlet.getCfg(); Assert.assertNotNull("Solr Fusion schema not loaded", oldCfg); // try to re-load immediately, which should be done after 5 minutes only log.info("----1"); servlet.loadSolrFusionConfig(tmpSchema.getName(), false); Assert.assertEquals("Solr Fusion schema re-loaded", oldCfg, servlet.getCfg()); // 6 minutes in the future, without schema modifications, nothing should happen currentCal.add(Calendar.MINUTE, 6); servlet.currentTime = currentCal.getTimeInMillis(); log.info("----2"); servlet.loadSolrFusionConfig(tmpSchema.getName(), false); Assert.assertEquals("Solr Fusion schema re-loaded", oldCfg, servlet.getCfg()); // 6 minutes in the future with schema modifications servlet.setSolrFusionSchemaLoadTime(startTime); // modified after loadSolrFusionConfig() call Thread.sleep(1001); // await new time FileUtils.touch(tmpSchema); log.info("----3"); servlet.loadSolrFusionConfig(tmpSchema.getName(), false); Assert.assertNotSame("Solr Fusion schema not re-loaded", oldCfg, servlet.getCfg()); oldCfg = servlet.getCfg(); // force re-load currentCal.add(Calendar.MINUTE, 1); servlet.currentTime = currentCal.getTimeInMillis(); log.info("----4"); servlet.loadSolrFusionConfig(tmpSchema.getName(), false); Assert.assertEquals("Solr Fusion schema re-loaded", oldCfg, servlet.getCfg()); log.info("----5"); servlet.loadSolrFusionConfig(tmpSchema.getName(), true); Assert.assertNotSame("Solr Fusion schema not re-loaded", oldCfg, servlet.getCfg()); }
From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java
/** * set subscription, make a change as the same user, get subscription * results no key specified/* w w w. ja v a 2 s. c om*/ * * @throws DatatypeConfigurationException */ @Test public void JUDDI_606_11() throws DatatypeConfigurationException { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("JUDDI_606_11"); Assume.assumeTrue(TckPublisher.isSubscriptionEnabled()); String key = null; DatatypeFactory df = DatatypeFactory.newInstance(); try { Holder<List<Subscription>> data = new Holder<List<Subscription>>(); data.value = new ArrayList<Subscription>(); Subscription sub = new Subscription(); sub.setBrief(false); sub.setExpiresAfter(null); sub.setMaxEntities(null); sub.setNotificationInterval(null); sub.setBindingKey(null); sub.setSubscriptionFilter(new SubscriptionFilter()); sub.getSubscriptionFilter().setFindBusiness(new FindBusiness()); sub.getSubscriptionFilter().getFindBusiness().setFindQualifiers(new FindQualifiers()); sub.getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier() .add(UDDIConstants.APPROXIMATE_MATCH); sub.getSubscriptionFilter().getFindBusiness().getName().add(new Name("%", null)); data.value.add(sub); tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data); SaveBusiness sb = new SaveBusiness(); sb.setAuthInfo(authInfoJoe); BusinessEntity be = new BusinessEntity(); be.getName().add(new Name("Test business", null)); sb.getBusinessEntity().add(be); BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb); key = saveBusiness.getBusinessEntity().get(0).getBusinessKey(); GetSubscriptionResults gsr = new GetSubscriptionResults(); gsr.setAuthInfo(authInfoJoe); gsr.setSubscriptionKey(null); gsr.setCoveragePeriod(new CoveragePeriod()); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.HOUR, -1); gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal)); gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal)); tckSubscriptionJoe.subscription.getSubscriptionResults(gsr); Assert.fail(); } catch (Exception ex) { //HandleException(ex); //Assert.fail(); logger.info("Expected exception: " + ex.getMessage()); } finally { TckCommon.DeleteBusiness(key, authInfoJoe, publicationJoe); } }
From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java
/** * set subscription, make a change as the same user, get subscription * results valid find_Business/* w w w . jav a 2 s. c o m*/ * * @throws DatatypeConfigurationException */ @Test public void JUDDI_606_13() throws DatatypeConfigurationException { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("JUDDI_606_13"); Assume.assumeTrue(TckPublisher.isSubscriptionEnabled()); String key = null; DatatypeFactory df = DatatypeFactory.newInstance(); try { Holder<List<Subscription>> data = new Holder<List<Subscription>>(); data.value = new ArrayList<Subscription>(); Subscription sub = new Subscription(); sub.setBrief(false); sub.setExpiresAfter(null); sub.setMaxEntities(null); sub.setNotificationInterval(null); sub.setBindingKey(null); sub.setSubscriptionFilter(new SubscriptionFilter()); sub.getSubscriptionFilter().setFindBusiness(new FindBusiness()); sub.getSubscriptionFilter().getFindBusiness().setFindQualifiers(new FindQualifiers()); sub.getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier() .add(UDDIConstants.APPROXIMATE_MATCH); sub.getSubscriptionFilter().getFindBusiness().getName().add(new Name("%", null)); data.value.add(sub); tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data); SaveBusiness sb = new SaveBusiness(); sb.setAuthInfo(authInfoJoe); BusinessEntity be = new BusinessEntity(); be.getName().add(new Name("Test business", null)); sb.getBusinessEntity().add(be); BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb); key = saveBusiness.getBusinessEntity().get(0).getBusinessKey(); GetSubscriptionResults gsr = new GetSubscriptionResults(); gsr.setAuthInfo(authInfoJoe); gsr.setSubscriptionKey(data.value.get(0).getSubscriptionKey()); gsr.setCoveragePeriod(new CoveragePeriod()); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.HOUR, -1); gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal)); gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal)); SubscriptionResultsList subscriptionResults = tckSubscriptionJoe.subscription .getSubscriptionResults(gsr); Assert.assertNotNull(subscriptionResults); Assert.assertNotNull(subscriptionResults.getBusinessList()); Assert.assertNotNull(subscriptionResults.getCoveragePeriod()); Assert.assertNotNull(subscriptionResults.getBusinessList().getBusinessInfos()); Assert.assertNotNull(subscriptionResults.getBusinessList().getBusinessInfos().getBusinessInfo().get(0)); Assert.assertNotNull(subscriptionResults.getBusinessList().getBusinessInfos().getBusinessInfo().get(0) .getBusinessKey()); Assert.assertNotNull(subscriptionResults.getBusinessList().getBusinessInfos().getBusinessInfo().get(0) .getName().get(0)); } catch (Exception ex) { HandleException(ex); Assert.fail(); } finally { TckCommon.DeleteBusiness(key, authInfoJoe, publicationJoe); } }
From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java
/** * set subscription, make a change as the same user, get subscription * results valid find_services// w ww.j a va 2 s . c o m * * @throws DatatypeConfigurationException */ @Test public void JUDDI_606_14() throws DatatypeConfigurationException { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("JUDDI_606_14"); Assume.assumeTrue(TckPublisher.isSubscriptionEnabled()); DatatypeFactory df = DatatypeFactory.newInstance(); try { Holder<List<Subscription>> data = new Holder<List<Subscription>>(); data.value = new ArrayList<Subscription>(); Subscription sub = new Subscription(); sub.setBrief(false); sub.setExpiresAfter(null); sub.setMaxEntities(null); sub.setNotificationInterval(null); sub.setBindingKey(null); sub.setSubscriptionFilter(new SubscriptionFilter()); sub.getSubscriptionFilter().setFindService(new FindService()); sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers()); sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier() .add(UDDIConstants.APPROXIMATE_MATCH); sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null)); data.value.add(sub); tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data); tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe); /*SaveService sb = new SaveService(); sb.setAuthInfo(authInfoJoe); BusinessService bs = new BusinessService(); bs.getName().add(new Name("svc", null)); sb.getBusinessService().add(bs); publicationJoe.saveService(sb);*/ GetSubscriptionResults gsr = new GetSubscriptionResults(); gsr.setAuthInfo(authInfoJoe); gsr.setSubscriptionKey(data.value.get(0).getSubscriptionKey()); gsr.setCoveragePeriod(new CoveragePeriod()); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.HOUR, -1); gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal)); gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal)); SubscriptionResultsList subscriptionResults = tckSubscriptionJoe.subscription .getSubscriptionResults(gsr); Assert.assertNotNull(subscriptionResults); Assert.assertNull(subscriptionResults.getBusinessList()); Assert.assertNotNull(subscriptionResults.getCoveragePeriod()); Assert.assertNotNull(subscriptionResults.getServiceList()); Assert.assertNotNull(subscriptionResults.getServiceList().getServiceInfos().getServiceInfo().get(0)); Assert.assertNotNull(subscriptionResults.getServiceList().getServiceInfos().getServiceInfo().get(0) .getBusinessKey()); Assert.assertNotNull(subscriptionResults.getServiceList().getServiceInfos().getServiceInfo().get(0) .getName().get(0)); } catch (Exception ex) { HandleException(ex); Assert.fail(ex.getMessage()); } finally { tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe); tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe); } }
From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java
/** * //set subscription, make a change as the same user, get subscription * results. valid. publisher assertion, incomplete * * @throws DatatypeConfigurationException *//* w w w .j a v a 2s .c o m*/ @Test public void JUDDI_606_15() throws DatatypeConfigurationException { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("JUDDI_606_15"); Assume.assumeTrue(TckPublisher.isSubscriptionEnabled()); DatatypeFactory df = DatatypeFactory.newInstance(); try { tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelSam.saveSamSyndicatorTmodel(authInfoSam); tckBusinessSam.saveSamSyndicatorBusiness(authInfoSam); Holder<List<Subscription>> data = new Holder<List<Subscription>>(); data.value = new ArrayList<Subscription>(); Subscription sub = new Subscription(); sub.setBrief(false); sub.setExpiresAfter(null); sub.setMaxEntities(null); sub.setNotificationInterval(null); sub.setBindingKey(null); sub.setSubscriptionFilter(new SubscriptionFilter()); sub.getSubscriptionFilter().setGetAssertionStatusReport(new GetAssertionStatusReport()); sub.getSubscriptionFilter().getGetAssertionStatusReport() .setCompletionStatus(CompletionStatus.STATUS_TO_KEY_INCOMPLETE); data.value.add(sub); tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data); AddPublisherAssertions r = new AddPublisherAssertions(); r.setAuthInfo(authInfoJoe); PublisherAssertion pa = new PublisherAssertion(); pa.setFromKey(TckBusiness.JOE_BUSINESS_KEY); pa.setToKey(TckBusiness.SAM_BUSINESS_KEY); pa.setKeyedReference(new KeyedReference()); pa.getKeyedReference().setKeyName("Subsidiary"); pa.getKeyedReference().setKeyValue("parent-child"); pa.getKeyedReference().setTModelKey("uddi:uddi.org:relationships"); r.getPublisherAssertion().add(pa); publicationJoe.addPublisherAssertions(r); GetSubscriptionResults gsr = new GetSubscriptionResults(); gsr.setAuthInfo(authInfoJoe); gsr.setSubscriptionKey(data.value.get(0).getSubscriptionKey()); gsr.setCoveragePeriod(new CoveragePeriod()); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.HOUR, -1); gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal)); gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal)); SubscriptionResultsList subscriptionResults = tckSubscriptionJoe.subscription .getSubscriptionResults(gsr); Assert.assertNotNull(subscriptionResults); Assert.assertNull(subscriptionResults.getBusinessList()); Assert.assertNotNull(subscriptionResults.getCoveragePeriod()); Assert.assertNull(subscriptionResults.getServiceList()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem()); Assert.assertFalse(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().isEmpty()); Assert.assertEquals( subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getFromKey(), TckBusiness.JOE_BUSINESS_KEY); Assert.assertEquals( subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getToKey(), TckBusiness.SAM_BUSINESS_KEY); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getCompletionStatus()); Assert.assertEquals(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getCompletionStatus(), CompletionStatus.STATUS_TO_KEY_INCOMPLETE); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getKeyedReference()); } catch (Exception ex) { HandleException(ex); Assert.fail(ex.getMessage()); } finally { tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessSam.deleteSamSyndicatorBusiness(authInfoSam); tckTModelSam.deleteSamSyndicatorTmodel(authInfoSam); } }
From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java
/** * set subscription, make a change as the same user, get subscription * results valid publisher assertion, deleted * * @throws DatatypeConfigurationException *//* w ww. ja v a 2 s.c o m*/ @Test public void JUDDI_606_17() throws DatatypeConfigurationException { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("JUDDI_606_17"); Assume.assumeTrue(TckPublisher.isSubscriptionEnabled()); DatatypeFactory df = DatatypeFactory.newInstance(); try { tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelSam.saveSamSyndicatorTmodel(authInfoSam); tckBusinessSam.saveSamSyndicatorBusiness(authInfoSam); Holder<List<Subscription>> data = new Holder<List<Subscription>>(); data.value = new ArrayList<Subscription>(); Subscription sub = new Subscription(); sub.setBrief(false); sub.setExpiresAfter(null); sub.setMaxEntities(null); sub.setNotificationInterval(null); sub.setBindingKey(null); sub.setSubscriptionFilter(new SubscriptionFilter()); sub.getSubscriptionFilter().setGetAssertionStatusReport(new GetAssertionStatusReport()); sub.getSubscriptionFilter().getGetAssertionStatusReport() .setCompletionStatus(CompletionStatus.STATUS_BOTH_INCOMPLETE); data.value.add(sub); tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data); AddPublisherAssertions r = new AddPublisherAssertions(); r.setAuthInfo(authInfoJoe); PublisherAssertion pa = new PublisherAssertion(); pa.setFromKey(TckBusiness.JOE_BUSINESS_KEY); pa.setToKey(TckBusiness.SAM_BUSINESS_KEY); pa.setKeyedReference(new KeyedReference()); pa.getKeyedReference().setKeyName("Subsidiary"); pa.getKeyedReference().setKeyValue("parent-child"); pa.getKeyedReference().setTModelKey("uddi:uddi.org:relationships"); r.getPublisherAssertion().add(pa); publicationJoe.addPublisherAssertions(r); //approve it r = new AddPublisherAssertions(); r.setAuthInfo(authInfoSam); r.getPublisherAssertion().add(pa); publicationSam.addPublisherAssertions(r); DeletePublisherAssertions dp = new DeletePublisherAssertions(); dp.setAuthInfo(authInfoJoe); dp.getPublisherAssertion().add(pa); publicationJoe.deletePublisherAssertions(dp); dp = new DeletePublisherAssertions(); dp.setAuthInfo(authInfoSam); dp.getPublisherAssertion().add(pa); //publicationSam.deletePublisherAssertions(dp); GetSubscriptionResults gsr = new GetSubscriptionResults(); gsr.setAuthInfo(authInfoJoe); gsr.setSubscriptionKey(data.value.get(0).getSubscriptionKey()); gsr.setCoveragePeriod(new CoveragePeriod()); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.HOUR, -1); gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal)); gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal)); SubscriptionResultsList subscriptionResults = tckSubscriptionJoe.subscription .getSubscriptionResults(gsr); Assert.assertNotNull(subscriptionResults); Assert.assertNull(subscriptionResults.getBusinessList()); Assert.assertNotNull(subscriptionResults.getCoveragePeriod()); Assert.assertNull(subscriptionResults.getServiceList()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem()); Assert.assertTrue(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().isEmpty()); /* Assert.assertEquals(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getFromKey(), TckBusiness.JOE_BUSINESS_KEY); Assert.assertEquals(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getToKey(), TckBusiness.SAM_BUSINESS_KEY); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getCompletionStatus()); Assert.assertEquals(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getCompletionStatus(), CompletionStatus.STATUS_BOTH_INCOMPLETE); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getKeyedReference());*/ } catch (Exception ex) { HandleException(ex); Assert.fail(ex.getMessage()); } finally { tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessSam.deleteSamSyndicatorBusiness(authInfoSam); tckTModelSam.deleteSamSyndicatorTmodel(authInfoSam); } }
From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java
/** * set subscription, make a change as the same user, get subscription * results valid publisher assertion, complete * * @throws DatatypeConfigurationException *///from w w w .j ava 2 s .c o m @Test public void JUDDI_606_16() throws DatatypeConfigurationException { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("JUDDI_606_16"); Assume.assumeTrue(TckPublisher.isSubscriptionEnabled()); DatatypeFactory df = DatatypeFactory.newInstance(); try { tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelSam.saveSamSyndicatorTmodel(authInfoSam); tckBusinessSam.saveSamSyndicatorBusiness(authInfoSam); Holder<List<Subscription>> data = new Holder<List<Subscription>>(); data.value = new ArrayList<Subscription>(); Subscription sub = new Subscription(); sub.setBrief(false); sub.setExpiresAfter(null); sub.setMaxEntities(null); sub.setNotificationInterval(null); sub.setBindingKey(null); sub.setSubscriptionFilter(new SubscriptionFilter()); sub.getSubscriptionFilter().setGetAssertionStatusReport(new GetAssertionStatusReport()); sub.getSubscriptionFilter().getGetAssertionStatusReport() .setCompletionStatus(CompletionStatus.STATUS_COMPLETE); data.value.add(sub); tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data); AddPublisherAssertions r = new AddPublisherAssertions(); r.setAuthInfo(authInfoJoe); PublisherAssertion pa = new PublisherAssertion(); pa.setFromKey(TckBusiness.JOE_BUSINESS_KEY); pa.setToKey(TckBusiness.SAM_BUSINESS_KEY); pa.setKeyedReference(new KeyedReference()); pa.getKeyedReference().setKeyName("Subsidiary"); pa.getKeyedReference().setKeyValue("parent-child"); pa.getKeyedReference().setTModelKey("uddi:uddi.org:relationships"); r.getPublisherAssertion().add(pa); publicationJoe.addPublisherAssertions(r); r = new AddPublisherAssertions(); r.setAuthInfo(authInfoSam); pa = new PublisherAssertion(); pa.setFromKey(TckBusiness.JOE_BUSINESS_KEY); pa.setToKey(TckBusiness.SAM_BUSINESS_KEY); pa.setKeyedReference(new KeyedReference()); pa.getKeyedReference().setKeyName("Subsidiary"); pa.getKeyedReference().setKeyValue("parent-child"); pa.getKeyedReference().setTModelKey("uddi:uddi.org:relationships"); r.getPublisherAssertion().add(pa); publicationJoe.addPublisherAssertions(r); GetSubscriptionResults gsr = new GetSubscriptionResults(); gsr.setAuthInfo(authInfoJoe); gsr.setSubscriptionKey(data.value.get(0).getSubscriptionKey()); gsr.setCoveragePeriod(new CoveragePeriod()); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.HOUR, -1); gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal)); gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal)); SubscriptionResultsList subscriptionResults = tckSubscriptionJoe.subscription .getSubscriptionResults(gsr); Assert.assertNotNull(subscriptionResults); Assert.assertNull(subscriptionResults.getBusinessList()); Assert.assertNotNull(subscriptionResults.getCoveragePeriod()); Assert.assertNull(subscriptionResults.getServiceList()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem()); Assert.assertFalse(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().isEmpty()); Assert.assertEquals( subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getFromKey(), TckBusiness.JOE_BUSINESS_KEY); Assert.assertEquals( subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getToKey(), TckBusiness.SAM_BUSINESS_KEY); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getCompletionStatus()); Assert.assertEquals(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getCompletionStatus(), CompletionStatus.STATUS_COMPLETE); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getKeyedReference()); } catch (Exception ex) { HandleException(ex); Assert.fail(ex.getMessage()); } finally { tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessSam.deleteSamSyndicatorBusiness(authInfoSam); tckTModelSam.deleteSamSyndicatorTmodel(authInfoSam); } }
From source file:org.opencms.workplace.CmsLogin.java
/** * Sets the cookie in the response.<p> * // w w w. ja v a 2s . com * @param cookie the cookie to set * @param delete flag to determine if the cookir should be deleted */ protected void setCookie(Cookie cookie, boolean delete) { if (getRequest().getAttribute(PARAM_PREDEF_OUFQN) != null) { // prevent the use of cookies if using a direct ou login url return; } int maxAge = 0; if (!delete) { // set the expiration date of the cookie to six months from today GregorianCalendar cal = new GregorianCalendar(); cal.add(Calendar.MONTH, 6); maxAge = (int) ((cal.getTimeInMillis() - System.currentTimeMillis()) / 1000); } cookie.setMaxAge(maxAge); // set the path cookie.setPath(link("/system/login")); // set the cookie getResponse().addCookie(cookie); }
From source file:com.enonic.cms.core.search.builder.ContentIndexDataFactoryTest.java
private ContentDocument createTestContent() throws Exception { final GregorianCalendar date = new GregorianCalendar(2011, Calendar.JANUARY, 10); ContentDocument content = new ContentDocument(new ContentKey(1)); content.setCategoryKey(new CategoryKey(2)); content.setCategoryName("MyCategory"); content.setContentTypeKey(new ContentTypeKey(3)); content.setContentTypeName("MyContentType"); content.setCreated(date.getTime());/*w ww. j av a 2s . c om*/ content.setTimestamp(date.getTime()); content.setModified(date.getTime()); content.setTitle("MyTitle"); content.setStatus(2); content.setPriority(1); content.setLanguageCode("en"); content.setModifierKey("10"); content.setModifierName("ModifierName"); content.setModifierQualifiedName("ModifierQName"); content.setOwnerKey("11"); content.setOwnerName("OwnerName"); content.setOwnerQualifiedName("OwnerQName"); content.setAssigneeKey("12"); content.setAssigneeName("AssigneeName"); content.setAssigneeQualifiedName("AssigneeQName"); content.setAssignerKey("14"); content.setAssignerName("AssignerName"); content.setAssignerQualifiedName("AssignerQName"); date.add(Calendar.MONTH, 1); content.setAssignmentDueDate(date.getTime()); content.setPublishFrom(date.getTime()); date.add(Calendar.MONTH, 1); content.setPublishTo(date.getTime()); content.setContentLocations(new ContentLocations(new ContentEntity())); content.addUserDefinedField("data/person/age", "38"); content.addUserDefinedField("data/person/gender", "male"); content.addUserDefinedField("data/person/description", "description 38"); content.addUserDefinedField("data/person/age", "28"); content.addUserDefinedField("data/person/gender", "male"); content.addUserDefinedField("data/person/description", "description 28"); content.addUserDefinedField("data/person/age", "10"); content.addUserDefinedField("data/person/gender", "male"); content.addUserDefinedField("data/person/description", "description 10"); return content; }