Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 18 for ClassCastException (0.09 sec)

  1. src/main/java/jcifs/DfsReferralData.java

         *
         * @param <T> the target type to unwrap to
         * @param type the class of the target type
         * @return the referral adapted to type
         * @throws ClassCastException
         *             if the type is not valid for this object
         */
        <T extends DfsReferralData> T unwrap(Class<T> type);
    
        /**
         * Get the server this referral points to
         *
    Registered: Sat Dec 20 13:44:44 UTC 2025
    - Last Modified: Sat Aug 16 01:32:48 UTC 2025
    - 2.5K bytes
    - Viewed (0)
  2. src/test/java/jcifs/SmbTreeTest.java

         */
        @Test
        void testUnwrap_throwsException() {
            when(smbTree.unwrap(any())).thenThrow(new ClassCastException("Cannot unwrap to specified type"));
    
            assertThrows(ClassCastException.class, () -> smbTree.unwrap(CustomSmbTree.class),
                    "Should throw ClassCastException when type is incompatible");
        }
    
        /**
         * Test for close() method under normal conditions.
    Registered: Sat Dec 20 13:44:44 UTC 2025
    - Last Modified: Thu Aug 14 05:31:44 UTC 2025
    - 9.2K bytes
    - Viewed (0)
  3. src/test/java/jcifs/smb/SmbPipeHandleImplTest.java

            // Happy path: unwrap to concrete type
            SmbPipeHandleImpl unwrapped = target.unwrap(SmbPipeHandleImpl.class);
            assertSame(target, unwrapped);
    
            // Incompatible type: expect ClassCastException
            class OtherPipeHandle implements SmbPipeHandle {
                @Override
                public SmbPipeResource getPipe() {
                    return mock(SmbPipeResource.class);
                }
    
    Registered: Sat Dec 20 13:44:44 UTC 2025
    - Last Modified: Thu Aug 14 05:31:44 UTC 2025
    - 11.7K bytes
    - Viewed (0)
  4. src/test/java/jcifs/smb/SmbTransportImplTest.java

                        return type.cast(this);
                    }
                    throw new ClassCastException("Cannot unwrap to " + type.getName());
                }
    
                @Override
                public void close() {
                    // no-op for test
                }
            }
            assertThrows(ClassCastException.class, () -> transport.unwrap(OtherTransport.class));
        }
    
        @Test
    Registered: Sat Dec 20 13:44:44 UTC 2025
    - Last Modified: Thu Aug 14 05:31:44 UTC 2025
    - 17.6K bytes
    - Viewed (0)
  5. src/test/java/jcifs/dcerpc/msrpc/MsrpcShareGetInfoTest.java

            infoField.setAccessible(true);
            infoField.set(msrpcShareGetInfo, info0);
    
            // This should throw ClassCastException
            assertThrows(ClassCastException.class, () -> {
                msrpcShareGetInfo.getSecurity();
            });
        }
    
        @Test
        void testGetSecurityWhenInfoIsNull() throws Exception {
    Registered: Sat Dec 20 13:44:44 UTC 2025
    - Last Modified: Thu Aug 14 05:31:44 UTC 2025
    - 14.3K bytes
    - Viewed (0)
  6. src/test/java/jcifs/smb/SmbSessionImplTest.java

            assertSame(session, session.unwrap(jcifs.SmbSession.class));
    
            // Edge: force incompatible class via raw type to trigger ClassCastException
            assertThrows(ClassCastException.class, () -> session.unwrap((Class) String.class));
        }
    
        @Test
        @DisplayName("toString contains key identifiers")
        void testToString() {
    Registered: Sat Dec 20 13:44:44 UTC 2025
    - Last Modified: Thu Aug 14 05:31:44 UTC 2025
    - 12.5K bytes
    - Viewed (0)
  7. src/test/java/jcifs/smb/SIDTest.java

            void testUnwrap() throws Exception {
                SID sid = new SID("S-1-5-21-1");
                // Happy path
                assertSame(sid, sid.unwrap(SID.class));
                assertSame(sid, sid.unwrap(Object.class));
                // Invalid unwrap
                assertThrows(ClassCastException.class, () -> sid.unwrap(String.class));
            }
    
    Registered: Sat Dec 20 13:44:44 UTC 2025
    - Last Modified: Thu Aug 14 05:31:44 UTC 2025
    - 15.8K bytes
    - Viewed (0)
  8. src/test/java/jcifs/smb/SmbTreeImplTest.java

            SmbTreeImpl unwrapped = tree.unwrap(SmbTreeImpl.class);
            assertEquals(tree, unwrapped);
            // Test unwrapping to a non-assignable type should fail
            assertThrows(ClassCastException.class, () -> {
                // Create a mock class that extends SmbTree but is not assignable from SmbTreeImpl
                class CustomSmbTree extends SmbTreeImpl {
                    CustomSmbTree() {
    Registered: Sat Dec 20 13:44:44 UTC 2025
    - Last Modified: Thu Aug 14 05:31:44 UTC 2025
    - 7.8K bytes
    - Viewed (0)
  9. src/test/java/jcifs/smb/SmbRenewableCredentialsTest.java

            }
    
            @Override
            public <T extends Credentials> T unwrap(Class<T> type) {
                if (type.isInstance(this)) {
                    return type.cast(this);
                }
                throw new ClassCastException("Cannot unwrap to " + type.getName());
            }
        }
    
        static class SelfRenewingCreds extends BaseCreds {
            @Override
            public CredentialsInternal renew() {
    Registered: Sat Dec 20 13:44:44 UTC 2025
    - Last Modified: Thu Aug 14 05:31:44 UTC 2025
    - 7K bytes
    - Viewed (0)
  10. src/main/java/jcifs/smb/SmbTreeImpl.java

        @Override
        public <T extends SmbTree> T unwrap(final Class<T> type) {
            if (type.isAssignableFrom(this.getClass())) {
                return (T) this;
            }
            throw new ClassCastException();
        }
    
        /**
         * @param track
         * @return tree with increased usage count
         */
        public SmbTreeImpl acquire(final boolean track) {
    Registered: Sat Dec 20 13:44:44 UTC 2025
    - Last Modified: Sun Aug 31 08:00:57 UTC 2025
    - 30K bytes
    - Viewed (0)
Back to top