protected boolean isAssumeIdentity(ConnectionReference conn) {
        return isAnonymousAccessAllowed() ||
                (isSystemConnection(conn) && !isVmConnectionAuthenticationRequired());
    }
@Test
    public void testIsAssumeIdentityWithSystemConnection() {

        ConnectionContext ctx = new ConnectionContext();
        Connection connection = new Connection() {

            private final long connectedTimestamp = System.currentTimeMillis();

            @Override
            public Connector getConnector() {
                return null;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void dispatchSync(Command message) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void dispatchAsync(Command command) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public Response service(Command command) {
                return null;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void serviceException(Throwable error) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public boolean isSlow() {
                return false;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public boolean isBlocked() {
                return false;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public boolean isConnected() {
                return false;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public boolean isActive() {
                return false;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public int getDispatchQueueSize() {
                return 0;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public ConnectionStatistics getStatistics() {
                return null;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public boolean isManageable() {
                return false;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public String getRemoteAddress() {
                return "vm://localhost";
            }

            @Override
            public void serviceExceptionAsync(IOException e) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public String getConnectionId() {
                return null;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public boolean isNetworkConnection() {
                return false;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public boolean isFaultTolerantConnection() {
                return false;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void updateClient(ConnectionControl control) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void start() throws Exception {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void stop() throws Exception {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public int getActiveTransactionCount() {
                return 0;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public Long getOldestActiveTransactionDuration() {
                return null;  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public Long getConnectedTimestamp() {
                return connectedTimestamp;
            }

        };

        ctx.setConnection(connection);

        SubjectConnectionReference sc = new SubjectConnectionReference(ctx, new ConnectionInfo(),
                new DefaultEnvironment(), new SubjectAdapter());

        assertTrue(policy.isAssumeIdentity(sc));
    }