Skip to content

Commit

Permalink
Moved some core tests from container-cdi. Added XATransaction to syst…
Browse files Browse the repository at this point in the history
…em classpath specs
  • Loading branch information
lincolnthree committed Oct 2, 2013
1 parent 5264511 commit ce5ea90
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 2 deletions.
@@ -0,0 +1,31 @@
package test.org.jboss.forge.furnace.classpath;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.forge.arquillian.archive.ForgeArchive;
import org.jboss.forge.arquillian.services.LocalServices;
import org.jboss.forge.furnace.Furnace;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class ForgeGetVersionIsCallableTest
{
@Deployment
public static ForgeArchive getDeployment()
{
ForgeArchive archive = ShrinkWrap.create(ForgeArchive.class)
.addAsLocalServices(ForgeGetVersionIsCallableTest.class);

return archive;
}

@Test
public void testGetVersionIsCallable() throws Exception
{
Furnace furnace = LocalServices.getFurnace(this.getClass().getClassLoader());
furnace.getVersion();
}

}
@@ -0,0 +1,57 @@
/*
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package test.org.jboss.forge.furnace.classpath;

import java.io.File;
import java.io.IOException;

import org.jboss.forge.furnace.Furnace;
import org.jboss.forge.furnace.impl.util.Files;
import org.jboss.forge.furnace.repositories.AddonRepositoryMode;
import org.jboss.forge.furnace.se.FurnaceFactory;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public class ForgeSetArgsTest
{
static File repodir1;

@Before
public void init() throws IOException
{
repodir1 = File.createTempFile("forge", "repo1");
repodir1.deleteOnExit();
}

@After
public void teardown()
{
Files.delete(repodir1, true);
}

@Test
public void testAddonsCanReferenceDependenciesInOtherRepositories() throws IOException
{
String[] args = new String[] { "arg1", "arg2" };

Furnace forge = FurnaceFactory.getInstance(Furnace.class.getClassLoader());
forge.setArgs(args);
forge.addRepository(AddonRepositoryMode.MUTABLE, repodir1);
forge.startAsync();

String[] forgeArgs = forge.getArgs();
Assert.assertArrayEquals(args, forgeArgs);

forge.stop();
}

}
@@ -0,0 +1,44 @@
package test.org.jboss.forge.furnace.classpath;

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.ShrinkWrap;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class XATransactionLookupTest
{
@Deployment
public static ForgeArchive getDeployment()
{
ForgeArchive archive = ShrinkWrap.create(ForgeArchive.class)
.addAsLocalServices(XATransactionLookupTest.class);

return archive;
}

@Test
public void testGetJDKProvidedXATypes() throws Exception
{
try
{
getClass().getClassLoader().loadClass("javax.transaction.xa.XAResource");
getClass().getClassLoader().loadClass("javax.transaction.TransactionRequiredException");
}
catch (Exception e)
{
Assert.fail("Could not load required transaction classes." + e.getMessage());
}
}

@Test
public void testXATypeInstantiations()
{
Assert.assertNotNull(new javax.transaction.xa.XAException());
Assert.assertNotNull(new javax.transaction.TransactionRequiredException());
}

}
@@ -0,0 +1,54 @@
package test.org.jboss.forge.furnace.classpath;

import javax.xml.xpath.XPathFactory;

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.ShrinkWrap;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class XPathLookupTest
{
@Deployment
public static ForgeArchive getDeployment()
{
ForgeArchive archive = ShrinkWrap.create(ForgeArchive.class)
.addAsLocalServices(XPathLookupTest.class);

return archive;
}

@Test
public void testGetJDKProvidedXPathImpl() throws Exception
{
try
{
getClass().getClassLoader().loadClass("com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl");
getClass().getClassLoader().loadClass("com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
getClass().getClassLoader().loadClass("com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
getClass().getClassLoader().loadClass("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
getClass().getClassLoader().loadClass("com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl");
getClass().getClassLoader().loadClass("com.sun.xml.internal.stream.events.XMLEventFactoryImpl");
getClass().getClassLoader().loadClass("com.sun.xml.internal.stream.XMLInputFactoryImpl");
getClass().getClassLoader().loadClass("com.sun.xml.internal.stream.XMLOutputFactoryImpl");
getClass().getClassLoader().loadClass("com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl");
getClass().getClassLoader().loadClass("com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory");
getClass().getClassLoader().loadClass("com.sun.org.apache.xerces.internal.parsers.SAXParser");
}
catch (Exception e)
{
Assert.fail("Could not load required Factory class." + e.getMessage());
}
}

@Test
public void testXPathFactoryLookup()
{
Assert.assertNotNull(XPathFactory.newInstance().newXPath());
}

}
Expand Up @@ -25,6 +25,7 @@
import org.jboss.forge.furnace.impl.addons.AddonStateManager;
import org.jboss.forge.furnace.impl.modules.providers.FurnaceContainerSpec;
import org.jboss.forge.furnace.impl.modules.providers.SystemClasspathSpec;
import org.jboss.forge.furnace.impl.modules.providers.XATransactionJDKClasspathSpec;
import org.jboss.forge.furnace.impl.modules.providers.XPathJDKClasspathSpec;
import org.jboss.forge.furnace.repositories.AddonDependencyEntry;
import org.jboss.forge.furnace.repositories.AddonRepository;
Expand Down Expand Up @@ -149,6 +150,7 @@ private ModuleSpec findAddonModule(ModuleIdentifier id)

builder.addDependency(DependencySpec.createModuleDependencySpec(SystemClasspathSpec.ID));
builder.addDependency(DependencySpec.createModuleDependencySpec(XPathJDKClasspathSpec.ID));
builder.addDependency(DependencySpec.createModuleDependencySpec(XATransactionJDKClasspathSpec.ID));
builder.addDependency(DependencySpec.createModuleDependencySpec(PathFilters.acceptAll(),
PathFilters.rejectAll(), null, FurnaceContainerSpec.ID, false));
try
Expand All @@ -160,7 +162,7 @@ private ModuleSpec findAddonModule(ModuleIdentifier id)
logger.warning(e.getMessage());
return null;
}

builder.addDependency(DependencySpec.createLocalDependencySpec(PathFilters.acceptAll(),
PathFilters.acceptAll()));

Expand Down
@@ -0,0 +1,31 @@
package org.jboss.forge.furnace.impl.modules.providers;

import java.util.HashSet;
import java.util.Set;

import org.jboss.modules.ModuleIdentifier;

public class XATransactionJDKClasspathSpec extends AbstractModuleSpecProvider
{
public static final ModuleIdentifier ID = ModuleIdentifier.create("javax.transaction.xa");

public static Set<String> paths = new HashSet<String>();

static
{
paths.add("javax/transaction");
paths.add("javax/transaction/xa");
}

@Override
protected ModuleIdentifier getId()
{
return ID;
}

@Override
protected Set<String> getPaths()
{
return paths;
}
}
Expand Up @@ -2,4 +2,5 @@ org.jboss.forge.furnace.impl.modules.providers.FurnaceContainerSpec
org.jboss.forge.furnace.impl.modules.providers.SunMiscClasspathSpec
org.jboss.forge.furnace.impl.modules.providers.SunJDKClasspathSpec
org.jboss.forge.furnace.impl.modules.providers.SystemClasspathSpec
org.jboss.forge.furnace.impl.modules.providers.XPathJDKClasspathSpec
org.jboss.forge.furnace.impl.modules.providers.XPathJDKClasspathSpec
org.jboss.forge.furnace.impl.modules.providers.XATransactionJDKClasspathSpec

0 comments on commit ce5ea90

Please sign in to comment.