@Test
    public void testSceneGraphSort() {
        Node n = new Node("node");
        Geometry g = new Geometry("geom", new Mesh());
        SpotLight spot = new SpotLight(Vector3f.ZERO, Vector3f.UNIT_X);
        PointLight point = new PointLight(Vector3f.UNIT_X);
        DirectionalLight directional = new DirectionalLight(Vector3f.UNIT_X);
        AmbientLight ambient = new AmbientLight();
        
        // Some lights are on the node
        n.addLight(spot);
        n.addLight(point);
        
        // ... and some on the geometry.
        g.addLight(directional);
        g.addLight(ambient);
        
        n.attachChild(g);
        n.updateGeometricState();
        
        LightList list = g.getWorldLightList();
        
        // check the sorting (when geom is at 0,0,0)
        assert list.get(0) instanceof AmbientLight;
        assert list.get(1) instanceof DirectionalLight;
        assert list.get(2) instanceof SpotLight;
        assert list.get(3) instanceof PointLight;
        
        // move the geometry closer to the point light
        g.setLocalTranslation(Vector3f.UNIT_X);
        n.updateGeometricState();
        
        assert list.get(0) instanceof AmbientLight;
        assert list.get(1) instanceof DirectionalLight;
        assert list.get(2) instanceof PointLight;
        assert list.get(3) instanceof SpotLight;
        
        // now move the point light away from the geometry
        // and the spot light closer
        
        // XXX: doesn't work! jME can't detect that the light moved!
//        point.setPosition(Vector3f.ZERO);
//        spot.setPosition(Vector3f.UNIT_X);
//        n.updateGeometricState();
//        
//        assert list.get(0) instanceof AmbientLight;
//        assert list.get(1) instanceof DirectionalLight;
//        assert list.get(2) instanceof SpotLight;
//        assert list.get(3) instanceof PointLight;
    }
Test light sorting (in the scene graph) for various light types.

@author Kirill Vainer
jme3-core/src/test/java/com/jme3/light/LightSortTest.java