<commit_before>package de.zib.gndmc.DSpace.tests;

/*
 * Copyright 2008-2011 Zuse Institute Berlin (ZIB)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */



import de.zib.gndms.dspace.client.DSpaceClient;
import de.zib.gndms.dspace.slice.client.SliceClient;
import de.zib.gndms.dspace.slice.common.SliceConstants;
import de.zib.gndms.dspace.slice.stubs.types.SliceReference;
import de.zib.gndms.dspace.subspace.client.SubspaceClient;
import de.zib.gndms.dspace.subspace.stubs.types.SubspaceReference;
import de.zib.gndms.gritserv.delegation.DelegationAux;
import org.apache.axis.message.MessageElement;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.apache.axis.message.addressing.ReferencePropertiesType;
import org.apache.axis.types.URI;
import org.globus.gsi.GlobusCredential;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import types.ContextT;

import javax.xml.namespace.QName;
import java.rmi.RemoteException;
import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;


/**
 * Yet another test client
 *
 * This test client does unit testing on the dspace entities.
 * It expects a dspace which is set up using the default setup-dataprovider.sh script. Also setup-testsubspace.sh should
 * be executed befor running this test.
 * If there are some more subspaces or the like, some tests may trigger assertions even so they are correct.
 *
 *
 * @author  try ma ik jo rr a zib
 * @version  $Id$
 * <p/>
 * User: mjorra, Date: 27.10.2008, Time: 17:39:54
 */
public class Yatc {

    private static final String[] C3GRID_SLICE_KINDS =
        {"http://www.c3grid.de/G2/SliceKind/Staging", "http://www.c3grid.de/G2/SliceKind/DMS"};
    private static final String[] PTGRID_SLICE_KINDS =
        {"http://www.ptgrid.de/G1/SliceKind/Staging_RW", "http://www.c3grid.de/G2/SliceKind/DMS"};
    private static String[] SLICE_KINDS = PTGRID_SLICE_KINDS;

    private String dspaceURI;
    // c3grid workspace
    // private static final String SCHEMA_URI = "http://www.c3grid.de/G2/Subspace";
    // ptgrid workspace
    private static final String SCHEMA_URI = "http://www.ptgrid.de/G1/Subspace";
    private String localName;
    private String scopeName;
    private String gsiPath;
    private DSpaceClient client;
    private SliceClient slice;
    // some slice test values required in different methods
    private GregorianCalendar tt;
    private long ssize;
    private String skuri;

    private boolean useDelegation = true;


    // Params should be self-explanatory. gsiPath denotes the public grid ftp location
    // of the provided workspace. And scope- resp. localName are the address of the test
    // subspace.
    @Parameters( { "dspaceURI", "scopeName", "localName", "gsiPath" } )
    public Yatc( String dspaceURI, String scopeName, String localName, String gsiPath ) {
        this.dspaceURI = dspaceURI;
        this.scopeName = scopeName;
        this.localName = localName;
        this.gsiPath = gsiPath;
    }


    @BeforeClass( groups={ "dspace", "subspace" } )
    public void beforeTest( ) throws Exception {
        client = new DSpaceClient( dspaceURI );

        if( useDelegation ) {
            // with delegation
            String delfac = DelegationAux.createDelationAddress( dspaceURI );
            GlobusCredential credential = DelegationAux.findCredential( DelegationAux.defaultProxyFileName( "1000" ) );
            EndpointReferenceType epr = DelegationAux.createProxy( delfac, credential );
            DelegationAux.addDelegationEPR( new ContextT(), epr );
            client.setProxy( credential );
        }
    }



    @Parameters( { "noSubspaces", "noSchemas"} )
    @Test( groups={ "dspace"  } ) 
    public void runDspaceTests( int noSubspaces, int noSchemas ) throws Exception {

        System.out.println( ">>> Performing dspace tests" );

        System.out.println( "checking listSupportedSchemas()" );
        URI[] uris = client.listSupportedSchemas();

        Assert.assertEquals ( uris.length, noSchemas, "length of result" );
        URI suri = new URI( SCHEMA_URI );
        Assert.assertEquals ( uris[0], suri, "expected value?" );<commit_msg>fixed typo<commit_after>package de.zib.gndmc.DSpace.tests;

/*
 * Copyright 2008-2011 Zuse Institute Berlin (ZIB)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */



import de.zib.gndms.dspace.client.DSpaceClient;
import de.zib.gndms.dspace.slice.client.SliceClient;
import de.zib.gndms.dspace.slice.common.SliceConstants;
import de.zib.gndms.dspace.slice.stubs.types.SliceReference;
import de.zib.gndms.dspace.subspace.client.SubspaceClient;
import de.zib.gndms.dspace.subspace.stubs.types.SubspaceReference;
import de.zib.gndms.gritserv.delegation.DelegationAux;
import org.apache.axis.message.MessageElement;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.apache.axis.message.addressing.ReferencePropertiesType;
import org.apache.axis.types.URI;
import org.globus.gsi.GlobusCredential;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import types.ContextT;

import javax.xml.namespace.QName;
import java.rmi.RemoteException;
import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;


/**
 * Yet another test client
 *
 * This test client does unit testing on the dspace entities.
 * It expects a dspace which is set up using the default setup-dataprovider.sh script. Also setup-testsubspace.sh should
 * be executed befor running this test.
 * If there are some more subspaces or the like, some tests may trigger assertions even so they are correct.
 *
 *
 * @author  try ma ik jo rr a zib
 * @version  $Id$
 * <p/>
 * User: mjorra, Date: 27.10.2008, Time: 17:39:54
 */
public class Yatc {

    private static final String[] C3GRID_SLICE_KINDS =
        {"http://www.c3grid.de/G2/SliceKind/Staging", "http://www.c3grid.de/G2/SliceKind/DMS"};
    private static final String[] PTGRID_SLICE_KINDS =
        {"http://www.ptgrid.de/G1/SliceKind/Staging_RW", "http://www.c3grid.de/G2/SliceKind/DMS"};
    private static String[] SLICE_KINDS = PTGRID_SLICE_KINDS;

    private String dspaceURI;
    // c3grid workspace
    // private static final String SCHEMA_URI = "http://www.c3grid.de/G2/Subspace";
    // ptgrid workspace
    private static final String SCHEMA_URI = "http://www.ptgrid.de/G1/Subspace";
    private String localName;
    private String scopeName;
    private String gsiPath;
    private DSpaceClient client;
    private SliceClient slice;
    // some slice test values required in different methods
    private GregorianCalendar tt;
    private long ssize;
    private String skuri;

    private boolean useDelegation = true;


    // Params should be self-explanatory. gsiPath denotes the public grid ftp location
    // of the provided workspace. And scope- resp. localName are the address of the test
    // subspace.
    @Parameters( { "dspaceURI", "scopeName", "localName", "gsiPath" } )
    public Yatc( String dspaceURI, String scopeName, String localName, String gsiPath ) {
        this.dspaceURI = dspaceURI;
        this.scopeName = scopeName;
        this.localName = localName;
        this.gsiPath = gsiPath;
    }


    @BeforeClass( groups={ "dspace", "subspace" } )
    public void beforeTest( ) throws Exception {
        client = new DSpaceClient( dspaceURI );

        if( useDelegation ) {
            // with delegation
            String delfac = DelegationAux.createDelegationAddress( dspaceURI );
            GlobusCredential credential = DelegationAux.findCredential( DelegationAux.defaultProxyFileName( "1000" ) );
            EndpointReferenceType epr = DelegationAux.createProxy( delfac, credential );
            DelegationAux.addDelegationEPR( new ContextT(), epr );
            client.setProxy( credential );
        }
    }



    @Parameters( { "noSubspaces", "noSchemas"} )
    @Test( groups={ "dspace"  } ) 
    public void runDspaceTests( int noSubspaces, int noSchemas ) throws Exception {

        System.out.println( ">>> Performing dspace tests" );

        System.out.println( "checking listSupportedSchemas()" );
        URI[] uris = client.listSupportedSchemas();

        Assert.assertEquals ( uris.length, noSchemas, "length of result" );
        URI suri = new URI( SCHEMA_URI );
        Assert.assertEquals ( uris[0], suri, "expected value?" );
{'fraction_non_alphanumeric': 0.10009364270107168, 'fraction_numerical': 0.00894808032462803, 'mean_word_length': 3.5126760563380284, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 14, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4037066', 'n_tokens_mistral': 3020, 'n_tokens_neox': 2917, 'n_words': 817}