method2testcases
stringlengths 118
6.63k
|
---|
### Question:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { protected void initTailLock () { tailLock = TAILLOCK + "." + Integer.toString (this.hashCode()); sp.put (tailLock, TAILLOCK); } @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 testInitTailLockThrowsNullPointerException() throws Throwable { try { transactionManager.initTailLock(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.space.Space.put(Object, Object)\" because \"this.sp\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(transactionManager.sp, "transactionManager.sp"); } } |
### Question:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { protected long nextId () { long h; synchronized (psp) { commitOff (psp); psp.in (HEAD); h = head; psp.out (HEAD, ++head); commitOn (psp); } return h; } @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 testNextIdThrowsNullPointerException() throws Throwable { try { transactionManager.nextId(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot enter synchronized block because \"this.psp\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(transactionManager.psp, "transactionManager.psp"); assertEquals(0L, transactionManager.head, "transactionManager.head"); } } |
### Question:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { protected int prepareForAbort (TransactionParticipant p, long id, Serializable context) { Chronometer c = new Chronometer(); try { if (p instanceof AbortParticipant) { setThreadName(id, "prepareForAbort", p); return ((AbortParticipant)p).prepareForAbort (id, context); } } catch (Throwable t) { getLog().warn ("PREPARE-FOR-ABORT: " + Long.toString (id), t); } finally { if (metrics != null) metrics.record(getName(p) + "-prepare-for-abort", c.elapsed()); } return ABORTED | NO_JOIN; } @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 testPrepareForAbort1() throws Throwable { int result = transactionManager.prepareForAbort(new Trace(), 100L, new File("testTransactionManagerParam1")); assertEquals(64, result, "result"); }
@Test public void testPrepareForAbort2() throws Throwable { int result = transactionManager.prepareForAbort(new Debug(), 100L, Boolean.FALSE); assertEquals(129, 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:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { protected void purge (long id, boolean full) { String stateKey = getKey (STATE, id); String contextKey = getKey (CONTEXT, id); String groupsKey = getKey (GROUPS, id); synchronized (psp) { commitOff (psp); if (full) SpaceUtil.wipe(psp, stateKey); SpaceUtil.wipe(psp, contextKey); SpaceUtil.wipe(psp, groupsKey); commitOn (psp); } } @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 testPurgeThrowsNullPointerException() throws Throwable { try { transactionManager.purge(100L, true); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"String.length()\" because \"str\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(transactionManager.psp, "transactionManager.psp"); } } |
### Question:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { protected void recover () { if (doRecover) { if (tail < head) { getLog().info ("recover - tail=" +tail+", head="+head); } while (tail < head) { recover (0, tail++); } } else tail = head; syncTail (); } @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 testRecoverThrowsNullPointerException() throws Throwable { try { transactionManager.recover(1, 100L); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"String.length()\" because \"str\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(transactionManager.psp, "transactionManager.psp"); assertNull(transactionManager.groups, "transactionManager.groups"); } }
@Test public void testRecoverThrowsNullPointerException1() throws Throwable { try { transactionManager.recover(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot enter synchronized block because \"this.psp\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(transactionManager.psp, "transactionManager.psp"); assertEquals(0L, transactionManager.tail, "transactionManager.tail"); assertNull(transactionManager.groups, "transactionManager.groups"); } } |
### 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:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { protected void setState (long id, Integer state) { String stateKey = getKey (STATE, id); synchronized (psp) { commitOff (psp); SpaceUtil.wipe(psp, stateKey); if (state!= null) psp.out (stateKey, state); commitOn (psp); } } @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 testSetStateThrowsNullPointerException() throws Throwable { try { transactionManager.setState(100L, Integer.valueOf(-1)); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"String.length()\" because \"str\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(transactionManager.psp, "transactionManager.psp"); } } |
### Question:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { protected void snapshot (long id, Serializable context) { snapshot (id, context, null); } @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 testSnapshotThrowsNullPointerException() throws Throwable { try { transactionManager.snapshot(100L, "testString", Integer.valueOf(-100)); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"String.length()\" because \"str\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(transactionManager.psp, "transactionManager.psp"); } }
@Test public void testSnapshotThrowsNullPointerException1() throws Throwable { try { transactionManager.snapshot(100L, new Comment("testTransactionManagerText")); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"String.length()\" because \"str\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(transactionManager.psp, "transactionManager.psp"); } } |
### Question:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { @Override public void startService () throws Exception { NameRegistrar.register(getName(), this); recover(); threads = Collections.synchronizedList(new ArrayList(maxSessions)); if (tps != null) tps.stop(); tps = new TPS (cfg.getBoolean ("auto-update-tps", true)); for (int i=0; i<sessions; i++) { new Thread(this).start(); } if (psp.rdp (RETRY_QUEUE) != null) checkRetryTask(); if (maxSessions > sessions) { loadMonitorExecutor = ConcurrentUtil.newScheduledThreadPoolExecutor(); loadMonitorExecutor.scheduleAtFixedRate( new Thread(() -> { int outstandingTransactions = getOutstandingTransactions(); int activeSessions = getActiveSessions(); if (activeSessions < maxSessions && outstandingTransactions > threshold) { int count = Math.min(outstandingTransactions, maxSessions - activeSessions); for (int i=0; i<count; i++) new Thread(this).start(); getLog().info("Created " + count + " additional sessions"); } }), 5, 1, TimeUnit.SECONDS) ; } if (iisp != isp) { new Thread(new InputQueueMonitor()).start(); } } @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 testStartServiceThrowsNullPointerException1() throws Throwable { transactionManager.setName("testTransactionManagerName"); try { transactionManager.startService(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot enter synchronized block because \"this.psp\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(transactionManager.psp, "transactionManager.psp"); assertNull(transactionManager.threads, "transactionManager.threads"); assertNull(transactionManager.getConfiguration(), "transactionManager.getConfiguration()"); assertEquals(0L, transactionManager.tail, "transactionManager.tail"); assertNull(transactionManager.groups, "transactionManager.groups"); } } |
### Question:
TransactionManager extends QBeanSupport implements Runnable, TransactionConstants, TransactionManagerMBean, Loggeable, MetricsProvider { protected boolean tailDone () { String stateKey = getKey(STATE, tail); if (DONE.equals (psp.rdp (stateKey))) { purge (tail, true); return true; } return false; } @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 testTailDoneThrowsNullPointerException() throws Throwable { try { transactionManager.tailDone(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"String.length()\" because \"str\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(transactionManager.psp, "transactionManager.psp"); } } |
### 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 { public <T> T get(Object key) { @SuppressWarnings("unchecked") T obj = (T) getMap().get(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 testGet() throws Throwable { Context context = new Context(); context.put("", new Object(), true); Object result = context.get(Float.valueOf(-10.0F), -100L); assertNull(result, "result"); }
@Test public void testGet2() throws Throwable { Context context = new Context(); Object result = context.get(""); assertNull(result, "result"); }
@Test public void testGet8() throws Throwable { Context context = new Context(); Integer defValue = -1; Integer result = (Integer) context.get("", defValue); assertSame(defValue, result, "result"); }
@Test public void testGetThrowsNullPointerException() throws Throwable { Context context = new Context(); try { context.get("", 49L); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.util.Map.get(Object)\" because \"this.map\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### 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:
Context implements Externalizable, Loggeable, Pausable, Cloneable { public void put (Object key, Object value) { if (trace) { getProfiler().checkPoint( String.format("%s='%s' [%s]", getKeyName(key), value, Caller.info(1)) ); } getMap().put (key, value); synchronized (this) { notifyAll(); } } 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 testPut() throws Throwable { Context context = new Context(); context.checkPoint("testContextDetail"); context.put("", Long.valueOf(-128L), true); assertTrue(true, "Test completed without Exception"); }
@Test public void testPut1() throws Throwable { new Context().put("", new Object(), true); assertTrue(true, "Test completed without Exception"); }
@Test public void testPut2() throws Throwable { new Context().put("", "", true); assertTrue(true, "Test completed without Exception"); }
@Test public void testPut6() throws Throwable { new Context().put("", "", false); assertTrue(true, "Test completed without Exception"); }
@Test public void testPut7() throws Throwable { Context context = new Context(); context.put("", new Object(), true); context.put("testString", new Object()); assertTrue(true, "Test completed without Exception"); }
@Test public void testPut8() throws Throwable { new Context().put("testString", ""); 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 writeExternal (ObjectOutput out) throws IOException { out.writeByte (0); Set s = getPMap().entrySet(); out.writeInt (s.size()); Iterator iter = s.iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); out.writeObject(entry.getKey()); out.writeObject(entry.getValue()); } } 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 testWriteExternal1() throws Throwable { Context context = new Context(); context.writeExternal(new ObjectOutputStream(new ByteArrayOutputStream())); }
@Test public void testWriteExternalThrowsNullPointerException() throws Throwable { Context context = new Context(); try { context.writeExternal(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.ObjectOutput.writeByte(int)\" because \"out\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### 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:
BSHMethod { protected Interpreter initInterpreter(Map arguments) throws EvalError, IOException { Interpreter i = new Interpreter(); Map.Entry entry; for (Object o : arguments.entrySet()) { entry = (Map.Entry) o; i.set((String) entry.getKey(), entry.getValue()); } if (source) { i.source(bshData); } else { i.eval(bshData); } return i; } 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 testInitInterpreterThrowsClassCastException() throws Throwable { BSHMethod bSHMethod = new BSHMethod("testBSHMethodBshData", true); Map<Object, Object> arguments = new HashMap(); arguments.put(new Object(), "char7set"); try { bSHMethod.initInterpreter(arguments); fail("Expected ClassCastException to be thrown"); } catch (ClassCastException ex) { assertEquals(ClassCastException.class, ex.getClass(), "ex.getClass()"); assertEquals(1, arguments.size(), "(HashMap) arguments.size()"); } }
@Test public void testInitInterpreterThrowsFileNotFoundException() throws Throwable { BSHMethod bSHMethod = new BSHMethod("testBSHMethodBshData", true); arguments.put("lt", ""); try { bSHMethod.initInterpreter(arguments); fail("Expected FileNotFoundException to be thrown"); } catch (FileNotFoundException ex) { assertEquals(FileNotFoundException.class, ex.getClass(), "ex.getClass()"); assertEquals(1, arguments.size(), "(HashMap) arguments.size()"); } }
@Test public void testInitInterpreterThrowsFileNotFoundException1() throws Throwable { BSHMethod bSHMethod = new BSHMethod("testBSHMethodBshData", true); try { bSHMethod.initInterpreter(arguments); fail("Expected FileNotFoundException to be thrown"); } catch (FileNotFoundException ex) { assertEquals(FileNotFoundException.class, ex.getClass(), "ex.getClass()"); assertEquals(0, arguments.size(), "(HashMap) arguments.size()"); } }
@Test public void testInitInterpreterThrowsNullPointerException() throws Throwable { BSHMethod bSHMethod = new BSHMethod(null, false); try { bSHMethod.initInterpreter(arguments); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"String.endsWith(String)\" because \"statements\" is null", ex.getMessage(), "ex.getMessage()"); } assertEquals(0, arguments.size(), "(HashMap) arguments.size()"); } }
@Test public void testInitInterpreterThrowsNullPointerException1() throws Throwable { BSHMethod bSHMethod = new BSHMethod("testBSHMethodBshData", true); try { bSHMethod.initInterpreter(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.util.Map.entrySet()\" because \"arguments\" is null", ex.getMessage(), "ex.getMessage()"); } } }
@Test public void testInitInterpreterThrowsParseException() throws Throwable { arguments.put("", new Object()); BSHMethod bSHMethod = new BSHMethod(":]Z", false); try { bSHMethod.initInterpreter(arguments); fail("Expected ParseException to be thrown"); } catch (ParseException ex) { assertThat(ex.getMessage(), allOf(notNullValue(), containsString("line 1, column 1"))); } } |
### 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:
BSHTransactionParticipant extends SimpleLogSource implements TransactionParticipant, AbortParticipant, XmlConfigurable { public void setConfiguration(Element e) throws ConfigurationException { try { prepareMethod = BSHMethod.createBshMethod(e.getChild("prepare")); prepareForAbortMethod = BSHMethod.createBshMethod(e.getChild("prepare-for-abort")); commitMethod = BSHMethod.createBshMethod(e.getChild("commit")); abortMethod = BSHMethod.createBshMethod(e.getChild("abort")); trace = "yes".equals (QFactory.getAttributeValue (e, "trace")); } catch (Exception ex) { throw new ConfigurationException(ex.getMessage(), ex); } } 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 testSetConfiguration() throws Throwable { BSHTransactionParticipant bSHTransactionParticipant = new BSHTransactionParticipant(); bSHTransactionParticipant.setConfiguration(new Element("testBSHTransactionParticipantName", "testBSHTransactionParticipantUri")); assertNull(bSHTransactionParticipant.prepareForAbortMethod, "bSHTransactionParticipant.prepareForAbortMethod"); assertNull(bSHTransactionParticipant.abortMethod, "bSHTransactionParticipant.abortMethod"); assertNull(bSHTransactionParticipant.commitMethod, "bSHTransactionParticipant.commitMethod"); assertNull(bSHTransactionParticipant.prepareMethod, "bSHTransactionParticipant.prepareMethod"); assertFalse(bSHTransactionParticipant.trace, "bSHTransactionParticipant.trace"); }
@Test public void testSetConfigurationThrowsConfigurationException1() throws Throwable { BSHTransactionParticipant bSHTransactionParticipant = new BSHTransactionParticipant(); try { bSHTransactionParticipant.setConfiguration(null); fail("Expected ConfigurationException to be thrown"); } catch (ConfigurationException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); assertNull(ex.getNested().getMessage(), "ex.getNested().getMessage()"); } else { assertEquals("Cannot invoke \"org.jdom2.Element.getChild(String)\" because \"e\" is null", ex.getMessage(), "ex.getMessage()"); assertEquals("Cannot invoke \"org.jdom2.Element.getChild(String)\" because \"e\" is null", ex.getNested().getMessage(), "ex.getNested().getMessage()"); } assertNull(bSHTransactionParticipant.prepareForAbortMethod, "bSHTransactionParticipant.prepareForAbortMethod"); assertNull(bSHTransactionParticipant.abortMethod, "bSHTransactionParticipant.abortMethod"); assertNull(bSHTransactionParticipant.commitMethod, "bSHTransactionParticipant.commitMethod"); assertNull(bSHTransactionParticipant.prepareMethod, "bSHTransactionParticipant.prepareMethod"); assertFalse(bSHTransactionParticipant.trace, "bSHTransactionParticipant.trace"); } } |
### 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:
BSHGroupSelector extends BSHTransactionParticipant implements GroupSelector { public void setConfiguration(Element e) throws ConfigurationException { super.setConfiguration(e); try { selectMethod = BSHMethod.createBshMethod(e.getChild("select")); } catch (Exception ex) { throw new ConfigurationException(ex.getMessage(), ex); } } void setConfiguration(Element e); String select(long id, java.io.Serializable context); String defaultSelect(long id, Serializable context); }### Answer:
@Test public void testSetConfiguration() throws Throwable { BSHGroupSelector bSHGroupSelector = new BSHGroupSelector(); bSHGroupSelector.setConfiguration(new Element("testBSHGroupSelectorName", "testBSHGroupSelectorUri")); assertNull(bSHGroupSelector.prepareForAbortMethod, "bSHGroupSelector.prepareForAbortMethod"); assertNull(bSHGroupSelector.selectMethod, "bSHGroupSelector.selectMethod"); assertNull(bSHGroupSelector.commitMethod, "bSHGroupSelector.commitMethod"); assertNull(bSHGroupSelector.abortMethod, "bSHGroupSelector.abortMethod"); assertNull(bSHGroupSelector.prepareMethod, "bSHGroupSelector.prepareMethod"); assertFalse(bSHGroupSelector.trace, "bSHGroupSelector.trace"); }
@Test public void testSetConfigurationThrowsConfigurationException() throws Throwable { BSHGroupSelector bSHGroupSelector = new BSHGroupSelector(); try { bSHGroupSelector.setConfiguration(null); fail("Expected ConfigurationException to be thrown"); } catch (ConfigurationException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); assertNull(ex.getNested().getMessage(), "ex.getNested().getMessage()"); } else { assertEquals("Cannot invoke \"org.jdom2.Element.getChild(String)\" because \"e\" is null", ex.getMessage(), "ex.getMessage()"); assertEquals("Cannot invoke \"org.jdom2.Element.getChild(String)\" because \"e\" is null", ex.getNested().getMessage(), "ex.getNested().getMessage()"); } assertNull(bSHGroupSelector.prepareForAbortMethod, "bSHGroupSelector.prepareForAbortMethod"); assertNull(bSHGroupSelector.selectMethod, "bSHGroupSelector.selectMethod"); assertNull(bSHGroupSelector.commitMethod, "bSHGroupSelector.commitMethod"); assertNull(bSHGroupSelector.abortMethod, "bSHGroupSelector.abortMethod"); assertNull(bSHGroupSelector.prepareMethod, "bSHGroupSelector.prepareMethod"); assertFalse(bSHGroupSelector.trace, "bSHGroupSelector.trace"); } } |
### 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:
Redirect implements ActionListener, UIAware { public void actionPerformed (ActionEvent ev) { StringTokenizer st = new StringTokenizer (ev.getActionCommand ()); ui.reconfigure ( st.nextToken(), st.hasMoreTokens () ? st.nextToken () : null ); } Redirect(); void setUI(UI ui, Element e); void actionPerformed(ActionEvent ev); public UI ui; }### Answer:
@Test public void testActionPerformedThrowsNoSuchElementException() throws Throwable { try { new Redirect().actionPerformed(new ActionEvent("", 100, "", 100L, 1000)); fail("Expected NoSuchElementException to be thrown"); } catch (NoSuchElementException ex) { assertNull(ex.getMessage(), "ex.getMessage()"); } }
@Test public void testActionPerformedThrowsNullPointerException() throws Throwable { try { new Redirect().actionPerformed(new ActionEvent(Long.valueOf(0L), 100, null, 100L, 1000)); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"String.length()\" because \"str\" is null", ex.getMessage(), "ex.getMessage()"); } } }
@Test public void testActionPerformedThrowsNullPointerException1() throws Throwable { try { new Redirect().actionPerformed(new ActionEvent("", 100, "testRedirectParam3", 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.reconfigure(String, String)\" because \"this.ui\" is null", ex.getMessage(), "ex.getMessage()"); } } }
@Test public void testActionPerformedThrowsNullPointerException2() throws Throwable { try { new Redirect().actionPerformed(new ActionEvent("", 100, "testRedirect\rParam3", 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.reconfigure(String, String)\" because \"this.ui\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### 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:
SimpleConfiguration implements Configuration, Serializable { public String get (String name, String def) { Object obj = props.get (name); if (obj instanceof String[]) { String[] arr= (String[]) obj; obj = arr.length > 0 ? arr[0] : null; } else if (obj instanceof List) { List l = (List) obj; obj = l.size() > 0 ? l.get(0) : null; } return (obj instanceof String) ? Environment.get((String) obj, def) : def; } 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 testGet() throws Throwable { String result = new SimpleConfiguration(new Properties()).get("testSimpleConfigurationName", null); assertNull(result, "result"); }
@Test public void testGet1() throws Throwable { String result = new SimpleConfiguration(new Properties()).get("testSimpleConfigurationName", "testSimpleConfigurationDef"); assertEquals("testSimpleConfigurationDef", result, "result"); }
@Test public void testGet3() throws Throwable { String result = new SimpleConfiguration(new Properties()).get("testSimpleConfigurationName"); assertEquals("", result, "result"); }
@Test public void testGetThrowsNullPointerException() throws Throwable { try { new SimpleConfiguration((Properties) null).get("testSimpleConfigurationName", "testSimpleConfigurationDef"); 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.get(Object)\" because \"this.props\" is null", ex.getMessage(), "ex.getMessage()"); } } }
@Test public void testGetThrowsNullPointerException1() throws Throwable { try { new SimpleConfiguration((Properties) null).get("testSimpleConfigurationName"); 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.get(Object)\" because \"this.props\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
SimpleConfiguration implements Configuration, Serializable { public String[] getAll (String name) { String[] ret; Object obj = props.get (name); if (obj instanceof String[]) { ret = (String[]) obj; } else if (obj instanceof String) { ret = new String[1]; ret[0] = (String) obj; } else ret = new String[0]; Environment env = Environment.getEnvironment(); IntStream.range(0, ret.length).forEachOrdered(i -> ret[i] = env.getProperty(ret[i])); return Arrays.stream(ret).filter(Objects::nonNull).toArray(String[]::new); } 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 testGetAll() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(); simpleConfiguration.put("testString", ""); String[] result = simpleConfiguration.getAll("testString"); assertEquals(1, result.length, "result.length"); assertEquals("", result[0], "result[0]"); }
@Test public void testGetAll1() throws Throwable { String[] result = new SimpleConfiguration(new Properties()).getAll("testSimpleConfigurationName"); assertEquals(0, result.length, "result.length"); }
@Test public void testGetAllThrowsNullPointerException() throws Throwable { try { new SimpleConfiguration((Properties) null).getAll("testSimpleConfigurationName"); 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.get(Object)\" because \"this.props\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
SimpleConfiguration implements Configuration, Serializable { public boolean getBoolean (String name) { String v = get (name, "false").trim(); return v.equalsIgnoreCase("true") || v.equalsIgnoreCase("yes"); } 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 testGetBoolean() throws Throwable { boolean result = new SimpleConfiguration().getBoolean("testSimpleConfigurationName", true); assertTrue(result, "result"); }
@Test public void testGetBoolean4() throws Throwable { boolean result = new SimpleConfiguration(new Properties()).getBoolean("testSimpleConfigurationName"); assertFalse(result, "result"); }
@Test public void testGetBooleanThrowsNullPointerException() throws Throwable { try { new SimpleConfiguration((Properties) null).getBoolean("testSimpleConfigurationName", true); 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.get(Object)\" because \"this.props\" is null", ex.getMessage(), "ex.getMessage()"); } } }
@Test public void testGetBooleanThrowsNullPointerException1() throws Throwable { try { new SimpleConfiguration((Properties) null).getBoolean("testSimpleConfigurationName"); 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.get(Object)\" because \"this.props\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
SimpleConfiguration implements Configuration, Serializable { public double getDouble(String name) { return Double.valueOf(get(name, "0.00").trim()); } 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 testGetDouble() throws Throwable { double result = new SimpleConfiguration(new Properties()).getDouble("testSimpleConfigurationName"); assertEquals(0.0, result, 1.0E-6, "result"); }
@Test public void testGetDouble1() throws Throwable { double result = new SimpleConfiguration(new Properties()).getDouble("testSimpleConfigurationName", 0.0); assertEquals(0.0, result, 1.0E-6, "result"); }
@Test public void testGetDouble2() throws Throwable { double result = new SimpleConfiguration(new Properties()).getDouble("testSimpleConfigurationName", 100.0); assertEquals(100.0, result, 1.0E-6, "result"); }
@Test public void testGetDoubleThrowsNullPointerException() throws Throwable { try { new SimpleConfiguration((Properties) null).getDouble("testSimpleConfigurationName"); 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.get(Object)\" because \"this.props\" is null", ex.getMessage(), "ex.getMessage()"); } } }
@Test public void testGetDoubleThrowsNullPointerException1() throws Throwable { try { new SimpleConfiguration((Properties) null).getDouble("testSimpleConfigurationName", 100.0); 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.get(Object)\" because \"this.props\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### Question:
SimpleConfiguration implements Configuration, Serializable { public int getInt (String name) { return Integer.parseInt(get(name, "0").trim()); } 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 testGetInt() throws Throwable { int result = new SimpleConfiguration(new Properties()).getInt("testSimpleConfigurationName", 100); assertEquals(100, result, "result"); }
@Test public void testGetInt1() throws Throwable { int result = new SimpleConfiguration(new Properties()).getInt("testSimpleConfigurationName", 0); assertEquals(0, result, "result"); }
@Test public void testGetInt2() throws Throwable { int result = new SimpleConfiguration(new Properties()).getInt("testSimpleConfigurationName"); assertEquals(0, result, "result"); }
@Test public void testGetIntThrowsNullPointerException() throws Throwable { try { new SimpleConfiguration((Properties) null).getInt("testSimpleConfigurationName", 100); 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.get(Object)\" because \"this.props\" is null", ex.getMessage(), "ex.getMessage()"); } } }
@Test public void testGetIntThrowsNullPointerException1() throws Throwable { try { new SimpleConfiguration((Properties) null).getInt("testSimpleConfigurationName"); 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.get(Object)\" because \"this.props\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### 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 long getLong (String name) { return Long.parseLong(get(name, "0").trim()); } 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 testGetLong() throws Throwable { long result = new SimpleConfiguration().getLong("testSimpleConfigurationName", 100L); assertEquals(100L, result, "result"); }
@Test public void testGetLong1() throws Throwable { long result = new SimpleConfiguration(new Properties()).getLong("testSimpleConfigurationName", 0L); assertEquals(0L, result, "result"); }
@Test public void testGetLong2() throws Throwable { long result = new SimpleConfiguration(new Properties()).getLong("testSimpleConfigurationName"); assertEquals(0L, result, "result"); }
@Test public void testGetLongThrowsNullPointerException() throws Throwable { try { new SimpleConfiguration(new Properties()).getLong(null, 100L); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"Object.hashCode()\" because \"key\" is null", ex.getMessage(), "ex.getMessage()"); } } }
@Test public void testGetLongThrowsNullPointerException1() throws Throwable { try { new SimpleConfiguration((Properties) null).getLong("testSimpleConfigurationName"); 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.get(Object)\" because \"this.props\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### 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:
SubConfiguration implements Configuration { public String get(String propertyName){ return cfg.get(prefix + propertyName); } 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 testGet() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); String result = subConfiguration.get("testSubConfigurationPropertyName"); assertEquals("", result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGet1() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); String result = subConfiguration.get("testSubConfigurationPropertyName", "testSubConfigurationDefaultValue"); assertEquals("testSubConfigurationDefaultValue", result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetThrowsNullPointerException() throws Throwable { Configuration cfg = new SubConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); try { subConfiguration.get("testSubConfigurationPropertyName"); 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.get(String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); } }
@Test public void testGetThrowsNullPointerException1() throws Throwable { SubConfiguration subConfiguration = new SubConfiguration(); try { subConfiguration.get("testSubConfigurationPropertyName", "testSubConfigurationDefaultValue"); 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.get(String, String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(subConfiguration.cfg, "subConfiguration.cfg"); } } |
### Question:
SubConfiguration implements Configuration { public String[] getAll(String propertyName){ return cfg.getAll(prefix + propertyName); } 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 testGetAll() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); subConfiguration.put("testString", ""); String[] result = subConfiguration.getAll("testString"); assertEquals(1, result.length, "result.length"); assertEquals("", result[0], "result[0]"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetAll1() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); String[] result = subConfiguration.getAll("testSubConfigurationPropertyName"); assertEquals(0, result.length, "result.length"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetAllThrowsNullPointerException() throws Throwable { Configuration cfg = new SubConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); try { subConfiguration.getAll("testSubConfigurationPropertyName"); 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()"); } assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); } } |
### Question:
SubConfiguration implements Configuration { public boolean getBoolean(String propertyName){ return cfg.getBoolean(prefix + propertyName); } 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 testGetBoolean() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); boolean result = subConfiguration.getBoolean("testSubConfigurationPropertyName"); assertFalse(result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetBoolean1() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); boolean result = subConfiguration.getBoolean("testSubConfigurationPropertyName", false); assertFalse(result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetBoolean2() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); boolean result = subConfiguration.getBoolean("testSubConfigurationPropertyName", true); assertTrue(result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetBooleanThrowsNullPointerException() throws Throwable { Configuration cfg = new SubConfiguration(new SubConfiguration(), "testSubConfigurationPrefix"); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix1"); try { subConfiguration.getBoolean("testSubConfigurationPropertyName"); 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.getBoolean(String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); } }
@Test public void testGetBooleanThrowsNullPointerException1() throws Throwable { SubConfiguration subConfiguration = new SubConfiguration(); try { subConfiguration.getBoolean("testSubConfigurationPropertyName", true); 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.getBoolean(String, boolean)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(subConfiguration.cfg, "subConfiguration.cfg"); } } |
### 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 double getDouble(String propertyName){ return cfg.getDouble(prefix + propertyName); } 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 testGetDouble() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); double result = subConfiguration.getDouble("testSubConfigurationPropertyName"); assertEquals(0.0, result, 1.0E-6, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetDouble1() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); double result = subConfiguration.getDouble("testSubConfigurationPropertyName", 0.0); assertEquals(0.0, result, 1.0E-6, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetDouble2() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); double result = subConfiguration.getDouble("testSubConfigurationPropertyName", 100.0); assertEquals(100.0, result, 1.0E-6, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetDoubleThrowsNullPointerException() throws Throwable { Configuration cfg = new SubConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); try { subConfiguration.getDouble("testSubConfigurationPropertyName"); 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.getDouble(String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); } }
@Test public void testGetDoubleThrowsNullPointerException1() throws Throwable { Configuration cfg = new SubConfiguration(new SubConfiguration(), "testSubConfigurationPrefix"); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix1"); try { subConfiguration.getDouble("testSubConfigurationPropertyName", 100.0); 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.getDouble(String, double)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); } } |
### Question:
SubConfiguration implements Configuration { public int getInt(String propertyName){ return cfg.getInt(prefix + propertyName); } 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 testGetInt() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); int result = subConfiguration.getInt("testSubConfigurationPropertyName", 100); assertEquals(100, result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetInt1() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); int result = subConfiguration.getInt("testSubConfigurationPropertyName", 0); assertEquals(0, result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetInt2() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); int result = subConfiguration.getInt("testSubConfigurationPropertyName"); assertEquals(0, result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetIntThrowsNullPointerException() throws Throwable { Configuration cfg = new SubConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); try { subConfiguration.getInt("testSubConfigurationPropertyName", 100); 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.getInt(String, int)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); } }
@Test public void testGetIntThrowsNullPointerException1() throws Throwable { Configuration cfg = new SubConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); try { subConfiguration.getInt("testSubConfigurationPropertyName"); 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.getInt(String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); } } |
### Question:
SubConfiguration implements Configuration { public long getLong(String propertyName){ return cfg.getLong(prefix + propertyName); } 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 testGetLong() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); long result = subConfiguration.getLong("testSubConfigurationPropertyName", 100L); assertEquals(100L, result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetLong1() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); long result = subConfiguration.getLong("testSubConfigurationPropertyName", 0L); assertEquals(0L, result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetLong2() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); long result = subConfiguration.getLong("testSubConfigurationPropertyName"); assertEquals(0L, result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetLongThrowsNullPointerException() throws Throwable { Configuration cfg = new SubConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); try { subConfiguration.getLong("testSubConfigurationPropertyName", 100L); 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.getLong(String, long)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); } }
@Test public void testGetLongThrowsNullPointerException1() throws Throwable { SubConfiguration subConfiguration = new SubConfiguration(); try { subConfiguration.getLong("testSubConfigurationPropertyName"); 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.getLong(String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(subConfiguration.cfg, "subConfiguration.cfg"); } } |
### Question:
SubConfiguration implements Configuration { public Object getObject (String propertyName) throws ConfigurationException{ try{ Object ret = Class.forName (get (propertyName)).newInstance(); if(ret instanceof Configurable) ((Configurable)ret).setConfiguration(this); return ret; } catch (Exception e){ throw new ConfigurationException ("Error trying to create an " + "object from property " + prefix + propertyName, e ); } } 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 testGetObjectThrowsConfigurationException() throws Throwable { Configuration cfg = new SubConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); try { subConfiguration.getObject("testSubConfigurationPropertyName"); fail("Expected ConfigurationException to be thrown"); } catch (ConfigurationException ex) { assertEquals( "Error trying to create an object from property testSubConfigurationPrefixtestSubConfigurationPropertyName", ex.getMessage(), "ex.getMessage()"); if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getNested().getMessage(), "ex.getNested().getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.core.Configuration.get(String)\" because \"this.cfg\" is null", ex.getNested().getMessage(), "ex.getNested().getMessage()"); } assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); } } |
### 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 void dump (PrintStream p, String indent) { p.print (indent + "<CardHolder"); if (hasTrack1()) p.print (" trk1=\"true\""); if (hasTrack2()) p.print (" trk2=\"true\""); if (hasSecurityCode()) p.print (" sec=\"true\""); if (isExpired()) p.print (" expired=\"true\""); p.println (">"); p.println (indent + " " + "<pan>" +pan +"</pan>"); p.println (indent + " " + "<exp>" +exp +"</exp>"); p.println (indent + "</CardHolder>"); } 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 testDump() throws Throwable { CardHolder cardHolder = new CardHolder("testCardHolderPan", "4Cha"); cardHolder.setSecurityCode("testCardHolderSecurityCode"); PrintStream p = new PrintStream(new ByteArrayOutputStream(), true, "UTF-8"); cardHolder.dump(p, "testCardHolderIndent"); assertTrue(true, "Test completed without Exception"); }
@Test public void testDump6() throws Throwable { PrintStream p = new PrintStream(new ByteArrayOutputStream(), true, "UTF-8"); new CardHolder("testCardHolderPan", "4Cha").dump(p, "testCardHolderIndent"); assertTrue(true, "Test completed without Exception"); }
@Test public void testDumpThrowsNullPointerException() throws Throwable { try { new CardHolder("k'X9|DH:!;uQ<kG8!P?- ,\"Y!u`r;jB^)>3AbS9,").dump(null, "testCardHolderIndent"); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.io.PrintStream.print(String)\" because \"p\" is null", ex.getMessage(), "ex.getMessage()"); } } } |
### 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"); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.