@Before public void setUp() throws Exception { functions = new Functions(FunctionsTest.class); }
/** * Creates a Functions class with the specified */ public Functions(Class<?>... functionClasses) { for (Class<?> functionClass : functionClasses) { for (Method m : functionClass.getMethods()) { if ((m.getModifiers() & Modifier.STATIC) == 0) { continue; } addMethod(m); } } }
@Test public void testExpose() throws Exception { Method hi = functions.resolveFunction("test", "hi"); assertEquals("hi", hi.invoke(null)); Method hiAlternate = functions.resolveFunction("test", "hola"); assertEquals("hi", hiAlternate.invoke(null)); Method bonjour = functions.resolveFunction("other", "bonjour"); assertEquals("French hello", bonjour.invoke(null)); }
@Before public void setUp() throws Exception { functions = new Functions(FunctionsTest.class); }
@Test public void testExpose() throws Exception { Method hi = functions.resolveFunction("test", "hi"); assertEquals("hi", hi.invoke(null)); Method hiAlternate = functions.resolveFunction("test", "hola"); assertEquals("hi", hiAlternate.invoke(null)); Method bonjour = functions.resolveFunction("other", "bonjour"); assertEquals("French hello", bonjour.invoke(null)); }
/** * Creates a Functions class with the specified */ public Functions(Class<?>... functionClasses) { for (Class<?> functionClass : functionClasses) { for (Method m : functionClass.getMethods()) { if ((m.getModifiers() & Modifier.STATIC) == 0) { continue; } addMethod(m); } } }
@Before public void setUp() throws Exception { functions = new Functions(FunctionsTest.class); }
@Test public void testExpose() throws Exception { Method hi = functions.resolveFunction("test", "hi"); assertEquals("hi", hi.invoke(null)); Method hiAlternate = functions.resolveFunction("test", "hola"); assertEquals("hi", hiAlternate.invoke(null)); Method bonjour = functions.resolveFunction("other", "bonjour"); assertEquals("French hello", bonjour.invoke(null)); }
/** * Creates a Functions class with the specified */ public Functions(Class<?>... functionClasses) { for (Class<?> functionClass : functionClasses) { for (Method m : functionClass.getMethods()) { if ((m.getModifiers() & Modifier.STATIC) == 0) { continue; } addMethod(m); } } }
@Before public void setUp() throws Exception { functions = new Functions(FunctionsTest.class); }
@Test public void testExpose() throws Exception { Method hi = functions.resolveFunction("test", "hi"); assertEquals("hi", hi.invoke(null)); Method hiAlternate = functions.resolveFunction("test", "hola"); assertEquals("hi", hiAlternate.invoke(null)); Method bonjour = functions.resolveFunction("other", "bonjour"); assertEquals("French hello", bonjour.invoke(null)); }
/** * Creates a Functions class with the specified */ public Functions(Class<?>... functionClasses) { for (Class<?> functionClass : functionClasses) { for (Method m : functionClass.getMethods()) { if ((m.getModifiers() & Modifier.STATIC) == 0) { continue; } addMethod(m); } } }
@Before public void setUp() throws Exception { functions = new Functions(FunctionsTest.class); }
@Test public void testExpose() throws Exception { Method hi = functions.resolveFunction("test", "hi"); assertEquals("hi", hi.invoke(null)); Method hiAlternate = functions.resolveFunction("test", "hola"); assertEquals("hi", hiAlternate.invoke(null)); Method bonjour = functions.resolveFunction("other", "bonjour"); assertEquals("French hello", bonjour.invoke(null)); }
/** * Creates a Functions class with the specified */ public Functions(Class<?>... functionClasses) { for (Class<?> functionClass : functionClasses) { for (Method m : functionClass.getMethods()) { if ((m.getModifiers() & Modifier.STATIC) == 0) { continue; } addMethod(m); } } }
@Before public void setUp() throws Exception { JSONObject config = createConfig(); JsonContainerConfig containerConfig = new JsonContainerConfig(config, Expressions.forTesting(new Functions())); mockFetcher = mock(HttpFetcher.class); fetcher = new DefaultServiceFetcher(containerConfig, mockFetcher); }
@Test public void testDefaultBinding() throws Exception { Injector injector = Guice.createInjector(); functions = injector.getInstance(Functions.class); Method toJson = functions.resolveFunction("osx", "parseJson"); Object o = toJson.invoke(null, "{a : 1}"); assertTrue(o instanceof JSONObject); assertEquals(1, ((JSONObject) o).getInt("a")); }
@Before public void setUp() throws Exception { JSONObject config = createConfig(); JsonContainerConfig containerConfig = new JsonContainerConfig(config, Expressions.forTesting(new Functions())); mockFetcher = mock(HttpFetcher.class); fetcher = new DefaultServiceFetcher(containerConfig, mockFetcher); }
@Test public void testDefaultBinding() throws Exception { Injector injector = Guice.createInjector(); functions = injector.getInstance(Functions.class); Method toJson = functions.resolveFunction("osx", "parseJson"); Object o = toJson.invoke(null, "{a : 1}"); assertTrue(o instanceof JSONObject); assertEquals(1, ((JSONObject) o).getInt("a")); }
@Before public void setUp() throws Exception { JSONObject config = createConfig(); JsonContainerConfig containerConfig = new JsonContainerConfig(config, Expressions.forTesting(new Functions())); mockFetcher = mock(HttpFetcher.class); fetcher = new DefaultServiceFetcher(containerConfig, mockFetcher); }