From 1b7c6464818a980738305d9126d1475b81c22804 Mon Sep 17 00:00:00 2001 From: Yuji Konishi Date: Tue, 9 Aug 2011 00:31:03 +0900 Subject: [PATCH] =?utf8?q?=E9=81=85=E5=BB=B6=E3=83=86=E3=82=B9=E3=83=88?= =?utf8?q?=E3=82=B1=E3=83=BC=E3=82=B9=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../com/td/service/TrainDelayedServiceImpl.java | 9 +- .../src/com/td/service/TrainTwitterAdapter.java | 4 +- .../com/td/service/TrainTwitterAdapterTest.java | 114 +++++++++++++++++++-- .../TrainDelayed/src/com/td/utility/Debug.java | 2 +- 4 files changed, 114 insertions(+), 15 deletions(-) diff --git a/workspace/TrainDelayed/src/com/td/service/TrainDelayedServiceImpl.java b/workspace/TrainDelayed/src/com/td/service/TrainDelayedServiceImpl.java index 84f256e..6c1f97a 100644 --- a/workspace/TrainDelayed/src/com/td/service/TrainDelayedServiceImpl.java +++ b/workspace/TrainDelayed/src/com/td/service/TrainDelayedServiceImpl.java @@ -169,11 +169,12 @@ public class TrainDelayedServiceImpl extends Service implements TrainDelayedServ if (Debug.isDebug()){ Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(next); - Date d = cal.getTime(); - int ymd = DateUtil.getYmd(d); - int hm = DateUtil.getHm(d); + Date date = cal.getTime(); + int ymd = DateUtil.getYmd(date); + int d = DateUtil.getD(ymd); + int hm = DateUtil.getHm(date); - long val = id * 1000000 * 10000 + ymd * 10000 + hm; + long val = id * 100 * 10000 + d * 10000 + hm; TrainTwitterAdapter.insert( TrainDelayedServiceImpl.this, diff --git a/workspace/TrainDelayed/src/com/td/service/TrainTwitterAdapter.java b/workspace/TrainDelayed/src/com/td/service/TrainTwitterAdapter.java index 4828fc3..4e31e44 100644 --- a/workspace/TrainDelayed/src/com/td/service/TrainTwitterAdapter.java +++ b/workspace/TrainDelayed/src/com/td/service/TrainTwitterAdapter.java @@ -174,13 +174,15 @@ public class TrainTwitterAdapter extends TwitterAdapter { if (newDelay != null) { Delay.setData(sb, newDelay); } + ConfUtil.setDelay(pref, sb.toString()); if (isDelay) { - // @’x‰„‚ð’Ê’m + // ’x‰„‚ð’Ê’m if (impl != null) { impl.notificate(train.getName()); } } + pref.update(); return isDelay; } diff --git a/workspace/TrainDelayed/src/com/td/service/TrainTwitterAdapterTest.java b/workspace/TrainDelayed/src/com/td/service/TrainTwitterAdapterTest.java index bfb18d5..e1f0856 100644 --- a/workspace/TrainDelayed/src/com/td/service/TrainTwitterAdapterTest.java +++ b/workspace/TrainDelayed/src/com/td/service/TrainTwitterAdapterTest.java @@ -36,10 +36,10 @@ public class TrainTwitterAdapterTest { Train train = null; long id = -1; - String name = null; + String name = "name"; Calendar cal = null; - int ymd = -1; - int hm = -1; + int ymd = 2011; + int hm = 810; int count = -1; int len = -1; int h = -1; @@ -51,30 +51,126 @@ public class TrainTwitterAdapterTest { boolean ret = false; String retData = null; - for (int i = 0; i < 1; i++){ - StringBuffer sb = new StringBuffer(); + for (int i = 0; i < 4; i++){ + StringBuffer sb = null; switch (i){ case 0: id = 1; - name = "foo"; cal = DateUtil.getCalendar(ymd, hm); - count = 10; + // Twit” + count = 9; + // ŠÄŽ‹ŠÔŠu len = 10; + // ’PˆÊŽžŠÔ(•ª)‚ ‚½‚è‚ÌTwit”B‚±‚ê‚ð’´‚¦‚é‚Æ’x‰„ h = 1; + // ’x‰„ŒãA‚±‚ÌŠúŠÔ‚Í’x‰„‚ð’Ê’m‚µ‚È‚¢ + w = 1; + + // ‘O‰ñ‚Ü‚Å‚Ì’x‰„ó‹µ + sb = new StringBuffer(); + //delay = new Delay(id, ymd, hm, 0, true); + //Delay.setData(sb, delay); + ConfUtil.setDelay(pref, sb.toString()); + + // ’x‰„Œ‹‰Ê + ret = false; + // ’x‰„ó‹µ + sb = new StringBuffer(); + //delay = new Delay(id, ymd, hm, 0, true); + //Delay.setData(sb, delay); + retData = sb.toString(); + break; + case 1: + id = 1; + cal = DateUtil.getCalendar(ymd, hm); + // Twit” + count = 10; + // ŠÄŽ‹ŠÔŠu + len = 5; + + // ’PˆÊŽžŠÔ(•ª)‚ ‚½‚è‚ÌTwit”B‚±‚ê‚ð’´‚¦‚é‚Æ’x‰„ + h = 2; + // ’x‰„ŒãA‚±‚ÌŠúŠÔ‚Í’x‰„‚ð’Ê’m‚µ‚È‚¢ w = 1; + // ‘O‰ñ‚Ü‚Å‚Ì’x‰„ó‹µ + sb = new StringBuffer(); + //delay = new Delay(id, ymd, hm, 0, true); + //Delay.setData(sb, delay); + ConfUtil.setDelay(pref, sb.toString()); + + // ’x‰„Œ‹‰Ê + ret = true; + // ’x‰„ó‹µ + sb = new StringBuffer(); delay = new Delay(id, ymd, hm, 0, true); Delay.setData(sb, delay); + retData = sb.toString(); + break; + case 2: + // ’x‰„‚ÌŽžŠÔ‚É–¢XV(’Ê’m‚Í‚µ‚È‚¢) + id = 1; + cal = DateUtil.getCalendar(ymd, hm + 1); + // Twit” + count = 10; + // ŠÄŽ‹ŠÔŠu + len = 5; + + // ’PˆÊŽžŠÔ(•ª)‚ ‚½‚è‚ÌTwit”B‚±‚ê‚ð’´‚¦‚é‚Æ’x‰„ + h = 2; + // ’x‰„ŒãA‚±‚ÌŠúŠÔ‚Í’x‰„‚ð’Ê’m‚µ‚È‚¢ + w = 1; + // ‘O‰ñ‚Ü‚Å‚Ì’x‰„ó‹µ + sb = new StringBuffer(); + delay = new Delay(id, ymd, hm, 0, true); + Delay.setData(sb, delay); + ConfUtil.setDelay(pref, sb.toString()); + + // ’x‰„Œ‹‰Ê ret = false; - retData = ""; + // ’x‰„ó‹µ + sb = new StringBuffer(); + delay = new Delay(id, ymd, hm + 1, 0, true); + Delay.setData(sb, delay); + retData = sb.toString(); + break; + case 3: + // w‚ð’´‚¦‚Ä‚Ì’x‰„B’Ê’m‚ ‚è + id = 1; + cal = DateUtil.getCalendar(ymd, hm + 2); + // Twit” + count = 10; + // ŠÄŽ‹ŠÔŠu + len = 5; + + // ’PˆÊŽžŠÔ(•ª)‚ ‚½‚è‚ÌTwit”B‚±‚ê‚ð’´‚¦‚é‚Æ’x‰„ + h = 2; + // ’x‰„ŒãA‚±‚ÌŠúŠÔ‚Í’x‰„‚ð’Ê’m‚µ‚È‚¢ + w = 1; + + // ‘O‰ñ‚Ü‚Å‚Ì’x‰„ó‹µ + sb = new StringBuffer(); + delay = new Delay(id, ymd, hm, 0, true); + Delay.setData(sb, delay); + ConfUtil.setDelay(pref, sb.toString()); + + // ’x‰„Œ‹‰Ê + ret = true; + // ’x‰„ó‹µ + sb = new StringBuffer(); + delay = new Delay(id, ymd, hm + 2, 0, true); + Delay.setData(sb, delay); + retData = sb.toString(); break; } ConfUtil.setHeight(pref, h); ConfUtil.setWidth(pref, w); data = sb.toString(); ConfUtil.setDelay(pref, data); + pref.update(); + train = new Train(id, name); boolean isDelay = adpt.checkDelay(train, cal, count, len); @@ -83,7 +179,7 @@ public class TrainTwitterAdapterTest { } data = ConfUtil.getDelay(pref); - if (data.equals(retData)){ + if (!data.equals(retData)){ throw new TestException(); } } diff --git a/workspace/TrainDelayed/src/com/td/utility/Debug.java b/workspace/TrainDelayed/src/com/td/utility/Debug.java index bb20013..e6093c2 100644 --- a/workspace/TrainDelayed/src/com/td/utility/Debug.java +++ b/workspace/TrainDelayed/src/com/td/utility/Debug.java @@ -55,7 +55,7 @@ public class Debug { } public static void d(Object target, String msg){ - d(target, msg, (Throwable)null); + d(target, msg, null, Log.DEBUG); } public static void d(Object target, String msg, Throwable t){ -- 2.11.0