Advertisement
Guest User

Untitled

a guest
May 19th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 5.59 KB | None | 0 0
  1. /*
  2.  * OpenSpotLight - Open Source IT Governance Platform
  3.  *
  4.  * Copyright (c) 2009, CARAVELATECH CONSULTORIA E TECNOLOGIA EM INFORMATICA LTDA
  5.  * or third-party contributors as indicated by the @author tags or express
  6.  * copyright attribution statements applied by the authors.  All third-party
  7.  * contributions are distributed under license by CARAVELATECH CONSULTORIA E
  8.  * TECNOLOGIA EM INFORMATICA LTDA.
  9.  *
  10.  * This copyrighted material is made available to anyone wishing to use, modify,
  11.  * copy, or redistribute it subject to the terms and conditions of the GNU
  12.  * Lesser General Public License, as published by the Free Software Foundation.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17.  *
  18.  * See the GNU Lesser General Public License  for more details.
  19.  *
  20.  * You should have received a copy of the GNU Lesser General Public License
  21.  * along with this distribution; if not, write to:
  22.  * Free Software Foundation, Inc.
  23.  * 51 Franklin Street, Fifth Floor
  24.  * Boston, MA  02110-1301  USA
  25.  *
  26.  ***********************************************************************
  27.  * OpenSpotLight - Plataforma de Governança de TI de Código Aberto
  28.  *
  29.  * Direitos Autorais Reservados (c) 2009, CARAVELATECH CONSULTORIA E TECNOLOGIA
  30.  * EM INFORMATICA LTDA ou como contribuidores terceiros indicados pela etiqueta
  31.  * @author ou por expressa atribuição de direito autoral declarada e atribuída pelo autor.
  32.  * Todas as contribuições de terceiros estão distribuídas sob licença da
  33.  * CARAVELATECH CONSULTORIA E TECNOLOGIA EM INFORMATICA LTDA.
  34.  *
  35.  * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo sob os
  36.  * termos da Licença Pública Geral Menor do GNU conforme publicada pela Free Software
  37.  * Foundation.
  38.  *
  39.  * Este programa é distribuído na expectativa de que seja útil, porém, SEM NENHUMA
  40.  * GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU ADEQUAÇÃO A UMA
  41.  * FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral Menor do GNU para mais detalhes.
  42.  *
  43.  * Você deve ter recebido uma cópia da Licença Pública Geral Menor do GNU junto com este
  44.  * programa; se não, escreva para:
  45.  * Free Software Foundation, Inc.
  46.  * 51 Franklin Street, Fifth Floor
  47.  * Boston, MA  02110-1301  USA
  48.  */
  49. package org.openspotlight.graph.server.test;
  50.  
  51. import org.apache.log4j.Logger;
  52. import org.junit.*;
  53. import org.openspotlight.graph.*;
  54. import org.openspotlight.graph.annotation.SLVisibility.VisibilityLevel;
  55. import org.openspotlight.graph.client.RemoteGraphSessionFactory;
  56. import org.openspotlight.graph.client.RemoteGraphSessionFactory.RemoteGraphFactoryConnectionData;
  57. import org.openspotlight.graph.exception.*;
  58. import org.openspotlight.graph.server.RemoteGraphSessionServer;
  59. import org.openspotlight.graph.test.BaseGraphTest;
  60. import org.openspotlight.graph.test.NamePredicate;
  61. import org.openspotlight.graph.test.domain.link.JavaPackageNode;
  62. import org.openspotlight.graph.test.domain.link.*;
  63. import org.openspotlight.graph.test.domain.node.*;
  64. import org.openspotlight.jcr.provider.DefaultJcrDescriptor;
  65. import org.openspotlight.jcr.provider.JcrConnectionProvider;
  66. import org.openspotlight.remote.server.UserAuthenticator;
  67. import org.openspotlight.security.SLInvalidCredentialException;
  68.  
  69. import java.io.Serializable;
  70. import java.util.*;
  71.  
  72. import static org.openspotlight.graph.SLLink.*;
  73. import static org.openspotlight.graph.SLPersistenceMode.NORMAL;
  74. import static org.openspotlight.graph.SLPersistenceMode.TRANSIENT;
  75. import static org.openspotlight.graph.SLRecursiveMode.RECURSIVE;
  76.  
  77. /**
  78.  * The Class SLGraphTest.
  79.  *
  80.  * @author Vitor Hugo Chagas
  81.  */
  82.  
  83. public class SLRemoteGraphTest extends BaseGraphTest {
  84.  
  85.     private static final String userName = "testUser";
  86.  
  87.     private static final String pass = "password";
  88.  
  89.     private static RemoteGraphSessionFactory client;
  90.  
  91.     private static RemoteGraphSessionServer server;
  92.  
  93.     @BeforeClass
  94.     public static void init() throws Exception {
  95.         JcrConnectionProvider.createFromData(
  96.                 DefaultJcrDescriptor.TEMP_DESCRIPTOR)
  97.                 .closeRepositoryAndCleanResources();
  98.  
  99.         server = new RemoteGraphSessionServer(new UserAuthenticator() {
  100.  
  101.             public boolean canConnect(final String userName,
  102.                     final String password, final String clientHost) {
  103.                 return true;
  104.             }
  105.         }, 7070, 10 * 60 * 1000L, DefaultJcrDescriptor.TEMP_DESCRIPTOR);
  106.  
  107.     }
  108.  
  109.     @Override
  110.     public SLGraphSession openSession() throws SLGraphException {
  111.         return client.createRemoteGraphSession(userName, pass, SLConsts.DEFAULT_REPOSITORY_NAME);
  112.     }
  113.  
  114.     /**
  115.      * Before test.
  116.      *
  117.      * @throws org.openspotlight.graph.exception.SLGraphException
  118.      *             the SL graph exception
  119.      */
  120.     @Before
  121.     public void beforeTest() throws Exception {
  122.         JcrConnectionProvider.createFromData(
  123.                 DefaultJcrDescriptor.TEMP_DESCRIPTOR)
  124.                 .closeRepositoryAndCleanResources();
  125.         if (session == null) {
  126.             session = client.createRemoteGraphSession(userName, pass,
  127.                     SLConsts.DEFAULT_REPOSITORY_NAME);
  128.         }
  129.     }
  130.  
  131.  
  132.     @Before
  133.     public void setupClient() throws Exception {
  134.         if (session != null) {
  135.             session.clear();
  136.         }
  137.         server.remoteAllObjectsFromServer();
  138.         client = new RemoteGraphSessionFactory(
  139.                 new RemoteGraphFactoryConnectionData() {
  140.  
  141.                     public String getHost() {
  142.                         return "localhost";
  143.                     }
  144.  
  145.                     public String getPassword() {
  146.                         return "***";
  147.                     }
  148.  
  149.                     public int getPort() {
  150.                         return 7070;
  151.                     }
  152.  
  153.                     public String getUserName() {
  154.                         return "***";
  155.                     }
  156.                 });
  157.  
  158.     }
  159.  
  160.  
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement