Examples of JarVisitor


Examples of org.hibernate.ejb.packaging.JarVisitor

    File nestedEarDir = buildNestedEarDir( defaultPar );
    addPackageToClasspath( nestedEar );

    String jarFileName = nestedEar.toURL().toExternalForm() + "!/defaultpar.par";
    Filter[] filters = getFilters();
    JarVisitor jarVisitor = new JarProtocolVisitor( new URL( jarFileName ), filters, "" );
    //TODO should we fix the name here to reach defaultpar rather than nestedjar ??
    //assertEquals( "defaultpar", jarVisitor.getUnqualifiedJarName() );
    Set entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    Entry entry = new Entry( ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new Entry( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( ( Entry ) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for ( Entry localEntry : ( Set<Entry> ) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }

    jarFileName = nestedEarDir.toURL().toExternalForm() + "!/defaultpar.par";
    //JarVisitor jarVisitor = new ZippedJarVisitor( jarFileName, true, true );
    filters = getFilters();
    jarVisitor = new JarProtocolVisitor( new URL( jarFileName ), filters, "" );
    //TODO should we fix the name here to reach defaultpar rather than nestedjar ??
    //assertEquals( "defaultpar", jarVisitor.getUnqualifiedJarName() );
    entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    entry = new Entry( ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new Entry( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( ( Entry ) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for ( Entry localEntry : ( Set<Entry> ) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }
  }
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

    File war = buildWar();
    addPackageToClasspath( war );

    String jarFileName = war.toURL().toExternalForm() + "!/WEB-INF/classes";
    Filter[] filters = getFilters();
    JarVisitor jarVisitor = new JarProtocolVisitor( new URL( jarFileName ), filters, "" );
    assertEquals( "war", jarVisitor.getUnqualifiedJarName() );
    Set entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    Entry entry = new Entry( org.hibernate.ejb.test.pack.war.ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new Entry( org.hibernate.ejb.test.pack.war.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( ( Entry ) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for ( Entry localEntry : ( Set<Entry> ) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }
  }
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

  public void testZippedJar() throws Exception {
    File defaultPar = buildDefaultPar();
    addPackageToClasspath( defaultPar );

    Filter[] filters = getFilters();
    JarVisitor jarVisitor = new FileZippedJarVisitor( defaultPar.toURL(), filters, "" );
    assertEquals( "defaultpar", jarVisitor.getUnqualifiedJarName() );
    Set entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    Entry entry = new Entry( ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new Entry( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( ( Entry ) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for ( Entry localEntry : ( Set<Entry> ) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }
  }
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

    String dirPath = explodedPar.toURL().toExternalForm();
    // TODO - shouldn't  ExplodedJarVisitor take care of a trailing slash?
    if ( dirPath.endsWith( "/" ) ) {
      dirPath = dirPath.substring( 0, dirPath.length() - 1 );
    }
    JarVisitor jarVisitor = new ExplodedJarVisitor( dirPath, filters );
    assertEquals( "explodedpar", jarVisitor.getUnqualifiedJarName() );
    Set[] entries = jarVisitor.getMatchingEntries();
    assertEquals( 1, entries[1].size() );
    assertEquals( 1, entries[0].size() );
    assertEquals( 1, entries[2].size() );

    Entry entry = new Entry( Carpet.class.getName(), null );
    assertTrue( entries[1].contains( entry ) );
    for ( Entry localEntry : ( Set<Entry> ) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }
  }
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

    }
    catch (IOException ie) {
      //fail silently
      return;
    }
    JarVisitor visitor = JarVisitorFactory.getVisitor( url, getFilters() );
    assertEquals( 0, visitor.getMatchingEntries()[0].size() );
    assertEquals( 0, visitor.getMatchingEntries()[1].size() );
    assertEquals( 0, visitor.getMatchingEntries()[2].size() );
  }
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

          return null;
      }
    });
       
    URL jarUrl  = new URL ("file:./target/test-packages/defaultpar.par");
    JarVisitor jarVisitor =  JarVisitorFactory.getVisitor(jarUrl, getFilters(), null);
    assertEquals(FileZippedJarVisitor.class.getName(), jarVisitor.getClass().getName());
   
    jarUrl  = new URL ("file:./target/test-packages/explodedpar.par");
    jarVisitor =  JarVisitorFactory.getVisitor(jarUrl, getFilters(), null);
    assertEquals(ExplodedJarVisitor.class.getName(), jarVisitor.getClass().getName());
   
      jarUrl  = new URL ("vfszip:./target/test-packages/defaultpar.par");
    jarVisitor =  JarVisitorFactory.getVisitor(jarUrl, getFilters(), null);
    //ideally it should be FileZippedJarVisitor as well, but there is a bug in FileZippedJarVisitor
    //which causes regression for some tests in EAP test suite. InputStreamZippedJarVisitor is safer than it, for now.
    assertEquals(InputStreamZippedJarVisitor.class.getName(), jarVisitor.getClass().getName());
   
    jarUrl  = new URL ("vfsfile:./target/test-packages/explodedpar.par");
    jarVisitor =  JarVisitorFactory.getVisitor(jarUrl, getFilters(), null);
    assertEquals(ExplodedJarVisitor.class.getName(), jarVisitor.getClass().getName());   
 
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

  public void testInputStreamZippedJar() throws Exception {
    String jarFileName = "file:./target/test-packages/defaultpar.par";
    //JarVisitor jarVisitor = new ZippedJarVisitor( jarFileName, true, true );
    Filter[] filters = getFilters();
    JarVisitor jarVisitor = new InputStreamZippedJarVisitor( new URL( jarFileName ), filters, "" );
    assertEquals( "defaultpar", jarVisitor.getUnqualifiedJarName() );
    Set entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    Entry entry = new Entry( ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new Entry( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( (Entry) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for (Entry localEntry : (Set<Entry>) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }
  }
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

  public void testNestedJarProtocol() throws Exception {
    String jarFileName = "jar:file:./target/test-packages/nestedjar.ear!/defaultpar.par";
    //JarVisitor jarVisitor = new ZippedJarVisitor( jarFileName, true, true );
    Filter[] filters = getFilters();
    JarVisitor jarVisitor = new JarProtocolVisitor( new URL( jarFileName ), filters, "" );
    //TODO should we fix the name here to reach defaultpar rather than nestedjar ??
    //assertEquals( "defaultpar", jarVisitor.getUnqualifiedJarName() );
    Set entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    Entry entry = new Entry( ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new Entry( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( (Entry) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for (Entry localEntry : (Set<Entry>) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }

    jarFileName = "jar:file:./target/test-packages/nesteddir.ear!/defaultpar.par";
    //JarVisitor jarVisitor = new ZippedJarVisitor( jarFileName, true, true );
    filters = getFilters();
    jarVisitor = new JarProtocolVisitor( new URL( jarFileName ), filters, "" );
    //TODO should we fix the name here to reach defaultpar rather than nestedjar ??
    //assertEquals( "defaultpar", jarVisitor.getUnqualifiedJarName() );
    entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    entry = new Entry( ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new Entry( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( (Entry) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for (Entry localEntry : (Set<Entry>) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }
  }
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

  public void testJarProtocol() throws Exception {
    String jarFileName = "jar:file:./target/test-packages/war.war!/WEB-INF/classes";
    //JarVisitor jarVisitor = new ZippedJarVisitor( jarFileName, true, true );
    Filter[] filters = getFilters();
    JarVisitor jarVisitor = new JarProtocolVisitor( new URL( jarFileName ), filters, "" );
    assertEquals( "war", jarVisitor.getUnqualifiedJarName() );
    Set entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    Entry entry = new Entry( org.hibernate.ejb.test.pack.war.ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new Entry( org.hibernate.ejb.test.pack.war.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( (Entry) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for (Entry localEntry : (Set<Entry>) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }
  }
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

  public void testZippedJar() throws Exception {
    String jarFileName = "file:./target/test-packages/defaultpar.par";
    //JarVisitor jarVisitor = new ZippedJarVisitor( jarFileName, true, true );
    Filter[] filters = getFilters();
    JarVisitor jarVisitor = new FileZippedJarVisitor( new URL( jarFileName ), filters, "" );
    assertEquals( "defaultpar", jarVisitor.getUnqualifiedJarName() );
    Set entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    Entry entry = new Entry( ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new Entry( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( (Entry) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for (Entry localEntry : (Set<Entry>) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.