use of org.apache.openejb.assembler.classic.OpenEjbConfiguration in project tomee by apache.
the class DeploymentsElementTest method deploymentsDir_Ear_Packed_Unpacked_NoApplicationXml.
/**
* <Deployments dir="myapps"/>
* <p/>
* EAR file packed
* EAR file extracted
*
* @throws Exception
*/
@Test
public void deploymentsDir_Ear_Packed_Unpacked_NoApplicationXml() throws Exception {
final Server server = new Server();
final File apps = server.deploymentsDir("myapps");
final String appName = "deploymentsDir_Ear_Packed_Unpacked_NoApplicationXml";
final File ear = new File(server.getBase(), appName + ".ear");
{
final Map<String, Object> contents = new HashMap<String, Object>();
contents.put("foo.jar", Archives.jarArchive(Orange.class));
Archives.jarArchive(ear, contents);
}
// packed
IO.copy(ear, Files.path(apps, appName + ".ear"));
// unpacked
Zips.unzip(ear, Files.mkdir(apps, appName));
final OpenEjbConfiguration configuration = server.init();
assertEquals(1, configuration.containerSystem.applications.size());
assertEquals(1, configuration.containerSystem.applications.get(0).ejbJars.size());
assertEquals(1, configuration.containerSystem.applications.get(0).ejbJars.get(0).enterpriseBeans.size());
assertEquals("Orange", configuration.containerSystem.applications.get(0).ejbJars.get(0).enterpriseBeans.get(0).ejbName);
}
use of org.apache.openejb.assembler.classic.OpenEjbConfiguration in project tomee by apache.
the class DeploymentsElementTest method deploymentsDir_Ear_Packed_Unpacked_Modified.
/**
* <Deployments dir="myapps"/>
* <p/>
* EAR file packed
* EAR file extracted
* <p/>
* The packed version is newer and an updated version of the packed version
* We should remove the extracted version and unpack the newer ear
*
* @throws Exception
*/
@Test
public void deploymentsDir_Ear_Packed_Unpacked_Modified() throws Exception {
final Server server = new Server();
final File apps = server.deploymentsDir("myapps");
final String appName = "deploymentsDir_Ear_Packed_Unpacked_Modified";
{
// Unpacked version -- Orange
final File ear = new File(server.getBase(), appName + ".ear");
final Map<String, Object> contents = new HashMap<String, Object>();
contents.put("foo.jar", Archives.jarArchive(Orange.class));
contents.put("META-INF/application.xml", "<application><module><ejb>foo.jar</ejb></module></application>");
Archives.jarArchive(ear, contents);
// unpacked
Zips.unzip(ear, Files.mkdir(apps, appName));
}
Thread.sleep(100);
{
// Packed version -- Yellow
final File ear = new File(server.getBase(), appName + ".ear");
final Map<String, Object> contents = new HashMap<String, Object>();
contents.put("foo.jar", Archives.jarArchive(Yellow.class));
contents.put("META-INF/application.xml", "<application><module><ejb>foo.jar</ejb></module></application>");
Archives.jarArchive(ear, contents);
// unpacked
Zips.unzip(ear, Files.mkdir(apps, appName));
}
final OpenEjbConfiguration configuration = server.init();
assertEquals(1, configuration.containerSystem.applications.size());
assertEquals(1, configuration.containerSystem.applications.get(0).ejbJars.size());
assertEquals(1, configuration.containerSystem.applications.get(0).ejbJars.get(0).enterpriseBeans.size());
assertEquals("Yellow", configuration.containerSystem.applications.get(0).ejbJars.get(0).enterpriseBeans.get(0).ejbName);
}
use of org.apache.openejb.assembler.classic.OpenEjbConfiguration in project tomee by apache.
the class DeploymentsElementTest method deploymentsDir_Ear_Packed_NoApplicationXml.
/**
* <Deployments dir="myapps"/>
* <p/>
* EAR file not extracted
*
* @throws Exception
*/
@Test
public void deploymentsDir_Ear_Packed_NoApplicationXml() throws Exception {
final Server server = new Server();
final File apps = server.deploymentsDir("myapps");
final String appName = "deploymentsDir_Ear_Packed_NoApplicationXml";
final File ear = new File(apps, appName + ".ear");
{
final Map<String, Object> contents = new HashMap<String, Object>();
contents.put("foo.jar", Archives.jarArchive(Orange.class));
Archives.jarArchive(ear, contents);
}
final OpenEjbConfiguration configuration = server.init();
assertEquals(1, configuration.containerSystem.applications.size());
assertEquals(1, configuration.containerSystem.applications.get(0).ejbJars.size());
assertEquals(1, configuration.containerSystem.applications.get(0).ejbJars.get(0).enterpriseBeans.size());
assertEquals("Orange", configuration.containerSystem.applications.get(0).ejbJars.get(0).enterpriseBeans.get(0).ejbName);
}
use of org.apache.openejb.assembler.classic.OpenEjbConfiguration in project tomee by apache.
the class Info2Properties method main.
public static void main(final String[] args) {
final CommandLineParser parser = new PosixParser();
// create the Options
final Options options = new Options();
options.addOption(option("v", "version", "cmd.properties.opt.version"));
options.addOption(option("h", "help", "cmd.properties.opt.help"));
options.addOption(option("s", "server-url", "url", "cmd.properties.opt.server"));
CommandLine line = null;
try {
// parse the command line arguments
line = parser.parse(options, args);
} catch (final ParseException exp) {
help(options);
System.exit(-1);
}
if (line.hasOption("help")) {
help(options);
System.exit(0);
} else if (line.hasOption("version")) {
OpenEjbVersion.get().print(System.out);
System.exit(0);
}
final Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
final String serverUrl = line.getOptionValue("server-url", defaultServerUrl);
p.put(Context.PROVIDER_URL, serverUrl);
ConfigurationInfo configInfo = null;
try {
final InitialContext ctx = new InitialContext(p);
configInfo = (ConfigurationInfo) ctx.lookup("openejb/ConfigurationInfoBusinessRemote");
} catch (final ServiceUnavailableException e) {
System.out.println(e.getCause().getMessage());
System.out.println(messages.format("cmd.deploy.serverOffline"));
System.exit(1);
} catch (final NamingException e) {
System.out.println("ConfigurationInfo does not exist in server '" + serverUrl + "', check the server logs to ensure it exists and has not been removed.");
System.exit(2);
}
File tempFile = null;
try {
try {
tempFile = File.createTempFile("configrequest", "txt");
} catch (final Throwable e) {
final File tmp = new File("tmp");
if (!tmp.exists() && !tmp.mkdirs()) {
throw new IOException("Failed to create local tmp directory: " + tmp.getAbsolutePath());
}
tempFile = File.createTempFile("configrequest", "txt", tmp);
}
if (!tempFile.exists()) {
throw new IllegalStateException("Failed to create tmp file: " + tempFile.getAbsolutePath());
}
} catch (final Exception e) {
System.err.println("Temp file creation failed.");
e.printStackTrace();
System.exit(1);
}
OpenEjbConfiguration configuration = null;
try {
configuration = configInfo.getOpenEjbConfiguration(tempFile);
} catch (final ConfigurationInfo.UnauthorizedException e) {
System.err.println("This tool is currently crippled to only work with server's on the same physical machine. See this JIRA issue for details: http://issues.apache.org/jira/browse/OPENEJB-621");
System.exit(10);
}
printConfig(configuration);
}
use of org.apache.openejb.assembler.classic.OpenEjbConfiguration in project tomee by apache.
the class DefaultDataSourceTest method test.
/**
* Default DataSource should be a JtaManaged DataSource
*
* @throws Exception
*/
public void test() throws Exception {
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new SingletonBean(MyBean.class));
assembler.createApplication(config.configureApplication(new EjbModule(ejbJar)));
final OpenEjbConfiguration configuration = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
final ResourceInfo resourceInfo = configuration.facilities.resources.get(0);
assertEquals("Default JDBC Database", resourceInfo.id);
assertEquals("true", resourceInfo.properties.getProperty("JtaManaged"));
}
Aggregations