/*
* 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.
*/
/*
* @test
* @bug 6222826
* @summary Test that tasks are cancelled properly when
* monitors are started and stopped in a loop.
* @author Luis-Miguel Alventosa
* @run clean StartStopTest
* @run build StartStopTest
*/
public class StartStopTest {
static int maxPoolSize;
// MBean class
public boolean called = false;
task("Integer");
return 0;
}
task("Double");
return 0.0;
}
task("String");
return "";
}
called = true;
final int c = counter.incrementAndGet();
}
}
// MBean interface
public interface ObservedObjectMBean {
}
/**
* Run test
*/
try {
echo(">>> CREATE MBeanServer");
for (int i = 0; i < nTasks; i++) {
mbeanNames[i] =
monitored[i] = new ObservedObject();
switch (monitorType) {
case 1:
"instance=" + (i + 1));
monitor[i] = new CounterMonitor();
break;
case 2:
"instance=" + (i + 1));
monitor[i] = new GaugeMonitor();
break;
case 3:
"instance=" + (i + 1));
monitor[i] = new StringMonitor();
break;
default:
echo("Unsupported monitor type");
return 1;
}
}
for (int j = 0; j < 2; j++) {
echo(">>> Start MONITORS");
for (int i = 0; i < nTasks; i++)
echo(">>> MONITORS started");
echo(">>> Check FLAGS true");
for (int i = 0; i < nTasks; i++)
echo("KO: At least one attribute was not called");
return 1;
}
echo(">>> FLAGS checked true");
echo(">>> Stop MONITORS");
for (int i = 0; i < nTasks; i++)
echo(">>> MONITORS stopped");
echo(">>> Set FLAGS to false");
for (int i = 0; i < nTasks; i++)
echo(">>> FLAGS set to false");
echo(">>> Check FLAGS remain false");
for (int i = 0; i < nTasks; i++)
echo("KO: At least one attribute " +
"continued to get called");
return 1;
}
echo(">>> FLAGS checked false");
}
} finally {
for (int i = 0; i < nTasks; i++)
}
return 0;
}
/*
* Print message
*/
}
/*
* Standalone entry point.
*
* Run the test and report to stdout.
*/
maxPoolSize = 10;
echo(">>> MAXIMUM POOL SIZE = 10 [default value]");
} else {
}
if (error > 0) {
echo(">>> Unhappy Bye, Bye!");
throw new IllegalStateException(
"Test FAILED: Unexpected Maximum Pool Size Overflow!");
} else {
echo(">>> Happy Bye, Bye!");
}
}
}