syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/2] syncope git commit: [SYNCOPE-760] Mail templates are now managed entities, not from filesystem anymore
Date Fri, 29 Jan 2016 14:53:17 GMT
Repository: syncope
Updated Branches:
  refs/heads/master a4a9ef568 -> 2ac6f8d50


http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/core/provisioning-java/src/main/resources/mailTemplates/requestPasswordReset.html.jexl3
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/resources/mailTemplates/requestPasswordReset.html.jexl3
b/core/provisioning-java/src/main/resources/mailTemplates/requestPasswordReset.html.jexl3
deleted file mode 100644
index 0c0428d..0000000
--- a/core/provisioning-java/src/main/resources/mailTemplates/requestPasswordReset.html.jexl3
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-<html>
-<body>
-<p>Hi,
-a password reset was request for ${user.getUsername()}.</p>
-
-<p>In order to complete this request, you need to visit this 
-<a href="http://localhost:9080/syncope-console/?pwdResetToken=${input.get(0).replaceAll('
', '%20')}">link</a></p>.
-
-<p>If you did not request this reset, just ignore the present e-mail.</p>
-
-<p>Best regards.</p>
-</body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/core/provisioning-java/src/main/resources/mailTemplates/requestPasswordReset.txt.jexl3
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/resources/mailTemplates/requestPasswordReset.txt.jexl3
b/core/provisioning-java/src/main/resources/mailTemplates/requestPasswordReset.txt.jexl3
deleted file mode 100644
index 4778884..0000000
--- a/core/provisioning-java/src/main/resources/mailTemplates/requestPasswordReset.txt.jexl3
+++ /dev/null
@@ -1,26 +0,0 @@
-## Licensed to the Apache Software Foundation (ASF) under one
-## or more contributor license agreements.  See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership.  The ASF licenses this file
-## to you under the Apache License, Version 2.0 (the
-## "License"); you may not use this file except in compliance
-## with the License.  You may obtain a copy of the License at
-##
-##   http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing,
-## software distributed under the License is distributed on an
-## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-## KIND, either express or implied.  See the License for the
-## specific language governing permissions and limitations
-## under the License.
-Hi,
-a password reset was request for ${user.getUsername()}.
-
-In order to complete this request, you need to visit this link:
-
-http://localhost:9080/syncope-console/?pwdResetToken=${input.get(0).replaceAll(' ', '%20')}
-
-If you did not request this reset, just ignore the present e-mail.
-
-Best regards.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/core/provisioning-java/src/main/resources/provisioningContext.xml
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/resources/provisioningContext.xml b/core/provisioning-java/src/main/resources/provisioningContext.xml
index 8f4dee9..ae1bb5e 100644
--- a/core/provisioning-java/src/main/resources/provisioningContext.xml
+++ b/core/provisioning-java/src/main/resources/provisioningContext.xml
@@ -118,11 +118,6 @@ under the License.
     <constructor-arg value="5000"/>
   </bean>
 
-  <bean id="mailTemplateResourceLoader" class="org.apache.syncope.core.misc.spring.ResourceWithFallbackLoader">
-    <property name="primary" value="file:${templates.directory}/"/>
-    <property name="fallback" value="classpath:"/>
-  </bean>
-
   <bean id="connIdBundleManager" class="org.apache.syncope.core.provisioning.java.ConnIdBundleManagerImpl">
     <property name="stringLocations" value="${connid.locations}"/>
   </bean>

http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/MailTemplateTest.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/MailTemplateTest.java
b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/MailTemplateTest.java
index d123792..3697d04 100644
--- a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/MailTemplateTest.java
+++ b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/MailTemplateTest.java
@@ -30,32 +30,27 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
-import javax.annotation.Resource;
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.jexl3.MapContext;
 import org.apache.commons.lang3.SerializationUtils;
 import org.apache.syncope.common.lib.to.AttrTO;
 import org.apache.syncope.common.lib.to.MembershipTO;
 import org.apache.syncope.common.lib.to.UserTO;
 import org.apache.syncope.core.misc.jexl.JexlUtils;
