@Test(expected = PhoenixNonRetryableRuntimeException.class) public void loadAndGetGuidePostsCacheFactoryBadStringFailure(){ helper.loadAndGetGuidePostsCacheFactory("not a class"); }
@VisibleForTesting GuidePostsCacheFactory loadAndGetGuidePostsCacheFactory(String classString) { Preconditions.checkNotNull(classString); if (guidePostsCacheFactory == null) { try { Class clazz = Class.forName(classString); if (!GuidePostsCacheFactory.class.isAssignableFrom(clazz)) { String msg = String.format( "Could not load/instantiate class %s is not an instance of GuidePostsCacheFactory", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } List<GuidePostsCacheFactory> factoryList = InstanceResolver.get(GuidePostsCacheFactory.class, null); for (GuidePostsCacheFactory factory : factoryList) { if (clazz.isInstance(factory)) { guidePostsCacheFactory = factory; LOGGER.info(String.format("Sucessfully loaded class for GuidePostsCacheFactor of type: %s", classString)); break; } } if (guidePostsCacheFactory == null) { String msg = String.format("Could not load/instantiate class %s", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } } catch (ClassNotFoundException e) { LOGGER.error(String.format("Could not load/instantiate class %s", classString), e); throw new PhoenixNonRetryableRuntimeException(e); } } return guidePostsCacheFactory; }
GuidePostsCacheProvider { @VisibleForTesting GuidePostsCacheFactory loadAndGetGuidePostsCacheFactory(String classString) { Preconditions.checkNotNull(classString); if (guidePostsCacheFactory == null) { try { Class clazz = Class.forName(classString); if (!GuidePostsCacheFactory.class.isAssignableFrom(clazz)) { String msg = String.format( "Could not load/instantiate class %s is not an instance of GuidePostsCacheFactory", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } List<GuidePostsCacheFactory> factoryList = InstanceResolver.get(GuidePostsCacheFactory.class, null); for (GuidePostsCacheFactory factory : factoryList) { if (clazz.isInstance(factory)) { guidePostsCacheFactory = factory; LOGGER.info(String.format("Sucessfully loaded class for GuidePostsCacheFactor of type: %s", classString)); break; } } if (guidePostsCacheFactory == null) { String msg = String.format("Could not load/instantiate class %s", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } } catch (ClassNotFoundException e) { LOGGER.error(String.format("Could not load/instantiate class %s", classString), e); throw new PhoenixNonRetryableRuntimeException(e); } } return guidePostsCacheFactory; } }
GuidePostsCacheProvider { @VisibleForTesting GuidePostsCacheFactory loadAndGetGuidePostsCacheFactory(String classString) { Preconditions.checkNotNull(classString); if (guidePostsCacheFactory == null) { try { Class clazz = Class.forName(classString); if (!GuidePostsCacheFactory.class.isAssignableFrom(clazz)) { String msg = String.format( "Could not load/instantiate class %s is not an instance of GuidePostsCacheFactory", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } List<GuidePostsCacheFactory> factoryList = InstanceResolver.get(GuidePostsCacheFactory.class, null); for (GuidePostsCacheFactory factory : factoryList) { if (clazz.isInstance(factory)) { guidePostsCacheFactory = factory; LOGGER.info(String.format("Sucessfully loaded class for GuidePostsCacheFactor of type: %s", classString)); break; } } if (guidePostsCacheFactory == null) { String msg = String.format("Could not load/instantiate class %s", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } } catch (ClassNotFoundException e) { LOGGER.error(String.format("Could not load/instantiate class %s", classString), e); throw new PhoenixNonRetryableRuntimeException(e); } } return guidePostsCacheFactory; }  }
GuidePostsCacheProvider { @VisibleForTesting GuidePostsCacheFactory loadAndGetGuidePostsCacheFactory(String classString) { Preconditions.checkNotNull(classString); if (guidePostsCacheFactory == null) { try { Class clazz = Class.forName(classString); if (!GuidePostsCacheFactory.class.isAssignableFrom(clazz)) { String msg = String.format( "Could not load/instantiate class %s is not an instance of GuidePostsCacheFactory", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } List<GuidePostsCacheFactory> factoryList = InstanceResolver.get(GuidePostsCacheFactory.class, null); for (GuidePostsCacheFactory factory : factoryList) { if (clazz.isInstance(factory)) { guidePostsCacheFactory = factory; LOGGER.info(String.format("Sucessfully loaded class for GuidePostsCacheFactor of type: %s", classString)); break; } } if (guidePostsCacheFactory == null) { String msg = String.format("Could not load/instantiate class %s", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } } catch (ClassNotFoundException e) { LOGGER.error(String.format("Could not load/instantiate class %s", classString), e); throw new PhoenixNonRetryableRuntimeException(e); } } return guidePostsCacheFactory; }  GuidePostsCacheWrapper getGuidePostsCache(String classStr, ConnectionQueryServices queryServices,
            Configuration config); }
GuidePostsCacheProvider { @VisibleForTesting GuidePostsCacheFactory loadAndGetGuidePostsCacheFactory(String classString) { Preconditions.checkNotNull(classString); if (guidePostsCacheFactory == null) { try { Class clazz = Class.forName(classString); if (!GuidePostsCacheFactory.class.isAssignableFrom(clazz)) { String msg = String.format( "Could not load/instantiate class %s is not an instance of GuidePostsCacheFactory", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } List<GuidePostsCacheFactory> factoryList = InstanceResolver.get(GuidePostsCacheFactory.class, null); for (GuidePostsCacheFactory factory : factoryList) { if (clazz.isInstance(factory)) { guidePostsCacheFactory = factory; LOGGER.info(String.format("Sucessfully loaded class for GuidePostsCacheFactor of type: %s", classString)); break; } } if (guidePostsCacheFactory == null) { String msg = String.format("Could not load/instantiate class %s", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } } catch (ClassNotFoundException e) { LOGGER.error(String.format("Could not load/instantiate class %s", classString), e); throw new PhoenixNonRetryableRuntimeException(e); } } return guidePostsCacheFactory; }  GuidePostsCacheWrapper getGuidePostsCache(String classStr, ConnectionQueryServices queryServices,
            Configuration config);  }