Package org.apache.kato.tck.scenario142.javaruntime

Source Code of org.apache.kato.tck.scenario142.javaruntime.TestJavaThreadInspection

/*******************************************************************************
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.apache.kato.tck.scenario142.javaruntime;

import java.util.Iterator;

import javax.tools.diagnostics.image.CorruptDataException;
import javax.tools.diagnostics.image.MemoryAccessException;
import javax.tools.diagnostics.runtime.java.JavaField;
import javax.tools.diagnostics.runtime.java.JavaObject;
import javax.tools.diagnostics.runtime.java.JavaThread;

import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;


/**
* Tests to ensure that valid Thread objects get reported correctly
*
*/
public class TestJavaThreadInspection extends TCKJavaRuntimeTestcase{


private JavaObject[] threadDumpInstances=null;

 
  /**
   * Locate special holder
   * @throws CorruptDataException
   * @throws MemoryAccessException
   */
  public void setUp() throws CorruptDataException, MemoryAccessException {
       
    JavaObject thisTestInstanceInDump=getScenerioReference();
    assertNotNull(thisTestInstanceInDump);
   
   
    Iterator i=thisTestInstanceInDump.getJavaClass().getDeclaredFields().iterator();
    assertNotNull("declared fields iterator is null",i);
   
    while(i.hasNext()) {
      Object o=i.next();
      if(o instanceof JavaField) {
        JavaField field=(JavaField) o;
        String name=field.getName();
        if(name.equals("configThreadInstances")) {
          JavaObject obj=(JavaObject) field.get(thisTestInstanceInDump);
          // found field
       
          int arraySize=obj.getArraySize();
          assertEquals(3,arraySize);
          threadDumpInstances=new JavaObject[arraySize];
          obj.arraycopy(0,threadDumpInstances,0,arraySize);
          return;
        }
       
      }
    }
   
    fail("unable to locate thread instances field in testcase instance in dump");
   
  }
 
  /**
   * Test that the contents of a thread created using new Thread() can be
   * retrieved
   */
  public void testSimpleThreadCreation() throws Exception {
    assertNotNull(threadDumpInstances);
    JavaObject o1=threadDumpInstances[0];
   
    Thread t=new Thread();
    JavaThread jt;
   
  }
}
TOP

Related Classes of org.apache.kato.tck.scenario142.javaruntime.TestJavaThreadInspection

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.