@Test(expected = ContainerConfigException.class) public void badConfigThrows() throws Exception { JSONObject json = new JSONObject(); json.put(CONTAINER_KEY, new String[]{CHILD_CONTAINER}); json.put(PARENT_KEY, "bad bad bad parent!"); json.put(ARRAY_NAME, ARRAY_ALT_VALUE); new JsonContainerConfig(createContainer(json).getAbsolutePath(), Expressions.forTesting()); }
@Test(expected = ContainerConfigException.class) public void badConfigThrows() throws Exception { JSONObject json = new JSONObject(); json.put(CONTAINER_KEY, new String[]{CHILD_CONTAINER}); json.put(PARENT_KEY, "bad bad bad parent!"); json.put(ARRAY_NAME, ARRAY_ALT_VALUE); new JsonContainerConfig(createContainer(json).getAbsolutePath(), Expressions.forTesting()); }
@Before public void setUp() { elValues = Maps.newHashMap(); elResolver = new RootELResolver(elValues); expressions = Expressions.forTesting(); }
@Test public void expressionEvaluation() throws Exception { // We use a JSON Object here to guarantee that we're well formed up front. JSONObject json = new JSONObject(); json.put(CONTAINER_KEY, new String[]{DEFAULT_CONTAINER}); json.put("expression", "Hello, ${world}!"); json.put("world", "Earth"); ContainerConfig config = new JsonContainerConfig(createContainer(json).getAbsolutePath(), Expressions.forTesting()); assertEquals("Hello, Earth!", config.getString(DEFAULT_CONTAINER, "expression")); }
@Test public void expressionEvaluation() throws Exception { // We use a JSON Object here to guarantee that we're well formed up front. JSONObject json = new JSONObject(); json.put(CONTAINER_KEY, new String[]{DEFAULT_CONTAINER}); json.put("expression", "Hello, ${world}!"); json.put("world", "Earth"); ContainerConfig config = new JsonContainerConfig(createContainer(json).getAbsolutePath(), Expressions.forTesting()); assertEquals("Hello, Earth!", config.getString(DEFAULT_CONTAINER, "expression")); }
@Test public void expressionEvaluation() throws Exception { // We use a JSON Object here to guarantee that we're well formed up front. JSONObject json = new JSONObject(); json.put(CONTAINER_KEY, new String[]{DEFAULT_CONTAINER}); json.put("expression", "Hello, ${world}!"); json.put("world", "Earth"); ContainerConfig config = new JsonContainerConfig(createContainer(json).getAbsolutePath(), Expressions.forTesting()); assertEquals("Hello, Earth!", config.getString(DEFAULT_CONTAINER, "expression")); }
@Before public void setUp() { expressions = Expressions.forTesting(); variables = Maps.newHashMap(); context = expressions.newELContext(new RootELResolver(variables)); }
@Test public void shindigPortTest() throws Exception { // We use a JSON Object here to guarantee that we're well formed up front. JSONObject json = new JSONObject(); json.put(CONTAINER_KEY, new String[]{DEFAULT_CONTAINER}); json.put("expression", "port=${SERVER_PORT}"); ContainerConfig config = new JsonContainerConfig(createContainer(json).getAbsolutePath(), Expressions.forTesting()); assertEquals("port=8080", config.getString(DEFAULT_CONTAINER, "expression")); }
@Before public void setUp() { expressions = Expressions.forTesting(null); variables = Maps.newHashMap(); context = expressions.newELContext(new RootELResolver(variables)); }
@Test public void shindigPortTest() throws Exception { // We use a JSON Object here to guarantee that we're well formed up front. JSONObject json = new JSONObject(); json.put(CONTAINER_KEY, new String[]{DEFAULT_CONTAINER}); json.put("expression", "port=${SERVER_PORT}"); ContainerConfig config = new JsonContainerConfig(createContainer(json).getAbsolutePath(), Expressions.forTesting()); assertEquals("port=8080", config.getString(DEFAULT_CONTAINER, "expression")); }
@Test public void aliasesArePopulated() throws Exception { JSONObject json = new JSONObject() .put(CONTAINER_KEY, new String[]{CONTAINER_A, CONTAINER_B}) .put(NESTED_KEY, NESTED_VALUE); File parentFile = createDefaultContainer(); File childFile = createContainer(json); ContainerConfig config = new JsonContainerConfig(childFile.getAbsolutePath() + JsonContainerConfig.FILE_SEPARATOR + parentFile.getAbsolutePath(), Expressions.forTesting()); assertEquals(NESTED_VALUE, config.getString(CONTAINER_A, NESTED_KEY)); assertEquals(NESTED_VALUE, config.getString(CONTAINER_B, NESTED_KEY)); }
@Test public void testExpressionEvaluation() { Expressions expressions = Expressions.forTesting(functions); ELContext context = expressions.newELContext(); ValueExpression expression = expressions.parse("${other:bonjour()}", String.class); assertEquals("French hello", expression.getValue(context)); expression = expressions.parse("${test:add(1, 2)}", Integer.class); assertEquals(3, expression.getValue(context)); }
@Test public void testExpressionEvaluation() { Expressions expressions = Expressions.forTesting(functions); ELContext context = expressions.newELContext(); ValueExpression expression = expressions.parse("${other:bonjour()}", String.class); assertEquals("French hello", expression.getValue(context)); expression = expressions.parse("${test:add(1, 2)}", Integer.class); assertEquals(3, expression.getValue(context)); }
@Test public void pathQuery() throws Exception { ContainerConfig config = new JsonContainerConfig(createDefaultContainer().getAbsolutePath(), Expressions.forTesting()); String path = "${" + NESTED_KEY + "['" + NESTED_NAME + "']}"; String data = config.getString(DEFAULT_CONTAINER, path); assertEquals(NESTED_VALUE, data); }
@Test public void pathQuery() throws Exception { ContainerConfig config = new JsonContainerConfig(createDefaultContainer().getAbsolutePath(), Expressions.forTesting()); String path = "${" + NESTED_KEY + "['" + NESTED_NAME + "']}"; String data = config.getString(DEFAULT_CONTAINER, path); assertEquals(NESTED_VALUE, data); }
@Test public void invalidContainerReturnsNull() throws Exception { ContainerConfig config = new JsonContainerConfig(createDefaultContainer().getAbsolutePath(), Expressions.forTesting()); assertNull("Did not return null for invalid container.", config.getString("fake", PARENT_KEY)); }
@Before public void setUp() throws Exception { control = EasyMock.createStrictControl(); preloader = control.createMock(PipelinedDataPreloader.class); preloaderService = new ConcurrentPreloaderService(Executors.newSingleThreadExecutor(), null); executor = new PipelineExecutor(preloader, preloaderService, Expressions.forTesting()); context = new GadgetContext(){}; }
@Override public void setUp() throws Exception { config = new ExpressionContainerConfig(Expressions.forTesting()); config.newTransaction().addContainer(DEFAULT_EXPR_CONTAINER).commit(); }
@Before public void setUp() { Functions functions = new Functions(OpensocialFunctions.class); expressions = Expressions.forTesting(functions); context = expressions.newELContext(new RootELResolver(vars)); }
@Before public void setUp() throws Exception { expressions = Expressions.forTesting(); variables = Maps.newHashMap(); Set<TagHandler> handlers = ImmutableSet.<TagHandler> of(new VarTagHandler()); registry = new DefaultTagRegistry(handlers); processor = new DefaultTemplateProcessor(expressions); resolver = new RootELResolver(); parser = new NekoSimplifiedHtmlParser(new ParseModule.DOMImplementationProvider().get()); context = new TemplateContext(new Gadget(), variables); }