ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adorosz...@apache.org
Subject [1/2] ambari git commit: AMBARI-20394. Missing Content-Type header of woff/ttf files (Attila Magyar via adoroszlai)
Date Thu, 16 Mar 2017 09:29:01 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 373ed97e1 -> cd6f14872
  refs/heads/trunk b37f6f37d -> 167e111bd


AMBARI-20394. Missing Content-Type header of woff/ttf files (Attila Magyar via adoroszlai)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/167e111b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/167e111b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/167e111b

Branch: refs/heads/trunk
Commit: 167e111bd443d27dad940c0db54245d5835e1daf
Parents: b37f6f3
Author: Attila Magyar <amagyar@hortonworks.com>
Authored: Thu Mar 16 10:26:24 2017 +0100
Committer: Attila Doroszlai <adoroszlai@hortonworks.com>
Committed: Thu Mar 16 10:26:24 2017 +0100

----------------------------------------------------------------------
 .../ambari/server/controller/AmbariServer.java    |  6 ++++++
 .../server/controller/AmbariServerTest.java       | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/167e111b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index a2441bd..1f1689a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -790,6 +790,7 @@ public class AmbariServer {
    */
   protected void configureRootHandler(ServletContextHandler root) {
     configureHandlerCompression(root);
+    configureAdditionalContentTypes(root);
     root.setContextPath(CONTEXT_PATH);
     root.setErrorHandler(injector.getInstance(AmbariErrorHandler.class));
     root.setMaxFormContentSize(-1);
@@ -819,6 +820,11 @@ public class AmbariServer {
     }
   }
 
+  private void configureAdditionalContentTypes(ServletContextHandler root) {
+    root.getMimeTypes().addMimeMapping("woff", "application/font-woff");
+    root.getMimeTypes().addMimeMapping("ttf", "application/font-sfnt");
+  }
+
   /**
    * Performs basic configuration of session manager with static values and values from
    * configuration file.

http://git-wip-us.apache.org/repos/asf/ambari/blob/167e111b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
index 85c47fc..f64a97f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
@@ -18,10 +18,12 @@
 
 package org.apache.ambari.server.controller;
 
+import static junit.framework.Assert.assertEquals;
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.createNiceMock;
 import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
 import static org.easymock.EasyMock.partialMockBuilder;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
@@ -55,6 +57,7 @@ import org.apache.ambari.server.state.stack.OsFamily;
 import org.apache.velocity.app.Velocity;
 import org.easymock.EasyMock;
 import org.easymock.EasyMockSupport;
+import org.eclipse.jetty.http.MimeTypes;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.SessionManager;
 import org.eclipse.jetty.servlet.FilterHolder;
@@ -162,6 +165,7 @@ public class AmbariServerTest {
     EasyMock.expectLastCall().once();
     EasyMock.expect(handler.addFilter(GzipFilter.class, "/*",
         EnumSet.of(DispatcherType.REQUEST))).andReturn(filter).once();
+    EasyMock.expect(handler.getMimeTypes()).andReturn(new MimeTypes()).anyTimes();
     replay(handler, filter);
 
     injector.getInstance(AmbariServer.class).configureRootHandler(handler);
@@ -186,6 +190,20 @@ public class AmbariServerTest {
     EasyMock.verify(handler);
   }
 
+  @Test
+  public void testConfigureContentTypes() throws Exception {
+    ServletContextHandler handler = EasyMock.createNiceMock(ServletContextHandler.class);
+    FilterHolder filter = EasyMock.createNiceMock(FilterHolder.class);
+    MimeTypes expectedMimeTypes = new MimeTypes();
+    EasyMock.expect(handler.getMimeTypes()).andReturn(expectedMimeTypes).anyTimes();
+    EasyMock.expect(handler.addFilter(isA(Class.class), anyString(), isA(EnumSet.class))).andReturn(filter).anyTimes();
+    replay(handler, filter);
+    injector.getInstance(AmbariServer.class).configureRootHandler(handler);
+    assertEquals("application/font-woff", expectedMimeTypes.getMimeByExtension("/file.woff").toString());
+    assertEquals("application/font-sfnt", expectedMimeTypes.getMimeByExtension("/file.ttf").toString());
+    EasyMock.verify(handler);
+  }
+
   /**
    * Tests that Jetty pools are configured with the correct number of
    * Acceptor/Selector threads.


Mime
View raw message