You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by jo...@apache.org on 2010/12/09 21:56:50 UTC
svn commit: r1044126 - in /shindig/trunk/java/gadgets/src:
main/java/org/apache/shindig/gadgets/features/
main/java/org/apache/shindig/gadgets/render/
main/java/org/apache/shindig/gadgets/servlet/
main/java/org/apache/shindig/gadgets/templates/tags/ ma...
Author: johnh
Date: Thu Dec 9 20:56:49 2010
New Revision: 1044126
URL: http://svn.apache.org/viewvc?rev=1044126&view=rev
Log:
Expose bundle information from FeatureRegistry.
This CL changes FeatureRegistry getX(...) methods to return a LookupResult rather than a
List<FeatureResource>. This allows FeatureRegistry to be used by other
components in a more intelligent way, exposing API information, subtracting
existing code (ie. for incremental JS load), and so on.
Added:
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/ApiDirective.java
Modified:
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureParser.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriter.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/HttpRequestHandler.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/JsHandler.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandler.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/AllJsIframeVersioner.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultJsVersioner.java
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureParserTest.java
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureRegistryTest.java
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultServiceFetcherTest.java
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriterTest.java
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandlerTest.java
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/AllJsIframeVersionerTest.java
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultJsVersionerTest.java
Added: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/ApiDirective.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/ApiDirective.java?rev=1044126&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/ApiDirective.java (added)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/ApiDirective.java Thu Dec 9 20:56:49 2010
@@ -0,0 +1,71 @@
+/*
+ * 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.shindig.gadgets.features;
+
+/**
+ * Represents a single <exports> or <uses> tag in a
+ * feature manifest. These in turn provide context to compiler/optimizer
+ * code and container code (for gadgets.rpc service IDs).
+ */
+public class ApiDirective {
+ public enum Type {
+ JS("js"),
+ RPC("rpc");
+
+ private final String code;
+
+ private Type(String code) {
+ this.code = code;
+ }
+
+ public static Type fromCode(String code) {
+ for (Type value : Type.values()) {
+ if (value.code.equals(code)) {
+ return value;
+ }
+ }
+ return null;
+ }
+ }
+
+ private final Type type;
+ private final String value;
+ private final boolean isUses;
+
+ ApiDirective(String type, String value, boolean isUses) {
+ this.type = Type.fromCode(type);
+ this.value = value;
+ this.isUses = isUses;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public boolean isUses() {
+ return isUses;
+ }
+
+ public boolean isExports() {
+ return !isUses;
+ }
+}
\ No newline at end of file
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureParser.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureParser.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureParser.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureParser.java Thu Dec 9 20:56:49 2010
@@ -82,7 +82,7 @@ class FeatureParser {
src != null && src.length() != 0 ? null : content,
getAttribs(resourceChild)));
}
- List<ParsedFeature.ApiDirective> apiDirectives = Lists.newArrayList();
+ List<ApiDirective> apiDirectives = Lists.newArrayList();
NodeList apiKids = element.getElementsByTagName("api");
for (int x = 0, y = apiKids.getLength(); x < y; ++x) {
Element apiChild = (Element)apiKids.item(x);
@@ -94,13 +94,13 @@ class FeatureParser {
boolean isImport = "uses".equals(apiElem.getNodeName());
boolean isExport = "exports".equals(apiElem.getNodeName());
if (isImport || isExport) {
- apiDirectives.add(new ParsedFeature.ApiDirective(
+ apiDirectives.add(new ApiDirective(
apiElem.getAttribute("type"), apiElem.getTextContent(), isImport));
}
}
}
}
- bundles.add(new ParsedFeature.Bundle(type, getAttribs(element), resources, apiDirectives));
+ bundles.add(new ParsedFeature.Bundle(name, type, getAttribs(element), resources, apiDirectives));
}
}
}
@@ -143,68 +143,26 @@ class FeatureParser {
return bundles;
}
- public final static class ApiDirective {
- public enum Type {
- JS("js"),
- RPC("rpc");
-
- private final String code;
-
- private Type(String code) {
- this.code = code;
- }
-
- public static Type fromCode(String code) {
- for (Type value : Type.values()) {
- if (value.code.equals(code)) {
- return value;
- }
- }
- return null;
- }
- }
-
- private final Type type;
- private final String value;
- private final boolean isUses;
-
- public ApiDirective(String type, String value, boolean isUses) {
- this.type = Type.fromCode(type);
- this.value = value;
- this.isUses = isUses;
- }
-
- public Type getType() {
- return type;
- }
-
- public String getValue() {
- return value;
- }
-
- public boolean isUses() {
- return isUses;
- }
-
- public boolean isExports() {
- return !isUses;
- }
- }
-
public final static class Bundle {
+ private final String name;
private final String type;
private final Map<String, String> attribs;
private final List<Resource> resources;
private final List<ApiDirective> apiDirectives;
- private Bundle(String type, Map<String, String> attribs,
+ private Bundle(String name, String type, Map<String, String> attribs,
List<Resource> resources, List<ApiDirective> apiDirectives) {
+ this.name = name;
this.type = type;
this.attribs = attribs;
this.resources = resources;
this.apiDirectives = apiDirectives;
}
+ public String getName() {
+ return name;
+ }
+
public String getType() {
return type;
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java Thu Dec 9 20:56:49 2010
@@ -68,7 +68,7 @@ public class FeatureRegistry {
private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
// Map keyed by FeatureNode object created as a lookup for transitive feature deps.
- private final Map<FeatureCacheKey, List<FeatureResource>> cache = new MapMaker().makeMap();
+ private final Map<FeatureCacheKey, LookupResult> cache = new MapMaker().makeMap();
private final FeatureParser parser;
private final FeatureResourceLoader resourceLoader;
@@ -76,14 +76,18 @@ public class FeatureRegistry {
/**
- *
+ * Construct a new FeatureRegistry, using resourceLoader to load actual resources,
+ * and loading data from the list of features provided, each of which points to a
+ * directory (whose .xml files will be scanned), file (interpreted as feature.xml),
+ * or resource (interpreted as feature.xml).
* @param resourceLoader
- * @param featuresoo
+ * @param features
* @throws GadgetException
*/
@Inject
public FeatureRegistry(FeatureResourceLoader resourceLoader,
- @Named("org.apache.shindig.features") List<String> features) throws GadgetException {
+ @Named("org.apache.shindig.features") List<String> features)
+ throws GadgetException {
this.parser = new FeatureParser();
this.resourceLoader = resourceLoader;
@@ -118,7 +122,8 @@ public class FeatureRegistry {
* them with a comma.
* @throws GadgetException If any of the files can't be read, are malformed, or invalid.
*/
- protected ImmutableMap<String,FeatureNode> register(List<String> resourceList) throws GadgetException {
+ protected ImmutableMap<String, FeatureNode> register(List<String> resourceList)
+ throws GadgetException {
Map<String,FeatureNode> featureMapBuilder = Maps.newHashMap();
try {
@@ -135,7 +140,8 @@ public class FeatureRegistry {
location = location.substring(1);
}
if (LOG.isLoggable(Level.INFO)) {
- LOG.logp(Level.INFO, classname, "register", MessageKeys.LOAD_RESOURCES_FROM, new Object[] {uriLoc.toString()});
+ LOG.logp(Level.INFO, classname, "register",
+ MessageKeys.LOAD_RESOURCES_FROM, new Object[] {uriLoc.toString()});
}
if (location.endsWith(".txt")) {
// Text file contains a list of other resource files to load
@@ -155,7 +161,8 @@ public class FeatureRegistry {
} else {
// Load files in directory structure.
if (LOG.isLoggable(Level.INFO)) {
- LOG.logp(Level.INFO, classname, "register", MessageKeys.LOAD_FILES_FROM, new Object[] {location});
+ LOG.logp(Level.INFO, classname, "register",
+ MessageKeys.LOAD_FILES_FROM, new Object[] {location});
}
loadFile(new File(uriLoc.getPath()), featureMapBuilder);
}
@@ -181,10 +188,10 @@ public class FeatureRegistry {
* @param ctx Context for the request.
* @param needed List of all needed features.
* @param unsupported If non-null, a List populated with unknown features from the needed list.
- * @return List of FeatureResources that may be used to render the needed features.
+ * @return LookupResult object that may be used to render the needed features.
* @throws GadgetException
*/
- public List<FeatureResource> getFeatureResources(
+ public LookupResult getFeatureResources(
GadgetContext ctx, Collection<String> needed, List<String> unsupported, boolean transitive) {
boolean useCache = (transitive && !ctx.getIgnoreCache());
FeatureCacheKey cacheKey = new FeatureCacheKey(needed, ctx, unsupported != null);
@@ -200,8 +207,10 @@ public class FeatureRegistry {
featureNodes = getRequestedNodes(needed, unsupported);
}
- String targetBundleType = ctx.getRenderingContext() == RenderingContext.CONTAINER ? "container" : "gadget";
- ImmutableList.Builder<FeatureResource> resourcesBuilder = new ImmutableList.Builder<FeatureResource>();
+ String targetBundleType =
+ ctx.getRenderingContext() == RenderingContext.CONTAINER ? "container" : "gadget";
+ ImmutableList.Builder<FeatureBundle> bundlesBuilder =
+ new ImmutableList.Builder<FeatureBundle>();
for (FeatureNode entry : featureNodes) {
boolean specificContainerMatched = false;
@@ -211,7 +220,7 @@ public class FeatureRegistry {
String containerAttrib = bundle.getAttribs().get("container");
if (containerAttrib != null) {
if (containerMatch(containerAttrib, ctx.getContainer())) {
- resourcesBuilder.addAll(bundle.getResources());
+ bundlesBuilder.add(bundle);
specificContainerMatched = true;
}
} else {
@@ -222,16 +231,17 @@ public class FeatureRegistry {
}
if (!specificContainerMatched) {
for (FeatureBundle bundle : noContainerBundles) {
- resourcesBuilder.addAll(bundle.getResources());
+ bundlesBuilder.add(bundle);
}
}
}
- List<FeatureResource> resources = resourcesBuilder.build();
+
+ LookupResult result = new LookupResult(bundlesBuilder.build());
if (useCache && (unsupported == null || unsupported.isEmpty())) {
- cache.put(cacheKey, resources);
+ cache.put(cacheKey, result);
}
- return resources;
+ return result;
}
/**
@@ -241,7 +251,8 @@ public class FeatureRegistry {
* @param unsupported If non-null, a List populated with unknown features from the needed list.
* @return List of FeatureResources that may be used to render the needed features.
*/
- public List<FeatureResource> getFeatureResources(GadgetContext ctx, Collection<String> needed, List<String> unsupported) {
+ public LookupResult getFeatureResources(GadgetContext ctx, Collection<String> needed,
+ List<String> unsupported) {
return getFeatureResources(ctx, needed, unsupported, true);
}
@@ -251,7 +262,7 @@ public class FeatureRegistry {
* JS checksum.
* @return List of all known (RenderingContext.GADGET) FeatureResources.
*/
- public List<FeatureResource> getAllFeatures() {
+ public LookupResult getAllFeatures() {
return getFeatureResources(new GadgetContext(), featureMap.keySet(), null);
}
@@ -297,7 +308,8 @@ public class FeatureRegistry {
return uri;
}
- private List<FeatureNode> getTransitiveDeps(Collection<String> needed, List<String> unsupported) {
+ private List<FeatureNode> getTransitiveDeps(
+ Collection<String> needed, List<String> unsupported) {
final List<FeatureNode> requested = getRequestedNodes(needed, unsupported);
Comparator<FeatureNode> nodeDepthComparator = new Comparator<FeatureNode>() {
@@ -334,7 +346,8 @@ public class FeatureRegistry {
return fullDeps;
}
- private List<FeatureNode> getRequestedNodes(Collection<String> needed, List<String> unsupported) {
+ private List<FeatureNode> getRequestedNodes(
+ Collection<String> needed, List<String> unsupported) {
List<FeatureNode> requested = Lists.newArrayList();
for (String featureName : needed) {
if (featureMap.containsKey(featureName)) {
@@ -394,7 +407,8 @@ public class FeatureRegistry {
}
}
- private void loadResources(List<String> resources, Map<String,FeatureNode> featureMapBuilder) throws GadgetException {
+ private void loadResources(List<String> resources, Map<String,FeatureNode> featureMapBuilder)
+ throws GadgetException {
try {
for (String resource : resources) {
if (LOG.isLoggable(Level.FINE)) {
@@ -410,7 +424,8 @@ public class FeatureRegistry {
}
}
- private void loadFile(File file, Map<String,FeatureNode> featureMapBuilder) throws GadgetException, IOException {
+ private void loadFile(File file, Map<String,FeatureNode> featureMapBuilder)
+ throws GadgetException, IOException {
if (!file.exists() || !file.canRead()) {
throw new GadgetException(GadgetException.Code.INVALID_CONFIG,
"Feature file '" + file.getPath() + "' doesn't exist or can't be read");
@@ -447,7 +462,8 @@ public class FeatureRegistry {
// Duplicate feature = OK, just indicate it's being overridden.
if (featureMapBuilder.containsKey(parsed.getName())) {
if (LOG.isLoggable(Level.WARNING)) {
- LOG.logp(Level.WARNING, classname, "doFilter", MessageKeys.OVERRIDING_FEATURE, new Object[] {parsed.getName(),parent});
+ LOG.logp(Level.WARNING, classname, "doFilter", MessageKeys.OVERRIDING_FEATURE,
+ new Object[] {parsed.getName(),parent});
}
}
@@ -464,18 +480,21 @@ public class FeatureRegistry {
getResourceAttribs(parsedBundle.getAttribs(), parsedResource.getAttribs())));
}
}
- bundles.add(new FeatureBundle(parsedBundle.getType(), parsedBundle.getAttribs(), resources));
+ bundles.add(new FeatureBundle(parsedBundle, resources));
}
// Add feature to the master Map. The dependency tree isn't connected/validated/linked yet.
- featureMapBuilder.put(parsed.getName(), new FeatureNode(parsed.getName(), bundles, parsed.getDeps()));
+ featureMapBuilder.put(parsed.getName(),
+ new FeatureNode(parsed.getName(), bundles, parsed.getDeps()));
}
private Map<String, String> getResourceAttribs(Map<String, String> bundleAttribs,
Map<String, String> resourceAttribs) {
- // For a given resource, attribs are a merge (by key, not by value) of bundle attribs and per-resource
- // attribs, the latter serving as higher-precedence overrides.
- return ImmutableMap.<String, String>builder().putAll(bundleAttribs).putAll(resourceAttribs).build();
+ // For a given resource, attribs are a merge (by key, not by value) of bundle attribs and
+ // per-resource attribs, the latter serving as higher-precedence overrides.
+ return ImmutableMap.<String, String>builder()
+ .putAll(bundleAttribs)
+ .putAll(resourceAttribs).build();
}
private static final class InlineFeatureResource extends FeatureResource.Default {
@@ -493,29 +512,58 @@ public class FeatureRegistry {
return content;
}
}
+
+ public static class LookupResult {
+ private final List<FeatureBundle> bundles;
+ private final List<FeatureResource> allResources;
+
+ private LookupResult(List<FeatureBundle> bundles) {
+ this.bundles = bundles;
+ ImmutableList.Builder<FeatureResource> resourcesBuilder = ImmutableList.builder();
+ for (FeatureBundle bundle : getBundles()) {
+ resourcesBuilder.addAll(bundle.getResources());
+ }
+ this.allResources = resourcesBuilder.build();
+ }
+
+ public List<FeatureBundle> getBundles() {
+ return bundles;
+ }
+
+ public List<FeatureResource> getResources() {
+ return allResources;
+ }
+ }
- private static final class FeatureBundle {
- private final String type;
- private final Map<String, String> attribs;
+ public static final class FeatureBundle {
+ private final FeatureParser.ParsedFeature.Bundle bundle;
private final List<FeatureResource> resources;
- private FeatureBundle(String type, Map<String, String> attribs, List<FeatureResource> resources) {
- this.type = type;
- this.attribs = ImmutableMap.copyOf(attribs);
+ private FeatureBundle(FeatureParser.ParsedFeature.Bundle bundle,
+ List<FeatureResource> resources) {
+ this.bundle = bundle;
this.resources = ImmutableList.copyOf(resources);
}
+ public String getName() {
+ return bundle.getName();
+ }
+
public String getType() {
- return type;
+ return bundle.getType();
}
public Map<String, String> getAttribs() {
- return attribs;
+ return bundle.getAttribs();
}
public List<FeatureResource> getResources() {
return resources;
}
+
+ public List<ApiDirective> getApis() {
+ return bundle.getApis();
+ }
}
private static final class FeatureNode {
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriter.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriter.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriter.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriter.java Thu Dec 9 20:56:49 2010
@@ -242,7 +242,7 @@ public class RenderingGadgetRewriter imp
List<String> unsupported = Lists.newLinkedList();
List<FeatureResource> externForcedResources =
- featureRegistry.getFeatureResources(context, externForcedLibs, unsupported);
+ featureRegistry.getFeatureResources(context, externForcedLibs, unsupported).getResources();
if (!unsupported.isEmpty()) {
if (LOG.isLoggable(Level.INFO)) {
LOG.logp(Level.INFO, classname, "injectFeatureLibraries", MessageKeys.UNKNOWN_FEATURES, new Object[] {unsupported.toString()});
@@ -254,7 +254,7 @@ public class RenderingGadgetRewriter imp
Map<String, Feature> featureMap = gadget.getSpec().getModulePrefs().getFeatures();
List<String> gadgetFeatureKeys = Lists.newArrayList(gadget.getDirectFeatureDeps());
List<FeatureResource> gadgetResources =
- featureRegistry.getFeatureResources(context, gadgetFeatureKeys, unsupported);
+ featureRegistry.getFeatureResources(context, gadgetFeatureKeys, unsupported).getResources();
if (!unsupported.isEmpty()) {
List<String> requiredUnsupported = Lists.newLinkedList();
for (String notThere : unsupported) {
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/HttpRequestHandler.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/HttpRequestHandler.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/HttpRequestHandler.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/HttpRequestHandler.java Thu Dec 9 20:56:49 2010
@@ -29,7 +29,6 @@ import org.apache.shindig.gadgets.http.H
import org.apache.shindig.gadgets.http.HttpResponse;
import org.apache.shindig.gadgets.http.RequestPipeline;
import org.apache.shindig.gadgets.oauth.OAuthArguments;
-import org.apache.shindig.gadgets.rewrite.ResponseRewriterList;
import org.apache.shindig.gadgets.rewrite.ResponseRewriterList.RewriteFlow;
import org.apache.shindig.gadgets.rewrite.ResponseRewriterRegistry;
import org.apache.shindig.gadgets.rewrite.RewriterRegistry;
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/JsHandler.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/JsHandler.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/JsHandler.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/JsHandler.java Thu Dec 9 20:56:49 2010
@@ -45,7 +45,9 @@ public class JsHandler {
protected final Map<String, ConfigContributor> configContributors;
@Inject
- public JsHandler(FeatureRegistry registry, ContainerConfig containerConfig,
+ public JsHandler(
+ FeatureRegistry registry,
+ ContainerConfig containerConfig,
Map<String, ConfigContributor> configContributors) {
this.registry = registry;
this.containerConfig = containerConfig;
@@ -65,7 +67,7 @@ public class JsHandler {
StringBuilder jsData = new StringBuilder();
Collection<String> needed = jsUri.getLibs();
Collection<? extends FeatureResource> resources =
- registry.getFeatureResources(ctx, needed, null);
+ registry.getFeatureResources(ctx, needed, null).getResources();
String container = ctx.getContainer();
boolean isProxyCacheable = true;
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandler.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandler.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandler.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandler.java Thu Dec 9 20:56:49 2010
@@ -203,7 +203,7 @@ public class FlashTagHandler extends Abs
swfobject.setAttribute("type", "text/javascript");
List<FeatureResource> resources =
featureRegistry.getFeatureResources(processor.getTemplateContext().getGadget().getContext(),
- ImmutableSet.of(SWFOBJECT), null);
+ ImmutableSet.of(SWFOBJECT), null).getResources();
for (FeatureResource resource : resources) {
// Emits all content for feature SWFOBJECT, which has no downstream dependencies.
swfobject.setTextContent(resource.getContent());
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/AllJsIframeVersioner.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/AllJsIframeVersioner.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/AllJsIframeVersioner.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/AllJsIframeVersioner.java Thu Dec 9 20:56:49 2010
@@ -48,7 +48,7 @@ public class AllJsIframeVersioner implem
@Inject
public AllJsIframeVersioner(FeatureRegistry registry) {
StringBuilder jsBuf = new StringBuilder();
- for (FeatureResource resource : registry.getAllFeatures()) {
+ for (FeatureResource resource : registry.getAllFeatures().getResources()) {
jsBuf.append(resource.getContent()).append(resource.getDebugContent());
}
allJsChecksum = HashUtil.checksum(jsBuf.toString().getBytes());
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultJsVersioner.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultJsVersioner.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultJsVersioner.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultJsVersioner.java Thu Dec 9 20:56:49 2010
@@ -62,7 +62,8 @@ public class DefaultJsVersioner implemen
};
// Registry itself will cache these requests.
- List<FeatureResource> resources = registry.getFeatureResources(ctx, extern, null);
+ List<FeatureResource> resources =
+ registry.getFeatureResources(ctx, extern, null).getResources();
if (versionCache.containsKey(resources)) {
return versionCache.get(resources);
}
Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureParserTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureParserTest.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureParserTest.java (original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureParserTest.java Thu Dec 9 20:56:49 2010
@@ -90,19 +90,19 @@ public class FeatureParserTest {
assertEquals(1, bundle1.getResources().get(1).getAttribs().size());
assertEquals("gadget_value", bundle1.getResources().get(1).getAttribs().get("gadget_attrib"));
assertEquals(5, bundle1.getApis().size());
- assertEquals(FeatureParser.ParsedFeature.ApiDirective.Type.JS, bundle1.getApis().get(0).getType());
+ assertEquals(ApiDirective.Type.JS, bundle1.getApis().get(0).getType());
assertTrue(bundle1.getApis().get(0).isUses());
assertEquals("foo.symbol", bundle1.getApis().get(0).getValue());
- assertEquals(FeatureParser.ParsedFeature.ApiDirective.Type.RPC, bundle1.getApis().get(1).getType());
+ assertEquals(ApiDirective.Type.RPC, bundle1.getApis().get(1).getType());
assertFalse(bundle1.getApis().get(1).isUses());
assertEquals("rpc_service", bundle1.getApis().get(1).getValue());
- assertEquals(FeatureParser.ParsedFeature.ApiDirective.Type.JS, bundle1.getApis().get(2).getType());
+ assertEquals(ApiDirective.Type.JS, bundle1.getApis().get(2).getType());
assertFalse(bundle1.getApis().get(2).isUses());
assertEquals("bar.symbol", bundle1.getApis().get(2).getValue());
- assertEquals(FeatureParser.ParsedFeature.ApiDirective.Type.RPC, bundle1.getApis().get(3).getType());
+ assertEquals(ApiDirective.Type.RPC, bundle1.getApis().get(3).getType());
assertTrue(bundle1.getApis().get(3).isUses());
assertEquals("uses_service", bundle1.getApis().get(3).getValue());
- assertEquals(FeatureParser.ParsedFeature.ApiDirective.Type.JS, bundle1.getApis().get(4).getType());
+ assertEquals(ApiDirective.Type.JS, bundle1.getApis().get(4).getType());
assertTrue(bundle1.getApis().get(4).isUses());
assertEquals("last.symbol", bundle1.getApis().get(4).getValue());
Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureRegistryTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureRegistryTest.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureRegistryTest.java (original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureRegistryTest.java Thu Dec 9 20:56:49 2010
@@ -118,7 +118,7 @@ public class FeatureRegistryTest {
registry = new TestFeatureRegistry(withScheme ? featureFile.toString() : featureFile.getPath());
// Verify single resource works all the way through.
- List<FeatureResource> resources = registry.getAllFeatures();
+ List<FeatureResource> resources = registry.getAllFeatures().getResources();
assertEquals(1, resources.size());
assertEquals(content, resources.get(0).getContent());
}
@@ -150,7 +150,7 @@ public class FeatureRegistryTest {
registry = new TestFeatureRegistry(childDir.toURI().toString());
// Verify single resource works all the way through.
- List<FeatureResource> resources = registry.getAllFeatures();
+ List<FeatureResource> resources = registry.getAllFeatures().getResources();
assertEquals(1, resources.size());
assertEquals(content, resources.get(0).getContent());
}
@@ -163,7 +163,7 @@ public class FeatureRegistryTest {
registry = new TestFeatureRegistry(featureUri.toString());
// Verify single resource works all the way through.
- List<FeatureResource> resources = registry.getAllFeatures();
+ List<FeatureResource> resources = registry.getAllFeatures().getResources();
assertEquals(1, resources.size());
assertEquals(content, resources.get(0).getContent());
}
@@ -177,7 +177,7 @@ public class FeatureRegistryTest {
registry = new TestFeatureRegistry(featureUri.toString());
// Verify single resource works all the way through.
- List<FeatureResource> resources = registry.getAllFeatures();
+ List<FeatureResource> resources = registry.getAllFeatures().getResources();
assertEquals(1, resources.size());
assertEquals(content, resources.get(0).getContent());
}
@@ -200,7 +200,7 @@ public class FeatureRegistryTest {
registry = new TestFeatureRegistry(txtFile.toString());
// Contents should be ordered based on the way they went in.
- List<FeatureResource> resources = registry.getAllFeatures();
+ List<FeatureResource> resources = registry.getAllFeatures().getResources();
assertEquals(2, resources.size());
assertEquals(content2, resources.get(0).getContent());
assertEquals(content1, resources.get(1).getContent());
@@ -218,18 +218,18 @@ public class FeatureRegistryTest {
Uri feature2Uri = expectResource(xml(BOTTOM_TPL, "gadget", content2Uri.getPath(), null));
registry = new TestFeatureRegistry(feature1Uri.toString());
- List<FeatureResource> resources1 = registry.getAllFeatures();
+ List<FeatureResource> resources1 = registry.getAllFeatures().getResources();
assertEquals(1, resources1.size());
assertEquals(content1, resources1.get(0).getContent());
// Register it again, different def.
registry = new TestFeatureRegistry(feature2Uri.toString());
- List<FeatureResource> resources2 = registry.getAllFeatures();
+ List<FeatureResource> resources2 = registry.getAllFeatures().getResources();
assertEquals(1, resources2.size());
assertEquals(content2, resources2.get(0).getContent());
// Check cached resources too.
- List<FeatureResource> resourcesAgain = registry.getAllFeatures();
+ List<FeatureResource> resourcesAgain = registry.getAllFeatures().getResources();
assertSame(resources2, resourcesAgain);
}
@@ -249,11 +249,11 @@ public class FeatureRegistryTest {
List<String> needed = Lists.newArrayList("bottom");
List<String> unsupported = Lists.newArrayList();
List<FeatureResource> resources = registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, theContainer), needed, unsupported);
+ getCtx(RenderingContext.GADGET, theContainer), needed, unsupported).getResources();
// Retrieve again w/ no unsupported list.
List<FeatureResource> resourcesUnsup = registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, theContainer), needed, null);
+ getCtx(RenderingContext.GADGET, theContainer), needed, null).getResources();
assertNotSame(resources, resourcesUnsup);
assertEquals(resources, resourcesUnsup);
@@ -262,16 +262,16 @@ public class FeatureRegistryTest {
// Now make sure the cache DOES work when needed.
List<FeatureResource> resources2 = registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, theContainer), needed, unsupported);
+ getCtx(RenderingContext.GADGET, theContainer), needed, unsupported).getResources();
assertSame(resources, resources2);
List<FeatureResource> resourcesUnsup2 = registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, theContainer), needed, null);
+ getCtx(RenderingContext.GADGET, theContainer), needed, null).getResources();
assertSame(resourcesUnsup, resourcesUnsup2);
// Lastly, ensure that ignoreCache is properly accounted.
List<FeatureResource> resourcesIgnoreCache = registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, theContainer, true), needed, unsupported);
+ getCtx(RenderingContext.GADGET, theContainer, true), needed, unsupported).getResources();
assertNotSame(resources, resourcesIgnoreCache);
assertEquals(1, resourcesIgnoreCache.size());
assertEquals(content1, resourcesIgnoreCache.get(0).getContent());
@@ -293,15 +293,15 @@ public class FeatureRegistryTest {
List<String> needed = Lists.newArrayList("bottom");
List<String> unsupported = Lists.newArrayList();
List<FeatureResource> resources = registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, theContainer), needed, unsupported);
+ getCtx(RenderingContext.GADGET, theContainer), needed, unsupported).getResources();
// Retrieve again w/ mismatch container.
List<FeatureResource> resourcesNoMatch = registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, "foo"), needed, unsupported);
+ getCtx(RenderingContext.GADGET, "foo"), needed, unsupported).getResources();
// Retrieve again w/ mismatched context.
List<FeatureResource> ctxMismatch = registry.getFeatureResources(
- getCtx(RenderingContext.CONTAINER, theContainer), needed, unsupported);
+ getCtx(RenderingContext.CONTAINER, theContainer), needed, unsupported).getResources();
assertNotSame(resources, resourcesNoMatch);
assertNotSame(resources, ctxMismatch);
@@ -314,30 +314,21 @@ public class FeatureRegistryTest {
// Make sure caches work with appropriate matching.
List<FeatureResource> resources2 = registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, theContainer), needed, unsupported);
+ getCtx(RenderingContext.GADGET, theContainer), needed, unsupported).getResources();
assertSame(resources, resources2);
List<FeatureResource> resourcesNoMatch2 = registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, "foo"), needed, unsupported);
+ getCtx(RenderingContext.GADGET, "foo"), needed, unsupported).getResources();
assertSame(resourcesNoMatch, resourcesNoMatch2);
List<FeatureResource> ctxMismatch2 = registry.getFeatureResources(
- getCtx(RenderingContext.CONTAINER, theContainer), needed, unsupported);
+ getCtx(RenderingContext.CONTAINER, theContainer), needed, unsupported).getResources();
assertSame(ctxMismatch, ctxMismatch2);
// Check ignoreCache
List<FeatureResource> resourcesIC = registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, theContainer, true), needed, unsupported);
+ getCtx(RenderingContext.GADGET, theContainer, true), needed, unsupported).getResources();
assertNotSame(resources, resourcesIC);
-
-// bogus tests - both requests return EMPTY_LIST now, so you can't ascertain cache behavior.
-// List<FeatureResource> resourcesNoMatchIC = registry.getFeatureResources(
-// getCtx(RenderingContext.GADGET, "foo", true), needed, unsupported);
-// assertNotSame(resourcesNoMatch, resourcesNoMatchIC);
-//
-// List<FeatureResource> ctxMismatchIC = registry.getFeatureResources(
-// getCtx(RenderingContext.CONTAINER, theContainer, true), needed, unsupported);
-// assertNotSame(ctxMismatch, ctxMismatchIC);
}
@Test
@@ -378,7 +369,7 @@ public class FeatureRegistryTest {
GadgetContext ctx = getCtx(rctx, null);
List<String> needed = Lists.newArrayList("nodep", "bottom");
List<String> unsupported = Lists.newLinkedList();
- List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported);
+ List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported).getResources();
assertEquals(0, unsupported.size());
assertEquals(2, resources.size());
assertEquals("nodep", resources.get(0).getContent());
@@ -401,7 +392,7 @@ public class FeatureRegistryTest {
GadgetContext ctx = getCtx(rctx, null);
List<String> needed = Lists.newArrayList("nodep", "bottom");
List<String> unsupported = Lists.newLinkedList();
- List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported);
+ List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported).getResources();
assertEquals(0, resources.size());
}
@@ -424,7 +415,7 @@ public class FeatureRegistryTest {
// Should come back in insertable order (from bottom of the graph up),
// querying in feature.xml dependency order.
- List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported);
+ List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported).getResources();
assertEquals(5, resources.size());
assertEquals("bottom", resources.get(0).getContent());
assertEquals("mid_a", resources.get(1).getContent());
@@ -441,7 +432,7 @@ public class FeatureRegistryTest {
GadgetContext ctx = getCtx(RenderingContext.GADGET, null);
List<String> needed = Lists.newArrayList("nodep", "does-not-exist");
List<String> unsupported = Lists.newLinkedList();
- List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported);
+ List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported).getResources();
assertEquals(1, resources.size());
assertEquals("nodep", resources.get(0).getContent());
assertEquals(1, unsupported.size());
@@ -455,7 +446,7 @@ public class FeatureRegistryTest {
GadgetContext ctx = getCtx(RenderingContext.GADGET, "two");
List<String> needed = Lists.newArrayList("nodep", "bottom");
List<String> unsupported = Lists.newLinkedList();
- List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported);
+ List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported).getResources();
assertEquals(2, resources.size());
assertEquals("nodep", resources.get(0).getContent());
assertEquals("bottom", resources.get(1).getContent());
@@ -469,7 +460,7 @@ public class FeatureRegistryTest {
GadgetContext ctx = getCtx(RenderingContext.GADGET, "four");
List<String> needed = Lists.newArrayList("nodep", "bottom");
List<String> unsupported = Lists.newLinkedList();
- List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported);
+ List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported).getResources();
assertEquals(0, resources.size()); // no resource matches but all feature keys valid
assertEquals(0, unsupported.size());
}
@@ -480,7 +471,7 @@ public class FeatureRegistryTest {
GadgetContext ctx = getCtx(RenderingContext.GADGET, null);
List<String> needed = Lists.newArrayList("top", "bottom");
List<String> unsupported = Lists.newLinkedList();
- List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported, false);
+ List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported, false).getResources();
// Should return in order requested.
assertEquals(2, resources.size());
assertEquals("top", resources.get(0).getContent());
@@ -491,7 +482,7 @@ public class FeatureRegistryTest {
@Test
public void getAllFeatures() throws Exception {
setupFullRegistry("gadget", null);
- List<FeatureResource> resources = registry.getAllFeatures();
+ List<FeatureResource> resources = registry.getAllFeatures().getResources();
// No guaranteed order (top/mid/bottom bundle may be before nodep)
// Just check that there are 5 resources around and let the above tests
@@ -564,7 +555,7 @@ public class FeatureRegistryTest {
List<String> unsupported = Lists.newLinkedList();
List<FeatureResource> resources =
registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, container), needed, unsupported);
+ getCtx(RenderingContext.GADGET, container), needed, unsupported).getResources();
assertEquals(1, resources.size());
assertEquals(containerContent, resources.get(0).getContent());
}
@@ -583,7 +574,7 @@ public class FeatureRegistryTest {
List<String> unsupported = Lists.newLinkedList();
List<FeatureResource> resources =
registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, "othercontainer"), needed, unsupported);
+ getCtx(RenderingContext.GADGET, "othercontainer"), needed, unsupported).getResources();
assertEquals(1, resources.size());
assertEquals(defaultContent, resources.get(0).getContent());
}
@@ -622,7 +613,7 @@ public class FeatureRegistryTest {
List<String> needed = Lists.newArrayList("bottom");
List<String> unsupported = Lists.newArrayList();
List<FeatureResource> resources = registry.getFeatureResources(
- getCtx(RenderingContext.GADGET, theContainer), needed, unsupported);
+ getCtx(RenderingContext.GADGET, theContainer), needed, unsupported).getResources();
// Sanity test.
assertEquals(1, resources.size());
Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultServiceFetcherTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultServiceFetcherTest.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultServiceFetcherTest.java (original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultServiceFetcherTest.java Thu Dec 9 20:56:49 2010
@@ -28,7 +28,6 @@ import org.apache.shindig.config.Contain
import org.apache.shindig.config.JsonContainerConfig;
import org.apache.shindig.expressions.Expressions;
import org.apache.shindig.expressions.Functions;
-import org.apache.shindig.expressions.ShindigTypeConverter;
import org.apache.shindig.gadgets.http.HttpFetcher;
import org.apache.shindig.gadgets.http.HttpRequest;
import org.apache.shindig.gadgets.http.HttpResponse;
Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriterTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriterTest.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriterTest.java (original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriterTest.java Thu Dec 9 20:56:49 2010
@@ -733,17 +733,23 @@ public class RenderingGadgetRewriterTest
Gadget gadget = makeGadgetWithSpec(gadgetXml);
reset(featureRegistry);
+ FeatureRegistry.LookupResult lr = createMock(FeatureRegistry.LookupResult.class);
+ expect(lr.getResources()).andReturn(ImmutableList.<FeatureResource>of());
+ replay(lr);
expect(featureRegistry.getFeatureResources(same(gadget.getContext()),
eq(ImmutableSet.<String>of()), eq(Lists.<String>newArrayList())))
- .andReturn(ImmutableList.<FeatureResource>of());
+ .andReturn(lr);
+ final FeatureRegistry.LookupResult lr2 = createMock(FeatureRegistry.LookupResult.class);
+ expect(lr2.getResources()).andReturn(ImmutableList.<FeatureResource>of());
+ replay(lr2);
expect(featureRegistry.getFeatureResources(same(gadget.getContext()),
eq(ImmutableList.<String>of("foo", "core")), eq(Lists.<String>newArrayList())))
- .andAnswer(new IAnswer<List<FeatureResource>>() {
+ .andAnswer(new IAnswer<FeatureRegistry.LookupResult>() {
@SuppressWarnings("unchecked")
- public List<FeatureResource> answer() throws Throwable {
+ public FeatureRegistry.LookupResult answer() throws Throwable {
List<String> unsupported = (List<String>)getCurrentArguments()[2];
unsupported.add("foo");
- return Lists.newArrayList();
+ return lr2;
}
});
replay(featureRegistry);
@@ -772,19 +778,22 @@ public class RenderingGadgetRewriterTest
Gadget gadget = makeGadgetWithSpec(gadgetXml).setContext(context);
reset(featureRegistry);
+ final FeatureRegistry.LookupResult lr = createMock(FeatureRegistry.LookupResult.class);
+ expect(lr.getResources()).andReturn(ImmutableList.<FeatureResource>of()).anyTimes();
+ replay(lr);
expect(featureRegistry.getFeatureResources(same(gadget.getContext()),
eq(ImmutableSet.<String>of("bar")), eq(Lists.<String>newArrayList())))
- .andAnswer(new IAnswer<List<FeatureResource>>() {
+ .andAnswer(new IAnswer<FeatureRegistry.LookupResult>() {
@SuppressWarnings("unchecked")
- public List<FeatureResource> answer() throws Throwable {
+ public FeatureRegistry.LookupResult answer() throws Throwable {
List<String> unsupported = (List<String>)getCurrentArguments()[2];
unsupported.add("bar");
- return Lists.newArrayList();
+ return lr;
}
});
expect(featureRegistry.getFeatureResources(same(gadget.getContext()),
eq(ImmutableList.<String>of("core")), eq(Lists.<String>newArrayList())))
- .andReturn(ImmutableList.<FeatureResource>of());
+ .andReturn(lr);
expect(featureRegistry.getFeatures(eq(ImmutableList.of("core", "bar"))))
.andReturn(ImmutableList.of("core"));
expect(featureRegistry.getFeatures(eq(ImmutableList.of("core"))))
@@ -952,10 +961,16 @@ public class RenderingGadgetRewriterTest
List<String> allFeaturesAndLibs = Lists.newArrayList(gadgetFeatures);
allFeaturesAndLibs.addAll(externLibs);
List<String> emptyList = Lists.newArrayList();
+ final FeatureRegistry.LookupResult externLr = createMock(FeatureRegistry.LookupResult.class);
+ expect(externLr.getResources()).andReturn(externResources);
+ replay(externLr);
+ final FeatureRegistry.LookupResult gadgetLr = createMock(FeatureRegistry.LookupResult.class);
+ expect(gadgetLr.getResources()).andReturn(gadgetResources);
+ replay(gadgetLr);
expect(featureRegistry.getFeatureResources(same(gadgetContext), eq(externLibs), eq(emptyList)))
- .andReturn(externResources);
+ .andReturn(externLr);
expect(featureRegistry.getFeatureResources(same(gadgetContext), eq(gadgetFeatures),
- eq(emptyList))).andReturn(gadgetResources);
+ eq(emptyList))).andReturn(gadgetLr);
expect(featureRegistry.getFeatures(eq(allFeatures)))
.andReturn(allFeatures);
expect(featureRegistry.getFeatures(eq(allFeaturesAndLibs)))
Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandlerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandlerTest.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandlerTest.java (original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandlerTest.java Thu Dec 9 20:56:49 2010
@@ -92,9 +92,12 @@ public class FlashTagHandlerTest extends
private void expectFeatureLookup() throws GadgetException {
List<FeatureResource> swfObjectResources = Lists.newArrayList();
swfObjectResources.add(new SwfResource());
+ final FeatureRegistry.LookupResult lr = EasyMock.createMock(FeatureRegistry.LookupResult.class);
+ EasyMock.expect(lr.getResources()).andReturn(swfObjectResources);
+ EasyMock.replay(lr);
EasyMock.expect(featureRegistry
.getFeatureResources(isA(GadgetContext.class), eq(ImmutableSet.of("swfobject")),
- EasyMock.<List<String>>isNull())).andReturn(swfObjectResources);
+ EasyMock.<List<String>>isNull())).andReturn(lr);
}
private static class SwfResource extends FeatureResource.Default {
Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/AllJsIframeVersionerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/AllJsIframeVersionerTest.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/AllJsIframeVersionerTest.java (original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/AllJsIframeVersionerTest.java Thu Dec 9 20:56:49 2010
@@ -53,7 +53,10 @@ public class AllJsIframeVersionerTest {
FeatureRegistry registry = createMock(FeatureRegistry.class);
FeatureResource resource = new FeatureResource.Simple(featureContent, debugContent);
List<FeatureResource> allResources = Lists.newArrayList(resource);
- expect(registry.getAllFeatures()).andReturn(allResources).once();
+ final FeatureRegistry.LookupResult lr = createMock(FeatureRegistry.LookupResult.class);
+ expect(lr.getResources()).andReturn(allResources);
+ replay(lr);
+ expect(registry.getAllFeatures()).andReturn(lr).once();
replay(registry);
versioner = new AllJsIframeVersioner(registry);
verify(registry);
Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultJsVersionerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultJsVersionerTest.java?rev=1044126&r1=1044125&r2=1044126&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultJsVersionerTest.java (original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultJsVersionerTest.java Thu Dec 9 20:56:49 2010
@@ -146,7 +146,10 @@ public class DefaultJsVersionerTest {
FeatureResource resource = new FeatureResource.Simple(content, "");
Collection<String> libs = Lists.newArrayList(feature);
List<FeatureResource> resources = Lists.newArrayList(resource);
+ final FeatureRegistry.LookupResult lr = createMock(FeatureRegistry.LookupResult.class);
+ expect(lr.getResources()).andReturn(resources).anyTimes();
+ replay(lr);
expect(registry.getFeatureResources(isA(GadgetContext.class), eq(libs),
- EasyMock.<List<String>>isNull())).andReturn(resources).anyTimes();
+ EasyMock.<List<String>>isNull())).andReturn(lr).anyTimes();
}
}