### Question:
XmlModelFactory extends AbstractWroModelFactory { public synchronized WroModel create() { model = new WroModel(); final StopWatch stopWatch = new StopWatch("Create Wro Model from XML"); try { stopWatch.start("createDocument"); final Document document = createDocument(); stopWatch.stop(); stopWatch.start("processGroups"); processGroups(document); stopWatch.stop(); stopWatch.start("processImports"); processImports(document); stopWatch.stop(); stopWatch.start("createModel"); parseGroups(); stopWatch.stop(); return model; } finally { processedImports.clear(); LOG.debug(stopWatch.prettyPrint()); } } XmlModelFactory(); private  XmlModelFactory(final Set<String> processedImports); synchronized WroModel create(); XmlModelFactory setValidateXml(final boolean validateXml); static final String ALIAS; }### Answer:
@Test(expected = RecursiveGroupDefinitionException.class) public void recursiveGroupThrowsException() { factory = new XmlModelFactory() { @Override protected InputStream getModelResourceAsStream() { return Thread.currentThread().getContextClassLoader().getResourceAsStream("recursive.xml"); } }; factory.create(); }
@Test public void testTwoConcurrentCreationCalls() { testSuccessfulCreation(); factory.create(); }
@Test public void testSuccessfulCreation() { factory = new XmlModelFactory() { @Override protected InputStream getModelResourceAsStream() { return Thread.currentThread().getContextClassLoader().getResourceAsStream("wro1.xml"); } }; final WroModel model = factory.create(); LOG.debug("model: " + model); }
@Test public void shouldBeThreadSafe() throws Exception { factory = new XmlModelFactory() { @Override protected InputStream getModelResourceAsStream() { return TestXmlModelFactory.class.getResourceAsStream("testimport/validImports.xml"); } }; WroTestUtils.init(factory); final WroModel expected = factory.create(); WroTestUtils.runConcurrently(new ContextPropagatingCallable<Void>(new Callable<Void>() { public Void call() throws Exception { assertEquals(expected, factory.create()); return null; } }), 10); }