method2testcases
stringlengths 118
3.08k
|
---|
### Question:
JCEHandler { public Key decryptDESKey(short keyLength, byte[] encryptedDESKey, Key encryptingKey, boolean checkParity) throws JCEHandlerException { byte[] clearKeyBytes = doCryptStuff(encryptedDESKey, encryptingKey, Cipher.DECRYPT_MODE); if (checkParity && !Util.isDESParityAdjusted(clearKeyBytes)) { throw new JCEHandlerException("Parity not adjusted"); } return formDESKey(keyLength, clearKeyBytes); } JCEHandler(String jceProviderClassName); JCEHandler(Provider provider); Key generateDESKey(short keyLength); byte[] encryptDESKey(short keyLength, Key clearDESKey, Key encryptingKey); Key decryptDESKey(short keyLength, byte[] encryptedDESKey, Key encryptingKey, boolean checkParity); byte[] encryptData(byte[] data, Key key); byte[] decryptData(byte[] encryptedData, Key key); byte[] encryptDataCBC(byte[] data, Key key, byte[] iv); byte[] decryptDataCBC(byte[] encryptedData, Key key, byte[] iv); byte[] generateMAC(byte[] data, Key kd, String macAlgorithm); }### Answer:
@Test public void testDecryptDESKeyThrowsNullPointerException() throws Throwable { byte[] encryptedDESKey = new byte[2]; try { new JCEHandler((Provider) null).decryptDESKey((short) 100, encryptedDESKey, null, true); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.security.Key.getAlgorithm()\" because \"key\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
JCEHandler { public byte[] encryptData(byte[] data, Key key) throws JCEHandlerException { return doCryptStuff(data, key, Cipher.ENCRYPT_MODE); } JCEHandler(String jceProviderClassName); JCEHandler(Provider provider); Key generateDESKey(short keyLength); byte[] encryptDESKey(short keyLength, Key clearDESKey, Key encryptingKey); Key decryptDESKey(short keyLength, byte[] encryptedDESKey, Key encryptingKey, boolean checkParity); byte[] encryptData(byte[] data, Key key); byte[] decryptData(byte[] encryptedData, Key key); byte[] encryptDataCBC(byte[] data, Key key, byte[] iv); byte[] decryptDataCBC(byte[] encryptedData, Key key, byte[] iv); byte[] generateMAC(byte[] data, Key kd, String macAlgorithm); }### Answer:
@Test public void testEncryptDataThrowsNullPointerException() throws Throwable { byte[] data = new byte[1]; try { new JCEHandler((Provider) null).encryptData(data, null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.security.Key.getAlgorithm()\" because \"key\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
BERTLVPackager extends GenericPackager { @Override public byte[] pack(ISOComponent m) throws ISOException { return pack(m, false, getFirstField(), m.getMaxField()); } BERTLVPackager(); @Override byte[] pack(ISOComponent m); byte[] pack(ISOComponent m, boolean nested, int startIdx, int endIdx); @Override int unpack(ISOComponent m, byte[] b); int unpack(ISOComponent m, byte[] b, boolean nested); @Override void unpack(ISOComponent m, InputStream in); }### Answer:
@Test public void testZeroLength() throws ISOException { BERTLVPackager p = new BERTLVAsciiHexPackager(); ISOTaggedField t = new ISOTaggedField( EMVStandardTagType.APPLICATION_FILE_LOCATOR_0x94.getTagNumberHex(), new ISOField(0, "")); t.setFieldNumber(1); ISOMsg m = new ISOMsg(55); m.set(t); byte[] b = p.pack(m, true, 1, 1); assertArrayEquals(ISOUtil.hex2byte("39343030"), b, ISOUtil.hexString(b)); } |
### Question:
BERTLVPackager extends GenericPackager { @Override public int unpack(ISOComponent m, byte[] b) throws ISOException { try { return unpack(m, b, false); } catch (RuntimeException e) { throw new ISOException(e); } } BERTLVPackager(); @Override byte[] pack(ISOComponent m); byte[] pack(ISOComponent m, boolean nested, int startIdx, int endIdx); @Override int unpack(ISOComponent m, byte[] b); int unpack(ISOComponent m, byte[] b, boolean nested); @Override void unpack(ISOComponent m, InputStream in); }### Answer:
@Test public void testUnpackingZeroLength() { try { BERTLVPackager p = new BERTLVBinaryPackager(); p.setFieldPackager(new ISOFieldPackager[]{new IFA_TTLLBINARY()}); ISOMsg m = new ISOMsg(55); p.unpack(m, ISOUtil.hex2byte("9F3400")); } catch (ISOException e) { fail("Unexpected java.lang.ArithmeticException: divide by zero", e); } }
@Test public void testUnpackingDate() { try { BERTLVPackager p = new BERTLVBinaryPackager(); p.setFieldPackager(new ISOFieldPackager[]{new IFA_TTLLBINARY()}); ISOMsg m = new ISOMsg(55); p.unpack(m, ISOUtil.hex2byte("9A03020618")); assertEquals("020618", m.getComponent("1").getValue()); } catch (ISOException e) { fail("Unexpected exception", e); } } |
### Question:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { @Override public long getHead () { return head; } @Override void initService(); @Override void startService(); @Override void stopService(); void queue(Serializable context); void push(Serializable context); @SuppressWarnings("unused") String getQueueName(); Space getSpace(); Space getInputSpace(); Space getPersistentSpace(); @Override void run(); @Override long getTail(); @Override long getHead(); long getInTransit(); @Override void setConfiguration(Configuration cfg); void addListener(TransactionStatusListener l); void removeListener(TransactionStatusListener l); TPS getTPS(); @Override String getTPSAsString(); @Override float getTPSAvg(); @Override int getTPSPeak(); @Override Date getTPSPeakWhen(); @Override long getTPSElapsed(); @Override void resetTPS(); @Override Metrics getMetrics(); @Override void dump(PrintStream ps, String indent); TransactionParticipant createParticipant(Element e); @Override int getOutstandingTransactions(); @Override void setDebug(boolean debug); @Override boolean getDebugContext(); @Override void setDebugContext(boolean debugContext); @Override boolean getDebug(); @Override int getActiveSessions(); int getPausedCounter(); int getActiveTransactions(); int getMaxSessions(); static Serializable getSerializable(); static T getContext(); static Long getId(); static final String HEAD; static final String TAIL; static final String CONTEXT; static final String STATE; static final String GROUPS; static final String TAILLOCK; static final String RETRY_QUEUE; static final Integer PREPARING; static final Integer COMMITTING; static final Integer DONE; static final String DEFAULT_GROUP; static final long MAX_PARTICIPANTS; static final long MAX_WAIT; static final long TIMER_PURGE_INTERVAL; }### Answer:
@Test public void testGetHead() throws Throwable { long result = new TransactionManager().getHead(); assertEquals(0L, result, "result"); } |
### Question:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { @Override public int getOutstandingTransactions() { if (iisp instanceof LocalSpace) return ((LocalSpace) iisp).size(queue); return -1; } @Override void initService(); @Override void startService(); @Override void stopService(); void queue(Serializable context); void push(Serializable context); @SuppressWarnings("unused") String getQueueName(); Space getSpace(); Space getInputSpace(); Space getPersistentSpace(); @Override void run(); @Override long getTail(); @Override long getHead(); long getInTransit(); @Override void setConfiguration(Configuration cfg); void addListener(TransactionStatusListener l); void removeListener(TransactionStatusListener l); TPS getTPS(); @Override String getTPSAsString(); @Override float getTPSAvg(); @Override int getTPSPeak(); @Override Date getTPSPeakWhen(); @Override long getTPSElapsed(); @Override void resetTPS(); @Override Metrics getMetrics(); @Override void dump(PrintStream ps, String indent); TransactionParticipant createParticipant(Element e); @Override int getOutstandingTransactions(); @Override void setDebug(boolean debug); @Override boolean getDebugContext(); @Override void setDebugContext(boolean debugContext); @Override boolean getDebug(); @Override int getActiveSessions(); int getPausedCounter(); int getActiveTransactions(); int getMaxSessions(); static Serializable getSerializable(); static T getContext(); static Long getId(); static final String HEAD; static final String TAIL; static final String CONTEXT; static final String STATE; static final String GROUPS; static final String TAILLOCK; static final String RETRY_QUEUE; static final Integer PREPARING; static final Integer COMMITTING; static final Integer DONE; static final String DEFAULT_GROUP; static final long MAX_PARTICIPANTS; static final long MAX_WAIT; static final long TIMER_PURGE_INTERVAL; }### Answer:
@Test public void testGetOutstandingTransactions() throws Throwable { int result = new TransactionManager().getOutstandingTransactions(); assertEquals(-1, result, "result"); } |
### Question:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { @Override public long getTail () { return tail; } @Override void initService(); @Override void startService(); @Override void stopService(); void queue(Serializable context); void push(Serializable context); @SuppressWarnings("unused") String getQueueName(); Space getSpace(); Space getInputSpace(); Space getPersistentSpace(); @Override void run(); @Override long getTail(); @Override long getHead(); long getInTransit(); @Override void setConfiguration(Configuration cfg); void addListener(TransactionStatusListener l); void removeListener(TransactionStatusListener l); TPS getTPS(); @Override String getTPSAsString(); @Override float getTPSAvg(); @Override int getTPSPeak(); @Override Date getTPSPeakWhen(); @Override long getTPSElapsed(); @Override void resetTPS(); @Override Metrics getMetrics(); @Override void dump(PrintStream ps, String indent); TransactionParticipant createParticipant(Element e); @Override int getOutstandingTransactions(); @Override void setDebug(boolean debug); @Override boolean getDebugContext(); @Override void setDebugContext(boolean debugContext); @Override boolean getDebug(); @Override int getActiveSessions(); int getPausedCounter(); int getActiveTransactions(); int getMaxSessions(); static Serializable getSerializable(); static T getContext(); static Long getId(); static final String HEAD; static final String TAIL; static final String CONTEXT; static final String STATE; static final String GROUPS; static final String TAILLOCK; static final String RETRY_QUEUE; static final Integer PREPARING; static final Integer COMMITTING; static final Integer DONE; static final String DEFAULT_GROUP; static final long MAX_PARTICIPANTS; static final long MAX_WAIT; static final long TIMER_PURGE_INTERVAL; }### Answer:
@Test public void testGetTail() throws Throwable { long result = new TransactionManager().getTail(); assertEquals(0L, result, "result"); } |
### Question:
SystemMonitor extends QBeanSupport implements Runnable, SystemMonitorMBean, Loggeable { public synchronized void setDetailRequired(boolean detail) { this.detailRequired = detail; setModified(true); if (me != null) me.interrupt(); } void startService(); void stopService(); synchronized void setSleepTime(long sleepTime); synchronized long getSleepTime(); synchronized void setDetailRequired(boolean detail); synchronized boolean getDetailRequired(); void run(); void dump(PrintStream p, String indent); @Override void setConfiguration(Configuration cfg); }### Answer:
@Test public void testSetDetailRequired() throws Throwable { systemMonitor.setDetailRequired(true); assertTrue(systemMonitor.getDetailRequired(), "systemMonitor.getDetailRequired()"); assertTrue(systemMonitor.isModified(), "systemMonitor.isModified()"); } |
### Question:
SystemMonitor extends QBeanSupport implements Runnable, SystemMonitorMBean, Loggeable { public synchronized void setSleepTime(long sleepTime) { this.sleepTime = sleepTime; setModified(true); if (me != null) me.interrupt(); } void startService(); void stopService(); synchronized void setSleepTime(long sleepTime); synchronized long getSleepTime(); synchronized void setDetailRequired(boolean detail); synchronized boolean getDetailRequired(); void run(); void dump(PrintStream p, String indent); @Override void setConfiguration(Configuration cfg); }### Answer:
@Test public void testSetSleepTime() throws Throwable { systemMonitor.setSleepTime(1L); assertEquals(1L, systemMonitor.getSleepTime(), "systemMonitor.getSleepTime()"); assertTrue(systemMonitor.isModified(), "systemMonitor.isModified()"); } |
### Question:
TransactionStatusEvent { public String toString() { return String.format("%02d %08d %s %s", session, id, state.toString(), info); } TransactionStatusEvent(int session, State state, long id, String info, Serializable context); String toString(); int getSession(); long getId(); String getInfo(); State getState(); String getStateAsString(); Serializable getContext(); }### Answer:
@Test public void testToString() { String expected = "01 00000002 Aborting inforString"; assertThat(transactionStatusEvent.toString(), is(expected)); } |
### Question:
TransactionStatusEvent { public int getSession() { return session; } TransactionStatusEvent(int session, State state, long id, String info, Serializable context); String toString(); int getSession(); long getId(); String getInfo(); State getState(); String getStateAsString(); Serializable getContext(); }### Answer:
@Test public void testGetSession() { assertThat(transactionStatusEvent.getSession(), is(1)); } |
### Question:
TransactionStatusEvent { public long getId() { return id; } TransactionStatusEvent(int session, State state, long id, String info, Serializable context); String toString(); int getSession(); long getId(); String getInfo(); State getState(); String getStateAsString(); Serializable getContext(); }### Answer:
@Test public void testGetId() { assertThat(transactionStatusEvent.getId(), is(2L)); } |
### Question:
TransactionStatusEvent { public String getInfo() { return info; } TransactionStatusEvent(int session, State state, long id, String info, Serializable context); String toString(); int getSession(); long getId(); String getInfo(); State getState(); String getStateAsString(); Serializable getContext(); }### Answer:
@Test public void testGetInfo() { assertThat(transactionStatusEvent.getInfo(), is("inforString")); } |
### Question:
TransactionStatusEvent { public State getState() { return state; } TransactionStatusEvent(int session, State state, long id, String info, Serializable context); String toString(); int getSession(); long getId(); String getInfo(); State getState(); String getStateAsString(); Serializable getContext(); }### Answer:
@Test public void testGetState() { assertThat(transactionStatusEvent.getState(), is(State.ABORTING)); } |
### Question:
SystemMonitor extends QBeanSupport implements Runnable, SystemMonitorMBean, Loggeable { void showThreadGroup(ThreadGroup g, PrintStream p, String indent) { if (g.getParent() != null) showThreadGroup(g.getParent(), p, indent + " "); else dumpThreads(g, p, indent + " "); } void startService(); void stopService(); synchronized void setSleepTime(long sleepTime); synchronized long getSleepTime(); synchronized void setDetailRequired(boolean detail); synchronized boolean getDetailRequired(); void run(); void dump(PrintStream p, String indent); @Override void setConfiguration(Configuration cfg); }### Answer:
@Test public void testShowThreadGroupThrowsNullPointerException() throws Throwable { assertThrows(NullPointerException.class, () -> { String indent = "++"; systemMonitor.showThreadGroup(null, printStream, indent); }); }
@Test public void testShowThreadGroup() throws Throwable { String indent = "++"; systemMonitor.showThreadGroup(threadGroup, printStream, indent); assertThat(baos.toString(), is("")); } |
### Question:
TransactionStatusEvent { public String getStateAsString () { return state.toString(); } TransactionStatusEvent(int session, State state, long id, String info, Serializable context); String toString(); int getSession(); long getId(); String getInfo(); State getState(); String getStateAsString(); Serializable getContext(); }### Answer:
@Test public void testGetStateAsString() { assertThat(transactionStatusEvent.getStateAsString(), is("Aborting")); } |
### Question:
TransactionStatusEvent { public Serializable getContext(){ return context; } TransactionStatusEvent(int session, State state, long id, String info, Serializable context); String toString(); int getSession(); long getId(); String getInfo(); State getState(); String getStateAsString(); Serializable getContext(); }### Answer:
@Test public void testGetContext() { assertThat(transactionStatusEvent.getContext(), is((Serializable) "someContextObject")); } |
### Question:
Context implements Externalizable, Loggeable, Pausable, Cloneable { public void checkPoint (String detail) { getProfiler().checkPoint (detail); } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }### Answer:
@Test public void testCheckPoint() throws Throwable { new Context().checkPoint("testContextDetail"); assertTrue(true, "Test completed without Exception"); }
@Test public void testCheckPointNull() throws Throwable { new Context().checkPoint(null); assertTrue(true, "Test completed without Exception"); } |
### Question:
Context implements Externalizable, Loggeable, Pausable, Cloneable { public void dump (PrintStream p, String indent) { String inner = indent + " "; p.println (indent + "<context>"); dumpMap (p, inner); p.println (indent + "</context>"); } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }### Answer:
@Test public void testDump() throws Throwable { PrintStream printStream = new PrintStream(new ByteArrayOutputStream(), true); Object[] objects = new Object[2]; printStream.format(Locale.FRANCE, "testContextParam2", objects); PrintStream p = new PrintStream(printStream, true, "ISO-8859-1"); Context context = new Context(); context.dump(p, "testContextIndent"); }
@Test public void testDumpThrowsNullPointerException() throws Throwable { assertThrows(NullPointerException.class, () -> { Context context = new Context(); context.dump(null, "testContextIndent"); }); } |
### Question:
Context implements Externalizable, Loggeable, Pausable, Cloneable { synchronized public LogEvent getLogEvent () { LogEvent evt = get (LOGEVT.toString()); if (evt == null) { evt = new LogEvent (); evt.setNoArmor(true); put (LOGEVT.toString(), evt); } return evt; } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }### Answer:
@Test public void testGetLogEvent() throws Throwable { LogEvent result = new Context().getLogEvent(); assertNotNull(result); } |
### Question:
Context implements Externalizable, Loggeable, Pausable, Cloneable { public PausedTransaction getPausedTransaction() { return get (PAUSED_TRANSACTION.toString()); } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }### Answer:
@Test public void testGetPausedTransaction() throws Throwable { Context context = new Context(); PausedTransaction result = context.getPausedTransaction(); assertNull(result, "result"); } |
### Question:
Context implements Externalizable, Loggeable, Pausable, Cloneable { synchronized public Profiler getProfiler () { Profiler prof = get (PROFILER.toString()); if (prof == null) { prof = new Profiler(); put (PROFILER.toString(), prof); } return prof; } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }### Answer:
@Test public void testGetProfiler() throws Throwable { new Context().getProfiler(); assertTrue(true, "Test completed without Exception"); } |
### Question:
Context implements Externalizable, Loggeable, Pausable, Cloneable { public String getString (Object key) { Object obj = getMap().get (key); if (obj instanceof String) return (String) obj; else if (obj != null) return obj.toString(); return null; } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }### Answer:
@Test public void testGetString1() throws Throwable { Context context = new Context(); String result = context.getString("testString"); assertNull(result, "result"); }
@Test public void testGetString2() throws Throwable { Context context = new Context(); String result = context.getString("", ""); assertEquals("", result, "result"); } |
### Question:
Context implements Externalizable, Loggeable, Pausable, Cloneable { public void log (Object msg) { if (msg != getMap()) getLogEvent().addMessage (msg); } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }### Answer:
@Test public void testLog() throws Throwable { Context context = new Context(); context.getPausedTransaction(); context.log("testString"); assertTrue(true, "Test completed without Exception"); }
@Test public void testLog1() throws Throwable { new Context().log(""); assertTrue(true, "Test completed without Exception"); } |
### Question:
QExec extends QBeanSupport implements QExecMBean { public String getShutdownScript () { return shutdownScript; } void setStartScript(String scriptPath); String getStartScript(); void setShutdownScript(String scriptPath); String getShutdownScript(); }### Answer:
@Test public void testGetShutdownScript() throws Throwable { String result = new QExec().getShutdownScript(); assertNull(result, "result"); } |
### Question:
Context implements Externalizable, Loggeable, Pausable, Cloneable { public void readExternal (ObjectInput in) throws IOException, ClassNotFoundException { in.readByte(); getMap(); getPMap(); int size = in.readInt(); for (int i=0; i<size; i++) { String k = (String) in.readObject(); Object v = in.readObject(); map.put (k, v); pmap.put (k, v); } } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }### Answer:
@Test public void testReadExternalThrowsNullPointerException() throws Throwable { Context context = new Context(); try { context.readExternal(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.io.ObjectInput.readByte()\" because \"in\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
Context implements Externalizable, Loggeable, Pausable, Cloneable { public synchronized <T> T remove(Object key) { getPMap().remove(key); @SuppressWarnings("unchecked") T obj = (T) getMap().remove(key); return obj; } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }### Answer:
@Test public void testRemove() throws Throwable { Context context = new Context(); context.getProfiler(); Object result = context.remove("testString"); assertNull(result, "result"); }
@Test public void testRemove1() throws Throwable { Context context = new Context(); Object result = context.remove(Integer.valueOf(33)); assertNull(result, "result"); } |
### Question:
Context implements Externalizable, Loggeable, Pausable, Cloneable { public void persist (Object key) { Object value = get(key); if (value instanceof Serializable) getPMap().put (key, value); } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }### Answer:
@Test public void testPersist() throws IOException, ClassNotFoundException { Context context = new Context(); context.put ("A", "ABC"); context.put ("B", "BCD"); context.persist("A"); context.persist("B"); Context deser = Serializer.serializeDeserialize(context); assertEquals(deser.get("A"), "ABC"); assertEquals(deser.get("B"), "BCD"); deser.evict("A"); deser = Serializer.serializeDeserialize(deser); assertEquals(deser.get("B"), "BCD"); assertNull(deser.get("A"), "A should be null"); } |
### Question:
Context implements Externalizable, Loggeable, Pausable, Cloneable { @Override public Context clone() { try { Context context = (Context) super.clone(); if (map != null) { context.map = Collections.synchronizedMap (new LinkedHashMap<>()); context.map.putAll(map); } if (pmap != null) { context.pmap = Collections.synchronizedMap (new LinkedHashMap<>()); context.pmap.putAll(pmap); } return context; } catch (CloneNotSupportedException e) { throw new AssertionError(); } } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }### Answer:
@Test public void testClone() throws IOException, ClassNotFoundException { Context context = new Context(); context.put ("A", "ABC", true); context.put ("B", "BCD"); Context cloned = context.clone(); assertEquals(cloned.get("A"), "ABC"); assertEquals(cloned.get("B"), "BCD"); assertEquals(context, cloned); context = Serializer.serializeDeserialize(cloned); assertEquals(context.get("A"), "ABC"); assertNull(context.get("B"), "A should be null"); } |
### Question:
QExec extends QBeanSupport implements QExecMBean { public String getStartScript () { return startScript; } void setStartScript(String scriptPath); String getStartScript(); void setShutdownScript(String scriptPath); String getShutdownScript(); }### Answer:
@Test public void testGetStartScript() throws Throwable { String result = new QExec().getStartScript(); assertNull(result, "result"); } |
### Question:
HasEntry implements GroupSelector, Configurable { public int prepare (long id, Serializable o) { return PREPARED | NO_JOIN | READONLY; } int prepare(long id, Serializable o); String select(long id, Serializable ser); void commit(long id, Serializable o); void abort(long id, Serializable o); void setConfiguration(Configuration cfg); static final String YES; static final String NO; static final String UNKNOWN; }### Answer:
@Test public void testPrepare() { assertThat(hasEntry.prepare(1L, context), is(HasEntry.PREPARED | HasEntry.NO_JOIN | HasEntry.READONLY)); } |
### Question:
HasEntry implements GroupSelector, Configurable { public String select (long id, Serializable ser) { Context ctx = (Context) ser; String name = cfg.get ("name"); String action = ctx.get (name) != null ? YES : NO; return cfg.get (action, UNKNOWN); } int prepare(long id, Serializable o); String select(long id, Serializable ser); void commit(long id, Serializable o); void abort(long id, Serializable o); void setConfiguration(Configuration cfg); static final String YES; static final String NO; static final String UNKNOWN; }### Answer:
@Test public void testSelect() { given(configuration.get("name")).willReturn("XYZtest"); given(context.get("XYZtest")).willReturn("someStuffs"); given(configuration.get("yes", "UNKNOWN")).willReturn("someStuffs"); String result = hasEntry.select(2L, context); assertThat(result, is("someStuffs")); }
@Test public void testSelectNo() { given(configuration.get("name")).willReturn("XYZtest"); given(context.get("XYZtest")).willReturn(null); given(configuration.get("no", "UNKNOWN")).willReturn("differentStuffs"); String result = hasEntry.select(3L, context); assertThat(result, is("differentStuffs")); } |
### Question:
Delay implements TransactionParticipant, Configurable { public void setConfiguration(Configuration cfg) throws ConfigurationException { prepareDelay = cfg.getLong ("prepare-delay"); commitDelay = cfg.getLong ("commit-delay"); abortDelay = cfg.getLong ("abort-delay"); random = cfg.getBoolean ("random") ? new Random() : null; } int prepare(long id, Serializable context); void commit(long id, Serializable context); void abort(long id, Serializable context); void setConfiguration(Configuration cfg); }### Answer:
@Test public void testSetConfiguration() throws ConfigurationException { delay.setConfiguration(cfg); verify(cfg, atLeastOnce()).getLong("prepare-delay"); verify(cfg, atLeastOnce()).getLong("commit-delay"); verify(cfg, atLeastOnce()).getLong("abort-delay"); verify(cfg, atLeastOnce()).getBoolean("random"); }
@Test public void testSetConfigurationNoRandomOrSetVars() throws ConfigurationException { given(cfg.getLong("prepare-delay")).willReturn(0L); given(cfg.getLong("commit-delay")).willReturn(0L); given(cfg.getLong("abort-delay")).willReturn(0L); given(cfg.getBoolean("random")).willReturn(false); delay.setConfiguration(cfg); verify(cfg, atLeastOnce()).getLong("prepare-delay"); verify(cfg, atLeastOnce()).getLong("commit-delay"); verify(cfg, atLeastOnce()).getLong("abort-delay"); verify(cfg, atLeastOnce()).getBoolean("random"); } |
### Question:
Delay implements TransactionParticipant, Configurable { public int prepare(long id, Serializable context) { sleep (prepareDelay); return PREPARED; } int prepare(long id, Serializable context); void commit(long id, Serializable context); void abort(long id, Serializable context); void setConfiguration(Configuration cfg); }### Answer:
@Test public void testPrepare() { assertThat(delay.prepare(0L, context), is(PREPARED)); } |
### Question:
Delay implements TransactionParticipant, Configurable { void sleep (long delay) { if (delay > 0L) { try { Thread.sleep (random != null ? (long)random.nextDouble()*delay : delay); } catch (InterruptedException ignored) { } } } int prepare(long id, Serializable context); void commit(long id, Serializable context); void abort(long id, Serializable context); void setConfiguration(Configuration cfg); }### Answer:
@Test public void testComputeDelay() { delay.sleep(5L); verify(random, atLeastOnce()).nextDouble(); } |
### Question:
QExec extends QBeanSupport implements QExecMBean { public void setShutdownScript (String scriptPath) { shutdownScript = scriptPath; } void setStartScript(String scriptPath); String getStartScript(); void setShutdownScript(String scriptPath); String getShutdownScript(); }### Answer:
@Test public void testSetShutdownScript() throws Throwable { QExec qExec = new QExec(); qExec.setShutdownScript("testQExecScriptPath"); assertEquals("testQExecScriptPath", qExec.shutdownScript, "qExec.shutdownScript"); } |
### Question:
QExec extends QBeanSupport implements QExecMBean { public void setStartScript (String scriptPath) { startScript = scriptPath; } void setStartScript(String scriptPath); String getStartScript(); void setShutdownScript(String scriptPath); String getShutdownScript(); }### Answer:
@Test public void testSetStartScript() throws Throwable { QExec qExec = new QExec(); qExec.setStartScript("testQExecScriptPath"); assertEquals("testQExecScriptPath", qExec.startScript, "qExec.startScript"); } |
### Question:
BSHMethod { public static BSHMethod createBshMethod(Element e) throws IOException { if (e == null) { return null; } String file = QFactory.getAttributeValue(e, "file"); String bsh; if (file != null) { boolean cache = false; String cacheAtt = QFactory.getAttributeValue(e, "cache"); if (cacheAtt != null) { cache = cacheAtt.equalsIgnoreCase("true"); } if (!cache) { return new BSHMethod(file, true); } else { bsh = ""; FileReader f = new FileReader(file); int c; while ( (c = f.read()) != -1) { bsh += (char) c; } f.close(); return new BSHMethod(bsh, false); } } else { bsh = e.getTextTrim(); if (bsh == null || bsh.equals("")) { return null; } return new BSHMethod(bsh, false); } } BSHMethod(String bshData, boolean source); static BSHMethod createBshMethod(Element e); Object execute(Map arguments, String resultName); Map execute(Map arguments, Collection returnNames); String toString(); }### Answer:
@Test public void testCreateBshMethod() throws Throwable { BSHMethod result = BSHMethod.createBshMethod(null); assertNull(result, "result"); }
@Test public void testCreateBshMethod1() throws Throwable { BSHMethod result = BSHMethod.createBshMethod(new Element("testBSHMethodName", Namespace.NO_NAMESPACE)); assertNull(result, "result"); }
@Test public void testCreateBshMethod2() throws Throwable { when(e.getTextTrim()).thenReturn("testStringtestStringtestStringIll(gal Surrogate Pair"); when(e.getAttributeValue("file")).thenReturn(null); BSHMethod result = BSHMethod.createBshMethod(e); assertNotNull(result, "result"); } |
### Question:
BSHTransactionParticipant extends SimpleLogSource implements TransactionParticipant, AbortParticipant, XmlConfigurable { public void abort(long id, java.io.Serializable context) { LogEvent ev = new LogEvent(this, "abort"); if (abortMethod != null) { try { executeMethod(abortMethod, id, context, ev, ""); } catch (Exception ex) { ev.addMessage(ex); } } else { defaultAbort(id, context, ev); } if (trace) Logger.log(ev); } BSHTransactionParticipant(); void abort(long id, java.io.Serializable context); void commit(long id, java.io.Serializable context); int prepare(long id, java.io.Serializable context); int prepareForAbort(long id, java.io.Serializable context); void setConfiguration(Element e); }### Answer:
@Test public void testAbort() throws Throwable { BSHTransactionParticipant bSHTransactionParticipant = new BSHTransactionParticipant(); bSHTransactionParticipant.abort(100L, new EOFException()); assertNull(bSHTransactionParticipant.abortMethod, "bSHTransactionParticipant.abortMethod"); assertFalse(bSHTransactionParticipant.trace, "bSHTransactionParticipant.trace"); } |
### Question:
BSHTransactionParticipant extends SimpleLogSource implements TransactionParticipant, AbortParticipant, XmlConfigurable { public void commit(long id, java.io.Serializable context) { LogEvent ev = new LogEvent(this, "commit"); if (commitMethod != null) { try { executeMethod(commitMethod, id, context, ev, ""); } catch (Exception ex) { ev.addMessage(ex); } } else { defaultCommit(id, context, ev); } if (trace) Logger.log(ev); } BSHTransactionParticipant(); void abort(long id, java.io.Serializable context); void commit(long id, java.io.Serializable context); int prepare(long id, java.io.Serializable context); int prepareForAbort(long id, java.io.Serializable context); void setConfiguration(Element e); }### Answer:
@Test public void testCommit() throws Throwable { BSHTransactionParticipant bSHTransactionParticipant = new BSHTransactionParticipant(); bSHTransactionParticipant.commit(100L, Boolean.TRUE); assertNull(bSHTransactionParticipant.commitMethod, "bSHTransactionParticipant.commitMethod"); assertFalse(bSHTransactionParticipant.trace, "bSHTransactionParticipant.trace"); } |
### Question:
BSHTransactionParticipant extends SimpleLogSource implements TransactionParticipant, AbortParticipant, XmlConfigurable { protected void defaultAbort(long id, Serializable context, LogEvent ev) {} BSHTransactionParticipant(); void abort(long id, java.io.Serializable context); void commit(long id, java.io.Serializable context); int prepare(long id, java.io.Serializable context); int prepareForAbort(long id, java.io.Serializable context); void setConfiguration(Element e); }### Answer:
@Test public void testDefaultAbort() throws Throwable { BSHTransactionParticipant bSHTransactionParticipant = new BSHTransactionParticipant(); bSHTransactionParticipant.defaultAbort(100L, new File("testBSHTransactionParticipantParam1"), new LogEvent()); assertTrue(true, "Test completed without Exception"); } |
### Question:
BSHTransactionParticipant extends SimpleLogSource implements TransactionParticipant, AbortParticipant, XmlConfigurable { protected void defaultCommit(long id, Serializable context, LogEvent ev) {} BSHTransactionParticipant(); void abort(long id, java.io.Serializable context); void commit(long id, java.io.Serializable context); int prepare(long id, java.io.Serializable context); int prepareForAbort(long id, java.io.Serializable context); void setConfiguration(Element e); }### Answer:
@Test public void testDefaultCommit() throws Throwable { BSHTransactionParticipant bSHTransactionParticipant = new BSHTransactionParticipant(); bSHTransactionParticipant.defaultCommit(100L, Long.valueOf(65L), new LogEvent("testBSHTransactionParticipantTag")); assertTrue(true, "Test completed without Exception"); } |
### Question:
BSHTransactionParticipant extends SimpleLogSource implements TransactionParticipant, AbortParticipant, XmlConfigurable { protected int defaultPrepare(long id, Serializable context, LogEvent ev) { return PREPARED | READONLY; } BSHTransactionParticipant(); void abort(long id, java.io.Serializable context); void commit(long id, java.io.Serializable context); int prepare(long id, java.io.Serializable context); int prepareForAbort(long id, java.io.Serializable context); void setConfiguration(Element e); }### Answer:
@Test public void testDefaultPrepare() throws Throwable { BSHTransactionParticipant bSHTransactionParticipant = new BSHTransactionParticipant(); int result = bSHTransactionParticipant.defaultPrepare(100L, new CharConversionException(), new LogEvent()); assertEquals(129, result, "result"); } |
### Question:
BSHTransactionParticipant extends SimpleLogSource implements TransactionParticipant, AbortParticipant, XmlConfigurable { public int prepare(long id, java.io.Serializable context) { LogEvent ev = new LogEvent(this, "prepare"); int result = ABORTED | READONLY; if (prepareMethod != null) { try { result = (Integer) executeMethod(prepareMethod, id, context, ev, "result"); } catch (Exception ex) { ev.addMessage(ex); } } else { result = defaultPrepare(id, context, ev); } ev.addMessage("result", Integer.toBinaryString(result)); if (trace) Logger.log(ev); return result; } BSHTransactionParticipant(); void abort(long id, java.io.Serializable context); void commit(long id, java.io.Serializable context); int prepare(long id, java.io.Serializable context); int prepareForAbort(long id, java.io.Serializable context); void setConfiguration(Element e); }### Answer:
@Test public void testPrepare() throws Throwable { int result = new BSHTransactionParticipant().prepare(100L, new NotActiveException()); assertEquals(129, result, "result"); } |
### Question:
BSHTransactionParticipant extends SimpleLogSource implements TransactionParticipant, AbortParticipant, XmlConfigurable { public int prepareForAbort(long id, java.io.Serializable context) { LogEvent ev = new LogEvent(this, "prepare-for-abort"); int result = ABORTED | READONLY; if (prepareForAbortMethod != null) { try { result = (Integer) executeMethod(prepareForAbortMethod, id, context, ev, "result"); } catch (Exception ex) { ev.addMessage(ex); } } ev.addMessage("result", Integer.toBinaryString(result)); if (trace) Logger.log(ev); return result; } BSHTransactionParticipant(); void abort(long id, java.io.Serializable context); void commit(long id, java.io.Serializable context); int prepare(long id, java.io.Serializable context); int prepareForAbort(long id, java.io.Serializable context); void setConfiguration(Element e); }### Answer:
@Test public void testPrepareForAbort() throws Throwable { int result = new BSHTransactionParticipant().prepareForAbort(100L, Boolean.FALSE); assertEquals(128, result, "result"); } |
### Question:
BSHGroupSelector extends BSHTransactionParticipant implements GroupSelector { public String defaultSelect(long id, Serializable context) { return ""; } void setConfiguration(Element e); String select(long id, java.io.Serializable context); String defaultSelect(long id, Serializable context); }### Answer:
@Test public void testDefaultSelect() throws Throwable { String result = new BSHGroupSelector().defaultSelect(100L, new StreamCorruptedException()); assertEquals("", result, "result"); } |
### Question:
BSHGroupSelector extends BSHTransactionParticipant implements GroupSelector { public String select(long id, java.io.Serializable context) { LogEvent ev = new LogEvent(this, "select"); String result = null; if (selectMethod != null) { try { result = (String) executeMethod(selectMethod, id, context, ev, "result"); } catch (Exception ex) { ev.addMessage(ex); } } if (result == null) { result = defaultSelect(id, context); } ev.addMessage("result", result); Logger.log(ev); return result; } void setConfiguration(Element e); String select(long id, java.io.Serializable context); String defaultSelect(long id, Serializable context); }### Answer:
@Test public void testSelect() throws Throwable { String result = new BSHGroupSelector().select(100L, new EOFException()); assertEquals("", result, "result"); } |
### Question:
Trace implements AbortParticipant, Configurable { public int prepare (long id, Serializable o) { Context ctx = (Context) o; ctx.checkPoint ("prepare:" + trace); return PREPARED | READONLY; } int prepare(long id, Serializable o); void commit(long id, Serializable o); void abort(long id, Serializable o); int prepareForAbort(long id, Serializable o); void setConfiguration(Configuration cfg); }### Answer:
@Test public void testPrepare() { int result = trace.prepare(1L, context); assertThat(result, is(Trace.PREPARED | Trace.READONLY)); verify(context).checkPoint("prepare:XXXtestXXX"); } |
### Question:
LoggerAdaptor extends QBeanSupport { protected void destroyService() { } }### Answer:
@Test public void testDestroyService() throws Throwable { LoggerAdaptor loggerAdaptor = new LoggerAdaptor(); loggerAdaptor.destroyService(); assertTrue(true, "Test completed without Exception"); } |
### Question:
Trace implements AbortParticipant, Configurable { public void commit (long id, Serializable o) { Context ctx = (Context) o; ctx.checkPoint ("commit:" + trace); } int prepare(long id, Serializable o); void commit(long id, Serializable o); void abort(long id, Serializable o); int prepareForAbort(long id, Serializable o); void setConfiguration(Configuration cfg); }### Answer:
@Test public void testCommit() { trace.commit(1L, context); verify(context).checkPoint("commit:XXXtestXXX"); } |
### Question:
Trace implements AbortParticipant, Configurable { public void abort (long id, Serializable o) { Context ctx = (Context) o; ctx.checkPoint ("abort:" + trace); } int prepare(long id, Serializable o); void commit(long id, Serializable o); void abort(long id, Serializable o); int prepareForAbort(long id, Serializable o); void setConfiguration(Configuration cfg); }### Answer:
@Test public void testAbort() { trace.abort(1L, context); verify(context).checkPoint("abort:XXXtestXXX"); } |
### Question:
Trace implements AbortParticipant, Configurable { public int prepareForAbort (long id, Serializable o) { Context ctx = (Context) o; ctx.checkPoint ("prepareForAbort:" + trace); return PREPARED | READONLY; } int prepare(long id, Serializable o); void commit(long id, Serializable o); void abort(long id, Serializable o); int prepareForAbort(long id, Serializable o); void setConfiguration(Configuration cfg); }### Answer:
@Test public void testPrepareForAbort() { int result = trace.prepareForAbort(1L, context); assertThat(result, is(Trace.PREPARED | Trace.READONLY)); verify(context).checkPoint("prepareForAbort:XXXtestXXX"); } |
### Question:
JTabbedPaneFactory implements UIFactory, ChangeListener { public void stateChanged (ChangeEvent e) { try { String action[] = new String[2]; action = (String[]) actions.get(p.getSelectedIndex()); Object al = ui.get (action[1]); if (al instanceof ActionListener) { ActionEvent ae = new ActionEvent(this,0,action[0]); ((ActionListener) al).actionPerformed(ae); } } catch (Exception f) { f.printStackTrace(); } } JComponent create(UI ui, Element e); void stateChanged(ChangeEvent e); }### Answer:
@Disabled("test fails because the component is not properly created from the jPOS UI") @Test public void testStateChanged() throws Throwable { JTabbedPaneFactory jTabbedPaneFactory = new JTabbedPaneFactory(); jTabbedPaneFactory.stateChanged(new ChangeEvent(Integer.valueOf(0))); assertEquals(0, jTabbedPaneFactory.actions.size(), "jTabbedPaneFactory.actions.size()"); assertNull(jTabbedPaneFactory.p, "jTabbedPaneFactory.p"); assertNull(jTabbedPaneFactory.ui, "jTabbedPaneFactory.ui"); } |
### Question:
Dispose implements ActionListener, UIAware { public void actionPerformed (ActionEvent ev) { ui.dispose (); } Dispose(); void setUI(UI ui, Element e); void actionPerformed(ActionEvent ev); public UI ui; }### Answer:
@Test public void testActionPerformedThrowsNullPointerException() throws Throwable { Dispose dispose = new Dispose(); try { dispose.actionPerformed(new ActionEvent(Integer.valueOf(0), 100, "testDisposeParam3", 100L, 1000)); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.ui.UI.dispose()\" because \"this.ui\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(dispose.ui, "dispose.ui"); } } |
### Question:
Debug implements ActionListener { public void actionPerformed (ActionEvent ev) { System.out.println ("Action command: "+ev.getActionCommand ()); System.out.println (ev.toString ()); System.out.println (""); } Debug(); void actionPerformed(ActionEvent ev); }### Answer:
@Test public void testActionPerformed() throws Throwable { Debug debug = new Debug(); debug.actionPerformed(new ActionEvent(debug, 100, "testDebugParam3", 100L, 1000)); assertTrue(true, "Test completed without Exception"); }
@Test public void testActionPerformedThrowsNullPointerException() throws Throwable { try { new Debug().actionPerformed(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.awt.event.ActionEvent.getActionCommand()\" because \"ev\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
SpaceLet extends QBeanSupport implements Space { public void initService() throws ConfigurationException { Element config = getPersist (); grabSpace (config.getChild ("space")); initSpace (config.getChild ("init")); String name = getName(); if ("spacelet".equals (name)) name = "default"; uri = "spacelet:" + name; Element e = config.getChild ("out"); outScript = getScript (e); if (e != null) outSource = e.getAttributeValue ("source"); e = config.getChild ("push"); pushScript = getScript (e); if (e != null) pushSource = e.getAttributeValue ("source"); e = config.getChild ("in"); inScript = getScript (e); if (e != null) inSource = e.getAttributeValue ("source"); e = config.getChild ("rd"); rdScript = getScript (e); if (e != null) rdSource = e.getAttributeValue ("source"); e = config.getChild ("put"); putScript = getScript (e); if (e != null) putSource = e.getAttributeValue ("source"); } void initService(); void startService(); void stopService(); void out(Object key, Object value); void out(Object key, Object value, long timeout); void push(Object key, Object value); void push(Object key, Object value, long timeout); void put(Object key, Object value); void put(Object key, Object value, long timeout); Object in(Object key); Object rd(Object key); Object in(Object key, long timeout); Object rd(Object key, long timeout); Object inp(Object key); Object rdp(Object key); boolean existAny(Object[] keys); boolean existAny(Object[] keys, long timeout); void nrd(Object key); Object nrd(Object key, long timeout); }### Answer:
@Test public void testInitServiceThrowsNullPointerException() throws Throwable { SpaceLet spaceLet = new SpaceLet(); try { spaceLet.initService(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { } } |
### Question:
VolatileSequencer implements Sequencer, VolatileSequencerMBean { synchronized public int get (String counterName, int add) { int i = 0; Integer I = (Integer) map.get (counterName); if (I != null) i = I; i += add; map.put (counterName, i); return i; } VolatileSequencer(); synchronized int get(String counterName, int add); int get(String counterName); synchronized int set(String counterName, int newValue); String[] getCounterNames(); }### Answer:
@Test public void testGet() throws Throwable { VolatileSequencer volatileSequencer = new VolatileSequencer(); volatileSequencer.get("abcdefghijklmnopqrstuvwxyz", 1); int result = volatileSequencer.get("abcdefghijklmnopqrstuvwxyz", -1); assertEquals(0, result, "result"); }
@Test public void testGet1() throws Throwable { VolatileSequencer volatileSequencer = new VolatileSequencer(); int add = volatileSequencer.get(" ", -1); int result = volatileSequencer.get(" ", 0); assertEquals(add, result, "result"); }
@Test public void testGet2() throws Throwable { VolatileSequencer volatileSequencer = new VolatileSequencer(); int result = volatileSequencer.get("testVolatileSequencerCounterName", 0); assertEquals(0, result, "result"); }
@Test public void testGet3() throws Throwable { VolatileSequencer volatileSequencer = new VolatileSequencer(); int result = volatileSequencer.get("testVolatileSequencerCounterName"); assertEquals(1, result, "result"); } |
### Question:
VolatileSequencer implements Sequencer, VolatileSequencerMBean { public String[] getCounterNames () { Object[] o = map.keySet().toArray(); String[] s = new String [o.length]; System.arraycopy (o, 0, s, 0, o.length); return s; } VolatileSequencer(); synchronized int get(String counterName, int add); int get(String counterName); synchronized int set(String counterName, int newValue); String[] getCounterNames(); }### Answer:
@Test public void testGetCounterNames() throws Throwable { VolatileSequencer volatileSequencer = new VolatileSequencer(); volatileSequencer.get("testVolatileSequencerCounterName", 100); String[] result = volatileSequencer.getCounterNames(); assertEquals(1, result.length, "result.length"); assertEquals("testVolatileSequencerCounterName", result[0], "result[0]"); }
@Test public void testGetCounterNames1() throws Throwable { VolatileSequencer volatileSequencer = new VolatileSequencer(); String[] result = volatileSequencer.getCounterNames(); assertEquals(0, result.length, "result.length"); } |
### Question:
VolatileSequencer implements Sequencer, VolatileSequencerMBean { synchronized public int set (String counterName, int newValue) { int oldValue = 0; Integer I = (Integer) map.get (counterName); if (I != null) oldValue = I; map.put (counterName, newValue); return oldValue; } VolatileSequencer(); synchronized int get(String counterName, int add); int get(String counterName); synchronized int set(String counterName, int newValue); String[] getCounterNames(); }### Answer:
@Test public void testSet() throws Throwable { VolatileSequencer volatileSequencer = new VolatileSequencer(); int add = volatileSequencer.get("", 100); int result = volatileSequencer.set("", add); assertEquals(add, result, "result"); }
@Test public void testSet2() throws Throwable { VolatileSequencer volatileSequencer = new VolatileSequencer(); int result = volatileSequencer.set("testVolatileSequencerCounterName", 100); assertEquals(0, result, "result"); } |
### Question:
Card { private Card() { } private Card(); Card(Builder builder); String getPan(); BigInteger getPanAsNumber(); String getExp(); String getCvv2(); String getServiceCode(); boolean hasTrack1(); boolean hasTrack2(); boolean hasBothTracks(); String getBin(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); Track1 getTrack1(); Track2 getTrack2(); boolean isExpired(Date currentDate); static Builder builder(); static final int BINLEN; }### Answer:
@Test public void testCard() throws Throwable { Track1 t1 = Track1.builder() .track("%B4111111111111111^FAT ALBERT ^201112345671234567890?").build(); Track2 t2 = Track2.builder() .track("4111111111111111=201112345612345678901").build(); Card c = Card.builder() .pan("4111111111111111") .exp("2011") .cvv("123") .cvv2("4567") .serviceCode("123") .track1(t1) .track2(t2) .build(); assertEquals(false, c.isExpired(new Date()), "not expired"); } |
### Question:
SpaceLet extends QBeanSupport implements Space { public Object inp (Object key) { try { Interpreter bsh = initInterpreter (key); bsh.set ("probe", true); synchronized (sp) { if (eval (bsh, inScript, inSource)) { return bsh.get ("value"); } else { return sp.inp (key); } } } catch (Throwable t) { throw new SpaceError (t); } } void initService(); void startService(); void stopService(); void out(Object key, Object value); void out(Object key, Object value, long timeout); void push(Object key, Object value); void push(Object key, Object value, long timeout); void put(Object key, Object value); void put(Object key, Object value, long timeout); Object in(Object key); Object rd(Object key); Object in(Object key, long timeout); Object rd(Object key, long timeout); Object inp(Object key); Object rdp(Object key); boolean existAny(Object[] keys); boolean existAny(Object[] keys, long timeout); void nrd(Object key); Object nrd(Object key, long timeout); }### Answer:
@Test public void testInp() throws Throwable { SpaceLet spaceLet = new SpaceLet(); Element persist = mock(Element.class); spaceLet.setPersist(persist); spaceLet.initService(); Object result = spaceLet.inp(Integer.valueOf(0)); assertNull(result); }
@Test public void testInpThrowsSpaceError() throws Throwable { SpaceLet spaceLet = new SpaceLet(); try { spaceLet.inp("testString"); fail("Expected SpaceError to be thrown"); } catch (SpaceError ex) { } } |
### Question:
Card { public static Builder builder() { return new Builder(); } private Card(); Card(Builder builder); String getPan(); BigInteger getPanAsNumber(); String getExp(); String getCvv2(); String getServiceCode(); boolean hasTrack1(); boolean hasTrack2(); boolean hasBothTracks(); String getBin(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); Track1 getTrack1(); Track2 getTrack2(); boolean isExpired(Date currentDate); static Builder builder(); static final int BINLEN; }### Answer:
@Test public void testInvalidPAN() throws Throwable { try { Track1 t1 = Track1.builder() .track("%B4111111111111112^FAT ALBERT ^201112345671234567890?").build(); Track2 t2 = Track2.builder() .track("4111111111111112=201112345612345678901").build(); Card c = Card.builder() .pan("4111111111111112") .exp("2011") .cvv("123") .cvv2("4567") .serviceCode("201") .track1(t1) .track2(t2) .build(); fail ("InvalidCardException was not raised"); } catch (InvalidCardException ignored) { } } |
### Question:
SpaceLet extends QBeanSupport implements Space { public Object in (Object key) { try { Interpreter bsh = initInterpreter (key); synchronized (sp) { if (eval (bsh, inScript, inSource)) { return bsh.get ("value"); } else { return sp.in (key); } } } catch (Throwable t) { throw new SpaceError (t); } } void initService(); void startService(); void stopService(); void out(Object key, Object value); void out(Object key, Object value, long timeout); void push(Object key, Object value); void push(Object key, Object value, long timeout); void put(Object key, Object value); void put(Object key, Object value, long timeout); Object in(Object key); Object rd(Object key); Object in(Object key, long timeout); Object rd(Object key, long timeout); Object inp(Object key); Object rdp(Object key); boolean existAny(Object[] keys); boolean existAny(Object[] keys, long timeout); void nrd(Object key); Object nrd(Object key, long timeout); }### Answer:
@Test public void testInThrowsSpaceError() throws Throwable { assertThrows(SpaceError.class, () -> { SpaceLet spaceLet = new SpaceLet(); spaceLet.in(""); }); }
@Test public void testInThrowsSpaceError1() throws Throwable { SpaceLet spaceLet = new SpaceLet(); try { spaceLet.in("", 100L); fail("Expected SpaceError to be thrown"); } catch (SpaceError ex) { } } |
### Question:
SimpleConfiguration implements Configuration, Serializable { public void load(String filename) throws IOException { FileInputStream fis = new FileInputStream(filename); props.load(new BufferedInputStream(fis)); fis.close(); } SimpleConfiguration(); SimpleConfiguration(Properties props); SimpleConfiguration(String filename); String get(String name, String def); String[] getAll(String name); int[] getInts(String name); long[] getLongs(String name); double[] getDoubles(String name); boolean[] getBooleans(String name); String get(String name); int getInt(String name); int getInt(String name, int def); long getLong(String name); long getLong(String name, long def); double getDouble(String name); double getDouble(String name, double def); boolean getBoolean(String name); boolean getBoolean(String name, boolean def); void load(String filename); synchronized void put(String name, Object value); @Override Set<String> keySet(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test public void testLoadThrowsFileNotFoundException() throws Throwable { Properties props = new Properties(); SimpleConfiguration simpleConfiguration = new SimpleConfiguration(props); try { simpleConfiguration.load("testSimpleConfigurationFilename"); fail("Expected FileNotFoundException to be thrown"); } catch (FileNotFoundException ex) { assertEquals(FileNotFoundException.class, ex.getClass(), "ex.getClass()"); } }
@Test public void testLoadThrowsNullPointerException() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(); try { simpleConfiguration.load(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { } } |
### Question:
SimpleConfiguration implements Configuration, Serializable { public synchronized void put (String name, Object value) { props.put (name, value); } SimpleConfiguration(); SimpleConfiguration(Properties props); SimpleConfiguration(String filename); String get(String name, String def); String[] getAll(String name); int[] getInts(String name); long[] getLongs(String name); double[] getDoubles(String name); boolean[] getBooleans(String name); String get(String name); int getInt(String name); int getInt(String name, int def); long getLong(String name); long getLong(String name, long def); double getDouble(String name); double getDouble(String name, double def); boolean getBoolean(String name); boolean getBoolean(String name, boolean def); void load(String filename); synchronized void put(String name, Object value); @Override Set<String> keySet(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test public void testPutThrowsNullPointerException() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration((Properties) null); try { simpleConfiguration.put("testSimpleConfigurationName", "testString"); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.util.Properties.put(Object, Object)\" because \"this.props\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
SpaceLet extends QBeanSupport implements Space { public void out (Object key, Object value) { try { Interpreter bsh = initInterpreter (key, value); synchronized (sp) { if (!eval (bsh, outScript, outSource)) sp.out (key, value); } } catch (Throwable t) { throw new SpaceError (t); } } void initService(); void startService(); void stopService(); void out(Object key, Object value); void out(Object key, Object value, long timeout); void push(Object key, Object value); void push(Object key, Object value, long timeout); void put(Object key, Object value); void put(Object key, Object value, long timeout); Object in(Object key); Object rd(Object key); Object in(Object key, long timeout); Object rd(Object key, long timeout); Object inp(Object key); Object rdp(Object key); boolean existAny(Object[] keys); boolean existAny(Object[] keys, long timeout); void nrd(Object key); Object nrd(Object key, long timeout); }### Answer:
@Test public void testOutThrowsSpaceError1() throws Throwable { SpaceLet spaceLet = new SpaceLet(); try { spaceLet.out("testString", "testString"); fail("Expected SpaceError to be thrown"); } catch (SpaceError ex) { } }
@Test public void testOutThrowsSpaceError3() throws Throwable { SpaceLet spaceLet = new SpaceLet(); try { spaceLet.out("testString", "", 100L); fail("Expected SpaceError to be thrown"); } catch (SpaceError ex) { } } |
### Question:
SubConfiguration implements Configuration { public void put (String name, Object value) { cfg.put(prefix + name, value); } SubConfiguration(); SubConfiguration(Configuration cfg, String prefix); void setConfiguration(Configuration newCfg); void setPrefix(String newPrefix); String get(String propertyName); String[] getAll(String propertyName); int[] getInts(String propertyName); long[] getLongs(String propertyName); double[] getDoubles(String propertyName); boolean[] getBooleans(String propertyName); String get(String propertyName, String defaultValue); boolean getBoolean(String propertyName); boolean getBoolean(String propertyName, boolean defaultValue); double getDouble(String propertyName); double getDouble(String propertyName, double defaultValue); long getLong(String propertyName); long getLong(String propertyName, long defaultValue); int getInt(String propertyName); int getInt(String propertyName, int defaultValue); void put(String name, Object value); Object getObject(String propertyName); @Override Set<String> keySet(); }### Answer:
@Test public void testPut() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); subConfiguration.put("testSubConfigurationName", ""); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testPutThrowsNullPointerException() throws Throwable { Configuration cfg = new SubConfiguration(new SubConfiguration(new SubConfiguration(), "testSubConfigurationPrefix"), "testSubConfigurationPrefix1"); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix2"); try { subConfiguration.put("testSubConfigurationName", "testString"); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.core.Configuration.put(String, Object)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); } } |
### Question:
SpaceLet extends QBeanSupport implements Space { public Object rdp (Object key) { try { Interpreter bsh = initInterpreter (key); bsh.set ("probe", true); synchronized (sp) { if (eval (bsh, rdScript, rdSource)) { return bsh.get ("value"); } else { return sp.rdp (key); } } } catch (Throwable t) { throw new SpaceError (t); } } void initService(); void startService(); void stopService(); void out(Object key, Object value); void out(Object key, Object value, long timeout); void push(Object key, Object value); void push(Object key, Object value, long timeout); void put(Object key, Object value); void put(Object key, Object value, long timeout); Object in(Object key); Object rd(Object key); Object in(Object key, long timeout); Object rd(Object key, long timeout); Object inp(Object key); Object rdp(Object key); boolean existAny(Object[] keys); boolean existAny(Object[] keys, long timeout); void nrd(Object key); Object nrd(Object key, long timeout); }### Answer:
@Test public void testRdpThrowsSpaceError() throws Throwable { SpaceLet spaceLet = new SpaceLet(); try { spaceLet.rdp(""); fail("Expected SpaceError to be thrown"); } catch (SpaceError ex) { } } |
### Question:
SubConfiguration implements Configuration { public void setConfiguration(Configuration newCfg){ cfg=newCfg; } SubConfiguration(); SubConfiguration(Configuration cfg, String prefix); void setConfiguration(Configuration newCfg); void setPrefix(String newPrefix); String get(String propertyName); String[] getAll(String propertyName); int[] getInts(String propertyName); long[] getLongs(String propertyName); double[] getDoubles(String propertyName); boolean[] getBooleans(String propertyName); String get(String propertyName, String defaultValue); boolean getBoolean(String propertyName); boolean getBoolean(String propertyName, boolean defaultValue); double getDouble(String propertyName); double getDouble(String propertyName, double defaultValue); long getLong(String propertyName); long getLong(String propertyName, long defaultValue); int getInt(String propertyName); int getInt(String propertyName, int defaultValue); void put(String name, Object value); Object getObject(String propertyName); @Override Set<String> keySet(); }### Answer:
@Test public void testSetConfiguration() throws Throwable { SubConfiguration subConfiguration = new SubConfiguration(new SubConfiguration(), "testSubConfigurationPrefix"); Configuration newCfg = new SimpleConfiguration(); subConfiguration.setConfiguration(newCfg); assertSame(newCfg, subConfiguration.cfg, "subConfiguration.cfg"); } |
### Question:
SubConfiguration implements Configuration { public void setPrefix(String newPrefix){ prefix = newPrefix; } SubConfiguration(); SubConfiguration(Configuration cfg, String prefix); void setConfiguration(Configuration newCfg); void setPrefix(String newPrefix); String get(String propertyName); String[] getAll(String propertyName); int[] getInts(String propertyName); long[] getLongs(String propertyName); double[] getDoubles(String propertyName); boolean[] getBooleans(String propertyName); String get(String propertyName, String defaultValue); boolean getBoolean(String propertyName); boolean getBoolean(String propertyName, boolean defaultValue); double getDouble(String propertyName); double getDouble(String propertyName, double defaultValue); long getLong(String propertyName); long getLong(String propertyName, long defaultValue); int getInt(String propertyName); int getInt(String propertyName, int defaultValue); void put(String name, Object value); Object getObject(String propertyName); @Override Set<String> keySet(); }### Answer:
@Test public void testSetPrefix() throws Throwable { SubConfiguration subConfiguration = new SubConfiguration(); subConfiguration.setPrefix("testSubConfigurationNewPrefix"); assertEquals("testSubConfigurationNewPrefix", subConfiguration.prefix, "subConfiguration.prefix"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public boolean hasTrack2() { return pan != null && exp != null && trailer != null; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testConstructor() throws Throwable { CardHolder cardHolder = new CardHolder(); assertFalse(cardHolder.hasTrack2(), "cardHolder.hasTrack2()"); }
@Test public void testHasTrack2() throws Throwable { boolean result = new CardHolder("k'X9|DH:!;uQ<kG8!P?- ,\"Y!u`r;jB^)>3AbS9,").hasTrack2(); assertTrue(result, "result"); }
@Test public void testHasTrack23() throws Throwable { boolean result = new CardHolder().hasTrack2(); assertFalse(result, "result"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public String getBIN () { return pan.substring(0, BINLEN); } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testGetBIN() throws Throwable { CardHolder cardHolder = new CardHolder(); cardHolder.setPAN("testCardHolderPan"); String result = cardHolder.getBIN(); assertEquals("testCa", result, "result"); }
@Test public void testGetBINThrowsNullPointerException() throws Throwable { try { new CardHolder().getBIN(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"String.substring(int, int)\" because \"this.pan\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public String getEXP () { return exp; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testGetEXP() throws Throwable { CardHolder cardHolder = new CardHolder(); cardHolder.setEXP("99-8"); String result = cardHolder.getEXP(); assertEquals("99-8", result, "result"); }
@Test public void testGetEXP1() throws Throwable { String result = new CardHolder().getEXP(); assertNull(result, "result"); } |
### Question:
SpaceLet extends QBeanSupport implements Space { public Object rd (Object key) { try { Interpreter bsh = initInterpreter (key); synchronized (sp) { if (eval (bsh, rdScript, rdSource)) { return bsh.get ("value"); } else { return sp.rd (key); } } } catch (Throwable t) { throw new SpaceError (t); } } void initService(); void startService(); void stopService(); void out(Object key, Object value); void out(Object key, Object value, long timeout); void push(Object key, Object value); void push(Object key, Object value, long timeout); void put(Object key, Object value); void put(Object key, Object value, long timeout); Object in(Object key); Object rd(Object key); Object in(Object key, long timeout); Object rd(Object key, long timeout); Object inp(Object key); Object rdp(Object key); boolean existAny(Object[] keys); boolean existAny(Object[] keys, long timeout); void nrd(Object key); Object nrd(Object key, long timeout); }### Answer:
@Test public void testRdThrowsSpaceError() throws Throwable { SpaceLet spaceLet = new SpaceLet(); try { spaceLet.rd(Integer.valueOf(0)); fail("Expected SpaceError to be thrown"); } catch (SpaceError ex) { } }
@Test public void testRdThrowsSpaceError1() throws Throwable { SpaceLet spaceLet = new SpaceLet(); try { spaceLet.rd(";1", 100L); fail("Expected SpaceError to be thrown"); } catch (SpaceError ex) { } } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public String getNameOnCard() { String name = null; if (track1!=null) { StringTokenizer st = new StringTokenizer(track1, TRACK1_SEPARATOR); if (st.countTokens()<2) return null; st.nextToken(); name = st.nextToken(); } return name; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testGetNameOnCard() throws Throwable { CardHolder cardHolder = new CardHolder(); cardHolder.setTrack1(" `^o;t~Dfv._uUa7agT,\tQ2lt @0@5BT0O)a"); String result = cardHolder.getNameOnCard(); assertEquals("o;t~Dfv._uUa7agT,\tQ2lt @0@5BT0O)a", result, "result"); }
@Test public void testGetNameOnCard2() throws Throwable { String result = new CardHolder().getNameOnCard(); assertNull(result, "result"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public String getPAN () { return pan; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testGetPAN() throws Throwable { CardHolder cardHolder = new CardHolder(); cardHolder.setPAN("testCardHolderPan"); String result = cardHolder.getPAN(); assertEquals("testCardHolderPan", result, "result"); }
@Test public void testGetPAN1() throws Throwable { String result = new CardHolder().getPAN(); assertNull(result, "result"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public String getSecurityCode() { return securityCode; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testGetSecurityCode() throws Throwable { String result = new CardHolder().getSecurityCode(); assertNull(result, "result"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public String getServiceCode () { return trailer != null && trailer.length() >= 3 ? trailer.substring (0, 3) : " "; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testGetServiceCode() throws Throwable { CardHolder cardHolder = new CardHolder(); cardHolder.parseTrack2(" trk1=\"true\""); String result = cardHolder.getServiceCode(); assertEquals(" ", result, "result"); }
@Test public void testGetServiceCode2() throws Throwable { String result = new CardHolder("testCardHolderPan", "4Cha").getServiceCode(); assertEquals(" ", result, "result"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public String getTrack1() { return track1; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testGetTrack1() throws Throwable { CardHolder cardHolder = new CardHolder("testCardHolderPan", "4Cha"); cardHolder.setTrack1("testCardHolderTrack1"); String result = cardHolder.getTrack1(); assertEquals("testCardHolderTrack1", result, "result"); }
@Test public void testGetTrack11() throws Throwable { String result = new CardHolder("testCardHolderPan", "4Cha").getTrack1(); assertNull(result, "result"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public String getTrack2() { if (hasTrack2()) return pan + TRACK2_SEPARATOR + exp + trailer; else return null; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testGetTrack2() throws Throwable { String result = new CardHolder().getTrack2(); assertNull(result, "result"); }
@Test public void testGetTrack21() throws Throwable { String result = new CardHolder("k'X9|DH:!;uQ<kG8!P?- ,\"Y!u`r;jB^)>3AbS9,").getTrack2(); assertEquals("k'X9|=H:!;uQ<kG8!P?- ,\"Y!u`r;jB^)>3AbS9,", result, "result"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public String getTrailer() { return trailer; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testGetTrailer() throws Throwable { CardHolder cardHolder = new CardHolder(); cardHolder.setTrailer("testCardHolderTrailler"); String result = cardHolder.getTrailer(); assertEquals("testCardHolderTrailler", result, "result"); }
@Test public void testGetTrailer1() throws Throwable { String result = new CardHolder().getTrailer(); assertNull(result, "result"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public boolean hasSecurityCode() { return securityCode != null; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testHasSecurityCode() throws Throwable { CardHolder cardHolder = new CardHolder("k'X9|DH:!;uQ<kG8!P?- ,\"Y!u`r;jB^)>3AbS9,"); cardHolder.setSecurityCode("testCardHolderSecurityCode"); boolean result = cardHolder.hasSecurityCode(); assertTrue(result, "result"); }
@Test public void testHasSecurityCode1() throws Throwable { boolean result = new CardHolder("testCardHolderPan", "4Cha").hasSecurityCode(); assertFalse(result, "result"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public boolean hasTrack1() { return track1!=null; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testHasTrack1() throws Throwable { CardHolder cardHolder = new CardHolder(); cardHolder.setTrack1("testCardHolderTrack1"); boolean result = cardHolder.hasTrack1(); assertTrue(result, "result"); }
@Test public void testHasTrack11() throws Throwable { boolean result = new CardHolder("testCardHolderPan", "4Cha").hasTrack1(); assertFalse(result, "result"); } |
### Question:
SpaceLet extends QBeanSupport implements Space { public void startService() { NameRegistrar.register (uri, this); Iterator iter = getPersist().getChildren("run").iterator(); while (iter.hasNext ()) launch ((Element) iter.next ()); } void initService(); void startService(); void stopService(); void out(Object key, Object value); void out(Object key, Object value, long timeout); void push(Object key, Object value); void push(Object key, Object value, long timeout); void put(Object key, Object value); void put(Object key, Object value, long timeout); Object in(Object key); Object rd(Object key); Object in(Object key, long timeout); Object rd(Object key, long timeout); Object inp(Object key); Object rdp(Object key); boolean existAny(Object[] keys); boolean existAny(Object[] keys, long timeout); void nrd(Object key); Object nrd(Object key, long timeout); }### Answer:
@Test public void testStartServiceThrowsNullPointerException() throws Throwable { SpaceLet spaceLet = new SpaceLet(); try { spaceLet.startService(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { } } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public boolean isExpired () { return isExpired(new Date()); } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testIsExpired() throws Throwable { boolean result = new CardHolder("testCardHolderPan", "4Cha").isExpired(); assertTrue(result, "result"); }
@Test public void testIsExpired4() throws Throwable { boolean result = new CardHolder().isExpired(); assertTrue(result, "result"); } |
### Question:
BSH extends QBeanSupport implements Runnable { public void initService() { bsh = new Interpreter (); BshClassManager bcm = bsh.getClassManager(); try { bcm.setClassPath(getServer().getLoader().getURLs()); } catch (UtilEvalError e) { e.printStackTrace(); } bcm.setClassLoader(getServer().getLoader()); } void initService(); void startService(); void run(); }### Answer:
@Test public void testInitServiceThrowsNullPointerException() throws Throwable { BSH bSH = new BSH(); try { bSH.initService(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.q2.Q2.getLoader()\" because the return value of \"org.jpos.q2.qbean.BSH.getServer()\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public boolean seemsManualEntry() { return trailer == null || trailer.trim().length() == 0; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testSeemsManualEntry() throws Throwable { CardHolder cardHolder = new CardHolder("k'X9|DH:!;uQ<kG8!P?- ,\"Y!u`r;jB^)>3AbS9,"); cardHolder.setTrailer(""); boolean result = cardHolder.seemsManualEntry(); assertTrue(result, "result"); }
@Test public void testSeemsManualEntry2() throws Throwable { boolean result = new CardHolder().seemsManualEntry(); assertTrue(result, "result"); } |
### Question:
BSH extends QBeanSupport implements Runnable { public void run () { Element config = getPersist(); try { bsh.set ("qbean", this); bsh.set ("log", getLog()); bsh.set ("cfg", getConfiguration()); bsh.eval (config.getText()); String source = config.getAttributeValue ("source"); if (source != null) bsh.source (source); } catch (Throwable e) { getLog().warn (e); } } void initService(); void startService(); void run(); }### Answer:
@Test public void testRun() throws Throwable { BSH bSH = new BSH(); bSH.run(); assertNull(bSH.bsh, "bSH.bsh"); assertFalse(bSH.isModified(), "bSH.isModified()"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public void setSecurityCode(String securityCode) { this.securityCode = securityCode; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testSetSecurityCode() throws Throwable { CardHolder cardHolder = new CardHolder(); cardHolder.setSecurityCode("testCardHolderSecurityCode"); assertEquals("testCardHolderSecurityCode", cardHolder.securityCode, "cardHolder.securityCode"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { public void setTrack1(String track1) { this.track1 = track1; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testSetTrack1() throws Throwable { CardHolder cardHolder = new CardHolder("testCardHolderPan", "4Cha"); cardHolder.setTrack1("testCardHolderTrack1"); assertEquals("testCardHolderTrack1", cardHolder.track1, "cardHolder.track1"); } |
### Question:
CardHolder implements Cloneable, Serializable, Loggeable { @SuppressWarnings("unused") public void setTrailler (String trailer) { this.trailer = trailer; } CardHolder(); CardHolder(String track2); CardHolder(String pan, String exp); CardHolder(ISOMsg m); void parseTrack2(String s); void setTrack1(String track1); String getTrack1(); boolean hasTrack1(); String getNameOnCard(); String getTrack2(); boolean hasTrack2(); void setSecurityCode(String securityCode); String getSecurityCode(); boolean hasSecurityCode(); @SuppressWarnings("unused") String getTrailler(); @SuppressWarnings("unused") void setTrailler(String trailer); String getTrailer(); void setTrailer(String trailer); void setPAN(String pan); String getPAN(); String getBIN(); void setEXP(String exp); String getEXP(); boolean isExpired(); boolean isExpired(Date currentDate); boolean isValidCRC(); static boolean isValidCRC(String p); void dump(PrintStream p, String indent); String getServiceCode(); boolean seemsManualEntry(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testSetTrailler() throws Throwable { CardHolder cardHolder = new CardHolder(); cardHolder.setTrailer("testCardHolderTrailler"); assertEquals("testCardHolderTrailler", cardHolder.trailer, "cardHolder.trailler"); } |
### Question:
BSHFilter implements RawIncomingFilter, Configurable { public ISOMsg filter (ISOChannel channel, ISOMsg m, LogEvent evt) throws VetoException { return filter (channel, m, null, null, evt); } BSHFilter(); void setConfiguration(Configuration cfg); ISOMsg filter(ISOChannel channel, ISOMsg m, LogEvent evt); ISOMsg filter(ISOChannel channel, ISOMsg m, byte[] header, byte[] image, LogEvent evt); }### Answer:
@Test public void testFilter() throws Throwable { Configuration cfg = new SimpleConfiguration(); BSHFilter bSHFilter = new BSHFilter(); bSHFilter.setConfiguration(cfg); ISOMsg result = bSHFilter.filter(new PADChannel(), null, new LogEvent("testBSHFilterTag", "testString")); assertNull(result, "result"); assertSame(cfg, bSHFilter.cfg, "bSHFilter.cfg"); }
@Test public void testFilterThrowsNullPointerException() throws Throwable { BSHFilter bSHFilter = new BSHFilter(); LogEvent evt = new LogEvent(); try { bSHFilter.filter(new CSChannel("testBSHFilterHost", 100, new PostPackager()), new ISOMsg("testBSHFilterMti"), evt); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.core.Configuration.getAll(String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(bSHFilter.cfg, "bSHFilter.cfg"); } } |
### Question:
BSH extends QBeanSupport implements Runnable { public void startService() { new Thread (this, "BSH-" + getName()).start (); } void initService(); void startService(); void run(); }### Answer:
@Test public void testStartService() throws Throwable { BSH bSH = new BSH(); bSH.startService(); assertNull(bSH.getName(), "bSH.getName()"); } |
### Question:
BSHFilter implements RawIncomingFilter, Configurable { public void setConfiguration (Configuration cfg) throws ConfigurationException { this.cfg = cfg; } BSHFilter(); void setConfiguration(Configuration cfg); ISOMsg filter(ISOChannel channel, ISOMsg m, LogEvent evt); ISOMsg filter(ISOChannel channel, ISOMsg m, byte[] header, byte[] image, LogEvent evt); }### Answer:
@Test public void testSetConfiguration() throws Throwable { BSHFilter bSHFilter = new BSHFilter(); Configuration cfg = new SimpleConfiguration(); bSHFilter.setConfiguration(cfg); assertSame(cfg, bSHFilter.cfg, "bSHFilter.cfg"); } |
### Question:
BSHRequestListener extends Log implements ISORequestListener, Configurable { public void setConfiguration (Configuration cfg) throws ConfigurationException { this.cfg = cfg; bshSource = cfg.getAll ("source"); String[] mti = cfg.get ("whitelist", "*").split(","); whitelist = new HashSet<>( Arrays.asList(mti) ); } BSHRequestListener(); void setConfiguration(Configuration cfg); boolean process(ISOSource source, ISOMsg m); }### Answer:
@Test public void testSetConfiguration() throws Throwable { BSHRequestListener bSHRequestListener = new BSHRequestListener(); Configuration cfg = new SimpleConfiguration(); bSHRequestListener.setConfiguration(cfg); assertEquals(1, bSHRequestListener.whitelist.size(), "bSHRequestListener.whitelist.size()"); assertEquals(0, bSHRequestListener.bshSource.length, "bSHRequestListener.bshSource.length"); assertSame(cfg, bSHRequestListener.cfg, "bSHRequestListener.cfg"); }
@Test public void testSetConfigurationThrowsNullPointerException() throws Throwable { BSHRequestListener bSHRequestListener = new BSHRequestListener(); Configuration cfg = new SubConfiguration(); try { bSHRequestListener.setConfiguration(cfg); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertSame(cfg, bSHRequestListener.cfg, "bSHRequestListener.cfg"); if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.core.Configuration.getAll(String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(bSHRequestListener.whitelist, "bSHRequestListener.whitelist"); assertNull(bSHRequestListener.bshSource, "bSHRequestListener.bshSource"); } } |
### Question:
BSHLogListener implements org.jpos.util.LogListener, org.jpos.core.Configurable { protected void addScriptInfo(String filename, String code, long lastModified){ Objects.requireNonNull(filename, "The script file name cannot be null"); scripts.put(filename, new ScriptInfo(code, lastModified)); } BSHLogListener(); @Override void setConfiguration(org.jpos.core.Configuration cfg); @Override LogEvent log(LogEvent ev); }### Answer:
@Test public void testAddScriptInfo() throws Throwable { BSHLogListener bSHLogListener = new BSHLogListener(); bSHLogListener.addScriptInfo("testBSHLogListenerFilename", "testBSHLogListenerCode", 100L); assertEquals(1, bSHLogListener.scripts.size(), "bSHLogListener.scripts.size()"); }
@Test public void testAddScriptInfoThrowsNullPointerException() throws Throwable { BSHLogListener bSHLogListener = new BSHLogListener(); try { bSHLogListener.addScriptInfo(null, "testBSHLogListenerCode", 100L); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertEquals("The script file name cannot be null", ex.getMessage()); assertEquals(0, bSHLogListener.scripts.size()); } } |
### Question:
BSHLogListener implements org.jpos.util.LogListener, org.jpos.core.Configurable { protected ScriptInfo getScriptInfo(String filename){ Objects.requireNonNull(filename, "The script file name cannot be null"); return scripts.get(filename); } BSHLogListener(); @Override void setConfiguration(org.jpos.core.Configuration cfg); @Override LogEvent log(LogEvent ev); }### Answer:
@Test public void testGetScriptInfo() throws Throwable { BSHLogListener bSHLogListener = new BSHLogListener(); BSHLogListener.ScriptInfo result = bSHLogListener.getScriptInfo("testBSHLogListenerFilename"); assertNull(result, "result"); assertEquals(0, bSHLogListener.scripts.size(), "bSHLogListener.scripts.size()"); }
@Test public void testGetScriptInfoThrowsNullPointerException() throws Throwable { BSHLogListener bSHLogListener = new BSHLogListener(); try { bSHLogListener.getScriptInfo(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertEquals("The script file name cannot be null", ex.getMessage()); assertEquals(0, bSHLogListener.scripts.size()); } } |
### Question:
Shutdown extends QBeanSupport { public void startService() { getServer().shutdown (); } void startService(); }### Answer:
@Test public void testStartService() throws Throwable { Shutdown shutdown = new Shutdown(); String[] args = new String[2]; args[0] = ""; args[1] = "testString"; shutdown.setServer(server); shutdown.startService(); assertSame(server, shutdown.getServer(), "shutdown.getServer()"); }
@Test public void testStartServiceThrowsNullPointerException() throws Throwable { try { new Shutdown().startService(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.q2.Q2.shutdown()\" because the return value of \"org.jpos.q2.qbean.Shutdown.getServer()\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
BSHLogListener implements org.jpos.util.LogListener, org.jpos.core.Configurable { protected String loadCode(File f) throws IOException{ StringBuilder buf = new StringBuilder((int)f.length()); char[] content = new char[(int)f.length()]; int l; Reader r = new BufferedReader(new FileReader(f)); try { while((l=r.read(content))!=-1) buf.append(content,0,l); } finally { r.close(); } return buf.toString(); } BSHLogListener(); @Override void setConfiguration(org.jpos.core.Configuration cfg); @Override LogEvent log(LogEvent ev); }### Answer:
@Test public void testLoadCodeThrowsFileNotFoundException() throws Throwable { BSHLogListener bSHLogListener = new BSHLogListener(); File f = new File("testBSHLogListenerParam1"); try { bSHLogListener.loadCode(f); fail("Expected FileNotFoundException to be thrown"); } catch (FileNotFoundException ex) { assertEquals(FileNotFoundException.class, ex.getClass(), "ex.getClass()"); assertEquals("testBSHLogListenerParam1", f.getName(), "f.getName()"); } }
@Test public void testLoadCodeThrowsNullPointerException() throws Throwable { BSHLogListener bSHLogListener = new BSHLogListener(); try { bSHLogListener.loadCode(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { } } |
### Question:
SpaceAdaptor extends QBeanSupport implements SpaceAdaptorMBean { public Set getKeys () { if (sp instanceof LocalSpace) return ((LocalSpace)sp).getKeySet (); return null; } SpaceAdaptor(); synchronized void setSpaceName(String spaceName); String getSpaceName(); Set getKeys(); }### Answer:
@SuppressWarnings("unchecked") @Test public void testGetKeys() throws Throwable { Set result = new SpaceAdaptor().getKeys(); assertNull(result, "result"); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.