Tabnine Logo
org.apache.commons.jcs.admin
Code IndexAdd Tabnine to your IDE (free)

How to use org.apache.commons.jcs.admin

Best Java code snippets using org.apache.commons.jcs.admin (Showing top 20 results out of 315)

origin: org.apache.tomee.patch/commons-jcs-core

/**
 * This should count the size of the array.
 *
 * @throws Exception
 */
public void testByteArray() throws Exception
{
  CountingOnlyOutputStream out = new CountingOnlyOutputStream();
  byte[] array = new byte[]{1,2,3,4,5};
  out.write( array );
  assertEquals( "Wrong number of bytes written.", array.length, out.getCount() );
  out.close();
}
origin: org.apache.commons/commons-jcs-core

  /**
   * @return string info on the item
   */
  @Override
  public String toString()
  {
    StringBuilder buf = new StringBuilder();
    buf.append( "\nCacheElementInfo " );
    buf.append( "\n Key [" ).append( getKey() ).append( "]" );
    buf.append( "\n Eternal [" ).append( isEternal() ).append( "]" );
    buf.append( "\n CreateTime [" ).append( getCreateTime() ).append( "]" );
    buf.append( "\n MaxLifeSeconds [" ).append( getMaxLifeSeconds() ).append( "]" );
    buf.append( "\n ExpiresInSeconds [" ).append( getExpiresInSeconds() ).append( "]" );

    return buf.toString();
  }
}
origin: org.apache.commons/commons-jcs-core

/**
 * Tries to estimate how much data is in a region. This is expensive. If there are any non serializable objects in
 * the region or an error occurs, suppresses exceptions and returns 0.
 * <p>
 *
 * @return int The size of the region in bytes.
 */
@Override
public int getByteCount(String cacheName)
{
  return getByteCount(cacheHub.getCache(cacheName));
}
origin: org.apache.commons/commons-jcs-core

/**
 * Remove an item via the remove method.
 *
 * @throws Exception
 */
public void testRemove()
  throws Exception
{
  JCSAdminBean admin = new JCSAdminBean();
  String regionName = "myRegion";
  CacheAccess<String, String> cache = JCS.getInstance( regionName );
  // clear the region
  cache.clear();
  admin.clearRegion( regionName );
  String key = "myKey";
  cache.put( key, "value" );
  CacheElementInfo[] elements = admin.buildElementInfo( regionName );
  assertEquals( "Wrong number of elements in the region.", 1, elements.length );
  CacheElementInfo elementInfo = elements[0];
  assertEquals( "Wrong key.", key, elementInfo.getKey() );
  admin.removeItem( regionName, key );
  CacheElementInfo[] elements2 = admin.buildElementInfo( regionName );
  assertEquals( "Wrong number of elements in the region after remove.", 0, elements2.length );
}
origin: org.apache.tomee.patch/commons-jcs-core

/**
 * Create a test region and then verify that we get it from the list.
 *
 * @throws Exception
 *
 */
public void testGetRegionInfo()
  throws Exception
{
  String regionName = "myRegion";
  CacheAccess<String, String> cache = JCS.getInstance( regionName );
  cache.put( "key", "value" );
  JCSAdminBean admin = new JCSAdminBean();
  CacheRegionInfo[] regions = admin.buildCacheInfo();
  boolean foundRegion = false;
  for (CacheRegionInfo info : regions)
  {
    if ( info.getCacheName().equals( regionName ) )
    {
      foundRegion = true;
      assertTrue( "Byte count should be greater than 5.", info.getByteCount() > 5 );
      assertNotNull( "Should have stats.", info.getCacheStatistics() );
    }
  }
  assertTrue( "Should have found the region we just created.", foundRegion );
}
origin: org.apache.tomee.patch/commons-jcs-core

/**
 * Put a value in a region and verify that it shows up.
 *
 * @throws Exception
 */
