ClassSourceFactory { public ClassSource create(final String source) { checkNotNull(source); String trimmed = source.trim(); log.trace("Creating class-source from: {}", trimmed); try { return new ClassSourceImpl(new URL(trimmed), null, null); } catch (MalformedURLException e) { log.trace("Not a URL", e); } try { File file = new File(trimmed).getCanonicalFile(); if (file.exists()) { return new ClassSourceImpl(null, file, null); } } catch (IOException e) { log.trace("Not a File", e); } return new ClassSourceImpl(null, null, new InlineImpl(source)); }  ClassSource create(final String source);  }
@Test public void create_inlineIncrementsCounter() { ClassSourceFactory.scriptCounter.set(0); underTest.create("println 1234"); assertThat(ClassSourceFactory.scriptCounter.get(), is(1)); underTest.create("println 5678"); assertThat(ClassSourceFactory.scriptCounter.get(), is(2)); }