public static Region createPartitionedRegion(String regionName, String localMaxMemory,
      int redundancy) {
    Region pr = null;
    PartitionAttributes pa;
    PartitionAttributesFactory paf = new PartitionAttributesFactory();
    AttributesFactory af = new AttributesFactory();
    RegionAttributes ra;
    // setting property
    // setting partition attributes to partitionAttributesFactory
    int lmax;
    try {
      lmax = Integer.parseInt(localMaxMemory);
    } catch (NumberFormatException nfe) {
      throw new IllegalArgumentException(
          "localMaxMemory must be an integer (" + localMaxMemory + ")");
    }
    pa = paf.setLocalMaxMemory(lmax).setRedundantCopies(redundancy).create();
    // setting attribute factor
    af.setPartitionAttributes(pa);
    // creating region attributes
    ra = af.create();
    cache = createCache();
    try {
      pr = cache.createRegion(regionName, ra);
    } catch (RegionExistsException rex) {
      pr = cache.getRegion(regionName);
    }
    return pr;
  }
This is a function to create partitioned region with following paramaters:
<p>
1) name
<p>
2) local max memory
<p>
3) redundancy and scope.

The cache created is a loner, so this is only suitable for single VM tests.
geode-junit/src/main/java/org/apache/geode/internal/cache/PartitionedRegionTestHelper.java