Skip to content

Commit

Permalink
Fix skinService test
Browse files Browse the repository at this point in the history
  • Loading branch information
phuong_vu committed Oct 18, 2012
1 parent 5b41037 commit bc2e9af
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ public String toString()
params.put(ResourceRequestHandler.COMPRESS_QN, compress ? "min" : "");
params.put(WebAppController.HANDLER_PARAM, "skin");
params.put(ResourceRequestHandler.RESOURCE_QN, resource);

StringBuilder url = new StringBuilder();
context.renderURL(params, new URIWriter(url, MimeType.PLAIN));
URIWriter writer = new URIWriter(url, MimeType.PLAIN);
writer.append("/" + service.portalContainerName);
context.renderURL(params, writer);

//
return url.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ public String toString()
params.put(ResourceRequestHandler.COMPRESS_QN, compress ? "min" : "");
params.put(WebAppController.HANDLER_PARAM, "skin");
params.put(ResourceRequestHandler.RESOURCE_QN, resource);

StringBuilder url = new StringBuilder();
URIWriter writer = new URIWriter(url, MimeType.PLAIN);
writer.append("/" + service_.portalContainerName);
context.renderURL(params, new URIWriter(url, MimeType.PLAIN));

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.gatein.common.logging.LoggerFactory;
import org.gatein.portal.controller.resource.ResourceRequestHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
Expand Down Expand Up @@ -45,16 +46,13 @@ public String getHandlerName()
}

@Override
public boolean execute(final ControllerContext context) throws Exception
public boolean execute(final ControllerContext context, HttpServletRequest request, final HttpServletResponse response) throws Exception
{
String compressParam = context.getParameter(ResourceRequestHandler.COMPRESS_QN);
boolean compress = "min".equals(compressParam);

//
final HttpServletResponse response = context.getResponse();

// Check if cached resource has not been modifed, return 304 code
long ifModifiedSince = context.getRequest().getDateHeader(IF_MODIFIED_SINCE);
long ifModifiedSince = request.getDateHeader(IF_MODIFIED_SINCE);
long cssLastModified = skinService.getLastModified(context);
if (isNotModified(ifModifiedSince, cssLastModified))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,11 @@ private void processCSSRecursively(ControllerContext context, Appendable appenda
params.put(ResourceRequestHandler.COMPRESS_QN, merge ? "min" : "");
params.put(WebAppController.HANDLER_PARAM, "skin");
params.put(ResourceRequestHandler.RESOURCE_QN, resource);
StringBuilder embeddedPath = new StringBuilder();
context.renderURL(params, new URIWriter(embeddedPath, MimeType.PLAIN));

StringBuilder embeddedPath = new StringBuilder();
URIWriter writer = new URIWriter(embeddedPath, MimeType.PLAIN);
writer.append("/" + portalContainerName);
context.renderURL(params, writer);

//
strReplace.append(matcher.group(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public static ControllerContext newControllerContext(Router router, String reque
{
parameters = matcher.next();
}
return new ControllerContext(null, router, request, null, parameters);
return new ControllerContext(router, parameters);
}
catch (MalformedURLException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.exoplatform.component.test.web.WebAppImpl;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.test.mocks.servlet.MockServletContext;
import org.exoplatform.test.mocks.servlet.MockServletRequest;
import org.exoplatform.web.ControllerContext;
import org.exoplatform.web.application.javascript.JavascriptConfigParser;
import org.exoplatform.web.application.javascript.JavascriptConfigService;
Expand Down Expand Up @@ -153,7 +152,7 @@ public void testGroupingScript() throws Exception

public void testGetJSConfig() throws Exception
{
JSONObject config = jsService.getJSConfig(CONTROLLER_CONTEXT, null);
JSONObject config = jsService.getJSConfig(CONTROLLER_CONTEXT, null, "");

//All SCRIPTS and remote resource have to had dependencies declared in shim configuration
JSONObject shim = config.getJSONObject("shim");
Expand Down Expand Up @@ -187,12 +186,12 @@ public void testGetJSConfig() throws Exception
public void testGenerateURL() throws Exception
{
ResourceId remote1 = new ResourceId(ResourceScope.SHARED, "remote1");
String remoteURL = jsService.generateURL(CONTROLLER_CONTEXT, remote1, false, null);
String remoteURL = jsService.generateURL(CONTROLLER_CONTEXT, remote1, false, null, "");
//Return remote module/script url as it's declared in gatein-resources.xml
assertEquals("http://js/remote1.js", remoteURL);

ResourceId module1 = new ResourceId(ResourceScope.SHARED, "module1");
remoteURL = jsService.generateURL(CONTROLLER_CONTEXT, module1, false, null);
remoteURL = jsService.generateURL(CONTROLLER_CONTEXT, module1, false, null, "");
assertEquals("mock_url_of_module1.js", remoteURL);
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<org.exoplatform.core.version>2.5.0-CR1</org.exoplatform.core.version>
<org.exoplatform.ws.version>2.3.0-CR1</org.exoplatform.ws.version>
<org.exoplatform.jcr.version>1.15.0-CR1</org.exoplatform.jcr.version>
<org.shindig.version>2.0.2.Final-gatein-2</org.shindig.version>
<org.shindig.version>2.0.2-CP02-SNAPSHOT</org.shindig.version>
<nl.captcha.simplecaptcha.version>1.1.1.Final-gatein-2</nl.captcha.simplecaptcha.version>
<org.gatein.common.version>2.1.0.Beta01</org.gatein.common.version>
<org.gatein.wci.version>2.3.0.Beta02</org.gatein.wci.version>
Expand Down

0 comments on commit bc2e9af

Please sign in to comment.