Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.drools.jboss.integration;
 
 import  org.jboss.arquillian.container.test.api.Deployment;
 import  org.jboss.shrinkwrap.api.ShrinkWrap;
 import  org.jboss.shrinkwrap.api.asset.Asset;
 import  org.jboss.shrinkwrap.api.spec.WebArchive;
 
import static junit.framework.TestCase.assertNotNull;
public class FullDistributionTest {
    private static final Logger logger = LoggerFactory.getLogger(FullDistributionTest.class);
    public static final String DIST_FILE = "distFile";
    public static WebArchive createDeploymentForDistribution(String distFilethrows Exception {
        WebArchive webArchive = ShrinkWrap.create(WebArchive.class);
        JarFile jar = new JarFile(distFile);
        JarEntry entry;
        Enumeration<JarEntryentries = jar.entries();
        while (entries.hasMoreElements() && (entry = entries.nextElement()) != null) {
            if (!entry.isDirectory()) {
                webArchive.add(getAsset(jarentry), entry.getName());
            }
        }
        webArchive.addClass(FullDistributionTest.class);
        ..println("Generated web archive");
        ..println("*******************************");
        ..println(webArchive.toString(true));
        ..println("*******************************");
        return webArchive;
    }
    public static Asset getAsset(final JarFile jarfinal JarEntry entry) {
        return new Asset() {
            @Override
            public InputStream openStream() {
                try {
                    return jar.getInputStream(entry);
                } catch (Exception e) {
                    .error("asset generation failed. entry: " + entrye);
                    //don't worry It's just a test
                    return null;
                }
            }
        };
    }
    @Deployment
    public static WebArchive createDeployment() {
        String distFile = System.getProperty();
        .info("Configured distribution file is: " + distFile);
        assertNotNull("Distribution file was not configured"distFile);
        WebArchive distWar = null;
        try {
            distWar = createDeploymentForDistribution(distFile);
        } catch (Exception e) {
            .error("WebArchive creation failed, fistFile: "distFilee);
        }
        assertNotNull("WebArchive couldn't be created."distWar);
        return distWar;
    }
New to GrepCode? Check out our FAQ X