00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 package org.openmobileis.module.test;
00027
00028 import java.io.File;
00029 import java.util.Enumeration;
00030 import java.util.Properties;
00031
00032 import junit.framework.Assert;
00033
00034 import org.openmobileis.bundle.update.server.FullAppUpdateSynchroTarget;
00035 import org.openmobileis.bundle.update.terminal.FullAppUpdateListener;
00036 import org.openmobileis.common.context.SessionContext;
00037 import org.openmobileis.common.context.SessionContextManager;
00038 import org.openmobileis.common.user.UserManager;
00039 import org.openmobileis.common.util.PropertiesManager;
00040 import org.openmobileis.common.util.log.LogManager;
00041 import org.openmobileis.synchro.client.SynchroDescriptor;
00042 import org.openmobileis.synchro.security.auth.Credential;
00043 import org.openmobileis.test.mock.common.MockUserManagerFactory;
00044 import org.openmobileis.test.mock.synchro.SimpleMockSynchroManager;
00045
00050 public final class TestJarSynchroUpdate {
00051
00055 public TestJarSynchroUpdate() {
00056
00057 }
00058
00062 public void testJarSynchro() {
00063 try {
00064
00065 LogManager.registerLogManager(null);
00066 Properties props = System.getProperties();
00067 Enumeration enume = props.keys();
00068 while (enume.hasMoreElements()){
00069 String key = (String) enume.nextElement();
00070 String value = props.getProperty(key);
00071 LogManager.traceDebug(0, "Key :"+key+" -> "+value);
00072 }
00073
00074
00075
00076 File removeFile = new File(System.getProperty("user.dir") + "/WEB-INF/conf/misc.properties");
00077 if (removeFile.exists()) removeFile.delete();
00078
00079
00080 PropertiesManager.getManager().addProperty("fastobjectdb.database.path", System.getProperty("user.dir") + "/database");
00081 PropertiesManager.getManager().addProperty("fastobjectdb.database.name", "testdb");
00082
00083 Credential cred = new Credential("test", "test");
00084 UserManager.getManager().registerUserManagerFactoryForGroup("defgroup", new MockUserManagerFactory("defgroup", "defname", cred));
00085
00086
00087 SessionContext context = SessionContextManager.getManager().createSessionContext("testsession");
00088 SessionContextManager.getManager().joinSessionContext("testsession");
00089 context.setUserGroup("defgroup");
00090 context.setUserId("defname");
00091
00092 String synchroInstallPath = System.getProperty("user.dir") + "/synchro";
00093 SimpleMockSynchroManager synchromock = new SimpleMockSynchroManager(synchroInstallPath);
00094 FullAppUpdateListener listener = new FullAppUpdateListener();
00095 FullAppUpdateSynchroTarget target = new FullAppUpdateSynchroTarget(new File(System.getProperty("user.dir")+"/../server/updatefile.jar"));
00096 synchromock.registerTerminalSynchroListener(listener);
00097 synchromock.registerServerSynchroTarget(target);
00098 synchromock.synchronize("defgroup", cred, new SynchroDescriptor());
00099
00100 } catch (Exception ex) {
00101 LogManager.traceError(0, ex);
00102 Assert.fail("Exception occurs during testXmlModuleParser :" + ex.getMessage());
00103 }
00104
00105 }
00106
00110 public static void main(String[] args) {
00111 TestJarSynchroUpdate test = new TestJarSynchroUpdate();
00112 test.testJarSynchro();
00113
00114 }
00115
00116 }