Skip to content

Instantly share code, notes, and snippets.

@eishay
eishay / GuiceServletConfigTest.java
Created October 4, 2011 21:36
Asserting Guice Servlet Module Binding
import static com.netflix.beacon.server.ServletModuleAssert.assertBindingToPattern;
import org.junit.Test;
import com.google.inject.Injector;
public class GuiceServletConfigTest {
@Test
public void testBinding() {
@eishay
eishay / gist:1263088
Created October 4, 2011 22:51
Test Guice can init all bounded servlets
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.inject.Binding;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceFilter;
...
public static void assertInit(Injector injector) {
// Code licensed under the Apache License v2.0 http://www.apache.org/licenses/LICENSE-2.0
public class AnyThrow {
public static RuntimeException uncheked(Throwable e) {
AnyThrow.<RuntimeException>throwAny(e);
return null;
}
@SuppressWarnings("unchecked")
try {
doSomethingThatThrows.exception();
} catch (Exception e) {
throw uncheked(e);
}
@eishay
eishay / gist:1843026
Created February 16, 2012 07:42
JsTestDriver conf
load:
- public/javascripts/external/jquery-1.7.1.min.js
- http://localhost:9000/assets/javascripts/my_file1.js
- http://localhost:9000/assets/javascripts/my_file2.js
- test/javascripts/*.js
getResources: function (path, callback) {
$.ajax({
'dataType': 'jsonp text',
'crossDomain': true,
'url': path,
'success': function (data) {
utils.async(function () {
callback(data)
});
},
Ember.View.create({
templateName: templateId
});
//current is a reference to the Application object
import play.api.Play.current
object Templates extends Controller {
//name is the template name
//callback is the jQuery jsonp function name as in jQuery17104730278281494975_1332396095851
def load(name: String, callback: String) = Action { request =>
val path = current.getFile("/templates/%s.handlebars.html".format(name));
val content = Files.readFile(path)
//making the file content javascript ready
GET /template/:name my.package.Templates.load(name: String, callback: String)
@eishay
eishay / gist:2491018
Created April 25, 2012 16:18
Ember.View.extend
var myView = Ember.View.extend({ templateName: 'my_view' }),
myWidget = Ember.View.extend({ templateName: 'widget/another_view' });