Skip to content

Commit

Permalink
Remote services and dependencies are working, baby! Time to go CELEBRATE
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Sep 13, 2012
1 parent 7b3d536 commit d6feb81
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.jboss.forge.arquillian;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import org.jboss.arquillian.container.spi.client.container.DeployableContainer;
import org.jboss.arquillian.container.spi.client.container.DeploymentException;
Expand All @@ -17,7 +19,10 @@
import org.jboss.forge.container.AddonUtil.AddonEntry;
import org.jboss.forge.container.util.Files;
import org.jboss.forge.container.util.OSUtils;
import org.jboss.forge.container.util.Streams;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.Node;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.descriptor.api.Descriptor;

public class ForgeDeployableContainer implements DeployableContainer<ForgeContainerConfiguration>
Expand Down Expand Up @@ -87,6 +92,23 @@ public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException
ShrinkWrapUtil.toFile(new File(destDir.getAbsolutePath() + "/" + archive.getName()), archive);
ShrinkWrapUtil.unzip(destDir, archive);

Node node = archive.get("/META-INF/forge.xml");
if (node != null)
{
Asset asset = node.getAsset();
try
{
Streams.write(asset.openStream(), new FileOutputStream(AddonUtil.getAddonDescriptor(addon)));
}
catch (FileNotFoundException e)
{
throw new DeploymentException("Could not open addon descriptor [" + AddonUtil.getAddonDescriptor(addon)
+ "].", e);
}
}

System.out.println("Unzipping " + archive.toString(true));

addon = AddonUtil.install(addon);

HTTPContext httpContext = new HTTPContext("localhost", 4141);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jboss.forge.arquillian.archive;

import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.container.LibraryContainer;
import org.jboss.shrinkwrap.api.container.ResourceContainer;
import org.jboss.shrinkwrap.api.container.ServiceProviderContainer;
Expand All @@ -14,4 +15,9 @@
public interface ForgeArchive extends Archive<ForgeArchive>, LibraryContainer<ForgeArchive>,
ResourceContainer<ForgeArchive>, ServiceProviderContainer<ForgeArchive>
{

/**
* Sets the current forge.xml descritor for this archive.
*/
ForgeArchive setAsForgeXML(Asset resource) throws IllegalArgumentException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.impl.base.Validate;
import org.jboss.shrinkwrap.impl.base.container.ContainerBase;

/**
Expand Down Expand Up @@ -55,6 +57,11 @@ public class ForgeArchiveImpl extends ContainerBase<ForgeArchive> implements For
*/
private static final ArchivePath PATH_MANIFEST = ArchivePaths.create("META-INF");

/**
* Path to the forge XML config file inside of the Archive.
*/
private static final ArchivePath PATH_FORGE_XML = ArchivePaths.create("META-INF/forge.xml");

/**
* Path to web archive service providers.
*/
Expand Down Expand Up @@ -93,6 +100,11 @@ protected ArchivePath getManifestPath()
return PATH_MANIFEST;
}

protected ArchivePath getForgeXMLPath()
{
return PATH_FORGE_XML;
}

/**
* {@inheritDoc}
*
Expand Down Expand Up @@ -125,4 +137,12 @@ protected ArchivePath getResourcePath()
{
return PATH_CLASSES;
}

@Override
public ForgeArchive setAsForgeXML(final Asset resource) throws IllegalArgumentException
{
Validate.notNull(resource, "Resource should be specified");
return add(resource, getForgeXMLPath());
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package org.example;

import org.jboss.forge.container.services.Remote;

@Remote
public class PublishedService
{
public String getMessage()
{
return "A message from PublishedService";
return "A message from PublishedService [" + this.getClass().getClassLoader() + "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.forge.arquillian.archive.ForgeArchive;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -16,12 +16,12 @@
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
@RunWith(Arquillian.class)
public class ContainerAdapterTest
public class ContainerAdapterTest2
{
@Deployment
public static JavaArchive getDeployment()
public static ForgeArchive getDeployment()
{
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar")
ForgeArchive archive = ShrinkWrap.create(ForgeArchive.class)
.addClasses(PublishedService.class)
.addAsManifestResource(new StringAsset(""), ArchivePaths.create("beans.xml"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ public static ForgeArchive getDeployment()
ForgeArchive archive = ShrinkWrap.create(ForgeArchive.class)
.addClasses(SimpleService.class, ConsumingService.class, TestExtension.class)
.addAsManifestResource(new StringAsset(""), ArchivePaths.create("beans.xml"))
.addAsServiceProvider(Extension.class, TestExtension.class);
.addAsServiceProvider(Extension.class, TestExtension.class)
.setAsForgeXML(new StringAsset("<addon><dependency " +
"name=\"3d09722c-6e71-4bac-b315-e8078217dc98\" " +
"min-version=\"X\" " +
"max-version=\"Y\" " +
"optional=\"false\"/></addon>"));

return archive;
}
Expand Down
Loading

0 comments on commit d6feb81

Please sign in to comment.