Questions Tagged With designerhttps://answers.axonivy.com/tags/designer/?type=rss&user=trungdvquestions tagged <span class="tag">designer</span>enMon, 07 Apr 2014 09:34:02 -0400How can Junit access to Ivy environment without EnvironmentNotAvailableExceptionhttps://answers.axonivy.com/questions/617/how-can-junit-access-to-ivy-environment-without-environmentnotavailableexception<p>Hello everybody I have two projects, one is A and one is A_Test. And i try to run JUnit Test case from project A_Test to test some functionalities of A. Here is a portion of code Project A</p> <pre><code>public CalendarEventRequest(){ this.organizer = **Ivy.var().get("xabs_calendarEvent_organizer").toString();** Calendar c = new GregorianCalendar(Ivy.session().getContentLocale()); this.timezone= c.getTimeZone(); } </code></pre> <p>Test case</p> <pre><code>@Test public void testCreateCalendarEvent002() throws Exception { CalendarEventRequest request = new CalendarEventRequest(); CalendarEventResult result = CalendarUtil.createCalendarEvent(request); assertNotNull(result); } </code></pre> <p>And JUnit threw this exception:</p> <pre><code> ch.ivyteam.ivy.environment.EnvironmentNotAvailableException: Access to ivy environment outside a process request thread is not possible. Current thread: Thread[main,5,main] at ch.ivyteam.ivy.environment.Ivy.getEnvironmentData(Ivy.java:455) at ch.ivyteam.ivy.environment.Ivy.var(Ivy.java:272) at ch.soreco.customers.xabs.bean.CalendarEventRequest.&lt;init&gt;(CalendarEventRequest.java:26) at ch.soreco.customers.xabs.bean.CalendarUtilTest.createRequestForOneDay(CalendarUtilTest.java:75) at ch.soreco.customers.xabs.bean.CalendarUtilTest.testCreateCalendarEvent002(CalendarUtilTest.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) </code></pre> <p>anyone can help me?</p>trungdvMon, 07 Apr 2014 09:34:02 -0400https://answers.axonivy.com/questions/617/how-can-junit-access-to-ivy-environment-without-environmentnotavailableexceptionenvironmentunit-testdesignerivyHow can send multipart email in Ivy?https://answers.axonivy.com/questions/585/how-can-send-multipart-email-in-ivy<p>Currently i have a problem when send the email with content type is multipart. I don't use Email script to send, i use Java mail to do because i have to add a ICS file content(invitation calendar file) to email header. Actually it can work perfectly if i create a main() in ivy and send it but if i called it by ivy script, it always throw error:</p> <pre><code> UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary="----=_Part_22_936261044.1395656648093" MessagingException: IOException while sending message IvyScriptMethodInvocationException: Error calling method sendMail(net.fortuna.ical4j.model.Calendar) on an object of class ch.ivyteam.ivy.scripting.internal.language.StaticAccess. Reason: javax.mail.MessagingException: IOException while sending message; nested exception is: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary="----=_Part_22_936261044.1395656648093" IvyScriptRuntimeException: IvyScript Runtime Exception in Instruction: ch.soreco.customers.xabs.util.CalendarUtil.sendMail() </code></pre> <p><strong>Below code is used for sending email:</strong></p> <pre><code>Session session = Session.getInstance(properties, authenticator); transport = session.getTransport(); transport.connect(username, password); // register the text/calendar mime type MimetypesFileTypeMap mimetypes = (MimetypesFileTypeMap) MimetypesFileTypeMap.getDefaultFileTypeMap(); mimetypes.addMimeTypes("text/calendar ics ICS"); //register the handling of text/calendar mime type MailcapCommandMap mailcap = (MailcapCommandMap) MailcapCommandMap.getDefaultCommandMap(); mailcap.addMailcap("text/calendar;; x-java-content-handler=com.sun.mail.handlers.text_plain"); mailcap.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); mailcap.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"); mailcap.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"); mailcap.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed; x-java-fallback-entry=true"); mailcap.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mailcap); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.setSubject(subject); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.setHeader("X-Mailer", "iQuest-Mailer"); // Create an alternative Multipart Multipart multipart = new MimeMultipart("mixed"); MimeBodyPart descriptionPart = new MimeBodyPart(); String content = "simple meeting invitation."; descriptionPart.setContent(content, "text/html; charset=utf-8"); BodyPart messageBodyPart = descriptionPart; multipart.addBodyPart(messageBodyPart); // Add part two, the calendar String calString = "BEGIN:VCALENDAR\n" + "PRODID:-//XpertIvy//iCal4j 1.0//XABS\n" + "VERSION:2.0\n" + "CALSCALE:GREGORIAN\n" + "METHOD:PUBLISH\n" + "BEGIN:VEVENT\n" + "DTSTAMP:20140321T033611Z\n" + "DTSTART;VALUE=DATE:20140323\n" + "DTEND;VALUE=DATE:20140324\n" + "UID:xpert.abs-recurrence-0\n" + "ORGANIZER:noreply@soreco.ch\n" + "ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=cavoirom@gmail.com:MAILTO:cavoirom@gmail.com\n" + "X-MICROSOFT-CDO-BUSYSTATUS:OOF\n" + "RRULE:FREQ=WEEKLY;COUNT=2;INTERVAL=1;BYDAY=MO,SU\n" + "DESCRIPTION:VINH weekly 21.3\n" + "SUMMARY:Fatality: Partner\\, Child\\, Parent\n" + "EXDATE:20140322\n" + "END:VEVENT\n" + "END:VCALENDAR\n"; BodyPart calendarPart = new MimeBodyPart(); calendarPart.addHeader("Content-Class", "urn:content-classes:calendarmessage"); calendarPart.setHeader("Content-ID","calendar_message"); calendarPart.setContent(calString, "text/calendar; charset=\"utf-8\"; method=REQUEST"); multipart.addBodyPart(calendarPart); //Put the multipart in message message.setContent(multipart); Transport.send(message); transport.close(); </code></pre> <p><strong>Ivy version:</strong> 5.04</p> <p><strong>Javamail verion:</strong> 1.4.4</p> <p>Anyone can help me?</p>trungdvMon, 24 Mar 2014 11:29:15 -0400https://answers.axonivy.com/questions/585/how-can-send-multipart-email-in-ivydesigner