### Question:
EventSubject implements Serializable { public static EventSubject getSubject(Class<?> subjectOwner, String subjectName) { if (subjectOwner == null) { throw new IllegalArgumentException("Owner class must not be null."); } if ((subjectName == null) || (subjectName.length() == 0)) { throw new IllegalArgumentException("Subject name must not be null or empty."); } String fullSubjectName = subjectOwner.getName() + "/" + subjectName; EventSubject newSubject = _registeredSubjects.get(fullSubjectName); if (newSubject == null) { newSubject = new EventSubject(fullSubjectName); _registeredSubjects.put(newSubject.getSubjectName(), newSubject); } return newSubject; } @SuppressWarnings("unused") private  EventSubject(); protected  EventSubject(String fullSubjectName); static EventSubject getSubject(Class<?> subjectOwner, String subjectName); @Override boolean equals(Object obj); @Override int hashCode(); String getSubjectName(); @Override String toString();  }### Answer:
@Test public void testIllegalArguments() { try { EventSubject.getSubject(null, "Subject"); fail(); } catch (IllegalArgumentException ex) { } try { EventSubject.getSubject(Object.class, null); fail(); } catch (IllegalArgumentException ex) { } try { EventSubject.getSubject(Object.class, ""); fail(); } catch (IllegalArgumentException ex) { } }
@Test public void testIdenticalSubject() { EventSubject s1 = EventSubject.getSubject(EventSubjectTest.class, "MySubject"); EventSubject s2 = EventSubject.getSubject(EventSubjectTest.class, "MySubject"); assertSame(s1, s2); }
@Test public void testEqualityOfIdenticalSubjects() { EventSubject s1 = EventSubject.getSubject(EventSubjectTest.class, "MySubject"); EventSubject s2 = EventSubject.getSubject(EventSubjectTest.class, "MySubject"); assertEquals(s1, s2); }