View Javadoc

    1   /**
    2    * Copyright (c) 2002-2011 "Neo Technology,"
    3    * Network Engine for Objects in Lund AB [http://neotechnology.com]
    4    *
    5    * This file is part of Neo4j.
    6    *
    7    * Neo4j is free software: you can redistribute it and/or modify
    8    * it under the terms of the GNU General Public License as published by
    9    * the Free Software Foundation, either version 3 of the License, or
    10   * (at your option) any later version.
    11   *
    12   * This program is distributed in the hope that it will be useful,
    13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15   * GNU General Public License for more details.
    16   *
    17   * You should have received a copy of the GNU General Public License
    18   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    19   */
    20  package org.neo4j.server.plugins;
    21
    22  import static org.hamcrest.Matchers.hasItem;
    23  import static org.junit.Assert.assertNotNull;
    24  import static org.junit.Assert.assertThat;
    25
    26  import java.util.List;
    27  import java.util.Map;
    28
    29  import javax.ws.rs.core.MediaType;
    30
    31  import org.junit.AfterClass;
    32  import org.junit.BeforeClass;
    33  import org.junit.Test;
    34  import org.neo4j.graphdb.GraphDatabaseService;
    35  import org.neo4j.kernel.AbstractGraphDatabase;
    36  import org.neo4j.kernel.ImpermanentGraphDatabase;
    37  import org.neo4j.server.rest.repr.formats.NullFormat;
    38
    39  public class PluginManagerTest
    40  {
    41      private static PluginManager manager;
    42      private static AbstractGraphDatabase graphDb;
    43
    44      @BeforeClass
    45      public static void loadExtensionManager() throws Exception
    46      {
    47          graphDb = new ImpermanentGraphDatabase();
    48          manager = new PluginManager( null );
    49      }
    50
    51      @AfterClass
    52      public static void destroyExtensionManager()
    53      {
    54          manager = null;
    55          if ( graphDb != null ) graphDb.shutdown();
    56          graphDb = null;
    57      }
    58
    59      @Test
    60      public void canGetUrisForNode() throws Exception
    61      {
    62          Map<String, List<String>> extensions = manager.getExensionsFor( GraphDatabaseService.class );
    63          List<String> methods = extensions.get( Plugin.class.getSimpleName() );
    64          assertNotNull( methods );
    65          assertThat( methods, hasItem( Plugin.GET_REFERENCE_NODE ) );
    66      }
    67
    68      @Test
    69      public void canInvokeExtension() throws Exception
    70      {
    71          manager.invoke( graphDb, Plugin.class.getSimpleName(), GraphDatabaseService.class,
    72                  Plugin.GET_REFERENCE_NODE, graphDb,
    73                  new NullFormat( null, (MediaType[]) null ).readParameterList( "" ) );
    74      }
    75  }