Skip to content

Commit 8d983bc

Browse files
author
Brian Oliver
committed
Resolves Issue ORACLETOOLS-21: Rename "Virtualization" to "Container" to improve understanding (https://java.net/jira/browse/ORACLETOOLS-21)
Resolves Issue ORACLETOOLS-26: Refactor ApplicationConsole to allow separate control of stdout, stderr and stdin (https://java.net/jira/browse/ORACLETOOLS-26) Resolves Issue ORACLETOOLS-27: Add the ability to turn on application lifecycle diagnostics (https://java.net/jira/browse/ORACLETOOLS-27) Resolves Issue ORACLETOOLS-28: Add the ability to enable remote Java debugging (https://java.net/jira/browse/ORACLETOOLS-28) Resolves Issue ORACLETOOLS-29: Application Group produced Application names should start at 1 not 0 (https://java.net/jira/browse/ORACLETOOLS-29) Resolves Issue ORACLETOOLS-30: Native Windows NT / XP processes may hang on destroy (https://java.net/jira/browse/ORACLETOOLS-30)
1 parent baf0508 commit 8d983bc

File tree

116 files changed

+5498
-5849
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+5498
-5849
lines changed

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
Welcome to Oracle Tools
22
=======================
33

4-
[Oracle Tools](http://coherence-community.github.com/oracle-tools/0.0.7-SNAPSHOT/) provides a set of runtime process management tools typically used
5-
to simplify the testing of multi-process and distributed applications.
4+
[Oracle Tools](http://coherence-community.github.com/oracle-tools/0.0.9-SNAPSHOT/)
5+
provides a set of runtime process management tools typically used to simplify the
6+
testing of multi-process and distributed applications.
67

7-
Official information about this project including the definition, licensing, contributors, maintainers, issue tracking, releases, source code and contact information is available at:
8+
Official information about this project including the definition, licensing,
9+
contributors, maintainers, issue tracking, releases, source code and contact
10+
information is available at:
811
[http://java.net/projects/oracletools](http://java.net/projects/oracletools)
912

10-
Detailed project documentation for the latest snapshot release (0.0.7) is available here: [http://coherence-community.github.com/oracle-tools/0.0.7-SNAPSHOT/](http://coherence-community.github.com/oracle-tools/0.0.7-SNAPSHOT/)
13+
Detailed project documentation for the latest snapshot release (0.0.9) is available
14+
here: [http://coherence-community.github.com/oracle-tools/0.0.9-SNAPSHOT/](http://coherence-community.github.com/oracle-tools/0.0.9-SNAPSHOT/)
1115

1216
> **NOTE**
1317
>

oracle-tools-coherence-testing-support/src/main/java/com/oracle/tools/junit/AbstractCoherenceTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
package com.oracle.tools.junit;
2727

28-
import com.oracle.tools.runtime.java.virtualization.Virtualization;
28+
import com.oracle.tools.runtime.java.container.Container;
2929

3030
import com.oracle.tools.runtime.network.Constants;
3131

@@ -61,7 +61,7 @@ public void onBeforeEachTest()
6161

6262
// we only want to run locally
6363
System.setProperty("tangosol.coherence.clusterport",
64-
Integer.toString(Virtualization.getAvailablePorts().next()));
64+
Integer.toString(Container.getAvailablePorts().next()));
6565
System.setProperty("tangosol.coherence.localhost", Constants.getLocalHost());
6666
System.setProperty("tangosol.coherence.ttl", Integer.toString(0));
6767
}

oracle-tools-coherence-tests/pom.xml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<parent>
5+
<artifactId>oracle-tools</artifactId>
6+
<groupId>com.oracle.tools</groupId>
7+
<version>0.0.9-SNAPSHOT</version>
8+
<relativePath>../pom.xml</relativePath>
9+
</parent>
10+
11+
<artifactId>oracle-tools-coherence-tests</artifactId>
12+
13+
<name>Oracle Tools for Coherence (Functional Tests)</name>
14+
15+
<description>
16+
Functional and Integration tests for the Oracle Tools Coherence module.
17+
</description>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>com.oracle.coherence</groupId>
22+
<artifactId>coherence</artifactId>
23+
<version>${coherence.version}</version>
24+
<scope>provided</scope>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>com.oracle.tools</groupId>
29+
<artifactId>oracle-tools-runtime</artifactId>
30+
<version>${project.parent.version}</version>
31+
</dependency>
32+
33+
<dependency>
34+
<groupId>com.oracle.tools</groupId>
35+
<artifactId>oracle-tools-coherence</artifactId>
36+
<version>${project.parent.version}</version>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>com.oracle.tools</groupId>
41+
<artifactId>oracle-tools-testing-support</artifactId>
42+
<version>${project.parent.version}</version>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>junit</groupId>
47+
<artifactId>junit</artifactId>
48+
<version>${junit.version}</version>
49+
</dependency>
50+
</dependencies>
51+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
/*
2+
* File: AbstractClusterBuilderTest.java
3+
*
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5+
*
6+
* The contents of this file are subject to the terms and conditions of
7+
* the Common Development and Distribution License 1.0 (the "License").
8+
*
9+
* You may not use this file except in compliance with the License.
10+
*
11+
* You can obtain a copy of the License by consulting the LICENSE.txt file
12+
* distributed with this file, or by consulting https://oss.oracle.com/licenses/CDDL
13+
*
14+
* See the License for the specific language governing permissions
15+
* and limitations under the License.
16+
*
17+
* When distributing the software, include this License Header Notice in each
18+
* file and include the License file LICENSE.txt.
19+
*
20+
* MODIFICATIONS:
21+
* If applicable, add the following below the License Header, with the fields
22+
* enclosed by brackets [] replaced by your own identifying information:
23+
* "Portions Copyright [year] [name of copyright owner]"
24+
*/
25+
26+
package com.oracle.tools.runtime.coherence;
27+
28+
import com.oracle.tools.junit.AbstractTest;
29+
30+
import com.oracle.tools.runtime.PropertiesBuilder;
31+
32+
import com.oracle.tools.runtime.coherence.ClusterMemberSchema.JMXManagementMode;
33+
34+
import com.oracle.tools.runtime.console.SystemApplicationConsole;
35+
36+
import com.oracle.tools.runtime.java.ContainerBasedJavaApplicationBuilder;
37+
import com.oracle.tools.runtime.java.JavaApplicationBuilder;
38+
import com.oracle.tools.runtime.java.SimpleJavaApplication;
39+
import com.oracle.tools.runtime.java.SimpleJavaApplicationSchema;
40+
import com.oracle.tools.runtime.java.container.Container;
41+
42+
import com.oracle.tools.runtime.network.AvailablePortIterator;
43+
44+
import junit.framework.Assert;
45+
46+
import org.hamcrest.Matchers;
47+
48+
import org.junit.Test;
49+
50+
import static com.oracle.tools.deferred.DeferredAssert.assertThat;
51+
52+
import static com.oracle.tools.deferred.DeferredHelper.eventually;
53+
import static com.oracle.tools.deferred.DeferredHelper.invoking;
54+
55+
import static org.hamcrest.CoreMatchers.is;
56+
57+
import java.util.HashSet;
58+
59+
import javax.management.ObjectName;
60+
61+
/**
62+
* Functional Tests for the {@link com.oracle.tools.runtime.coherence.ClusterBuilder} class.
63+
* <p>
64+
* Copyright (c) 2013. All Rights Reserved. Oracle Corporation.<br>
65+
* Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
66+
*
67+
* @author Brian Oliver
68+
*/
69+
public abstract class AbstractClusterBuilderTest extends AbstractTest
70+
{
71+
/**
72+
* Creates a new {@link com.oracle.tools.runtime.java.JavaApplicationBuilder}
73+
* to use for a tests in this class and/or sub-classes.
74+
*
75+
* @return the {@link com.oracle.tools.runtime.java.JavaApplicationBuilder}
76+
*/
77+
public abstract JavaApplicationBuilder<ClusterMember, ClusterMemberSchema> newJavaApplicationBuilder();
78+
79+
80+
/**
81+
* Ensure we can build and destroy a {@link com.oracle.tools.runtime.coherence.Cluster}
82+
* of storage enabled members.
83+
*
84+
* @throws Exception
85+
*/
86+
@Test
87+
public void shouldBuildStorageEnabledCluster() throws Exception
88+
{
89+
final int CLUSTER_SIZE = 3;
90+
91+
AvailablePortIterator portIterator = Container.getAvailablePorts();
92+
93+
ClusterMemberSchema schema =
94+
new ClusterMemberSchema().setEnvironmentVariables(PropertiesBuilder.fromCurrentEnvironmentVariables())
95+
.setSingleServerMode().setClusterPort(portIterator.next()).setJMXPort(portIterator)
96+
.setJMXManagementMode(JMXManagementMode.LOCAL_ONLY);
97+
98+
Cluster cluster = null;
99+
100+
try
101+
{
102+
ClusterBuilder builder = new ClusterBuilder();
103+
104+
builder.addBuilder(newJavaApplicationBuilder(), schema, "DCCF", CLUSTER_SIZE);
105+
106+
cluster = builder.realize(new SystemApplicationConsole());
107+
108+
assertThat(eventually(invoking(cluster).getClusterSize()), is(CLUSTER_SIZE));
109+
}
110+
catch (Exception e)
111+
{
112+
e.printStackTrace();
113+
Assert.fail();
114+
}
115+
finally
116+
{
117+
if (cluster != null)
118+
{
119+
cluster.destroy();
120+
}
121+
}
122+
}
123+
124+
125+
/**
126+
* Ensure we can build and destroy a {@link com.oracle.tools.runtime.coherence.Cluster}
127+
* of storage enabled members with a proxy server.
128+
*
129+
* @throws Exception
130+
*/
131+
@Test
132+
public void shouldBuildStorageAndProxyCluster() throws Exception
133+
{
134+
AvailablePortIterator jmxPorts = Container.getAvailablePorts();
135+
136+
int clusterPort = jmxPorts.next();
137+
138+
ClusterMemberSchema storageSchema =
139+
new ClusterMemberSchema().setClusterPort(clusterPort).setStorageEnabled(true)
140+
.setCacheConfigURI("test-cache-config.xml").setJMXSupport(true).setRemoteJMXManagement(true)
141+
.setJMXManagementMode(ClusterMemberSchema.JMXManagementMode.LOCAL_ONLY).setJMXPort(jmxPorts)
142+
.setSingleServerMode();
143+
144+
ClusterMemberSchema extendSchema =
145+
new ClusterMemberSchema().setStorageEnabled(false).setClusterPort(clusterPort)
146+
.setCacheConfigURI("test-extend-proxy-config.xml").setJMXSupport(true).setRemoteJMXManagement(true)
147+
.setSystemProperty("coherence.extend.port",
148+
jmxPorts).setJMXManagementMode(ClusterMemberSchema.JMXManagementMode.LOCAL_ONLY)
149+
.setJMXPort(jmxPorts).setSingleServerMode();
150+
151+
SystemApplicationConsole console = new SystemApplicationConsole();
152+
153+
Cluster cluster = null;
154+
155+
try
156+
{
157+
ClusterBuilder builder = new ClusterBuilder();
158+
159+
builder.addBuilder(newJavaApplicationBuilder(), storageSchema, "storage", 2);
160+
builder.addBuilder(newJavaApplicationBuilder(), extendSchema, "extend", 1);
161+
162+
cluster = builder.realize(new SystemApplicationConsole());
163+
164+
// ensure the cluster size is as expected
165+
assertThat(eventually(invoking(cluster).getClusterSize()), is(3));
166+
167+
// ensure the member id's are different
168+
HashSet<Integer> memberIds = new HashSet<Integer>();
169+
170+
for (ClusterMember member : cluster)
171+
{
172+
memberIds.add(member.getLocalMemberId());
173+
}
174+
175+
Assert.assertEquals(3, memberIds.size());
176+
177+
// ensure the there's only one extend service instance
178+
ObjectName objectName =
179+
new ObjectName("Coherence:type=ConnectionManager,name=ExtendTcpProxyService,nodeId=*");
180+
181+
ClusterMember extendMember = cluster.getApplication("extend-1");
182+
183+
assertThat(eventually(invoking(extendMember).queryMBeans(objectName, null).size()), Matchers.is(1));
184+
185+
for (ClusterMember storageMember : cluster.getApplications("storage"))
186+
{
187+
assertThat(eventually(invoking(storageMember).queryMBeans(objectName, null).size()), Matchers.is(0));
188+
}
189+
}
190+
catch (Exception e)
191+
{
192+
e.printStackTrace();
193+
Assert.fail();
194+
}
195+
finally
196+
{
197+
if (cluster != null)
198+
{
199+
cluster.destroy();
200+
}
201+
}
202+
}
203+
}

oracle-tools-coherence/src/test/java/com/oracle/tools/runtime/coherence/ClusterMemberBuilderTest.java oracle-tools-coherence-tests/src/test/java/com/oracle/tools/runtime/coherence/AbstractClusterMemberTest.java

+25-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* File: ClusterMemberBuilderTest.java
2+
* File: AbstractClusterMemberTest.java
33
*
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
55
*
@@ -28,13 +28,14 @@
2828
import com.oracle.tools.junit.AbstractTest;
2929

3030
import com.oracle.tools.runtime.Application;
31-
import com.oracle.tools.runtime.PropertiesBuilder;
3231

3332
import com.oracle.tools.runtime.coherence.ClusterMemberSchema.JMXManagementMode;
3433

35-
import com.oracle.tools.runtime.java.ExternalJavaApplicationBuilder;
34+
import com.oracle.tools.runtime.console.SystemApplicationConsole;
35+
3636
import com.oracle.tools.runtime.java.JavaApplicationBuilder;
37-
import com.oracle.tools.runtime.java.virtualization.Virtualization;
37+
import com.oracle.tools.runtime.java.NativeJavaApplicationBuilder;
38+
import com.oracle.tools.runtime.java.container.Container;
3839

3940
import com.oracle.tools.runtime.network.AvailablePortIterator;
4041

@@ -50,48 +51,49 @@
5051
import static org.hamcrest.CoreMatchers.is;
5152

5253
/**
53-
* Unit tests for building {@link ClusterMember}s.
54+
* Functional Tests for {@link com.oracle.tools.runtime.coherence.ClusterMember}s.
5455
* <p>
55-
* Copyright (c) 2010. All Rights Reserved. Oracle Corporation.<br>
56+
* Copyright (c) 2013. All Rights Reserved. Oracle Corporation.<br>
5657
* Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
5758
*
5859
* @author Brian Oliver
5960
*/
60-
public class ClusterMemberBuilderTest extends AbstractTest
61+
public abstract class AbstractClusterMemberTest extends AbstractTest
6162
{
6263
/**
63-
* A test to determine if we can connect to the Coherence JMX infrastructure.
64+
* Creates a new {@link com.oracle.tools.runtime.java.JavaApplicationBuilder}
65+
* to use for a tests in this class and/or sub-classes.
66+
*
67+
* @return the {@link com.oracle.tools.runtime.java.JavaApplicationBuilder}
68+
*/
69+
public abstract JavaApplicationBuilder<ClusterMember, ClusterMemberSchema> newJavaApplicationBuilder();
70+
71+
72+
/**
73+
* Ensure we can start and connect to the Coherence JMX infrastructure.
6474
*
6575
* @throws Exception
6676
*/
6777
@Test
68-
public void testJMXConnection() throws Exception
78+
public void shouldStartJMXConnection() throws Exception
6979
{
70-
AvailablePortIterator portIterator = Virtualization.getAvailablePorts();
80+
AvailablePortIterator portIterator = Container.getAvailablePorts();
7181

7282
ClusterMemberSchema schema =
73-
new ClusterMemberSchema().setEnvironmentVariables(PropertiesBuilder.fromCurrentEnvironmentVariables())
74-
.setSingleServerMode().setClusterPort(portIterator).setJMXPort(portIterator)
75-
.setJMXManagementMode(JMXManagementMode.LOCAL_ONLY).setRoleName("test-role").setSiteName("test-site");
83+
new ClusterMemberSchema().setEnvironmentInherited(true).setClusterPort(portIterator).setJMXSupport(true)
84+
.setSingleServerMode().setJMXPort(portIterator).setJMXManagementMode(JMXManagementMode.LOCAL_ONLY)
85+
.setRoleName("test-role").setSiteName("test-site");
7686

7787
ClusterMember member = null;
7888

7989
try
8090
{
81-
JavaApplicationBuilder<ClusterMember, ClusterMemberSchema> builder =
82-
new ExternalJavaApplicationBuilder<ClusterMember, ClusterMemberSchema>();
91+
JavaApplicationBuilder<ClusterMember, ClusterMemberSchema> builder = newJavaApplicationBuilder();
8392

84-
member = builder.realize(schema, "TEST");
93+
member = builder.realize(schema, "TEST", new SystemApplicationConsole());
8594

8695
assertThat(eventually(invoking(member).getClusterSize()), is(1));
8796

88-
if (member instanceof Application)
89-
{
90-
long pid = ((Application<?>) member).getPid();
91-
92-
Assert.assertTrue(pid > 0);
93-
}
94-
9597
Assert.assertEquals("test-role", member.getRoleName());
9698
Assert.assertEquals("test-site", member.getSiteName());
9799
}

0 commit comments

Comments
 (0)