-import org.apache.syncope.core.misc.spring.ResourceWithFallbackLoader;
-import org.apache.syncope.core.provisioning.java.notification.NotificationManagerImpl;
+import org.apache.syncope.core.persistence.api.dao.MailTemplateDAO;
 import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
 @Transactional("Master")
 public class MailTemplateTest extends AbstractTest {
 
-    @Resource(name = "mailTemplateResourceLoader")
-    private ResourceWithFallbackLoader mailTemplateResourceLoader;
-
-    private String evaluate(final String templateLocation, final Map<String, Object>
jexlVars) throws IOException {
-        org.springframework.core.io.Resource templateResource =
-                mailTemplateResourceLoader.getResource(templateLocation);
+    @Autowired
+    private MailTemplateDAO mailTemplateDAO;
 
+    private String evaluate(final String template, final Map<String, Object> jexlVars)
{
         StringWriter writer = new StringWriter();
         JexlUtils.newJxltEngine().
-                createTemplate(IOUtils.toString(templateResource.getInputStream())).
+                createTemplate(template).
                 evaluate(new MapContext(jexlVars), writer);
         return writer.toString();
     }
@@ -63,9 +58,7 @@ public class MailTemplateTest extends AbstractTest {
     @Test
     public void confirmPasswordReset() throws IOException {
         String htmlBody = evaluate(
-                NotificationManagerImpl.MAIL_TEMPLATES
-                + "confirmPasswordReset"
-                + NotificationManagerImpl.MAIL_TEMPLATE_HTML_SUFFIX,
+                mailTemplateDAO.find("confirmPasswordReset").getHTMLTemplate(),
                 new HashMap<String, Object>());
 
         assertNotNull(htmlBody);
@@ -86,9 +79,7 @@ public class MailTemplateTest extends AbstractTest {
         ctx.put("input", input);
 
         String htmlBody = evaluate(
-                NotificationManagerImpl.MAIL_TEMPLATES
-                + "requestPasswordReset"
-                + NotificationManagerImpl.MAIL_TEMPLATE_HTML_SUFFIX,
+                mailTemplateDAO.find("requestPasswordReset").getHTMLTemplate(),
                 ctx);
 
         assertNotNull(htmlBody);
@@ -122,12 +113,12 @@ public class MailTemplateTest extends AbstractTest {
         ctx.put("recipients", Collections.singletonList(recipient));
 
         String htmlBody = evaluate(
-                NotificationManagerImpl.MAIL_TEMPLATES
-                + "optin"
-                + NotificationManagerImpl.MAIL_TEMPLATE_HTML_SUFFIX,
+                mailTemplateDAO.find("optin").getHTMLTemplate(),
                 ctx);
 
         assertNotNull(htmlBody);
+        System.out.println("AAAAAAAAAAAAA\n" + htmlBody);
+        
         assertTrue(htmlBody.contains("Hi John Doe,"));
         assertTrue(htmlBody.contains("Your email address is john.doe@syncope.apache.org."));
         assertTrue(htmlBody.contains("<li>another@syncope.apache.org</li>"));

http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java
new file mode 100644
index 0000000..967b2f0
--- /dev/null
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.rest.cxf.service;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.List;
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.StreamingOutput;
+import org.apache.commons.io.IOUtils;
+import org.apache.syncope.common.lib.to.MailTemplateTO;
+import org.apache.syncope.common.lib.types.MailTemplateFormat;
+import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.MailTemplateService;
+import org.apache.syncope.core.logic.MailTemplateLogic;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MailTemplateServiceImpl extends AbstractServiceImpl implements MailTemplateService
{
+
+    @Autowired
+    private MailTemplateLogic logic;
+
+    @Override
+    public Response create(final MailTemplateTO mailTemplateTO) {
+        MailTemplateTO created = logic.create(mailTemplateTO.getKey());
+        URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(created.getKey())).build();
+        return Response.created(location).
+                header(RESTHeaders.RESOURCE_KEY, created.getKey()).
+                build();
+    }
+
+    @Override
+    public MailTemplateTO read(final String key) {
+        return logic.read(key);
+    }
+
+    @Override
+    public List<MailTemplateTO> list() {
+        return logic.list();
+    }
+
+    @Override
+    public void delete(final String key) {
+        logic.delete(key);
+    }
+
+    @Override
+    public Response getFormat(final String key, final MailTemplateFormat format) {
+        final String template = logic.getFormat(key, format);
+        StreamingOutput sout = new StreamingOutput() {
+
+            @Override
+            public void write(final OutputStream os) throws IOException {
+                os.write(template.getBytes());
+            }
+        };
+        return Response.ok(sout).
+                type(format.getMediaType()).
+                build();
+    }
+
+    @Override
+    public void setFormat(final String key, final MailTemplateFormat format, final InputStream
templateIn) {
+        try {
+            logic.setFormat(key, format, IOUtils.toString(templateIn));
+        } catch (final IOException e) {
+            LOG.error("While setting format {} for mail template {}", format, key, e);
+            throw new InternalServerErrorException("Could not read entity", e);
+        }
+    }
+
+    @Override
+    public void removeFormat(final String key, final MailTemplateFormat format) {
+        logic.setFormat(key, format, null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportServiceImpl.java
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportServiceImpl.java
index 82c25db..e80c611 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportServiceImpl.java
@@ -81,10 +81,9 @@ public class ReportServiceImpl extends AbstractServiceImpl implements ReportServ
                 logic.exportExecutionResult(os, reportExec, format);
             }
         };
-        String disposition = "attachment; filename=" + reportExec.getReport().getName() +
"." + format.name().
-                toLowerCase();
         return Response.ok(sout).
-                header(HttpHeaders.CONTENT_DISPOSITION, disposition).
+                header(HttpHeaders.CONTENT_DISPOSITION,
+                        "attachment; filename=" + reportExec.getReport().getName() + "."
+ format.name().toLowerCase()).
                 build();
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/deb/core/pom.xml
----------------------------------------------------------------------
diff --git a/deb/core/pom.xml b/deb/core/pom.xml
index 8be896ba..65e5031 100644
--- a/deb/core/pom.xml
+++ b/deb/core/pom.xml
@@ -140,7 +140,6 @@ under the License.
         <includes>
           <include>mail.properties</include>
           <include>connid.properties</include>
-          <include>mailTemplates/*.jexl3</include>
         </includes>
         <targetPath>${project.build.directory}/etc</targetPath>
         <filtering>true</filtering>

http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/deb/core/src/deb/control/conffiles
----------------------------------------------------------------------
diff --git a/deb/core/src/deb/control/conffiles b/deb/core/src/deb/control/conffiles
index 38d5f12..ae391c2 100644
--- a/deb/core/src/deb/control/conffiles
+++ b/deb/core/src/deb/control/conffiles
@@ -12,9 +12,3 @@
 /etc/apache-syncope/userRoutes.xml
 /etc/apache-syncope/userWorkflow.bpmn20.xml
 /etc/apache-syncope/workflow.properties
-/etc/apache-syncope/mailTemplates/confirmPasswordReset.html.jexl3
-/etc/apache-syncope/mailTemplates/confirmPasswordReset.txt.jexl3
-/etc/apache-syncope/mailTemplates/optin.html.jexl3
-/etc/apache-syncope/mailTemplates/optin.txt.jexl3
-/etc/apache-syncope/mailTemplates/requestPasswordReset.html.jexl3
-/etc/apache-syncope/mailTemplates/requestPasswordReset.txt.jexl3

http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/fit/core-reference/src/main/resources/mail.properties
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/main/resources/mail.properties b/fit/core-reference/src/main/resources/mail.properties
index 66f2e90..e8b9a5f 100644
--- a/fit/core-reference/src/main/resources/mail.properties
+++ b/fit/core-reference/src/main/resources/mail.properties
@@ -14,7 +14,6 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-templates.directory=${conf.directory}
 smtpHost=localhost
 smtpPort=2525
 smtpUser=

http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
index 27db9db..b7af72a 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
@@ -67,6 +67,7 @@ import org.apache.syncope.common.rest.api.service.PolicyService;
 import org.apache.syncope.common.rest.api.service.ReportService;
 import org.apache.syncope.common.rest.api.service.ResourceService;
 import org.apache.syncope.common.rest.api.service.GroupService;
+import org.apache.syncope.common.rest.api.service.MailTemplateService;
 import org.apache.syncope.common.rest.api.service.RealmService;
 import org.apache.syncope.common.rest.api.service.RelationshipTypeService;
 import org.apache.syncope.common.rest.api.service.RoleService;
@@ -193,6 +194,8 @@ public abstract class AbstractITCase {
 
     protected static WorkflowService workflowService;
 
+    protected static MailTemplateService mailTemplateService;
+
     protected static NotificationService notificationService;
 
     protected static SchemaService schemaService;
@@ -258,6 +261,7 @@ public abstract class AbstractITCase {
         taskService = adminClient.getService(TaskService.class);
         policyService = adminClient.getService(PolicyService.class);
         workflowService = adminClient.getService(WorkflowService.class);
+        mailTemplateService = adminClient.getService(MailTemplateService.class);
         notificationService = adminClient.getService(NotificationService.class);
         schemaService = adminClient.getService(SchemaService.class);
         securityQuestionService = adminClient.getService(SecurityQuestionService.class);

http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MailTemplateITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MailTemplateITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MailTemplateITCase.java
new file mode 100644
index 0000000..9a7f511
--- /dev/null
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MailTemplateITCase.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.fit.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.apache.commons.io.IOUtils;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.to.MailTemplateTO;
+import org.apache.syncope.common.lib.types.ClientExceptionType;
+import org.apache.syncope.common.lib.types.MailTemplateFormat;
+import org.apache.syncope.fit.AbstractITCase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.JVM)
+public class MailTemplateITCase extends AbstractITCase {
+
+    @Test
+    public void read() {
+        MailTemplateTO mailTemplateTO = mailTemplateService.read("optin");
+        assertNotNull(mailTemplateTO);
+    }
+
+    @Test
+    public void list() {
+        List<MailTemplateTO> mailTemplateTOs = mailTemplateService.list();
+        assertNotNull(mailTemplateTOs);
+        assertFalse(mailTemplateTOs.isEmpty());
+        for (MailTemplateTO instance : mailTemplateTOs) {
+            assertNotNull(instance);
+        }
+    }
+
+    @Test
+    public void crud() throws IOException {
+        final String key = getUUIDString();
+
+        // 1. create (empty) mail template
+        MailTemplateTO mailTemplateTO = new MailTemplateTO();
+        mailTemplateTO.setKey(key);
+
+        Response response = mailTemplateService.create(mailTemplateTO);
+        assertEquals(201, response.getStatus());
+
+        // 2. attempt to read HTML and TEXT -> fail
+        try {
+            mailTemplateService.getFormat(key, MailTemplateFormat.HTML);
+            fail();
+        } catch (SyncopeClientException e) {
+            assertEquals(ClientExceptionType.NotFound, e.getType());
+        }
+        try {
+            mailTemplateService.getFormat(key, MailTemplateFormat.TEXT);
+            fail();
+        } catch (SyncopeClientException e) {
+            assertEquals(ClientExceptionType.NotFound, e.getType());
+        }
+
+        // 3. set TEXT
+        String textTemplate = "Hi there, I am ${username}.";
+        mailTemplateService.setFormat(
+                key, MailTemplateFormat.TEXT, IOUtils.toInputStream(textTemplate));
+
+        response = mailTemplateService.getFormat(key, MailTemplateFormat.TEXT);
+        assertEquals(200, response.getStatus());
+        assertTrue(response.getMediaType().toString().startsWith(MediaType.TEXT_PLAIN));
+        assertTrue(response.getEntity() instanceof InputStream);
+        assertEquals(textTemplate, IOUtils.toString((InputStream) response.getEntity()));
+
+        // 3. set HTML
+        String htmlTemplate = "<html><body>Hi there, I am ${username}.</body></html>";
+        mailTemplateService.setFormat(
+                key, MailTemplateFormat.HTML, IOUtils.toInputStream(htmlTemplate));
+
+        response = mailTemplateService.getFormat(key, MailTemplateFormat.HTML);
+        assertEquals(200, response.getStatus());
+        assertTrue(response.getMediaType().toString().startsWith(MediaType.TEXT_HTML));
+        assertTrue(response.getEntity() instanceof InputStream);
+        assertEquals(htmlTemplate, IOUtils.toString((InputStream) response.getEntity()));
+
+        // 4. remove HTML
+        mailTemplateService.removeFormat(key, MailTemplateFormat.HTML);
+
+        try {
+            mailTemplateService.getFormat(key, MailTemplateFormat.HTML);
+            fail();
+        } catch (SyncopeClientException e) {
+            assertEquals(ClientExceptionType.NotFound, e.getType());
+        }
+
+        response = mailTemplateService.getFormat(key, MailTemplateFormat.TEXT);
+        assertEquals(200, response.getStatus());
+        assertTrue(response.getMediaType().toString().startsWith(MediaType.TEXT_PLAIN));
+        assertTrue(response.getEntity() instanceof InputStream);
+        assertEquals(textTemplate, IOUtils.toString((InputStream) response.getEntity()));
+
+        // 5. remove mail template
+        mailTemplateService.delete(key);
+
+        try {
+            mailTemplateService.read(key);
+            fail();
+        } catch (SyncopeClientException e) {
+            assertEquals(ClientExceptionType.NotFound, e.getType());
+        }
+        try {
+            mailTemplateService.getFormat(key, MailTemplateFormat.HTML);
+            fail();
+        } catch (SyncopeClientException e) {
+            assertEquals(ClientExceptionType.NotFound, e.getType());
+        }
+        try {
+            mailTemplateService.getFormat(key, MailTemplateFormat.TEXT);
+            fail();
+        } catch (SyncopeClientException e) {
+            assertEquals(ClientExceptionType.NotFound, e.getType());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/2ac6f8d5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 12f9354..ab6bcdc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -389,7 +389,7 @@ under the License.
     <font-awesome.version>4.5.0</font-awesome.version>
     <ionicons.version>2.0.1</ionicons.version>
     <highlightjs.version>8.7</highlightjs.version>
-    <codemirror.version>5.8</codemirror.version>
+    <codemirror.version>5.11</codemirror.version>
     <jsplumb.version>1.7.5</jsplumb.version>
     
     <wicket.version>7.1.0</wicket.version>


Mime
View raw message