Search in sources :

Example 6 with GenericServerRuntime

use of org.eclipse.jst.server.generic.core.internal.GenericServerRuntime in project webtools.servertools by eclipse.

the class GenericServerTest method testServerAndRuntimeInfoForServerDefAndRuntimeDef.

/**
 * serverTypeId used as a key to the .serverdef file, then
 * the runtimeTypeId used as key to .runtimedef
 *
 * @throws Exception
 */
public void testServerAndRuntimeInfoForServerDefAndRuntimeDef() throws Exception {
    GenericServerRuntime runtime = ServerRuntimeUtils.getGenericServerRuntime(TEST_RUNTIMETYPE_ID);
    GenericServer server = ServerRuntimeUtils.getGenericServer(TEST_SERVERTYPE_ID, runtime.getRuntime());
    assertNotNull(server);
    ServerRuntime serverRuntime = server.getServerDefinition();
    // Verify Server and Runtime info: properties from runtimedef and serverdef are available
    ServerRuntimeUtils.verifyProperty(serverRuntime.getProperty(), "foo.prop.a", "a runtime property value");
    ServerRuntimeUtils.verifyProperty(serverRuntime.getProperty(), "foo.prop.b", "a server property value");
    ServerRuntimeUtils.verifyClasspath(serverRuntime.getClasspath(), "foo.runtime.classpath");
    ServerRuntimeUtils.verifyClasspath(serverRuntime.getClasspath(), "foo.server.classpath");
}
Also used : GenericServerRuntime(org.eclipse.jst.server.generic.core.internal.GenericServerRuntime) GenericServerRuntime(org.eclipse.jst.server.generic.core.internal.GenericServerRuntime) ServerRuntime(org.eclipse.jst.server.generic.servertype.definition.ServerRuntime) GenericServer(org.eclipse.jst.server.generic.core.internal.GenericServer)

Example 7 with GenericServerRuntime

use of org.eclipse.jst.server.generic.core.internal.GenericServerRuntime in project webtools.servertools by eclipse.

the class ServerCreationTest method testCreateServer.

public void testCreateServer() throws Exception {
    // Finds the generic server type
    IServerType[] sTypes = ServerCore.getServerTypes();
    IServerType serverType = null;
    for (int i = 0; i < sTypes.length; i++) {
        IServerType sType = sTypes[i];
        if (ID.equals(sType.getId()))
            serverType = sType;
    }
    assertNotNull("Could not find org.eclipse.jst.server.generic.jonas4 server type", serverType);
    // Finds the generic server runtime type
    IRuntimeType runtimeType = serverType.getRuntimeType();
    assertNotNull("Could not find runtime type for the generic server type", runtimeType);
    // Create a new runtime instance from the type
    IRuntime runtime = runtimeType.createRuntime(ID + ".Jonas.Runtime", null);
    assertNotNull("Could not create runtime", runtime);
    // Create a new server instance from the type
    IServerWorkingCopy server = serverType.createServer(ID + ".Jonas.Server", null, runtime, null);
    assertNotNull("Could not create server", server);
    // Save the server
    server.save(false, null);
    // Set properties for the runtime
    IRuntimeWorkingCopy runtimeWorkingCopy = runtime.createWorkingCopy();
    assertNotNull("Could not create runtime working copy", runtimeWorkingCopy);
    // Set the JONAS runtime as the default runtime
    ServerUtil.setRuntimeDefaultName(runtimeWorkingCopy);
    assertNotNull("Runtime working copy has no name", runtimeWorkingCopy.getName());
    // Set properties for the JONAS runtime
    GenericServerRuntime runtimeDelegate = (GenericServerRuntime) runtimeWorkingCopy.loadAdapter(GenericServerRuntime.class, new NullProgressMonitor());
    assertNotNull("Could not obtain runtime delegate", runtimeDelegate);
    HashMap props = new HashMap();
    props.put("mappernames", "");
    props.put("classPathVariableName", "JONAS");
    props.put("serverAddress", "127.0.0.1");
    props.put("jonasBase", "C:\\nmd\\dev\\java\\appservers\\JOnAS-4.1.4");
    props.put("jonasRoot", "C:\\nmd\\dev\\java\\appservers\\JOnAS-4.1.4");
    props.put("classPath", "C:\\nmd\\dev\\java\\appservers\\JOnAS-4.1.4");
    props.put("protocols", "C:\\nmd\\dev\\java\\appservers\\JOnAS-4.1.4");
    props.put("port", "9000");
    runtimeDelegate.setServerInstanceProperties(props);
    // Save the runtime working copy
    runtimeWorkingCopy.save(false, null);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GenericServerRuntime(org.eclipse.jst.server.generic.core.internal.GenericServerRuntime) IServerType(org.eclipse.wst.server.core.IServerType) HashMap(java.util.HashMap) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 8 with GenericServerRuntime

use of org.eclipse.jst.server.generic.core.internal.GenericServerRuntime in project webtools.servertools by eclipse.

the class GenericServerRuntimeTest method testRuntimeInfoOnly.

/**
 * runtimeTypeId used as key to .runtimedef
 */
public void testRuntimeInfoOnly() throws Exception {
    GenericServerRuntime runtime = ServerRuntimeUtils.getGenericServerRuntime(TEST_RUNTIMETYPE_ID);
    assertNotNull(runtime);
    ServerRuntime runtimeDef = runtime.getServerTypeDefinition();
    assertNotNull(runtimeDef);
    // Verify runtime info, and *no* server info
    ServerRuntimeUtils.verifyProperty(runtimeDef.getProperty(), "foo.prop.a", "a runtime property value");
    ServerRuntimeUtils.verifyNoProperty(runtimeDef.getProperty(), "foo.prop.b");
}
Also used : GenericServerRuntime(org.eclipse.jst.server.generic.core.internal.GenericServerRuntime) GenericServerRuntime(org.eclipse.jst.server.generic.core.internal.GenericServerRuntime) ServerRuntime(org.eclipse.jst.server.generic.servertype.definition.ServerRuntime)

Aggregations

GenericServerRuntime (org.eclipse.jst.server.generic.core.internal.GenericServerRuntime)8 ServerRuntime (org.eclipse.jst.server.generic.servertype.definition.ServerRuntime)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 IRuntime (org.eclipse.wst.server.core.IRuntime)3 IRuntimeType (org.eclipse.wst.server.core.IRuntimeType)3 HashMap (java.util.HashMap)2 GenericServer (org.eclipse.jst.server.generic.core.internal.GenericServer)2 IRuntimeWorkingCopy (org.eclipse.wst.server.core.IRuntimeWorkingCopy)2 Map (java.util.Map)1 IServerType (org.eclipse.wst.server.core.IServerType)1 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)1