public void testGetElementForRegionInfo()
  throws Exception
{
  String regionName = "myRegion";
  CacheAccess<String, String> cache = JCS.getInstance( regionName );
  // clear the region
  cache.clear();
  String key = "myKey";
  cache.put( key, "value" );
  JCSAdminBean admin = new JCSAdminBean();
  CacheElementInfo[] elements = admin.buildElementInfo( regionName );
  assertEquals( "Wrong number of elements in the region.", 1, elements.length );
  CacheElementInfo elementInfo = elements[0];
  assertEquals( "Wrong key." + elementInfo, key, elementInfo.getKey() );
}
origin: org.apache.commons/commons-jcs-core

  /**
   * Add an item to a region. Call clear all and verify that it doesn't exist.
   *
   * @throws Exception
   */
  public void testClearAll()
    throws Exception
  {
    JCSAdminBean admin = new JCSAdminBean();

    String regionName = "myRegion";
    CacheAccess<String, String> cache = JCS.getInstance( regionName );

    String key = "myKey";
    cache.put( key, "value" );

    admin.clearAllRegions();

    CacheElementInfo[] elements2 = admin.buildElementInfo( regionName );
    assertEquals( "Wrong number of elements in the region after remove.", 0, elements2.length );
  }
}
origin: org.apache.tomee.patch/commons-jcs-core

  /**
   * @return string info on the region
   */
  @Override
  public String toString()
  {
    StringBuilder buf = new StringBuilder();
    buf.append( "\nCacheRegionInfo " );
    if ( cacheName != null )
    {
      buf.append( "\n CacheName [" + cacheName + "]" );
      buf.append( "\n Status [" + cacheStatus + "]" );
    }
    buf.append( "\n ByteCount [" + getByteCount() + "]" );

    return buf.toString();
  }
}
origin: org.apache.tomee.patch/commons-jcs-core

/**
 * Write a single byte and verify the count.
 *
 * @throws Exception
 */
public void testSingleByte() throws Exception
{
  CountingOnlyOutputStream out = new CountingOnlyOutputStream();
  out.write( 1 );
  assertEquals( "Wrong number of bytes written.", 1, out.getCount() );
  out.write( 1 );
  assertEquals( "Wrong number of bytes written.", 2, out.getCount() );
  out.close();
}
origin: org.apache.tomee.patch/commons-jcs-core

/**
 * Remove an item via the remove method.
 *
 * @throws Exception
 */
public void testRemove()
  throws Exception
{
  JCSAdminBean admin = new JCSAdminBean();
  String regionName = "myRegion";
  CacheAccess<String, String> cache = JCS.getInstance( regionName );
  // clear the region
  cache.clear();
  admin.clearRegion( regionName );
  String key = "myKey";
  cache.put( key, "value" );
  CacheElementInfo[] elements = admin.buildElementInfo( regionName );
  assertEquals( "Wrong number of elements in the region.", 1, elements.length );
  CacheElementInfo elementInfo = elements[0];
  assertEquals( "Wrong key.", key, elementInfo.getKey() );
  admin.removeItem( regionName, key );
  CacheElementInfo[] elements2 = admin.buildElementInfo( regionName );
  assertEquals( "Wrong number of elements in the region after remove.", 0, elements2.length );
}
origin: org.apache.commons/commons-jcs-core

/**
 * Create a test region and then verify that we get it from the list.
 *
 * @throws Exception
 *
 */
public void testGetRegionInfo()
  throws Exception
{
  String regionName = "myRegion";
  CacheAccess<String, String> cache = JCS.getInstance( regionName );
  cache.put( "key", "value" );
  JCSAdminBean admin = new JCSAdminBean();
  CacheRegionInfo[] regions = admin.buildCacheInfo();
  boolean foundRegion = false;
  for (CacheRegionInfo info : regions)
  {
    if ( info.getCacheName().equals( regionName ) )
    {
      foundRegion = true;
      assertTrue( "Byte count should be greater than 5.", info.getByteCount() > 5 );
      assertNotNull( "Should have stats.", info.getCacheStatistics() );
    }
  }
  assertTrue( "Should have found the region we just created.", foundRegion );
}
origin: org.apache.commons/commons-jcs-core

/**
 * Put a value in a region and verify that it shows up.
 *
 * @throws Exception
 */
