@Override protected void setUp() throws Exception { tmp = IO.getFile("generated/tmp"); tmp.mkdirs(); IO.copy(IO.getFile("testdata/ws"), tmp); workspace = Workspace.getWorkspace(tmp); workspace.refresh(); InfoRepository repo = workspace.getPlugin(InfoRepository.class); t1 = create("bsn-1", new Version(1, 0, 0)); t2 = create("bsn-2", new Version(1, 0, 0)); repo.put(new FileInputStream(t1), null); repo.put(new FileInputStream(t2), null); t1 = repo.get("bsn-1", new Version(1, 0, 0), null); t2 = repo.get("bsn-2", new Version(1, 0, 0), null); repo.put(new FileInputStream(IO.getFile("generated/biz.aQute.remote.launcher.jar")), null); workspace.getPlugins().add(repo); File storage = IO.getFile("generated/storage-1"); storage.mkdirs(); configuration = new HashMap<String, Object>(); configuration.put( Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT); configuration.put(Constants.FRAMEWORK_STORAGE, storage.getAbsolutePath()); configuration.put( Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.osgi.framework.launch;version=1.2"); framework = new org.apache.felix.framework.FrameworkFactory().newFramework(configuration); framework.init(); framework.start(); context = framework.getBundleContext(); location = "reference:" + IO.getFile("generated/biz.aQute.remote.agent.jar").toURI().toString(); agent = context.installBundle(location); agent.start(); thread = new Thread() { @Override public void run() { try { Main.main( new String[] { "-s", "generated/storage", "-c", "generated/cache", "-p", "1090", "-et" }); } catch (Exception e) { e.printStackTrace(); } } }; thread.setDaemon(true); thread.start(); super.setUp(); }
@Test public void selectAllCategoryList() { List<Info> infoList = infoRepository.selectAllCategoryList(ProductType.INTERNAL.getCode()); for (Info info : infoList) { log.info(info.toString()); } }
@Test public void selectList() { List<Info> infoList = infoRepository.selectList(InfoType.PRODUCT.getCode(), 1, 10); for (Info info : infoList) { log.info(info.toString()); } }
@Test public void insert() { Info info = new Info(); info.setInfoCode("999"); info.setInfoContent("test"); info.setInfoType(InfoType.PRODUCT.getCode()); info.setCreator("cuizuoli"); info.setModifier("cuizuoli"); infoRepository.insert(info); }
@Test public void delete() { infoRepository.delete("100"); }
@Test public void selectCategoryCount() { infoRepository.selectCategoryCount("001"); }
@Test public void selectCategoryList() { infoRepository.selectCategoryList("001", 0, 10); }
@Test public void selectCount() { infoRepository.selectCount(InfoType.PRODUCT.getCode()); }
@Test public void selectOne() { Info info = infoRepository.selectOne("001"); log.info(info.toString()); }