Examples of JarVisitor


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

Examples of org.hibernate.ejb.packaging.JarVisitor

  public void testExplodedJar() throws Exception {
    String jarFileName = "./target/test-packages/explodedpar.par";
    //JarVisitor jarVisitor = new ExplodedJarVisitor( jarFileName, true, true );
    Filter[] filters = getFilters();
    JarVisitor jarVisitor = new ExplodedJarVisitor( jarFileName, 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

              metadata.getProvider()
          ) ) {
            //correct provider

            //lazy compute the visitor if possible to avoid useless exceptions if an unexpected state happens
            JarVisitor visitor = null;

            if ( metadata.getName() == null ) {
              visitor = getMainJarVisitor( url, metadata, integration );
              metadata.setName( visitor.getUnqualifiedJarName() );
            }
            if ( persistenceUnitName == null && xmls.hasMoreElements() ) {
              throw new PersistenceException( "No name provided and several persistence units found" );
            }
            else if ( persistenceUnitName == null || metadata.getName().equals( persistenceUnitName ) ) {
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

    if (jar == null) {
      log.error( "Container is providing a null PersistenceUnitRootUrl: discovery impossible");
      return;
    }
    try {
      JarVisitor visitor = JarVisitorFactory.getVisitor( jar, getFilters( detectedArtifacts, searchORM, null ) );
      addScannedEntries( visitor, entities, packages, hbmFiles, null );
    }
    catch (RuntimeException e) {
      throw new RuntimeException( "error trying to scan <jar-file>: " + jar.toString(), e );
    }
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

  public void testInputStreamZippedJar() throws Exception {
    String jarFileName = "file:./build/testresources/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();
    }

//    Set<String> classes = jarVisitor.getClassNames();
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

  public void testNestedJarProtocol() throws Exception {
    String jarFileName = "jar:file:./build/testresources/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:./build/testresources/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();
    }

//    Set<String> classes = jarVisitor.getClassNames();
View Full Code Here

Examples of org.hibernate.ejb.packaging.JarVisitor

  public void testJarProtocol() throws Exception {
    String jarFileName = "jar:file:./build/testresources/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();
    }

//    Set<String> classes = jarVisitor.getClassNames();
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.