/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4607272 6842687
* @summary Unit test for AsynchronousChannelGroup
*/
/**
* Tests that the completion handler is invoked by a thread with
* the expected identity.
*/
public class Identity {
throw new RuntimeException(msg);
}
// thread-local identifies the thread
new ThreadLocal<Integer>() {
}
};
// creates a ThreadFactory that constructs groups with the given identity
return new ThreadFactory() {
public void run() {
r.run();
}});
t.setDaemon(true);
return t;
}
};
}
// create listener to accept connections
if (bytesRead < 0) {
} else {
}
}
}
});
}
}
});
// create 3-10 channels, each in its own group
for (int i=0; i<groupCount; i++) {
if (rand.nextBoolean()) {
} else {
}
// create channel in group and connect it to the server
}
// randomly write to each channel, ensuring that the completion handler
// is always invoked by a thread with the right identity.
if (bytesWritten != 1)
fail("Expected 1 byte to be written");
fail("Handler invoked by thread with the wrong identity");
} else {
}
}
}
});
// wait until done
// clean-up
group.shutdownNow();
throw new RuntimeException("Test failed - see log for details");
}
if (rand.nextBoolean()) {
} else {
}
return buf;
}
}