private static void testStencils() {
        boolean enabled = true;

        final RenderState.StencilOperation frontSfo = RenderState.StencilOperation.Increment;
        final RenderState.StencilOperation frontDfo = RenderState.StencilOperation.Invert;
        final RenderState.StencilOperation frontDpo = RenderState.StencilOperation.Zero;
        final RenderState.StencilOperation backSfo = RenderState.StencilOperation.Replace;
        final RenderState.StencilOperation backDfo = RenderState.StencilOperation.DecrementWrap;
        final RenderState.StencilOperation backDpo = RenderState.StencilOperation.Keep;
        /*
         * Vary the test functions (8th and 9th arguments).
         */
        for (RenderState.TestFunction front : RenderState.TestFunction.values()) {
            for (RenderState.TestFunction back : RenderState.TestFunction.values()) {
                testObject.setStencil(enabled,
                        frontSfo, frontDfo, frontDpo, backSfo, backDfo, backDpo,
                        front, back);
                test();
            }
        }

        final RenderState.TestFunction front = RenderState.TestFunction.GreaterOrEqual;
        final RenderState.TestFunction back = RenderState.TestFunction.NotEqual;
        /*
         * Vary the 2nd, 4th, and 7th arguments.
         */
        for (RenderState.StencilOperation arg2 : RenderState.StencilOperation.values()) {
            for (RenderState.StencilOperation arg4 : RenderState.StencilOperation.values()) {
                for (RenderState.StencilOperation arg7 : RenderState.StencilOperation.values()) {
                    testObject.setStencil(enabled,
                            arg2, frontDfo, arg4, backSfo, backDfo, arg7,
                            front, back);
                    test();
                }
            }
        }
        /*
         * Vary the 3rd, 5th, and 6th arguments.
         */
        for (RenderState.StencilOperation arg3 : RenderState.StencilOperation.values()) {
            for (RenderState.StencilOperation arg5 : RenderState.StencilOperation.values()) {
                for (RenderState.StencilOperation arg6 : RenderState.StencilOperation.values()) {
                    testObject.setStencil(enabled,
                            frontSfo, arg3, frontDpo, arg5, arg6, backDpo,
                            front, back);
                    test();
                }
            }
        }

        enabled = false;
        testObject.setStencil(enabled,
                frontSfo, frontDfo, frontDpo, backSfo, backDfo, backDpo,
                front, back);
        test();
    }
Tests a subset of the possile stencil combinations.
jme3-core/src/test/java/com/jme3/material/RenderStateTest.java