/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*
*
* Unit test for Attach API. Attaches to the given VM and performs a number
* unit tests.
*/
public class BasicTests {
// Test 1 - read the system properties from the target VM and
// check that property is set
throw new RuntimeException("attach.test property not set");
}
// Test 1a - read the agent properties from the target VM.
// By default, the agent property contains "sun.java.command",
// "sun.jvm.flags", and "sun.jvm.args".
// Just sanity check - make sure not empty.
throw new RuntimeException("Agent properties is empty");
}
// Test 2 - attempt to load an agent that does not exist
try {
} catch (AgentLoadException x) {
}
// Test 3 - load an "bad" agent (agentmain throws an exception)
+ "to appear in the application log about SilverBullet.jar "
+ "not being found and an agent failing to start.");
try {
throw new RuntimeException(
"AgentInitializationException not thrown as expected!");
} catch (AgentInitializationException x) {
" - AgentInitializationException thrown as expected!");
}
// Test 4 - detach from the VM and attempt a load (should throw IOE)
+ "to appear in the application log about a BadAgent including "
+ "a RuntimeException and an InvocationTargetException.");
try {
throw new RuntimeException("loadAgent did not throw an exception!!");
} catch (IOException ioe) {
}
// Test 5 - functional "end-to-end" test.
// Create a listener socket. Load Agent.jar into the target VM passing
// it the port number of our listener. When agent loads it should connect
// back to the tool.
// Test 5b - functional "end-to-end" test.
// Now with an agent that does redefine.
// Test 6 - list method should list the target VM
if (!l.isEmpty()) {
boolean found = false;
for (VirtualMachineDescriptor vmd: l) {
found = true;
break;
}
}
if (found) {
} else {
}
}
throw new RuntimeException("virtual machines are not equal");
}
throw new RuntimeException("virtual machine hashCodes not equal");
}
// ---
s.close();
}
}