Author: echatellier Date: 2013-11-23 21:17:17 +0100 (Sat, 23 Nov 2013) New Revision: 310 Url: http://nuiton.org/projects/nuiton-js/repository/revisions/310 Log: fixes #2927: Add new test module to test each packaged library Added: trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsTestManagerFactory.java trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsTestModelFactory.java Modified: trunk/nuiton-js-test/pom.xml trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsLibTest.java Modified: trunk/nuiton-js-test/pom.xml =================================================================== --- trunk/nuiton-js-test/pom.xml 2013-11-23 20:16:43 UTC (rev 309) +++ trunk/nuiton-js-test/pom.xml 2013-11-23 20:17:17 UTC (rev 310) @@ -41,7 +41,7 @@ <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> - <scope>runtime</scope> + <scope>compile</scope> </dependency> <dependency> Modified: trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsLibTest.java =================================================================== --- trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsLibTest.java 2013-11-23 20:16:43 UTC (rev 309) +++ trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsLibTest.java 2013-11-23 20:17:17 UTC (rev 310) @@ -1,3 +1,26 @@ +/* + * #%L + * Nuiton JS :: WRO + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2013 CodeLutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ package org.nuiton.js.wro; import java.io.IOException; @@ -29,24 +52,27 @@ private static final Logger LOG = LoggerFactory.getLogger(NuitonJsLibTest.class); + /** + * Load all available resources (wro-*.xml) file from classpath and try to parse model + * to detect errors. + * + * @throws IOException + */ @Test public void testModelLoad() throws IOException { // get configuration NuitonJsWroConfigurationFactory configFactory = new NuitonJsWroConfigurationFactory(); WroConfiguration wroConfig = configFactory.create(); - + // get test context - final HttpServletRequest request = Mockito.mock(HttpServletRequest.class); - final HttpServletResponse response = Mockito.mock(HttpServletResponse.class); + HttpServletRequest request = Mockito.mock(HttpServletRequest.class); + HttpServletResponse response = Mockito.mock(HttpServletResponse.class); Mockito.when(response.getOutputStream()).thenReturn(new DelegatingServletOutputStream(new NullOutputStream())); - //final WroConfiguration config = Context.get().getConfig(); - Context.set(Context.webContext(request, response, Mockito.mock(FilterConfig.class)), wroConfig); + FilterConfig filterConfig = Mockito.mock(FilterConfig.class); + Context.set(Context.webContext(request, response, filterConfig), wroConfig); // init manager factory - NuitonJsWroManagerFactory managerFactory = new NuitonJsWroManagerFactory(); - //WroManager manager = managerFactory.create(); - //manager.process(); - + NuitonJsWroManagerFactory managerFactory = new NuitonJsTestManagerFactory(); InjectorBuilder builder = new InjectorBuilder(managerFactory); Injector injector = builder.build(); WroModelFactory modelFactory = managerFactory.newModelFactory(); @@ -55,7 +81,6 @@ // parse model WroModel model = modelFactory.create(); Assert.assertTrue("Can't find any valid wro groups !", model.getGroups().size() >= 1); - LOG.info("Successfully parsed {} groups", model.getGroups().size()); GroupsProcessor groupProcessor = new GroupsProcessor(); Added: trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsTestManagerFactory.java =================================================================== --- trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsTestManagerFactory.java (rev 0) +++ trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsTestManagerFactory.java 2013-11-23 20:17:17 UTC (rev 310) @@ -0,0 +1,17 @@ +package org.nuiton.js.wro; + +import ro.isdc.wro.model.factory.WroModelFactory; + +/** + * Manager factory used to create test model factory instance. + * + * @author Eric Chatellier + */ +public class NuitonJsTestManagerFactory extends NuitonJsWroManagerFactory { + + @Override + protected WroModelFactory newModelFactory() { + return new NuitonJsTestModelFactory(); + } + +} Property changes on: trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsTestManagerFactory.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsTestModelFactory.java =================================================================== --- trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsTestModelFactory.java (rev 0) +++ trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsTestModelFactory.java 2013-11-23 20:17:17 UTC (rev 310) @@ -0,0 +1,45 @@ +/* + * #%L + * Nuiton JS :: WRO + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2013 CodeLutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.nuiton.js.wro; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; + +/** + * Model factory used to manage "non servlet context mode" and reduce, log error. + * + * @author Eric Chatellier + */ +public class NuitonJsTestModelFactory extends NuitonJsXmlModelFactory { + + @Override + protected InputStream getModelResourceAsStream() throws IOException { + // just return empty file + return new ByteArrayInputStream("<groups xmlns=\"http://www.isdc.ro/wro\" />".getBytes(Charset.forName("utf-8"))); + } + +} Property changes on: trunk/nuiton-js-test/src/main/java/org/nuiton/js/wro/NuitonJsTestModelFactory.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native
participants (1)
-
echatellier@users.nuiton.org