@Test public void testNoModelUsingWs() throws IOException { setupLocalCache(); final File temp = File.createTempFile("drools-service", ".jar"); // Delete temp file when program exits. temp.deleteOnExit(); final OutputStream out = new FileOutputStream(temp); buildWar(new ServiceConfig(WS_SERVICE_CONFIG), (Map<String, File>) null, out); final WebArchive archive = ShrinkWrap.createFromZipFile(WebArchive.class, temp); final Collection<String> fileNames = new LinkedList<String>(); for (final Map.Entry<ArchivePath, Node> entry : archive.getContent().entrySet()) { final String extension = getExtension(entry.getKey().get()); final String fileName = getName(entry.getKey().get()); if (extension.equalsIgnoreCase("jar")) { fileNames.add(fileName); } else if (extension.equalsIgnoreCase("xml")) { validateGeneratedFiles("ws-", fileName, toString(entry.getValue().getAsset().openStream())); } } assertEquals(2, fileNames.size()); assertTrue(LIBS.containsAll(fileNames)); }
@Test public void testRest() throws IOException, URISyntaxException { setupLocalCache(); final File temp = File.createTempFile("drools-service", ".jar"); // Delete temp file when program exits. temp.deleteOnExit(); final OutputStream out = new FileOutputStream(temp); final Map<String, File> models = new HashMap<String, File>() { { put( "jarWithSourceFiles.jar", new File( ServiceWarGeneratorTest.class .getClassLoader() .getResource(MODEL_NAME) .toURI())); } }; buildWar(new ServiceConfig(REST_SERVICE_CONFIG), models, out); final WebArchive archive = ShrinkWrap.createFromZipFile(WebArchive.class, temp); final Collection<String> fileNames = new LinkedList<String>(); for (final Map.Entry<ArchivePath, Node> entry : archive.getContent().entrySet()) { final String extension = getExtension(entry.getKey().get()); final String fileName = getName(entry.getKey().get()); if (extension.equalsIgnoreCase("jar")) { fileNames.add(fileName); } else if (extension.equalsIgnoreCase("xml")) { validateGeneratedFiles( "rest-", fileName, toString(entry.getValue().getAsset().openStream())); } } assertEquals(3, fileNames.size()); assertTrue(fileNames.containsAll(LIBS)); assertTrue(fileNames.contains("jarWithSourceFiles.jar")); }
@Test(expected = NullPointerException.class) public void testNullPointer2() throws IOException { buildWar(new ServiceConfig(REST_SERVICE_CONFIG), (Map<String, File>) null, null); }
@Test(expected = NullPointerException.class) public void testNullPointer1() throws IOException { buildWar(null, (Map<String, File>) null, null); }