public void testGetElementForRegionInfo()
  throws Exception
{
  String regionName = "myRegion";
  CacheAccess<String, String> cache = JCS.getInstance( regionName );
  // clear the region
  cache.clear();
  String key = "myKey";
  cache.put( key, "value" );
  JCSAdminBean admin = new JCSAdminBean();
  CacheElementInfo[] elements = admin.buildElementInfo( regionName );
  assertEquals( "Wrong number of elements in the region.", 1, elements.length );
  CacheElementInfo elementInfo = elements[0];
  assertEquals( "Wrong key." + elementInfo, key, elementInfo.getKey() );
}
origin: org.apache.tomee.patch/commons-jcs-core

  /**
   * Add an item to a region. Call clear all and verify that it doesn't exist.
   *
   * @throws Exception
   */
  public void testClearAll()
    throws Exception
  {
    JCSAdminBean admin = new JCSAdminBean();

    String regionName = "myRegion";
    CacheAccess<String, String> cache = JCS.getInstance( regionName );

    String key = "myKey";
    cache.put( key, "value" );

    admin.clearAllRegions();

    CacheElementInfo[] elements2 = admin.buildElementInfo( regionName );
    assertEquals( "Wrong number of elements in the region after remove.", 0, elements2.length );
  }
}
origin: org.apache.tomee.patch/commons-jcs-core

  /**
   * @return string info on the item
   */
  @Override
  public String toString()
  {
    StringBuilder buf = new StringBuilder();
    buf.append( "\nCacheElementInfo " );
    buf.append( "\n Key [" ).append( getKey() ).append( "]" );
    buf.append( "\n Eternal [" ).append( isEternal() ).append( "]" );
    buf.append( "\n CreateTime [" ).append( getCreateTime() ).append( "]" );
    buf.append( "\n MaxLifeSeconds [" ).append( getMaxLifeSeconds() ).append( "]" );
    buf.append( "\n ExpiresInSeconds [" ).append( getExpiresInSeconds() ).append( "]" );

    return buf.toString();
  }
}
origin: org.apache.commons/commons-jcs-core

  /**
   * @return string info on the region
   */
  @Override
  public String toString()
  {
    StringBuilder buf = new StringBuilder();
    buf.append( "\nCacheRegionInfo " );
    if ( cacheName != null )
    {
      buf.append( "\n CacheName [" + cacheName + "]" );
      buf.append( "\n Status [" + cacheStatus + "]" );
    }
    buf.append( "\n ByteCount [" + getByteCount() + "]" );

    return buf.toString();
  }
}
origin: org.apache.tomee.patch/commons-jcs-core

/**
 * Tries to estimate how much data is in a region. This is expensive. If there are any non serializable objects in
 * the region or an error occurs, suppresses exceptions and returns 0.
 * <p/>
 *
 * @return int The size of the region in bytes.
 */
@Override
public int getByteCount(String cacheName)
{
  return getByteCount(cacheHub.getCache(cacheName));
}
origin: org.apache.commons/commons-jcs-core

/**
 * This should count the size of the array.
 *
 * @throws Exception
 */
public void testByteArray() throws Exception
{
  CountingOnlyOutputStream out = new CountingOnlyOutputStream();
  byte[] array = new byte[]{1,2,3,4,5};
  out.write( array );
  assertEquals( "Wrong number of bytes written.", array.length, out.getCount() );
  out.close();
}
origin: org.apache.commons/commons-jcs-core

/**
 * Write a single byte and verify the count.
 *
 * @throws Exception
 */
public void testSingleByte() throws Exception
{
  CountingOnlyOutputStream out = new CountingOnlyOutputStream();
  out.write( 1 );
  assertEquals( "Wrong number of bytes written.", 1, out.getCount() );
  out.write( 1 );
  assertEquals( "Wrong number of bytes written.", 2, out.getCount() );
  out.close();
}
origin: org.apache.commons/commons-jcs-core

  /**
   * This should count the len -- the third arg
   *
   * @throws Exception
   */
  public void testByteArrayLenCount() throws Exception
  {
    CountingOnlyOutputStream out = new CountingOnlyOutputStream();
    byte[] array = new byte[]{1,2,3,4,5};
    int len = 3;
    out.write( array, 0, len );
    assertEquals( "Wrong number of bytes written.", len, out.getCount() );
    out.close();
  }
}
origin: org.apache.tomee.patch/commons-jcs-core

  /**
   * This should count the len -- the third arg
   *
   * @throws Exception
   */
  public void testByteArrayLenCount() throws Exception
  {
    CountingOnlyOutputStream out = new CountingOnlyOutputStream();
    byte[] array = new byte[]{1,2,3,4,5};
    int len = 3;
    out.write( array, 0, len );
    assertEquals( "Wrong number of bytes written.", len, out.getCount() );
    out.close();
  }
}
org.apache.commons.jcs.admin

Most used classes

  • JCSAdminBean
    A servlet which provides HTTP access to JCS. Allows a summary of regions to be viewed, and removeAll
  • CacheElementInfo
    Stores info on a cache element for the template
  • CacheRegionInfo
    Stores info on a cache region for the template
  • CountingOnlyOutputStream
    Keeps track of the number of bytes written to it, but doesn't write them anywhere.
  • AdminBeanUnitTest
    Test the admin bean that is used by the JCSAdmin.jsp
  • JCSAdminServlet
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now